Table of Contents
Rust
Notes on embedded rust.
https://github.com/rust-embedded/embedded-hal v1.0 released January 2024, considered stable.
probe-rs
A flashing and debug tool. Alternative to openocd and blackmagic probe. Not actually rust specific - can flash firmware built from C for example, but written in rust and integrates with cargo.
You can also use openocd as normal with rust build files.
Supports RTT - protocol which can be used for sending debugging console text through SWD / JTAG. Needs firmware support, which sets up ring buffers which are then read by a client over the debugger connection.
cargo embed
will build and flash firmware, then start an RTT console.
cargo embed
seems to be corrupting the rtt output. Using probe-rs directly works better.
e.g. probe-rs attach –chip STM32F429ZITx target/thumbv7em-none-eabihf/debug/disco-test
https://github.com/stm32-rs - peripheral access crates. Gives access to named registers, for all STM32s.
Debug print, I/O Interfaces
- Semihosting
- RTT
- SWO
- UART
RTT - works well with probe-rs, recommended. rprintln!
Semihosting not recommended. An ARM thing, uses special instructions. Slow. hprintln! https://developer.arm.com/documentation/dui0471/g/Bgbjjgij
RTOSen
Learning material
https://mikecoats.com/stm32-blinky-rust-part-2-debug/
https://www.st.com/en/evaluation-tools/32f429idiscovery.html#documentation
Abstractions
- Can work with registers directly.
- PAC - peripheral access crates.
- HAL - hardware abstraction layer.
- BSP - Board support package.
RCC.constrain() - takes PAC level RCC and returns a more limited HAL compatible interface to it. You may not be able to use the PAC again after doing this, but it might be possible to get PAC interface back with some implementations.
GPIO.split - Returns separate GPIO ports.