Firmware build
Compile and run the Rust firmware on opentag U1 V2 with the repository-pinned Embassy tree.
The current STM32 firmware is not in the public website repository. Request source access from hello@open-tags.com. A supplied checkout must include firmware/rust_bringup/stm32g4 and the pinned firmware/embassy dependency. For normal setup, use the browser quickstart; building is optional.
Toolchain
Install Rust first. From the supplied checkout's root, initialize the required submodule and enter the firmware package:
git submodule update --init --recursive firmware/embassy
cd firmware/rust_bringup/stm32g4
rustup target add thumbv7em-none-eabi
rustup component add llvm-tools-preview
cargo install cargo-binutils --locked
Install probe-rs tools only if you plan to use an SWD probe. The package's Cargo configuration selects the ARM target automatically.
Firmware targets
| Binary | Purpose | Interface |
|---|---|---|
twr_init | 40 Hz two-way-ranging initiator | DWM3000 + USB CDC |
twr_resp | Ranging responder, calibration, distance stream | DWM3000 + USB CDC |
tdoa_anchor | Configurable location anchor | UWB; configured by browser before flashing |
tdoa_tag | Onboard 2D/3D position solver | UWB + USB CDC |
can_tx | Classical CAN request / echo test | FDCAN2 at 500 kbit/s |
can_rx | Classical CAN echo peer | FDCAN2 at 500 kbit/s |
can_fd_tx | 64-byte CAN FD load generator | 1 Mbit/s nominal, 2 Mbit/s data |
can_fd_rx | CAN FD sequence, loss, and throughput receiver | 1 Mbit/s nominal, 2 Mbit/s data |
Build without hardware
cargo check --release --bin twr_init
cargo check --release --bin twr_resp
cargo check --release --bin tdoa_anchor --bin tdoa_tag
cargo check --release --bin can_tx --bin can_rx
cargo check --release --bin can_fd_tx --bin can_fd_rx
Build a distance binary for DFU
mkdir -p out
cargo objcopy --release --bin twr_init -- -O binary out/twr_init.bin
cargo objcopy --release --bin twr_resp -- -O binary out/twr_resp.bin
These commands produce flat binaries without touching the website's distributed images. Pass your binary's absolute path to the DFU script as its second argument. Location images need the surveyed configuration described in the Location quickstart; an unpatched build does not contain your installation's survey.
Flash and attach RTT
Connect a compatible SWD probe to the 10-pin Cortex Debug header. The package runner is already configured for STM32G474CC.
DEFMT_LOG=info cargo run --release --bin can_tx
probe-rs erases and programs the image, resets the target, and displays defmt RTT output. For release role images and no local toolchain, use the browser DFU console.
Clocking assumptions
The supplied TWR and Location roles use the 8 MHz HSE with an 8 / 2 × 72 / 2 = 144 MHz system clock. The CAN examples use an 8 / 2 × 85 / 2 = 170 MHz system clock. CAN FD routes FDCAN from PCLK1. Do not copy one target's bus timing into another clock configuration.