-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added docker file that cross-compiles for Raspberry Pi Zero #33
Conversation
This allows the package cache to be re-used between builds.
Amazing work, @petermoz |
Thanks for merging, and cool to see all the CI pipeline stuff you're doing!
Hah yeah I had a similar reaction myself. It's going to make any subsequent development for the Pi Zero so much easier |
Hi @petermoz,
Did you receive your RPi Zero 2 yet? Do you plan to create another docker file for it? If no, would you mind dumping some notes into an issue with some guidance on how to do that? Maybe someone will pick that challenge. The RPi Zero 2 has become my default architecture at the moment, I would love to add it to the CI workflow. Thanks! |
Hi @jcard0na, yes it arrived, but unfortunately I haven't even managed to solder on the headers yet. Is there a chance the Pi Zero 1 binary is compatible with the Pi Zero 2 without any changes? I thought it might be, so I copied the same binary across to a fresh raspian install on the Pi Zero 2 and it seems to start ok. Of course it crashes when it can't find the haxo hardware, so I can't check if it fully works - maybe you've discovered an issue further into the code? |
Oh, I did not think of that. I'll try that next week. Thanks! |
Had a chance to put everything together today, and the same binary works fine on the RPi Zero 2 :) I have no idea if a binary compiled for armv7 would be any faster |
Oh, thanks for checking.
I doubt there is a meaningful difference as we don't do any floating-point arithmetic. |
At the moment, https://github.com/cross-rs/cross doesn't support RPi Zero, due to it being the armv6 architecture. Trying to build a cross-rs image with packages from the raspian archive resulted in lots of problems with glibc, so this didn't work either.
Eventually, I pieced together parts from https://capnfabs.net/posts/cross-compiling-rust-apps-linker-shenanigans-multistrap-chroot/ and https://earthly.dev/blog/cross-compiling-raspberry-pi/ to come up with a docker file that uses multistrap to generate a RPi compatible sysroot, and then gets a linker from https://github.com/tttapa/docker-arm-cross-toolchain
The result is a docker image that you can build once with
docker build
and then calldocker run
to build (or incrementally rebuild) the haxo binary.I imagine support for newer RPis will be much simpler to add, but for now at least (I have a RPi Zero 2 coming in the mail :)) I don't have anything else to test on, so I think it's worth submitting this as is.
This is much faster than building on the RPi Zero directly, and I've tested it on Mac M1 and Linux. Mac M1 is much slower than Linux because the container itself is amd64, which means that the Mac is natively arm, emulating amd64, to cross compile to arm. There's probably a better way, but at least it works...