从 Windows 为 Raspberry Pi 3 B 交叉编译裸机 Rust

Cross-compiling baremetal Rust for Raspberry Pi 3 B from Windows

我是 trying to follow this blog 但在 Windows 并且使用最新的 Rust。在我看来,做这样事情的正确方法在 Rust 中经常变化,所以我希望有一个最新的 Windows 适应。

到目前为止我尝试过的:

我安装了gcc-arm-embedded

我在手动交叉编译 libcore 时取得了部分成功,但后来我转而使用推荐的 xargo,其功能(我读过)最终将被包含在 Cargo 中。虽然我对其中的任何一个都不是很了解,但我希望能够到达我可以 write/run 代码的部分,然后也许我可以重新理解编译。

japaric's awesome help, I was able to get the "aarch64" targeted build working to generate the .o file (as of this particular commit).

而这部分似乎验证了:

$ file target/aarch64-raspi3-none-elf/release/deps/rust_rasp-ed0c2377e0a7df81.o
target/aarch64-raspi3-none-elf/release/deps/rust_rasp-ed0c2377e0a7df81.o: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), not stripped

当我尝试使用 GNU Arm Embedded Toolchain 链接器时,我得到:

$ arm-none-eabi-gcc -O0 -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -nostartfiles target/aarch64-raspi3-none-elf/release/deps/rust_rasp-ed0c2377e0a7df81.o -o kernel.elf target/aarch64-raspi3-none-elf/release/deps/rust_rasp-ed0c2377e0a7df81.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status

#rust IRC 聊天室帮助告诉我 rpi3 是 aarch64,而不是 arm,所以我需要找到一个 aarch64 链接器 ...

我认为它有效!我学到的东西:

  • xargo很好
  • rpi3 与 rpi2 的差异足以导致我在工具选择方面出现问题
  • xargo 不关心 rustup 默认的工具链是什么,因为我没有要求它 link 并且它自己选择工具链
  • 我需要针对 aarch64,而不是 arm。为此,我使用了 linaro aarch64 mingw32 下载,解压,将其 bin 文件夹添加到我的 PATH 中。那么aarch64的工具就很容易从博客上适配了。

对于想要自己执行此操作的人,请参阅 https://github.com/JasonKleban/rust-rasp。没那么复杂!

我的目标是 blink 板载 activity 指示灯作为我们确实拥有控制权的确认,但看起来这在 rpi3 上会有点复杂(请参阅我的自述文件,如果仍然适用)