2026-09-23 17:27:54 +02:00
# obu-firmware
2026-11-11 00:13:57 +01:00
The production OBU firmware: the ESP32-C5 half of the MicrOBU station (Seeed XIAO ESP32-C5).
2026-09-23 17:27:54 +02:00
2026-11-11 00:13:57 +01:00
## Since 2026-11-10: Niklas Dathe's microbu-firmware architecture
2026-09-23 17:27:54 +02:00
2026-11-11 00:13:57 +01:00
This tree is the current station firmware written by Niklas Dathe (`microbu-firmware` , HAW GitLab
urban-mobility-lab/microbu/microbu-firmware, commit e4e4bd8) with the MicrOBU additions below. The
earlier port of their older `microbu-esp32c5` (vanetza-idf, 2026-09-23) is gone.
2026-09-23 17:27:54 +02:00
2026-11-11 00:13:57 +01:00
Layout:
2026-09-23 17:27:54 +02:00
2026-11-11 00:13:57 +01:00
| Path | What |
| --- | --- |
| `main/` | station and link service: `station.cpp` , `link_*` , `serial_link.cpp` , `simple_ble.cpp` , `c5_radio.cpp` , board controls, battery |
| `components/microbu_v2x/` | station wrapper, security entity, device PKI client (unchanged from Niklas Dathe's firmware) |
| `components/vanetza/` | ESP-IDF component around Vanetza (unchanged) |
| `external/vanetza/` | patched upstream Vanetza source (unchanged, see its `UPSTREAM` ) |
| `docs/station-link.tex` | the link interface reference this firmware and the app implement: **revision 2** , Niklas Dathe's revision 1 plus our extensions (the original PDF is `microbu-firmware/docs/station-link.pdf` ; build ours with `pdflatex` , no LaTeX is installed on the lab laptop) |
| `cmake/no_efuse_writes.cmake` | build guard: nothing in this firmware may program eFuses |
| `test/host/` | PC tests (`make` in that folder): the MicrOBU C code (`gn_unwrap.c` , `geonet.c` ), the battery policy and, with `make firmware` , 39 unit tests of the link codec, V2X_RX and the policies |
2026-09-23 17:27:54 +02:00
2026-11-11 00:13:57 +01:00
Take a newer release from Niklas Dathe by copying `firmware/{main,components,cmake}` and
`external/vanetza` over these folders and re-applying the `MicrOBU:` changes (search the sources
for that word). Nothing is fetched from or pushed to their repository.
2026-09-23 17:27:54 +02:00
2026-11-11 00:13:57 +01:00
Board: `CONFIG_MICROBU_BOARD_XIAO_C5` (sdkconfig.defaults). Their default is `mainboard-v5` , the
custom PCB; pick it in `menuconfig -> micrOBU firmware -> Board` .
2026-09-23 17:27:54 +02:00
2026-11-11 00:13:57 +01:00
### MicrOBU additions (search for `MicrOBU`)
2026-09-23 17:27:54 +02:00
2026-11-11 00:13:57 +01:00
- **Reception of everything on air: `V2X_RX` , opcode `0x90` .** The stack decapsulates strictly, so it
drops unsigned traffic (the bench sim car) and everything signed under a root other than the
provisioned one (every RSU). Every received data frame therefore also goes through `gn_unwrap.c`
(`Station::forward_raw` ) and reaches the phone as `V2X_RX` . Body: `u16 port, i8 rssi, u8 flags
(bit0 GBC area, bit1 signed), i32 lat, i32 lon, u16 distance_a, ITS payload` . `0x85` is the spec's
`RAW_FRAME` debug capture and `0x86` is reserved by Niklas Dathe, hence `0x90` . BTP ports 2001
CAM, 2002 DENM, 2003 MAPEM, 2004 SPATEM, 2018 VAM pass; a message over 494 bytes does not fit a
512-octet link message and is dropped and counted (not fragmented).
- **Unsigned transmission.** Niklas Dathe's station signs everything. A request with GN security
profile 1 (or 0 while the station is configured `security = 0` ) goes out unsigned with
`geonet.c` 's header and the position of the last PoTi (`Station::unsecured_request` ), from a
random locally administered MAC drawn at every STATION_CONFIGURE. The app's "Sign outgoing
messages" setting decides per message. It bypasses the BLE collision guard's queue but not the
guard itself.
- **Radio polled from configure on**, not from the first PoTi, so the 16-frame queue never overflows
while the phone has not sent a fix yet.
- **Radio bring-up** from the previous C firmware: manual country policy (5 GHz channels on), TX
power read-back logged, 2.4 KB receive buffer static instead of on the Wi-Fi task's stack, frames
too short to be GN packets ignored rather than counted as lost.
- **Battery guard.** Niklas Dathe's firmware only reports `battery_mv` in STATUS. A XIAO cell has no
protection board, so `battery_policy.hpp` (smoothing, warning hysteresis, shutdown) deep-sleeps the
board below 3.30 V for 30 s when no phone is on USB, re-checks every 5 min, and runs again from
3.60 V. Thresholds: `menuconfig -> micrOBU firmware` .
- **Serial link**: no write attempt while no USB host is connected; `last_frame_ms()` tells the battery
guard whether a phone is powering the board.
- **Partition table**: 80 KB NVS (Niklas Dathe's 24 KB filled up and BLE bonds stopped persisting),
app at `0x20000` . A plain app-only flash of an older layout is wrong: flash everything.
- **Flash size 8 MB** (XIAO), TX power ceiling 20 dBm (`radio_policy.hpp` admits 20 dBm on channel 180).
2026-08-04 17:58:07 +02:00
2026-11-11 00:13:57 +01:00
### Link spec revision 2
2026-08-04 17:58:07 +02:00
2026-11-11 00:13:57 +01:00
`docs/station-link.tex` is revision 2 of the interface reference: Niklas Dathe's revision 1 (microbu-firmware
e4e4bd8, kept unchanged as `microbu-firmware/docs/station-link.pdf` ) plus a section "MicrOBU extensions": `V2X_RX`
(0x90), unsigned transmission (security profile 0x01, or 0x00 with `security` 0; random MAC per configure),
the battery shutdown rule, no USB writes without a host, and a revision history. The wire format of
revision 1 is unchanged, so a revision 1 host still works. No LaTeX is installed on the lab laptop: build
the PDF with `pdflatex station-link.tex` (twice) elsewhere.
2026-08-04 17:58:07 +02:00
2026-11-11 00:13:57 +01:00
### What the new firmware changes for the phone
2026-08-04 17:58:07 +02:00
2026-11-11 00:13:57 +01:00
See `docs/station-link.tex` (revision history at its end). In short: `RESULT` /`STATUS` became `CONFIRM` (0x80) with the 131-octet
status in `CONFIRM.detail` of `STATUS_REQUEST` ; STATION_CONFIGURE is 6 octets (type, channel, power,
security, beaconing; no MAC, the address derives from the ticket); BTP-DATA.request carries
`generated_at_ms` (requests older than 1 s are refused); request bodies up to 1536 and indications up
to 65535 octets are fragmented; logs travel as LOG frames (0x7F) on the USB link, so a XIAO needs no
UART adapter any more.
Credentials: the app ships `assets/demo-chain.vcr` , a throwaway chain with psid 36 (CAM) and 638 (VAM).
Not EU-registered: receivers that verify against the EU trust list drop what it signs.
Time: TimestampIts counts TAI milliseconds since 2004 (TS 102 894-2), 5 leap seconds ahead of UTC;
the app's `ItsTime` follows that.