Settings > Connection > ESP32-C5 > Receive path chooses where received ITS messages come from. V2X_RX (default) is the MicrOBU extension the board builds with gn_unwrap.c. Raw frames is the station-link RAW_FRAME debug capture: the app switches RAW_CAPTURE on (mode 3), reassembles fragmented link messages as the spec defines (LinkReassembly), parses the ITS5 record (RawFrame) and unwraps the 802.11 frame with GnUnwrap, a Kotlin port of gn_unwrap.c. Both end as the same V2X_RX frames, so nothing above the link changes, and the firmware keeps both. GnUnwrapTest checks the port against the C code on 602 recorded, cut and corrupted frames (corpus from obu-firmware/test/host: make corpus). 145 app tests. Fix the Connection text that claimed the app picks the strongest micrOBU.
Host-side tests for obu-firmware
Status (2026-09-11): the chain test, the capture replay and the fuzzer are written and pass; results under "Running". Toolchain: MSYS2 UCRT64 gcc, Option B below (chosen and installed 2026-09-11).
Firmware unit tests (make firmware, test_firmware.cpp, 40 tests): the station-link codec byte-exact against
the app's StationLinkTest hex, the 131-octet STATUS offsets, request reassembly, the V2X_RX extension
(main/v2x_rx.hpp; the 494-octet limit, the 14-octet prefix, TX code -> air frame -> RX path), radio operating
points, the BLE TX guard, the ITS clock, CCA counters, BLE security and the battery policy. It prints PASS or FAIL
per test and a RESULT: line, and exits non-zero on a failure. It cannot test the radio, BLE, NVS or USB: those are
on the bench list in TODO.md.
geonet.c, dot11p.c and gn_unwrap.c include nothing but standard C headers, so they compile
unmodified on a PC. That makes three things possible without a board: a TX -> RX round trip
through our own code, replaying real captures through the RX parser, and fuzzing the parser that
reads untrusted radio bytes. ESP-IDF only builds main/ (and components/), so nothing under
test/ ever affects the firmware image.
Layout
obu-firmware/
├── main/ firmware sources; the tests compile these directly, never copies
└── test/
├── pcap_gn_tally.py GN header fields per station over .pcap captures (Python only)
└── host/
├── README.md this file
├── Makefile `make`: builds ../../main/{geonet,gn_unwrap}.c and ./dot11p.c + tests, runs them
├── test_chain.c geonet_wrap_shb -> dot11p_build_frame -> gn_unwrap_its, byte-checked
├── test_util.c/.h shared: guard page, crash report, pcap read/write
├── test_replay.c every recorded frame through gn_unwrap_its, results to a TSV
├── check_replay.py re-derives each result independently, then asn1tools on the messages
├── fuzz_gn_unwrap.c mutation fuzzer; each input ends against a no-access guard page, so
│ an over-read faults (no ASan on MinGW)
└── build/ compiler output; already ignored by the repo's `build/` rule
The repo's vanetza/ folder is a gitignored reading copy only; it is not built. check_replay.py
reads the IEEE 1609.2 ASN.1 modules from it (they carry no licence header, so they are not copied
into asn1/). Without it, signed frames are still replayed but not checked independently.
Running
From PowerShell, with MSYS2 on PATH for the session (Option B step 3):
$env:PATH = "C:\msys64\ucrt64\bin;C:\msys64\usr\bin;$env:PATH"
cd C:\Users\Ashin\AndroidStudioProjects\MicrOBU\obu-firmware\test\host
make
make runs three things (make chain, make replay, make fuzz run one). A non-zero exit, or a
CRASH ... during: <what> line (from the fuzzer, followed by the input as hex), is a failure.
- chain (
test_chain.c): frames built by the firmware's own TX code, checked byte by byte against EN 302 636-4-1 and parsed back. Covers the CAM layout (non-QoS and QoS), Source Position Vector edges, output-buffer bounds, a 512-byte payload throughmain.c's buffer sizes, hand-built GeoBroadcast frames in all three shapes, signed frames in all three COER length forms plus a top-level unsecuredData, one-byte mutations that must be rejected or accepted, the Common Header's payload length as the message boundary, the 8-byte RX trailer, and every truncation length of each frame against the guard page.pcap_gn_tally.pythen reads the frames back as a second parser;build/test_chain.pcapopens in Wireshark too. 2026-09-11: 1731 checks, 0 failed. - replay (
test_replay.c+check_replay.py): every record inits-g5-receiver-firmware/recordings/*.pcapthroughgn_unwrap_its, each cut tomain.c's 800-byte capture buffer as on the board.check_replay.pyre-derives each result on its own (its own GN/BTP parse; the security envelope decoded by asn1tools from the IEEE 1609.2 modules), compares record by record, then decodes and re-encodes every distinct message with asn1tools - a byte-identical re-encode is only possible when the message was cut at exactly the right byte. Needspy -3.11with asn1tools. 2026-09-11: 15 145 records, 15 131 accepted (10 831 CAM, 4 300 DENM; 157 of them signed); C and Python agree on every record; 11 043 of the 11 106 distinct messages re-encode byte-identically. The other 63 fail the same way with the old 8 trailing bytes put back, so the boundary is not the cause: 5 are our own CAMs from before the 2026-08-20 yawRateConfidence fix, 56 come from the CiT One and 1 from another station (seeTODO.md), and 1 uses an extension asn1tools cannot re-encode. - fuzz (
fuzz_gn_unwrap.c): random edits of every recorded frame, each run against the guard page; an over-read crashes, an accepted payload outside its input fails. Default 2 000 000 iterations (about 2 s);make fuzz FUZZ_ITER=50000000 FUZZ_SEED=7for a longer run. 2026-09-11: 50 000 000 iterations, no crash.
Not covered: the station, link and serial code in main/, which need ESP-IDF;
and the phone's encoder, whose bytes are opaque here (asn1tools and the app's golden test cover
it).
Option A (not used): WSL2 + Ubuntu 24.04
Kept as the fallback if AddressSanitizer or libFuzzer are ever needed; Option B has neither.
-
In PowerShell as Administrator:
wsl --install -d Ubuntu-24.04Reboot if it asks. Ubuntu then opens and asks for a Linux username and password (separate from the Windows account). Checked 2026-09-11: Hyper-V is already running on this PC, so no BIOS change should be needed. If the install says virtualization is disabled, enable Intel VT-x / AMD SVM in the BIOS.
-
Confirm it is WSL 2:
wsl -l -vshould listUbuntu-24.04with VERSION2. -
Inside Ubuntu, the compilers:
sudo apt update sudo apt install -y build-essential clang cmake ninja-build git pkg-config python3 -
Smoke test: the firmware sources compile on the host (expect no output):
cd /mnt/c/Users/Ashin/AndroidStudioProjects/MicrOBU/obu-firmware/test/host cc -std=c11 -Wall -Wextra -fsyntax-only ../../main/geonet.c dot11p.c ../../main/gn_unwrap.c
Option B (chosen): native Windows gcc via MSYS2
Enough for the round-trip test, the capture replay and the guard-page fuzzer. No libFuzzer and no AddressSanitizer with MinGW gcc, which is why the fuzzer uses a guard page instead.
-
In PowerShell:
winget install -e --id MSYS2.MSYS2(installs toC:\msys64). -
Open MSYS2 UCRT64 from the Start menu and run
pacman -Syu. If the window closes, reopen it and runpacman -Syuagain. Then:pacman -S --needed mingw-w64-ucrt-x86_64-gcc make -
C:\msys64\ucrt64\binmust be on PATH. CallingC:\msys64\ucrt64\bin\gcc.exeby its full path alone exits 1 with no message, because gcc's compiler stages load their DLLs from that folder.makelives on the MSYS side, inC:\msys64\usr\bin. Either work inside the MSYS2 UCRT64 shell, which has both, or put them on PATH for the current session:$env:PATH = "C:\msys64\ucrt64\bin;C:\msys64\usr\bin;$env:PATH" # PowerShellexport PATH=/c/msys64/ucrt64/bin:/c/msys64/usr/bin:$PATH # Git BashAdding them to the user PATH permanently also works; it was deliberately not done by setup.
-
Smoke test (expect no output):
cd C:\Users\Ashin\AndroidStudioProjects\MicrOBU\obu-firmware\test\host gcc -std=c11 -Wall -Wextra -fsyntax-only ../../main/geonet.c dot11p.c ../../main/gn_unwrap.c
Installed on this PC 2026-09-11: MSYS2 20260611, gcc 16.2.0 (UCRT64), GNU Make 4.4.1. All three
firmware sources compile with -std=c11 -O2 -Wall -Wextra -Wpedantic and no warnings.
Line endings
The repo runs with core.autocrlf=true, so Windows checkouts have CRLF line endings. C compilers
don't care; shell scripts run from WSL do (bash: $'\r': command not found). When the first .sh
file lands here, add *.sh text eol=lf to a root .gitattributes (none exists yet).