🛠 Programmer un CM3+ en C++ nu (bare metal) avec Circle
Objectives
The CM3+ is one of the few consumer products on which you can write code executed without any operating system: rsta2's Circle environment (github.com/rsta2/circle repository) explicitly lists "Compute Module 3+ — Reported to work". This tutorial compiles a bare-metal C++ program for the BCM2837B0 (ARMv8-A, Cortex-A53), places it on an SD card with the Raspberry Pi firmware, and launches it — the serial console displays the output. Useful for understanding SoC initialization, register drivers, or a hard real-time product.
Hardware
- CM3+ on CMIO3, SD card (the CM3+ Lite also works, without eMMC)
- USB-to-serial adapter on GPIO14/15 for the console (see the serial console tutorial)
- Linux PC with the cross-compilation toolchain:
gcc-aarch64-none-elf(or the free ARM bare-metal toolchain) - The module remains capped at 1.2 GHz, 1 GB LPDDR2, just like under Linux
Complete code
# 1. Toolchain (via ARM GNU bare-metal ou paquet distribution)
arm-none-eabi-gcc --version # ou aarch64-none-elf-gcc --version
# 2. Récupérer Circle et compiler l'exemple « hello » (mode 64 bits AArch64)
git clone https://github.com/rsta2/circle
cd circle/sample/01-helloworld
make -j4 CIRCLE_HOME=../.. AARCH64=1
# 3. Préparer la SD : partition FAT avec kernel8.img + les fichiers firmware
cp -r ../../testlibs ../.. ; # (les binaires RPiBasic/rpiboot ne sont pas requis)
cp kernel8.img /media/$USER/boot/kernel8.img
cp ../../testlibs/../../sample/01-helloworld/kernel8.img /media/$USER/boot/ 2>/dev/null
cat > /media/$USER/boot/config.txt <<'EOF'
enable_uart=1
arm_64bit=1
kernel=kernel8.img
EOF
sync && umount /media/$USER/boot
# 4. Démarrer le CM3+ : la console série 115200 affiche le programme
Expected verification
Without Linux, the serial console displays the output of the Circle program ("Hello" message followed by an LED blinking loop if the code adds it). The program runs on bare silicon: no shell, no Linux scheduler, startup in a few hundred milliseconds. make clean && make AARCH64=1 recompiles cleanly.
Common errors
- Forgetting
arm_64bit=1andkernel=kernel8.imgin config.txt: the firmware looks for the default kernel and does not start the bare-metal image. - Firmware too old: as with Linux, the CM3+ requires firmware from after November 2018 — copy recent bootcode.bin/start.elf files to the SD card.
- 32-bit toolchain (arm-none-eabi) for an AARCH64 target without the
AARCH64=1flag: linking error or image that does not start. - Silent serial console: missing
enable_uart=1in config.txt, or TX/RX not crossed — the code runs but you cannot see it. - Expecting CM4 peripherals: no PCIe or USB3 in Circle on BCM2837; the listed support concerns USB 2.0, Ethernet (via the USB chip on the CMIO3) and standard SODIMM peripherals.
Other tutorials for this board
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash