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.
131 lines
6.2 KiB
CMake
131 lines
6.2 KiB
CMake
# Vanetza (LGPL-3.0-or-later): upstream riebl/vanetza at the pinned commit plus patches/
|
|
# (series.cmake), as an ESP-IDF component or, on the host, as the static library `vanetza`.
|
|
# Only the sources listed in sources.cmake are compiled; the manifest fixes the compiled source set.
|
|
#
|
|
# Feature selection follows microbu_v2x: CONFIG_MICROBU_V2X_* on ESP-IDF, V2X_* on the host.
|
|
cmake_minimum_required(VERSION 3.22)
|
|
include("${CMAKE_CURRENT_LIST_DIR}/series.cmake")
|
|
vanetza_series_prepare(VANETZA_ROOT)
|
|
include("${CMAKE_CURRENT_LIST_DIR}/sources.cmake")
|
|
set(_vanetza_dir "${CMAKE_CURRENT_LIST_DIR}")
|
|
|
|
if(ESP_PLATFORM)
|
|
idf_component_register(SRCS "src/sha.cpp"
|
|
INCLUDE_DIRS "${VANETZA_ROOT}" "${VANETZA_ROOT}/vanetza/asn1/support"
|
|
REQUIRES esp-boost
|
|
PRIV_REQUIRES mbedtls)
|
|
if(CMAKE_BUILD_EARLY_EXPANSION)
|
|
return()
|
|
endif()
|
|
set(VANETZA_TARGET ${COMPONENT_LIB})
|
|
foreach(_feature NETWORK CAM DENM VAM SECURITY PKI)
|
|
set(V2X_${_feature} ${CONFIG_MICROBU_V2X_${_feature}})
|
|
endforeach()
|
|
else()
|
|
foreach(_feature NETWORK CAM DENM VAM SECURITY)
|
|
if(NOT DEFINED V2X_${_feature})
|
|
set(V2X_${_feature} ON)
|
|
endif()
|
|
endforeach()
|
|
add_library(vanetza STATIC "${_vanetza_dir}/src/sha.cpp")
|
|
add_library(Vanetza::vanetza ALIAS vanetza)
|
|
set(VANETZA_TARGET vanetza)
|
|
target_include_directories(vanetza PUBLIC "${VANETZA_ROOT}" "${VANETZA_ROOT}/vanetza/asn1/support")
|
|
if(V2X_BOOST_ROOT)
|
|
target_include_directories(vanetza SYSTEM PUBLIC "${V2X_BOOST_ROOT}")
|
|
if(WIN32)
|
|
target_compile_definitions(vanetza PUBLIC BOOST_NO_USER_CONFIG
|
|
BOOST_PLATFORM_CONFIG="boost/config/platform/win32.hpp")
|
|
endif()
|
|
else()
|
|
find_package(Boost 1.70 REQUIRED)
|
|
target_include_directories(vanetza SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
|
|
endif()
|
|
endif()
|
|
|
|
target_compile_features(${VANETZA_TARGET} PUBLIC cxx_std_17)
|
|
set_target_properties(${VANETZA_TARGET} PROPERTIES C_STANDARD 11 CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES)
|
|
|
|
set(_sources ${V2X_BASE_SOURCES})
|
|
if(V2X_NETWORK)
|
|
list(APPEND _sources ${V2X_NETWORK_SOURCES} ${V2X_SECURITY_ASN_SOURCES})
|
|
endif()
|
|
if(NOT ESP_PLATFORM)
|
|
# src/sha.cpp: OpenSSL digests on the host, PSA Crypto on the device
|
|
find_package(OpenSSL REQUIRED COMPONENTS Crypto)
|
|
target_link_libraries(${VANETZA_TARGET} PRIVATE OpenSSL::Crypto)
|
|
endif()
|
|
if(V2X_NETWORK OR V2X_CAM OR V2X_DENM OR V2X_VAM)
|
|
list(APPEND _sources ${V2X_ASN_SUPPORT_SOURCES})
|
|
endif()
|
|
foreach(_service CAM DENM VAM)
|
|
if(V2X_${_service})
|
|
list(APPEND _sources ${V2X_${_service}_SOURCES})
|
|
endif()
|
|
endforeach()
|
|
if(V2X_SECURITY)
|
|
list(APPEND _sources ${V2X_SECURITY_PROVIDER_SOURCES})
|
|
if(NOT ESP_PLATFORM)
|
|
# persistence.hpp declares the OpenSSL loaders under this define: keep it PUBLIC.
|
|
list(APPEND _sources ${V2X_SECURITY_HOST_SOURCES})
|
|
target_compile_definitions(${VANETZA_TARGET} PUBLIC VANETZA_WITH_OPENSSL)
|
|
target_compile_definitions(${VANETZA_TARGET} PRIVATE OPENSSL_API_COMPAT=0x10101000L)
|
|
endif()
|
|
if(V2X_PKI)
|
|
list(APPEND _sources ${V2X_PKI_ASN_SOURCES})
|
|
endif()
|
|
endif()
|
|
list(REMOVE_DUPLICATES _sources)
|
|
target_sources(${VANETZA_TARGET} PRIVATE ${_sources})
|
|
|
|
if(V2X_NETWORK)
|
|
foreach(_module circular_buffer geometry heap rational multiprecision)
|
|
if(NOT EXISTS "${_vanetza_dir}/third_party/${_module}/include/boost")
|
|
message(FATAL_ERROR "Missing Boost.${_module}; run git submodule update --init --recursive")
|
|
endif()
|
|
target_include_directories(${VANETZA_TARGET} SYSTEM PUBLIC "${_vanetza_dir}/third_party/${_module}/include")
|
|
endforeach()
|
|
# Last-resort fallback headers for older system Boost releases; searched after every real Boost include root.
|
|
target_include_directories(${VANETZA_TARGET} SYSTEM PUBLIC "${_vanetza_dir}/compat/include")
|
|
endif()
|
|
# Iostreams stream devices are header-only here; esp-boost omits these headers.
|
|
if(V2X_IOSTREAMS_ROOT)
|
|
target_include_directories(${VANETZA_TARGET} SYSTEM PUBLIC "${V2X_IOSTREAMS_ROOT}")
|
|
elseif(EXISTS "${_vanetza_dir}/third_party/iostreams/include/boost/iostreams/stream.hpp")
|
|
target_include_directories(${VANETZA_TARGET} SYSTEM PUBLIC "${_vanetza_dir}/third_party/iostreams/include")
|
|
elseif(ESP_PLATFORM)
|
|
message(FATAL_ERROR "Missing Boost.Iostreams. Run git submodule update --init --recursive or set V2X_IOSTREAMS_ROOT.")
|
|
endif()
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
target_compile_options(${VANETZA_TARGET} PRIVATE -ffunction-sections -fdata-sections
|
|
-Wno-error=deprecated-declarations)
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
|
|
target_compile_options(${VANETZA_TARGET} PRIVATE -Wno-error=deprecated-variadic-comma-omission)
|
|
endif()
|
|
endif()
|
|
if(ESP_PLATFORM)
|
|
target_compile_definitions(${VANETZA_TARGET} PUBLIC HAVE_NETINET_IN_H)
|
|
# The generated IOC table intentionally zero-initializes trailing fields.
|
|
set_source_files_properties("${VANETZA_ROOT}/vanetza/asn1/its/r2/WrappedExtensionContainer.c"
|
|
PROPERTIES COMPILE_OPTIONS -Wno-error=missing-field-initializers)
|
|
# Same for the IOC tables behind HeaderInfo's contributedExtensions; some generated object sets
|
|
# are referenced by no constraint in this closure.
|
|
set_source_files_properties(
|
|
"${VANETZA_ROOT}/vanetza/asn1/security/AppExtension.c"
|
|
"${VANETZA_ROOT}/vanetza/asn1/security/CertIssueExtension.c"
|
|
"${VANETZA_ROOT}/vanetza/asn1/security/CertRequestExtension.c"
|
|
"${VANETZA_ROOT}/vanetza/asn1/security/ContributedExtensionBlock.c"
|
|
"${VANETZA_ROOT}/vanetza/asn1/security/IeeeExtension.c"
|
|
PROPERTIES COMPILE_OPTIONS "-Wno-error=missing-field-initializers;-Wno-error=unused-const-variable")
|
|
# ESP-IDF 6 uses picolibc's native timegm, without a tm_gmtoff member.
|
|
# Do not confuse the missing struct member with timezone-mutating emulation.
|
|
if(IDF_VERSION_MAJOR GREATER_EQUAL 6)
|
|
set_source_files_properties("${VANETZA_ROOT}/vanetza/asn1/support/GeneralizedTime.c"
|
|
PROPERTIES COMPILE_DEFINITIONS HAVE_TIMEGM)
|
|
endif()
|
|
target_compile_options(${VANETZA_TARGET} PRIVATE
|
|
$<$<COMPILE_LANGUAGE:C>:-Wno-error=unused-function>
|
|
$<$<COMPILE_LANGUAGE:C>:-Wno-error=maybe-uninitialized>)
|
|
endif()
|