Rust on BBC micro:bit using Windows

I’ve decided to try how the BBC micro:bit and Rust play together when using Windows as a development machine. My setup is made of Window 10 (Enterprise 64-bit, but that should not make any difference at all). Additionally, I’ve installed Rust from here.

Then in my command prompt (I’m using regular cmd.exe), I’ve brought Cargo binaries into PATH:

set PATH=c:\windows;c:\windows\system32; %USERPROFILE%\.cargo\bin

Then, I’ve added Rust’s nightly channel, ade it default one, as well as additional target I would need for micro:bit - a thumbv6m-none-eabi:

rustup install nightly
rustup default nightly
rustup target install thumbv6m-none-eabi

Eventually, I’ve downloaded ZIP’ped variant of [GCC Arm cross-compilers] (https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads). Version for 32-bit was the only available, but that’s OK, would not make a difference.

I’ve extracted it to my C: drive and and brought into PATH as well:

set PATH=%PATH%;"C:\ArmCompilers\7 2017-q4-major\bin";
set PATH=%PATH%;"C:\ArmCompilers\7 2017-q4-major\arm-none-eabi\bin"

I’ve took my blinky example I come previosly and gave it a go:

cargo build --release

Compiling cc v1.0.17
Compiling vcell v0.1.0
Compiling aligned v0.2.0
Compiling bare-metal v0.2.0
Compiling nrf51 v0.5.0
Compiling r0 v0.2.2
Compiling nb v0.1.1
Compiling void v1.0.2
Compiling cast v0.2.2
Compiling panic-abort v0.2.0
Compiling volatile-register v0.2.0
Compiling embedded-hal v0.2.1
Compiling cortex-m v0.5.2
Compiling cortex-m-rt v0.5.1
Compiling nrf51-hal v0.5.1
Compiling microbit v0.5.4
Compiling microbit-blinky v0.1.0 ...
Finished release [optimized] target(s) in 29.96s

Voilà! All compiles nicely. No surprises with extraction of the HEX file too:

arm-none-eabi-objcopy -O ihex target\thumbv6m-none-eabi\release\microbit-blinky out.hex

So I can now send the out.hex produced to my BBC micro:bit board. It is mounted in my system as F: drive, so the command is:

copy out.hex F:\

And there it is. New program started and flashes the LED.

Conclusion

Windows and Rust and microbit crate played all well, no surprises, straightforward experience.

comments powered by Disqus