Skip to main content

mc683xx

An emulator for the Motorola MC68331 microcontroller, in Rust, with Python bindings: the CPU32 core, the chip's own modules (SIM, QSM, GPT), and a board layer that wires memories and peripherals around the chip as a board does. It runs real firmware inside a host program: board emulators, firmware test harnesses, fuzzers, debuggers.

The demo board's C firmware: mc683xx-run with its console on the left, gdb on the right; a Mandelbrot set, a breakpoint, and a fault stop

Licensed MIT OR Apache-2.0.

Crates

One repository and one version; this README is every crate's on crates.io.

Crate What it is
mc683xx-target A CPU32 under debug control: the Cpu32Target trait and its registers, entry sources, addresses, operand sizes and function codes, no_std, shared with a BDM pod on silicon.
mc683xx-cpu32 The CPU32 core, and a bare CPU on flat memory (flat).
mc683xx-modules The SIM and the QSM, and the interfaces host peripherals plug into.
mc683xx-mc68331 The GPT, and the MC68331 chip built from the core and the modules.
mc683xx-board Board files: memories, peripherals from a registry, decoders and nets around the chip, on board time.
mc683xx-peripherals Stock peripherals for board files, each from its datasheet.
mc683xx-gdb A GDB remote stub over the bare CPU, the chip or a board, and over any Cpu32Target, a BDM pod's among them.
mc683xx-debug Loading S-records, ELF and raw binary, and running init scripts, over any Cpu32Target: a BDM pod's or the chip's.
mc683xx-run The runner: runs a board file from the command line.
mc683xx (PyPI) The Python package.

Status

  • CPU32 core: every instruction family (data movement, integer arithmetic and logic, shifts and rotates, bit operations, BCD, multiply and divide, chk2/cmp2, tbl*, program and system control, movec/moves, stop/lpstop/bkpt), exception processing with the CPU32's frames, interrupts, trace, and table-based cycle estimates. Checked against the manuals, SingleStepTests' 68000 cases, Musashi and a firmware function corpus.
  • Chip: the SIM (clock synthesizer, chip selects, bus monitor, PIT, watchdog, ports, resets), the QSM (QSPI and SCI) and the GPT, on next-event timing, deterministic run to run.
  • Host interface: peripherals on chip-select pins, QSPI peripherals, module pins, code, block and memory hooks, page permissions, tracing, and save/restore.
  • Boards: board files in TOML (memories, peripherals from a registry, decoders and nets on picosecond board time), and mc683xx-run, a command that runs one.
  • Stock peripherals: 74x373/374 latches, 74x244 buffer, 74x164 shift register, AD569 DAC, ADC0838 ADC, AT28C64B EEPROM, MC144110 DAC, MC6850 ACIA, MC68681 and SCC68692 DUARTs, each modeled from its datasheet.
  • gdb: a GDB remote stub over the bare CPU, the chip or a board, or a CPU32 under BDM control.
  • Loading: S-records, ELF and raw binary loaded, verified and started, and init scripts run, on a CPU32 under BDM control or the emulated chip.
  • Python: the chip, boards and a bare CPU, with Python objects as peripherals and callables as hooks, and type stubs.
  • WebAssembly: a board from JavaScript (crates/wasm, the npm package mc683xx), and the demo board in a web page (examples/web): try it in your browser.

Beta: the API may still change before 1.0.

Install

cargo add mc683xx-board      # boards, with the chip and core below it
cargo install mc683xx-run    # the runner
pip install mc683xx          # the Python package

Rust: a board (mc683xx-board)

Load a board file with the stock peripherals and run it for a second of board time (from the repository's root):

use std::error::Error;
use std::path::Path;

use mc683xx_board::Board;
use mc683xx_board::Environment;
use mc683xx_board::Options;
use mc683xx_board::time::Time;
use mc683xx_mc68331::Mc68331;

fn main() -> Result<(), Box<dyn Error>> {
    let registry = mc683xx_peripherals::registry();
    let mut board = Board::<Mc68331>::read(
        Path::new("examples/boards/echo.toml"),
        &Options::default(),
        &registry,
        &Environment::default(),
    )?;
    let run = board.run_until(Time::from_secs(1))?;
    println!("{} at {}", run.stop, run.now);
    Ok(())
}

mc683xx_peripherals::registry() holds the built-in peripheral types (Registry::with_builtins()) and the stock ones, and a host registers its own peripheral models in a registry with Registry::register. A host can also build the chip directly, without a board file, with mc683xx_mc68331::Builder (the host guide, below).

Python: a board (mc683xx)

The same board, with bytes sent to its console and echoed back:

import mc683xx

board = mc683xx.Board("examples/boards/echo.toml")
board.run_for(seconds=0.001)
for byte in b"hello":
    board.send("console", byte)
run = board.run_for(seconds=0.01)
print(run.stop, [frame for _, frame in board.take_received("console")])

The runner (mc683xx-run)

cargo run --release -p mc683xx-run -- examples/boards/echo.toml --bind console=stdio --seconds 5

runs the board the file describes for five seconds of board time, its external.console on standard input and output, and says on standard error why it stopped. --trace bus-cycles,exceptions,pins,qspi traces the run; --stop-on-fault stops it at a bus or address error, before the firmware takes it, and says which; and --gdb 127.0.0.1:1234 waits at reset for gdb to run it. Standard input that is a file or a pipe is read to its end when input first goes in and fed a byte a turn, so the run is the same each time; a terminal's is live. --bind console=tty makes the terminal a serial console: keys go in raw as typed, Ctrl-C included, and Ctrl-] ends the run. --bind NAME=stdout writes an endpoint's output as stdio does and reads nothing, for an endpoint that only listens or to leave standard input to another binding. Its exit status is 0 when the run spent its time, 1 for a board or file error, 2 for a wrong command, 3 when the CPU halted, 4 when a hook, a peripheral or a fault (--stop-on-fault) stopped the run, gdb killed it, or Ctrl-C did, and 130 when a second Ctrl-C ended it at once. mc683xx-run --help gives the rest; --firmware gives a board another image. examples/README.md describes the example boards and their firmware.

Documentation

  • Host guide: embedding the chip in a Rust host: building a chip, running, peripherals, pins, hooks, save/restore, errors.
  • Board files: the format, the built-in peripheral types and the Rust API for peripheral models.
  • Stock peripherals: the peripherals a board file names by part number, their parameters and ports.
  • Python: the same from Python.
  • gdb: debugging firmware with gdb.
  • Firmware under gdb: a recipe: the demo board's C firmware under gdb, source level.
  • Tracing: the run trace's format.
  • Init scripts: the language that readies a target for a load.
  • Performance: measurements and the benchmarks.
  • PLAN.md: the architecture and the decisions behind it.
  • Releasing: versions and the release procedure.

Workspace

The crates above are in crates/: target (mc683xx-target), cpu32 (mc683xx-cpu32), mc683xx (mc683xx-modules), mc68331 (mc683xx-mc68331), mc68331-board (mc683xx-board), peripherals (mc683xx-peripherals), gdb (mc683xx-gdb), debug (mc683xx-debug) and mc68331-run (mc683xx-run). The other members are not on crates.io:

  • mc683xx-python (crates/python): the Python package mc683xx, on PyPI.
  • mc683xx-wasm (crates/wasm): JavaScript bindings for boards, through WebAssembly, the npm package mc683xx (crates/wasm/README.md).
  • examples: the example boards and their firmware, and the documentation's examples run as tests (examples/README.md).
  • benches: the criterion benchmarks.
  • cpu32-harness, cpu32-oracle: test-only checks of the core against SingleStepTests' 68000 cases, Musashi, Unicorn and the firmware functions of smartclock (HP's firmware images, not in this repository).
  • snapshot-golden: test-only golden files of the snapshot formats.

Building

make hooks   # once per clone
make ci      # fmt check, license copies, commit-msg hook, shellcheck, clippy, feature builds, tests, rustdoc
make python      # the Python module in .venv, with its tests
make wasm        # the JavaScript bindings (wasm32, wasm-bindgen), linted, as the npm package
make npm-test    # the npm package packed and installed, in Node and headless Chrome
make npm-types   # the npm package's TypeScript declarations compiled (fetches TypeScript)
make web-test    # the demo board's web page (examples/web) in headless Chrome
make pages       # the web page as a static site, for GitHub Pages
make pages-test  # that site in headless Chrome, under its subpath
make singlestep  # SingleStepTests m68000 (fetches about 140 MB once)
make oracle      # differential runs against Musashi (fetches it once)
make corpus SMARTCLOCK_FIRMWARE=...  # smartclock firmware functions
make boot-smoke SMARTCLOCK_FIRMWARE=...  # whole images from reset
make boot-diff SMARTCLOCK_FIRMWARE=... BOOT_DIFF_REFERENCE=...  # against smartclock-emu's trace
make bench       # benchmarks (docs/performance.md)
make deny        # dependencies' licenses and advisories (cargo-deny)
make smartclock-boards SMARTCLOCK_BOARDS=...  # smartclock's board files, stock peripherals real
make corpus-musashi SMARTCLOCK_FIRMWARE=...  # their results against Musashi
make corpus-unicorn SMARTCLOCK_FIRMWARE=...  # against Unicorn
make corpus-oracles SMARTCLOCK_FIRMWARE=...  # against both
make unicorn     # the Unicorn oracle's own tests and clippy
make gdb         # gdb-multiarch against the runner's --gdb, the demo board too

make python creates .venv with maturin, pytest and mypy the first time; after it, .venv/bin/python imports mc683xx.

The Unicorn targets build Unicorn and QEMU's m68k from C through the unicorn-engine crate the first time, which takes some minutes and needs cmake, a C compiler (cc or clang) and pkg-config. Unicorn is GPL-2.0; it is a test-only oracle, off by default and never part of the shipped crates (third_party/NOTICE).

The manuals in third_party/ are kept in Git LFS; git lfs install before cloning, or git lfs pull after.

Contributing

See CONTRIBUTING.md: changes follow the manuals and datasheets in third_party/, cite them, and come with tests.

Releases

One version for the crates, the Python package and the npm package, semver from 0.1.0; what it covers is in docs/releasing.md, Semver scope. Release notes are on GitHub's releases.

Specification

The vendor manuals in third_party/motorola/ are the specification; see third_party/NOTICE.

Metadata

Release files for mc683xx 0.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mc683xx 0.9.1
File Size Uploaded Provenance Actions
mc683xx-0.9.1.tar.gz 945.7 kB With provenance Details for mc683xx-0.9.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for mc683xx 0.9.1
File Actions
mc683xx-0.9.1-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for mc683xx-0.9.1-cp312-abi3-win_amd64.whl
mc683xx-0.9.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details for mc683xx-0.9.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
mc683xx-0.9.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details for mc683xx-0.9.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
mc683xx-0.9.1-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for mc683xx-0.9.1-cp312-abi3-macosx_11_0_arm64.whl
mc683xx-0.9.1-cp312-abi3-macosx_10_12_x86_64.whl CPython 3.12 abi3 macOS 10.12+ x86-64 Details for mc683xx-0.9.1-cp312-abi3-macosx_10_12_x86_64.whl

Total release size: 11.6 MB

Release files / mc683xx-0.9.1.tar.gz

Download URL mc683xx-0.9.1.tar.gz
Size 945.7 kB
Tags Source
SHA-256 checksum
How to use checksums
824d4b8fa0a74b724044de518c5838af4f47198411916870a5c9f5844912b9e1
BLAKE2b-256 checksum
How to use checksums
3d21cac72fec17ff05d3b142065159b765f7ee3b2b101a567c5080f583ab28be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / mc683xx-0.9.1-cp312-abi3-win_amd64.whl

Download URL mc683xx-0.9.1-cp312-abi3-win_amd64.whl
Size 1.9 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d1a6504b9153d03badb475b37bf11e7a20b227c0fadc37b47fed5bbad6bca5fa
BLAKE2b-256 checksum
How to use checksums
c70f10b3231b6d69d801d3057ee849fae974e7b2f644a8bd3c2b77d6e9ac89e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / mc683xx-0.9.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL mc683xx-0.9.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.2 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
79045d4e62625cd58969378d0490dfabdee9296effc02cffbb2d1b1d86418ed3
BLAKE2b-256 checksum
How to use checksums
bc6e5dfbefc6b8567d0841d2d277a2d412ad899b58aed0f505fd3ddec5ba84fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / mc683xx-0.9.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL mc683xx-0.9.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.3 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
d2301fba0fc9b14be371937938fb33ad86575a0a4304371fb66a377af39fe221
BLAKE2b-256 checksum
How to use checksums
6e178fcbc64c22f2df0306ce8f68a4d1adb4d3e77b09c4afe56239a7e7454e9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / mc683xx-0.9.1-cp312-abi3-macosx_11_0_arm64.whl

Download URL mc683xx-0.9.1-cp312-abi3-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2079aaf3d91c3b64832b164453b4c7464dfb22e2c4163ad2121cf742c4ec7c65
BLAKE2b-256 checksum
How to use checksums
350d9b8d028523aa2b19297aad4d26d701434a7bb65205974ed3459096ea044d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / mc683xx-0.9.1-cp312-abi3-macosx_10_12_x86_64.whl

Download URL mc683xx-0.9.1-cp312-abi3-macosx_10_12_x86_64.whl
Size 2.1 MB
Tags CPython 3.12 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
db3d4147ad74fb5086a055bc67f93334fa37a84a91dc7322a54071b79d4fe21d
BLAKE2b-256 checksum
How to use checksums
67d34b7587b405249b7dab8ec20dbed32ff43568493f60bb61ecf6dffca604f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for mc683xx 0.9.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for mc683xx-0.9.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page