5

I'm trying to follow this blog but on Windows and with the latest Rust. It seems to me that the correct way of doing things like this is changing very frequently with Rust, so I'm hoping for an up-to-date Windows adaptation.

What I've tried so far:

I installed gcc-arm-embedded.

I had unverified partial success manually cross-compiling libcore, but then I switched to use the recommended xargo, the functionality of which (I read) is on its way to being included in Cargo eventually. While I don't understand any of it very well, I'm hoping to get to the part where I can write/run the code and then maybe I can back into understanding the compilation better.

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

And this part seems to verify:

$ 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

When I try to use the GNU Arm Embedded Toolchain linker, I get:

$ 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

And #rust IRC chatroom helpfuls told me that rpi3 is aarch64, not arm, so I need to find an aarch64 linker ...

Jason Kleban
  • 20,024
  • 18
  • 75
  • 125

1 Answers1

0

I think it's working! Things I learned:

  • xargo is good
  • rpi3 is different enough from rpi2 to cause my problems in tool selection
  • xargo doesn't care what toolchain rustup defaults to because I'm not asking it to link for me and it does its own toolchain selection
  • I needed to target aarch64, not arm. For this I used the linaro aarch64 mingw32 download, unpacked, added its bin folder to my PATH. Then the aarch64 tools were easy to adapt from the blog.

For people who want to do this themselves, see https://github.com/JasonKleban/rust-rasp . Not so complicated!

I aim to blink the onboard activity led as confirmation that we do really have control, but looks like that will be kinda complicated on the rpi3 (see my readme, if still applicable)

Jason Kleban
  • 20,024
  • 18
  • 75
  • 125