A minimal embedded Rust application for the STM32F769 microcontroller demonstrating basic peripheral access and RTT (Real-Time Transfer) logging.
- Reads and displays device ID and revision ID from the DBGMCU peripheral
- 5-second countdown demonstrating SysTick timer with 1-second intervals
- Proper error handling without
unwrap() - Power-efficient idle state using
wfi()(Wait For Interrupt) - Uses
defmtfor efficient logging over RTT - Demonstrates proper embedded Rust project structure and best practices
- Microcontroller: STM32F769NIHx (or compatible STM32F7 series)
- Debug Probe: ST-Link V2/V3 or compatible
- Connection: USB cable for debug probe
- Rust toolchain (stable)
thumbv7em-none-eabitargetprobe-rstools for flashing and debugging
Install Rust and required tools:
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Add ARM Cortex-M target
rustup target add thumbv7em-none-eabi
# Install probe-rs
cargo install probe-rs-tools --lockedstm32_helloworld_rs/
├── .cargo/
│ └── config.toml # Cargo configuration with runner settings
├── .vscode/
│ └── launch.json # VS Code debugger configuration
├── src/
│ └── main.rs # Main application code
├── memory.x # Linker memory layout
├── Cargo.toml # Project dependencies
└── README.md # This file
Build the project:
cargo buildFor release builds with optimizations:
cargo build --releaseFlash and run with RTT output:
cargo runThis will:
- Build the project
- Flash it to the STM32F769
- Start RTT logging in the terminal
Press Ctrl+C to stop.
- Open the project in VS Code
- Open the "Run and Debug" panel (Ctrl+Shift+D / Cmd+Shift+D)
- Select "probe-rs STM32F769" from the dropdown
- Click the green play button or press F5
RTT output will appear in the Debug Console tab.
Hello, World!
device_id: 1105
revisions_id: 4097
5
4
3
2
1
Countdown complete! Program finished successfully.
device_id: 1105corresponds to0x0451(STM32F769)revisions_id: 4097corresponds to0x1001(chip revision)- The countdown demonstrates 1-second timer intervals
- After completion, the program enters a low-power idle state
macOS: If you encounter "Probe not found" errors:
- Close any other applications using the ST-Link (STM32CubeProgrammer, etc.)
- The
PROBE_RS_USB_BACKEND=rusbenvironment variable is already configured in.cargo/config.toml
Linux: You may need to configure udev rules:
# Create udev rules for ST-Link
sudo tee /etc/udev/rules.d/70-st-link.rules > /dev/null <<'EOF'
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", MODE:="0666"
EOF
# Reload udev rules
sudo udevadm control --reload-rules
sudo udevadm triggerEnsure that:
- The Debug Console tab is selected (not Terminal)
- RTT is enabled in
.vscode/launch.json(already configured) - The program is running (not paused at a breakpoint)
If you see linker errors:
- Verify
thumbv7em-none-eabitarget is installed:rustup target list --installed - Clean and rebuild:
cargo clean && cargo build
The application demonstrates fundamental embedded Rust concepts:
#![no_std]and#![no_main]: Required attributes for bare-metal embedded applications- Proper Error Handling: Uses
matchinstead ofunwrap()for safer peripheral initialization - Peripheral Access: Uses the
stm32f7xx-halHAL crate for hardware access - SysTick Timer: Configures the ARM Cortex-M SysTick timer for precise 1-second delays
- RTT Logging: Uses
defmtanddefmt-rttfor efficient debug output - Power Management: Enters low-power idle using
wfi()after completing the countdown - Register Efficiency: Demonstrates reading hardware registers once and extracting multiple fields
cortex-m: Low-level access to Cortex-M peripheralscortex-m-rt: Runtime support and startup codestm32f7xx-hal: Hardware Abstraction Layer for STM32F7defmt: Efficient logging framework for embeddeddefmt-rtt: RTT transport for defmtpanic-probe: Panic handler that reports panics over defmt
Copyright (c) 2025 Michael Gardner, A Bit of Help, Inc.
This project is licensed under the BSD-3-Clause License. See the LICENSE file for details.
Contributions are welcome! This project serves as a starting template for STM32F7 embedded Rust development.