Rebuild obu-firmware on Niklas Dathe's microbu-firmware

Replace the vanetza-idf port with his current station firmware (microbu-firmware
e4e4bd8: main/, components/microbu_v2x, components/vanetza, external/vanetza) and
re-apply the MicrOBU additions, each marked "MicrOBU:" in the sources:

- V2X_RX (opcode 0x90): every received ITS message, signed or not, through
  gn_unwrap.c, because the stack drops unsigned and foreign-root traffic. 0x85 is
  the spec's RAW_FRAME and 0x86 is reserved. The body is built in v2x_rx.hpp.
- Unsigned transmission (geonet.c) for security profile 1 or station security 0,
  from a random MAC per configuration.
- Radio polled from STATION_CONFIGURE on; manual country policy, TX power
  read-back, static RX buffer, short frames ignored.
- Battery guard (battery_policy.hpp): deep sleep below 3.30 V with no phone on USB.
- No USB writes without a host; last_frame_ms() for the guard.
- 80 KB NVS with the app at 0x20000, 8 MB flash, XIAO ESP32-C5 board, 20 dBm.

Remove the old C firmware, the bench listener and the old vanetza-idf copy. Add
docs/station-link.tex as revision 2 of the interface reference (V2X_RX, unsigned
sending, battery rule, revision history). Add 39 host unit tests (make firmware in
test/host) next to the existing chain, replay, fuzz and battery tests, and point
tools/station_status_watch.py at the new CONFIRM-based status.
This commit is contained in:
Ashin Walpola
2026-11-11 00:13:57 +01:00
parent 1c3a66e4da
commit 50bbf6552d
10307 changed files with 53622 additions and 850451 deletions
+24 -8
View File
@@ -21,17 +21,17 @@ FUZZ_SEED = 1
# -Werror: these sources must stay warning-free on the host compiler too.
# UBSan in trap mode needs no runtime library, so it works on MinGW; a trap shows up as a crash.
CFLAGS = -std=c11 -O2 -g -Wall -Wextra -Wpedantic -Werror -I$(FW) \
CFLAGS = -std=c11 -O2 -g -Wall -Wextra -Wpedantic -Werror -I$(FW) -I. \
-fsanitize=undefined -fsanitize-undefined-trap-on-error
FW_SRCS = $(FW)/geonet.c $(FW)/dot11p.c $(FW)/gn_unwrap.c
DEPS = test_util.c test_util.h $(FW_SRCS) $(wildcard $(FW)/*.h)
FW_SRCS = $(FW)/geonet.c dot11p.c $(FW)/gn_unwrap.c
DEPS = test_util.c test_util.h dot11p.h $(FW_SRCS) $(wildcard $(FW)/*.h)
.PHONY: all check chain replay fuzz battery clean
.PHONY: all check chain replay fuzz battery firmware clean
all: check
check: chain replay fuzz battery
check: chain replay fuzz battery firmware
$(BUILD):
mkdir -p $@
@@ -55,14 +55,30 @@ endif
fuzz: $(BUILD)/fuzz_gn_unwrap$(EXE)
$(BUILD)/fuzz_gn_unwrap$(EXE) $(FUZZ_ITER) $(FUZZ_SEED) $(RECORDINGS)
# Battery policy and the STATUS battery fields: C++17, so its own flags.
# Battery policy: C++17, so its own flags.
CXXFLAGS = -std=c++17 -O2 -g -Wall -Wextra -Wpedantic -Werror -I$(FW)
$(BUILD)/test_battery$(EXE): test_battery.cpp $(FW)/battery_monitor.hpp $(FW)/link_protocol.cpp $(FW)/link_protocol.hpp | $(BUILD)
$(CXX) $(CXXFLAGS) -o $@ test_battery.cpp $(FW)/link_protocol.cpp
$(BUILD)/test_battery$(EXE): test_battery.cpp $(FW)/battery_policy.hpp | $(BUILD)
$(CXX) $(CXXFLAGS) -o $@ test_battery.cpp
battery: $(BUILD)/test_battery$(EXE)
$(BUILD)/test_battery$(EXE)
clean:
rm -rf $(BUILD)
# Unit tests of the firmware logic that needs no ESP32: link codec against the app's bytes, request
# reassembly, V2X_RX, radio / BLE-guard / clock / battery policies. Prints PASS or FAIL per test and a RESULT line.
$(BUILD)/fw_c_%.o: $(FW)/%.c | $(BUILD)
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/fw_c_dot11p.o: dot11p.c dot11p.h | $(BUILD)
$(CC) $(CFLAGS) -c -o $@ $<
FW_CXX_SRCS = $(FW)/link_protocol.cpp $(FW)/tx_policy.cpp $(FW)/its_clock.cpp
$(BUILD)/test_firmware$(EXE): test_firmware.cpp $(FW_CXX_SRCS) $(wildcard $(FW)/*.hpp) $(BUILD)/fw_c_geonet.o $(BUILD)/fw_c_gn_unwrap.o $(BUILD)/fw_c_dot11p.o | $(BUILD)
$(CXX) $(CXXFLAGS) -std=c++20 -I. -o $@ test_firmware.cpp $(FW_CXX_SRCS) $(BUILD)/fw_c_geonet.o $(BUILD)/fw_c_gn_unwrap.o $(BUILD)/fw_c_dot11p.o
firmware: $(BUILD)/test_firmware$(EXE)
$(BUILD)/test_firmware$(EXE)