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.
85 lines
3.2 KiB
Makefile
85 lines
3.2 KiB
Makefile
# Host-side tests for obu-firmware. See README.md: needs gcc and make on PATH (MSYS2 UCRT64), and
|
|
# asn1tools under `py -3.11` for the replay check.
|
|
#
|
|
# make build and run everything: chain, replay, fuzz
|
|
# make chain | replay | fuzz | battery one of them
|
|
# make fuzz FUZZ_ITER=50000000 FUZZ_SEED=7 a longer or different fuzz run
|
|
# make clean remove build/
|
|
#
|
|
# The firmware sources are compiled straight from ../../main, never copied.
|
|
|
|
CC = gcc
|
|
CXX = g++
|
|
PYTHON = python
|
|
PYTHON_ASN1 = py -3.11
|
|
FW = ../../main
|
|
BUILD = build
|
|
EXE = $(if $(filter Windows_NT,$(OS)),.exe,)
|
|
RECORDINGS = $(wildcard ../../../its-g5-receiver-firmware/recordings/*.pcap)
|
|
FUZZ_ITER = 2000000
|
|
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) -I. \
|
|
-fsanitize=undefined -fsanitize-undefined-trap-on-error
|
|
|
|
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 firmware clean
|
|
|
|
all: check
|
|
|
|
check: chain replay fuzz battery firmware
|
|
|
|
$(BUILD):
|
|
mkdir -p $@
|
|
|
|
$(BUILD)/%$(EXE): %.c $(DEPS) | $(BUILD)
|
|
$(CC) $(CFLAGS) -o $@ $< test_util.c $(FW_SRCS)
|
|
|
|
# The pcap goes through pcap_gn_tally.py as a second, independent parser of the same frames.
|
|
chain: $(BUILD)/test_chain$(EXE)
|
|
$(BUILD)/test_chain$(EXE) $(BUILD)/test_chain.pcap
|
|
$(PYTHON) ../pcap_gn_tally.py $(BUILD)/test_chain.pcap
|
|
|
|
replay: $(BUILD)/test_replay$(EXE)
|
|
ifeq ($(RECORDINGS),)
|
|
@echo "replay: no recordings in ../../../its-g5-receiver-firmware/recordings, skipped"
|
|
else
|
|
$(BUILD)/test_replay$(EXE) $(BUILD)/replay.tsv $(RECORDINGS)
|
|
$(PYTHON_ASN1) check_replay.py $(BUILD)/replay.tsv $(RECORDINGS)
|
|
endif
|
|
|
|
fuzz: $(BUILD)/fuzz_gn_unwrap$(EXE)
|
|
$(BUILD)/fuzz_gn_unwrap$(EXE) $(FUZZ_ITER) $(FUZZ_SEED) $(RECORDINGS)
|
|
|
|
# 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_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)
|