【问题标题】:Cross-compiling baremetal Rust for Raspberry Pi 3 B from Windows从 Windows 为 Raspberry Pi 3 B 交叉编译裸机 Rust
【发布时间】:2018-08-21 18:53:25
【问题描述】:

我是 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 链接器...

【问题讨论】:

    标签: windows rust llvm cross-compiling raspberry-pi3


    【解决方案1】:

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

    • xargo不错
    • rpi3 与 rpi2 不同,导致我在工具选择方面出现问题
    • xargo 不在乎工具链 rustup 默认是什么,因为我没有要求它为我链接,它会自己选择工具链
    • 我需要针对 aarch64,而不是 arm。为此,我使用了 linaro aarch64 mingw32 下载,解压缩,将其 bin 文件夹添加到我的 PATH 中。然后 aarch64 工具很容易从博客中改编。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-28
      • 2020-11-16
      • 1970-01-01
      • 2019-11-23
      相关资源
      最近更新 更多