#hal #risc-v #bl702

no-std bl702-hal

HAL for the Bouffalo Lab BL702 microcontroller family

3 releases

0.0.3 Oct 8, 2022
0.0.2 Oct 8, 2022
0.0.1 Sep 19, 2022

#1803 in Embedded development

MIT OR MulanPSL-2.0

110KB
1.5K SLoC

Contains (static library, 6KB) bin/trap_riscv32if-unknown-none-elf.a, (static library, 6KB) bin/trap_riscv32i-unknown-none-elf.a

bl702-hal

Hardware Abstraction Layer for BL702 RISC-V SoC in embedded Rust.

Project status

Working:

  • Basic GPIO is working
  • Clock initialisation (not configurable)
  • UART0 (2MBaud only)

TODO:

  • Everything else

Getting started

Install cargo + rust + riscv32imac-unknown-none-elf + cargo-binutils + llvm-tools-preview
(google for instructions, TODO add step-by-step here)

pip install bflb-mcu-tool

cargo objcopy --release --example blinky -- -O binary blinky.bin
bflb-mcu-tool --chipname bl702 --firmware blinky.bin

Serial demo

cargo objcopy --release --example serial -- -O binary serial.bin
bflb-mcu-tool --chipname bl702 --firmware serial.bin
picocom --lower-rts --lower-dtr /dev/ttyUSB0 -b 2000000

Contributing

We welcome community contributions to this project. Please create a github issue or pull request if you have any issues or wish to contribute.

License

This project is licensed under both MIT or Mulan PSL v2


lib.rs:

HAL for the BL702 microcontroller

This is a Rust HAL for the BL702 microcontroller.

It implements the embedded-hal traits for peripherals, where such traits exist.

Usage

Commonly used setup

// Get access to the device specific peripherals from the peripheral access crate
let dp = pac::Peripherals::take().unwrap();
let mut parts = dp.GLB.split();

To avoid the linker to complain about missing symbols please add hal_defaults.x to .cargo/config like this

rustflags = [
  "-C", "link-arg=-Tmemory.x",
  "-C", "link-arg=-Tlink.x",
  "-C", "link-arg=-Thal_defaults.x",
]

Dependencies

~6MB
~155K SLoC