M1: external MCU toolchain spike
Inventory on this Mac, 2026-11-22 (local time). Versions and availability are a snapshot; the tools are not bundled with the repository.
| Tool | Observed |
|---|---|
clang | /opt/homebrew/opt/llvm/bin/clang, Homebrew clang 23.1.6 |
llvm-mc | /opt/homebrew/opt/llvm/bin/llvm-mc, Homebrew LLVM 23.1.6; the probe uses clang's integrated assembler |
ld.lld | /opt/homebrew/bin/ld.lld, Homebrew LLD 23.1.6 |
qemu-system-arm | /opt/homebrew/bin/qemu-system-arm, QEMU 11.1.3 |
qemu-system-riscv32 | /opt/homebrew/bin/qemu-system-riscv32, QEMU 11.1.3 |
arm-none-eabi-gcc | /opt/homebrew/bin/arm-none-eabi-gcc, Arm GNU Toolchain 14.3.Rel1, GCC 14.3.1 20250623 |
rustup | 1.28.2; the thumbv7m-none-eabi, thumbv7em-none-eabihf and riscv32imac-unknown-none-elf targets were listed but not installed in the earlier inventory. Rust targets are not needed for this probe. |
Put /opt/homebrew/opt/llvm/bin and /opt/homebrew/bin on PATH on this Mac. On another Homebrew installation use its own prefix. The probe requires clang, LLD, both QEMU executables and Python 3.
Furthest verified: Cortex-M3 and RV32IMAC execute in QEMU
With the PATH above, sh scripts/mcu-probe.sh exited 0 and printed exactly:
PASS: Cortex-M3 semihosting hello
PASS: RV32IMAC UART hello
The script compiles and links each freestanding guest in a temporary directory. Each QEMU run must exit zero and produce exactly the expected guest line within 10 seconds; a missing tool, build error, incorrect output, nonzero exit, or timeout fails the script with diagnostics.
Cortex-M3
Clang targets arm-none-eabi with -mcpu=cortex-m3 -mthumb; LLD links using mps2-an385.ld. startup.S and hello.c initialize .data and .bss, check them, print Hello from Cortex-M3! through semihosting, and exit. QEMU runs -M mps2-an385 -nographic -semihosting-config enable=on,target=native. The two-vector table suffices for this no-interrupt probe, not an application with exceptions; the memory layout is specific to this QEMU board.
The guest uses Thumb bkpt 0xab, semihosting SYS_WRITE0 (4), and SYS_EXIT (0x18) with ADP_Stopped_ApplicationExit (0x20026); startup failure uses 0x20023. Semihosting exposes host functionality, so use this invocation only with trusted guest images. An earlier GNU link also produced a little-endian ARM ELF32 with entry 0x9, flash at 0x00000000, and RAM at 0x20000000.
RV32IMAC
Clang assembles hello_rv32.S for riscv32-unknown-elf -march=rv32imac -mabi=ilp32; LLD links it with virt-rv32.ld at 0x80000000. QEMU runs -M virt -bios none -nographic, starts the ELF without firmware, and the guest prints Hello from RV32IMAC! through UART0 at 0x10000000. It writes 0x5555 to the SiFive test device at 0x100000 for successful shutdown.
This is a small assembly-only, single-hart QEMU virt smoke test. It does not initialize data or BSS, exercise the C ABI or interrupts, or verify a physical RISC-V board. Cortex-M4F also remains untested; its board map, startup and floating-point configuration require separate verification.
Gap to a Kern 32-bit backend
A direct encoder needs a correct target ABI (calling convention, stack alignment, data layout and relocations), target instruction encoding and branch/immediate resolution, plus an ELF32 object or executable accepted by the chosen linker and loader. It must provide target-specific startup, memory maps, sections and symbols, initialized data copying and BSS clearing before language code. Runtime and I/O conventions, interrupt vectors, and target-specific instructions remain separate work. These assembly/C shims demonstrate external-toolchain contracts; they do not prove Kern code generation or physical hardware behavior.