Skip to content

Latest commit

 

History

History
 
 

sdk_app_rust

Rust Firmware for BL602 IoT SDK

UPDATE: See the updated firmware in sdk_app_rust_gpio

This BL602 firmware shows how we may create Rust firmware with the BL602 IoT SDK. Read the article...

Rust source code for the BL602 firmware is here...

Run this script to build, flash and run the BL602 Rust firmware...

This script links the compiled Rust code into the BL602 firmware by overwriting the compiled rust_app Stub Library...

The script uses a Custom Rust Target riscv32imacf-unknown-none-elf...

This Custom Rust Target is a minor tweak of the standard Rust target riscv32imac-unknown-none-elf...

  1. We set features to +m,+a,+c,+f to generate RISC-V binaries with Single-Precision Hardware Floating-Point (+f)

  2. We set llvm-abiname to ilp32f to support Single-Precision Hardware Floating-Point for the Application Binary Interface

We can't use the standard target riscv32imac-unknown-none-elf because...

  1. BL602 IoT SDK was compiled with gcc -march=rv32imfc -mabi=ilp32f

    (Single-Precision Hardware Floating-Point)

  2. Linker fails with error can't link soft-float modules with single-float modules

How did we figure out the tweaks for the Custom Rust Target?

By comparing the Rust Target Specs for riscv32imac-unknown-none-elf vs riscv64gc-unknown-none-elf...

  1. riscv32imac-unknown-none-elf.json: 32-bit RISC-V with software floating point

    Generated by...

    rustc +nightly -Z unstable-options --print target-spec-json --target riscv32imac-unknown-none-elf
  2. riscv64gc-unknown-none-elf.json: 64-bit RISC-V with double-precision hardware floating point

    Generated by...

    rustc +nightly -Z unstable-options --print target-spec-json --target riscv64gc-unknown-none-elf

Read the Twitter Thread...

https://twitter.com/MisterTechBlog/status/1383219945308184578