Branch: slice/S.8b. Commit only there; never to trunk.
Read first:
docs/phases/S-small-targets.md: S.2 runs on Zephyr's emulatedqemu_cortex_m0board, which is QEMU'smicrobitmachine (an nRF51 with a Cortex-M0). S.8c runs emitted Thumb code on the same machine.qemu/PIN.md,qemu/inventory.yml,src/glint/qemu/minikconf.crandsrc/glint/qemu/build/compile.cr: how Glint buildsqemu-system-aarch64without Meson, from a static inventory.spec/qemu/minikconf_spec.crandspec/qemu_inventory_spec.cr: the cross-checks that say which sources a device selection needs.
These facts were checked in QEMU 11.1.2's source:
hw/arm/Kconfigline 680:config MICROBIT,depends on TCG && ARM,select NRF51_SOC;NRF51_SOCselectsARM_V7M,I2CandUNIMP.target/arm/Kconfig:AARCH64selectsARM, andARMselectsARM_COMPATIBLE_SEMIHOSTINGunder TCG. Soqemu-system-aarch64can carry the machine; noqemu-system-armis needed.- The inventory already has the
ARM_V7Msources (hw/arm/armv7m.c,hw/intc/armv7m_nvic.c,hw/timer/armv7m_systick.c,hw/misc/armv7m_ras.c). hw/arm/nrf51_soc.c: flash at 0x0, SRAM at 0x20000000, CPUcortex-m0.hw/arm/microbit.cloads-kernelwitharmv7m_load_kernel, which takes an ELF or else a raw image at 0.target/arm/tcg/m_helper.cline 2375: on M-profile,BKPT 0xabis a semihosting call when semihosting is on.semihosting/arm-compat-semi.c:SYS_EXIT_EXTENDED(0x20) with a block{0x20026, code}exits QEMU withcode.
Claim. Glint's qemu-system-aarch64 also runs QEMU's microbit
machine, so Cortex-M0 code can be run and checked on x86-1 with the QEMU
Glint builds.
Passage. S.8's demonstration: emitted code is "run on qemu_cortex_m0".
Make:
CONFIG_MICROBIT=yin the aarch64 device selection (Minikconf::ARM_VIRT_MAK, or a sibling constant both the build and the spec read; keep one place).- The sources and generated inputs the cross-check specs then ask for,
added to
qemu/inventory.ymlwith their Meson source sets, andqemu/PIN.md's counts updated. spec/qemu/microbit_spec.cr, pending withoutGLINT_QEMU_AARCH64(or the build's default path) like the other QEMU specs. It writes a raw image of a few hand-encoded Thumb instructions: a vector table (initial SP 0x20004000, reset handler with the Thumb bit), thenSYS_EXIT_EXTENDEDthroughBKPT 0xabwith exit code 7. It runsqemu-system-aarch64 -M microbit -kernel IMAGE -semihosting-config enable=on,target=native -display none -monitor none -serial nonewith a timeout, and expects exit status 7. It also checks that-M helplistsmicrobit.
Demonstration. bin/glint-qemu aarch64 rebuilds; the minikconf and
inventory specs pass with QEMU_SRC set; the new spec passes; and
bin/glint-run aarch64 is not affected (it can't build aarch64 images on
x86-1 yet, so say so rather than claim it). Report the binary's size before
and after.
Constraints. Only the sources the selection needs. No change to the
x86_64 binary. crystal tool format --check passes.