Cross-compiling for Raspberry Pi on an Apple silicon Mac

While developing the device software for 454 Bio’s DNA sequencer, I needed to be able to build rpicam-apps and our HAL. While I could compile directly on the Pi 4 it was running on, it was quite slow:

aarmea@raspberrypi:~/Code/tirf-hal/builddir $ meson compile --clean && time meson compile
Cleaning... 0 files.
[70/70] Linking target apps/capture-service
    
real    4m12.382s
user    14m38.012s
sys     1m8.128s

Instead, I set up my much faster M1 Mac to cross-compile this and our custom code, which is almost 10x faster and allowed me to iterate much more quickly:1

debian@debian:~/Code/454-hal/builddir$ meson compile --clean && time meson compile
Cleaning... 0 files.
[70/70] Linking target apps/capture-service

real    0m32.847s
user    1m46.109s
sys     0m14.082s

Because the environment is virtualized, it was much easier to set up and integrate Pi-specific libraries than with other cross-compilation toolchains.

Read More