Update the notes for the new firmware and name Niklas Dathe
README, docs/06, TODO and the architecture diagram describe the microbu-firmware based obu-firmware and station-link revision 2, add the hardware checks for the new image, and credit Niklas Dathe as the author of the station firmware and its interface specification. Ignore LaTeX build output next to station-link.tex.
This commit is contained in:
@@ -1,19 +1,21 @@
|
||||
# 06 – Signed ITS messages, VAM and the BLE link (2026-09-23)
|
||||
# 06 – Signed ITS messages, VAM and the BLE link (2026-09-23, firmware part updated 2026-11-10)
|
||||
|
||||
What changed when the ESP32-C5 OBU moved onto the colleague's vanetza-idf station, how the pieces
|
||||
fit together, how it was verified, and what is still open. Hardware checks still to do are in
|
||||
What changed when the ESP32-C5 OBU moved onto Niklas Dathe's station, how the pieces
|
||||
fit together, how it was verified, and what is still open. Since 2026-11-10 the firmware is built on
|
||||
Niklas Dathe's newer `microbu-firmware` layout (link spec revision 2, `obu-firmware/docs/station-link.tex`);
|
||||
the parts below that describe the earlier vanetza-idf port say so. Hardware checks still to do are in
|
||||
`TODO.md` ("Signed-TX firmware ...").
|
||||
|
||||
## Summary
|
||||
|
||||
- **Signing lives on the ESP32-C5.** The authorization ticket's private key is in the board's NVS;
|
||||
vanetza-idf's security entity signs every secured message there (IEEE 1609.2 / ETSI TS 103 097,
|
||||
the station's security entity signs every secured message there (IEEE 1609.2 / ETSI TS 103 097,
|
||||
ECDSA NIST P-256). The phone never holds a key and never signs.
|
||||
- **The phone decides what to send and when.** It builds CAM or VAM (UPER) from its own GNSS/IMU,
|
||||
hands each message to the board with the flag "signed" or "unsigned", and keeps the board's clock
|
||||
and position current.
|
||||
- **Two links, one protocol.** USB-C (native USB Serial/JTAG) or Bluetooth LE, chosen in Settings.
|
||||
Both carry the colleague's station-link protocol v1 plus one MicrOBU extension for reception.
|
||||
Both carry Niklas Dathe's station-link protocol (revision 2 of the spec adds the MicrOBU extensions: `V2X_RX`, unsigned sending, battery guard).
|
||||
- **Reception is unchanged for the app.** Every ITS message heard on air reaches the phone, signed
|
||||
or not, verifiable or not, exactly as with the previous firmware.
|
||||
- **Demo PKI, not the EU trust list.** Signed messages carry a throwaway chain. Receivers that
|
||||
@@ -35,73 +37,72 @@ fit together, how it was verified, and what is still open. Hardware checks still
|
||||
|
||||
## Firmware (obu-firmware)
|
||||
|
||||
obu-firmware is now a port of `microbu-esp32c5/firmware`, from the colleague's own repository
|
||||
(not part of this one; nothing is pushed there). The C-ITS library it needs is copied into this
|
||||
repository as `obu-firmware/external/vanetza-idf` (their commit cf4b99f, unchanged), so
|
||||
obu-firmware builds from a plain clone. It builds
|
||||
with **ESP-IDF 6.0.2 only**: the raw-TX path uses private Wi-Fi driver structures that vanetza-idf
|
||||
pins to that version. The previous C firmware (IDF 6.1) is backed up as a full flash image in
|
||||
`firmware-backups/` (gitignored, restore command in its README.txt); its sources stay on disk,
|
||||
unbuilt. Setup and flashing: `obu-firmware/FLASHING.md`. Design notes and every deviation from the
|
||||
colleague's code (`MicrOBU:` in the sources): `obu-firmware/NOTES.md`.
|
||||
obu-firmware is Niklas Dathe's `microbu-firmware` (commit e4e4bd8, HAW GitLab, not part of this
|
||||
repository; nothing is pushed there) with the MicrOBU additions: `main/`, `components/microbu_v2x`,
|
||||
`components/vanetza` and the patched `external/vanetza` are copied in unchanged, so obu-firmware builds
|
||||
from a plain clone. It builds with **ESP-IDF 6.0.2 only**: the raw-TX path uses private Wi-Fi driver
|
||||
structures that `microbu_v2x` pins to that version. Setup and flashing: `obu-firmware/FLASHING.md`.
|
||||
Design notes and every deviation from Niklas Dathe's code (`MicrOBU:` in the sources):
|
||||
`obu-firmware/NOTES.md`. The earlier port (vanetza-idf, 2026-09-23) and the previous C firmware are in
|
||||
git history (`1c3a66e`, `7285fa1`).
|
||||
|
||||
Main changes against the colleague's firmware:
|
||||
Main changes against Niklas Dathe's firmware:
|
||||
|
||||
- **Raw receive path kept.** vanetza-idf decapsulates strictly and would drop unsigned frames (the
|
||||
bench car) and anything not signed under the demo root (every RSU). Every captured frame also
|
||||
goes through the previous firmware's `gn_unwrap.c` and reaches the phone as link opcode
|
||||
`V2X_RX` (0x85), whose body is the old `SERIAL_MSG_V2X_RX` payload.
|
||||
- **Unsigned sending kept.** The colleague's station refuses unsecured requests; here they go out
|
||||
with the previous firmware's `geonet.c` header.
|
||||
- **Console on UART0** (GPIO11/12; the earlier two-port bench board had a CH343 bridge there, COM3);
|
||||
the native USB port carries only link frames. The production board is now a **Seeed XIAO ESP32-C5**
|
||||
(8 MB flash, a single native USB-C port, COM10 on the bench) running from a LiPo on its BAT pads.
|
||||
- **Battery:** the XIAO's own divider (GPIO6, enabled by GPIO26) is read every 5 s and sent in STATUS
|
||||
(`battery_mv`, `battery_flags`, octets 103-105); the app shows the voltage, a rough percentage and a
|
||||
low/critical warning on the ESP32-C5 card and in the top bar. Below 3.30 V with no phone on USB the
|
||||
board deep-sleeps, because the prototype cell has no protection board. See `obu-firmware/FLASHING.md`.
|
||||
- **BLE pauses advertising while USB is in use** (BLE and ITS-G5 share one RF front end).
|
||||
- **Raw receive path kept.** The stack decapsulates strictly and would drop unsigned frames (the
|
||||
bench car) and anything not signed under the demo root (every RSU). Every received frame also
|
||||
goes through `gn_unwrap.c` and reaches the phone as link opcode `V2X_RX` (**0x90**; 0x85 is the
|
||||
spec's RAW_FRAME), whose body is the old `SERIAL_MSG_V2X_RX` payload.
|
||||
- **Unsigned sending kept.** Niklas Dathe's station refuses unsecured requests; here they go out
|
||||
with `geonet.c`'s header and a random MAC per configuration.
|
||||
- **Production board: Seeed XIAO ESP32-C5** (8 MB flash, a single native USB-C port) running from a LiPo
|
||||
on its BAT pads. The log travels as LOG frames on the USB link (no UART adapter needed).
|
||||
- **Battery:** the XIAO's divider (GPIO6, enabled by GPIO26) is read every 5 s and reported in STATUS
|
||||
(`battery_mv`, octets 129-130); the app shows the voltage, a rough percentage and a low (3.50 V) /
|
||||
critical (3.30 V) warning on the ESP32-C5 card and in the top bar. Below 3.30 V with no phone on USB
|
||||
the board deep-sleeps, because the prototype cell has no protection board. See `obu-firmware/FLASHING.md`.
|
||||
- **BLE and ITS-G5** share one RF front end. Niklas Dathe's TX guard (`CONFIG_MICROBU_TX_BLE_GUARD`)
|
||||
holds a frame out of the BLE connection-event windows; the earlier "pause advertising while USB is
|
||||
in use" is gone.
|
||||
- **NVS 80 KB instead of 24 KB**, app at 0x20000. At 24 KB the BLE bond could not be stored and the
|
||||
phone had to pair on every connection.
|
||||
- Fixes found on the bench: radio queue drained before the first PoTi (no RX, ~177 queue drops
|
||||
before); station loop waited 0 ticks at 100 Hz and starved the idle task; 2.4 KB RX buffer moved
|
||||
off the Wi-Fi task stack; no silent truncation of BLE notifications; ATT MTU 517; serial writes
|
||||
skipped when no USB host is present.
|
||||
- Fixes carried over from the bench: radio queue drained before the first PoTi; 2.4 KB RX buffer off
|
||||
the Wi-Fi task stack; serial writes skipped when no USB host is present; manual country policy.
|
||||
|
||||
## Link protocol
|
||||
|
||||
Station-link v1 (colleague's repository, `station-link/README.md`): `[opcode][flags][sequence LE][body]`,
|
||||
little-endian, at most 512 octets. Over USB each message is one `0xAA55` frame of type `0x10`
|
||||
Station-link, revision 2 (`obu-firmware/docs/station-link.tex`; revision 1 is Niklas Dathe's): `[opcode][flags][sequence LE][body]`,
|
||||
little-endian, at most 512 octets (bodies above that are fragmented by the spec; this app never needs it). Over USB each message is one `0xAA55` frame of type `0x10`
|
||||
(the old framing and CRC). Over BLE each message is one GATT value on service
|
||||
`0000C175-BA5E-4C17-8000-00805F9B34FB` (the README describes a different, Nordic-UART layout; the
|
||||
firmware is what counts).
|
||||
firmware is what counts; the current spec table lists the same UUIDs).
|
||||
|
||||
| Direction | Message | Used for |
|
||||
|---|---|---|
|
||||
| phone → board | `STATION_CONFIGURE` | pseudonym MAC, station type, channel 180, 20 dBm; starts the radio |
|
||||
| phone → board | `STATION_CONFIGURE` | station type, channel 180, 20 dBm (6 octets); starts the radio |
|
||||
| phone → board | `CREDENTIALS_PROVISION` | the demo bundle, once, when the board reports no ticket |
|
||||
| phone → board | `POTI_UPDATE` | position and ITS time, once per new GNSS fix |
|
||||
| phone → board | `BTP_DATA_REQUEST` | one CAM (port 2001, psid 36) or VAM (port 2018, psid 638), signed or not |
|
||||
| board → phone | `RESULT` | answer to a request |
|
||||
| board → phone | `STATUS` | every second: counters, tickets, signed/refused counts |
|
||||
| board → phone | `V2X_RX` (0x85, MicrOBU) | every ITS message heard on air |
|
||||
| phone → board | `STATUS_REQUEST` | once a second; the answer is the heartbeat |
|
||||
| board → phone | `CONFIRM` | answer to a request; for `STATUS_REQUEST` its detail is the 131-octet snapshot: counters, tickets, signed/refused counts, battery |
|
||||
| board → phone | `V2X_RX` (0x90, MicrOBU) | every ITS message heard on air |
|
||||
|
||||
The app side is `Esp32Link.kt` (session), `StationLink.kt` (codec, pinned by unit tests to bytes
|
||||
from the colleague's Python implementation), `UsbSerialTransport.kt` and `BleLinkTransport.kt`.
|
||||
A board still on the previous firmware is recognised by its old heartbeat and keeps working for
|
||||
CAM over USB.
|
||||
from Niklas Dathe's Python implementation), `UsbSerialTransport.kt` and `BleLinkTransport.kt`.
|
||||
A board still on the previous C firmware is recognised by its old heartbeat and keeps working for
|
||||
CAM over USB. The app does not rotate the board's MAC any more (STATION_CONFIGURE has none): a signed
|
||||
station takes its address from the ticket, an unsigned one draws a random MAC per configuration.
|
||||
|
||||
## Redundancy and recovery
|
||||
|
||||
| Situation | What notices | What happens |
|
||||
|---|---|---|
|
||||
| USB link dead (board hung, cable) | app watchdog: no frame for 3.5 s (the board's `STATUS` comes every second) | link marked ERROR on the card |
|
||||
| USB link dead (board hung, cable) | app watchdog: no frame for 3.5 s (the app polls `STATUS` every second) | link marked ERROR on the card |
|
||||
| USB unplugged | Android detach broadcast | port closed; Connect again after re-plugging |
|
||||
| BLE link lost | BLE supervision timeout (4 s) | app reconnects by itself: 1 s after a drop, then backing off to 30 s if attempts fail |
|
||||
| Board reset / power cycle | first `STATUS` says "not configured" | app reconfigures (and re-provisions if needed) without user action |
|
||||
| Board reset / power cycle | first `STATUS` reply says "not configured" | app reconfigures (and re-provisions if needed) without user action |
|
||||
| App closed and reopened | new session | app configures the board again; BLE reconnects with the stored bond, no passkey (confirmed) |
|
||||
| Phone clock or GNSS time jumping | app tracks the board's clock | PoTi never moves it backwards (except a real correction of ≥ 60 s), so the board does not restart its stack |
|
||||
| Board firmware wedged | ESP task watchdog (30 s, logs on COM3) | the phone sees it as a dead link (above) |
|
||||
| Board firmware wedged | ESP task watchdog (30 s) | the phone sees it as a dead link (above) |
|
||||
|
||||
## App changes
|
||||
|
||||
@@ -117,14 +118,14 @@ CAM over USB.
|
||||
|
||||
## Credentials (demo PKI)
|
||||
|
||||
`app/src/main/assets/demo-chain.vcr`, generated 2026-09-23 with the colleague's `vidf_issue`: root
|
||||
`app/src/main/assets/demo-chain.vcr`, generated 2026-09-23 with Niklas Dathe's `vidf_issue`: root
|
||||
`6E7D0374FB021901` → AA `B3312F29844299E0` → AT `B80B49387A4C12EB` (two years; psid 36 SSP `010000`,
|
||||
psid 638 SSP `01`). It is throwaway and not EU-registered; its private key ships with the app on
|
||||
purpose. The colleague's own demo chain only grants psid 638 and cannot sign CAMs.
|
||||
purpose. Niklas Dathe's own demo chain only grants psid 638 and cannot sign CAMs.
|
||||
|
||||
## Verification
|
||||
|
||||
- **Unit tests** (103): VAM bytes against asn1tools, station-link messages against the colleague's
|
||||
- **Unit tests** (103): VAM bytes against asn1tools, station-link messages against Niklas Dathe's
|
||||
Python encoder, VAM generation rules.
|
||||
- **Signatures on air**: `obu-firmware/test/verify_signed_pcap.py` checks a pcap with asn1tools
|
||||
and OpenSSL, sharing no code with the firmware. Pinger capture of 2026-09-23: 12/12 signed CAMs,
|
||||
@@ -132,7 +133,7 @@ purpose. The colleague's own demo chain only grants psid 638 and cannot sign CAM
|
||||
- **Third-party stack**: the CiT One receives the signed CAMs (~1 Hz on `v2x/rx/cam`), so its
|
||||
stack unwraps our envelope. Its MQTT interface exposes no security information, and it forwards
|
||||
unsigned and unknown-root messages alike, so it cannot tell whether it verified the signature.
|
||||
- **V2X2MAP (COM10)**: now the colleague's v2x2map 0.3.0 bridge from source with a new
|
||||
- **V2X2MAP (COM10)**: now Niklas Dathe's v2x2map 0.3.0 bridge from source with a new
|
||||
`verify.py` and `--trust demo-chain.vcr`; it shows "signature verified", "SIGNATURE INVALID" or
|
||||
"not verified" per packet. Signed CAMs and signed VAMs verified live; a one-bit change in a
|
||||
signed CAM comes out invalid. Launcher: `micrOBU_workspace/v2x-obu-esp32c5/start-v2x2map-signed.bat`.
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user