我是 trying to follow this blog但在 Windows 和最新的 Rust 上。在我看来,做这样事情的正确方法在 Rust 中经常发生变化,所以我希望有一个最新的 Windows 适应。
到目前为止我尝试了什么:
我安装了 gcc-arm-embedded .
我在手动交叉编译 libcore 时取得了部分成功,但后来我转而使用推荐的 xargo
,其功能(我读过)最终将被包含在 Cargo 中。虽然我对其中的任何内容都不太了解,但我希望能够到达可以编写/运行代码的部分,然后也许我可以重新更好地理解编译。
与 japaric's awesome help ,我能够让“aarch64”目标构建工作以生成 .o 文件(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 默认的工具链是什么,因为我没有要求它为我链接并且它自己选择工具链- 我需要针对 aarch64,而不是 arm。为此,我使用了 linaro aarch64 mingw32 下载,解压,将其 bin 文件夹添加到我的 PATH 中。然后 aarch64 工具很容易从博客中改编。
对于想要自己执行此操作的人,请参阅 https://github.com/JasonKleban/rust-rasp .没那么复杂!
我的目标是让机载事件闪烁以确认我们确实拥有控制权,但看起来这在 rpi3 上会有点复杂(请参阅我的自述文件,如果仍然适用)
关于windows - 从 Windows 为 Raspberry Pi 3 B 交叉编译裸机 Rust,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51005145/