Files
ZephCore/zephcore/cmake/zephcore_board.cmake
T
liquidraver 38f815a0a1 server roles, event loops, companion transports, storage and prefs.json
Server roles (slice 7)
- CommonCLI split into upstream's shape; region CLI moved into CommonCLI;
  ClientACL, RegionMap, TransportKeyStore and both server meshes in
  upstream shape over an Arduino compat shim (helpers/compat: Arduino.h,
  Stream/Print, Serial, SHA256, FILESYSTEM/File over Zephyr fs)
- room server processAck port; `get acl` prints as upstream
- room: default name Room-XXXX, display/input rotation, live radio UI refresh

Event loops (slice 7b)
- repeater and room server share server_main_common with a ServerRole
  descriptor; shared event bits in src/mesh_events.h
- room server deadline-driven (idle wakes 2.2/s -> 0.08/s); companion
  loop() runs on housekeeping (closes the lazy contact-flush gap)
- `get loop.wakes` in debug builds (CONFIG_ZEPHCORE_LOOP_WAKE_STATS)

Companion transports and WiFi (slice 8)
- upstream MultiSerialInterface: BLE, USB/UART and TCP are each a
  BaseSerialInterface, every connected transport gets every frame;
  CompanionSerial holds a lossless reply; shared frame_txq for BLE/TCP
- SerialCompanionTransport and LinuxTCPTransport replaced by
  TcpCompanionTransport; ZephyrBLE split (gatt layout, DFU)
- WiFi companion (upstream wifi.ssid/pwd/enabled CLI, TCP port 5000) on
  boards declaring `capabilities: wifi` in zephcore.yml: the PSRAM
  ESP32-S3 boards, plus Heltec V3 (140 contacts), Wireless Tracker (130)
  and both C6 boards (280); ESP32-S3 without PSRAM gets bounded WiFi
  buffers and a measured 72 KB heap; PSRAM boards' internal heap 72 KB
- TCP queues: own depth (ZEPHCORE_TCP_QUEUE_SIZE=8), RX waits instead
  of dropping
- RAM: companion ClientACL dropped; main/BT-TX/TCP stacks sized from
  measured peaks (-7 KB nRF companions, -9 KB ESP32 companions)
- ESP32 WiFi stopped working under ~200 frames/s unicast. Fixed by:
  patches/zephyr/0017 never block the WiFi task in the RX callback;
  patches/zephyr/0018 lock shared_multi_heap (heap corruption with the
  WiFi heap in PSRAM); patches/modules/hal_espressif/0001 backport of
  hal_espressif af97fb02df (PSRAM realloc)

Storage and prefs (slice 9)
- prefs are now prefs.json through upstream's ConfigSerializer (ported
  verbatim), with upstream's key names for shared fields and ZephCore's
  own under "zc"; on first boot the binary new_prefs / repeater prefs is
  migrated and kept, so a downgrade still boots with the old settings
- helpers/PrefsCodec: both legacy binary layouts (companion 272 B,
  server 311 B) as Zephyr-free codecs; sanitizeNodePrefs is the only
  validator
- fix: server prefs could be replaced by a truncated file when a write
  failed; identity, prefs and channel writes go through one checked
  atomic replace (ZephyrFsUtil)
- fix: a corrupt cad_auto byte turned adaptive CAD off instead of the
  default on
- fix: a deliberate 300 s GPS duty on a repeater was rewritten to 48 h
  on every boot (that migration now runs on legacy files only)
- one identity loader for all roles (IdentityFile); an unusable key
  file is always parked as .bad before regenerating
- server store no longer stamps repeater defaults on room server and
  observer; companion first-boot volume policy moved into the store
  (adoptVolume)
- ZephyrDataStore 1435 -> ~850 lines
2026-09-25 08:34:21 +02:00

98 lines
4.2 KiB
CMake

# Resolve the ZephCore board directory, the platform, and the build class.
#
# Shared by zephcore/CMakeLists.txt and zephcore/sysbuild/CMakeLists.txt so the
# app and the MCUboot image always agree on which board directory they read.
# Runs before find_package(Zephyr): nothing here may depend on Kconfig or DT.
#
# Inputs: BOARD name[@revision][/soc[/cpucluster]]
# ZEPHCORE_SOURCE_DIR the application source dir
# Outputs: ZEPHCORE_BOARD_BASE board name without revision or qualifiers
# ZEPHCORE_BOARD_DIR boards/<platform-dir>/<board>, or "" if none
# ZEPHCORE_PLATFORM nrf52 | nrf54l | esp32 | mg24 | stm32wl | linux | ""
# ZEPHCORE_BOARD_LIGHT_SLEEP TRUE if the board manifest declares it
# ZEPHCORE_BOARD_WIFI TRUE if the board manifest declares it
# zephcore_board_file(<out-var> <file-name>)
# absolute path of <file-name> inside the board dir, or "".
string(REGEX REPLACE "[@/].*$" "" ZEPHCORE_BOARD_BASE "${BOARD}")
# ---- Board directory -------------------------------------------------------
# boards/<platform-dir>/<board>/. Exactly one may exist: two would make every
# per-board file (conf, overlay, partitions, battery curve) ambiguous, and the
# old "take the first glob match" behaviour picked one silently.
set(ZEPHCORE_BOARD_DIR "")
if(ZEPHCORE_BOARD_BASE)
file(GLOB _zb_candidates LIST_DIRECTORIES true
"${ZEPHCORE_SOURCE_DIR}/boards/*/${ZEPHCORE_BOARD_BASE}")
set(_zb_dirs "")
foreach(_c IN LISTS _zb_candidates)
if(IS_DIRECTORY "${_c}")
list(APPEND _zb_dirs "${_c}")
endif()
endforeach()
list(LENGTH _zb_dirs _zb_count)
if(_zb_count GREATER 1)
message(FATAL_ERROR
"ZephCore: board '${ZEPHCORE_BOARD_BASE}' has ${_zb_count} directories:\n"
" ${_zb_dirs}\nKeep exactly one under boards/<platform>/.")
elseif(_zb_count EQUAL 1)
set(ZEPHCORE_BOARD_DIR "${_zb_dirs}")
endif()
endif()
function(zephcore_board_file OUT NAME)
if(ZEPHCORE_BOARD_DIR AND EXISTS "${ZEPHCORE_BOARD_DIR}/${NAME}")
set(${OUT} "${ZEPHCORE_BOARD_DIR}/${NAME}" PARENT_SCOPE)
else()
set(${OUT} "" PARENT_SCOPE)
endif()
endfunction()
# ---- Platform --------------------------------------------------------------
# The board's directory is its platform. Boards without a ZephCore directory
# (a plain upstream board built for experiments) fall back to the SoC named in
# the board qualifier; native_sim is the Linux port, whose presets are
# boards/linux_native/<preset>.conf rather than board directories.
set(ZEPHCORE_PLATFORM "")
if(ZEPHCORE_BOARD_DIR)
get_filename_component(_zb_parent "${ZEPHCORE_BOARD_DIR}" DIRECTORY)
get_filename_component(_zb_platdir "${_zb_parent}" NAME)
if(_zb_platdir STREQUAL "nrf52840")
set(ZEPHCORE_PLATFORM nrf52)
elseif(_zb_platdir MATCHES "^(nrf54l|esp32|mg24|stm32wl)$")
set(ZEPHCORE_PLATFORM "${_zb_platdir}")
else()
message(FATAL_ERROR "ZephCore: unknown platform directory boards/${_zb_platdir}/")
endif()
elseif(BOARD MATCHES "nrf52")
set(ZEPHCORE_PLATFORM nrf52)
elseif(BOARD MATCHES "esp32")
set(ZEPHCORE_PLATFORM esp32)
elseif(BOARD MATCHES "nrf54l")
set(ZEPHCORE_PLATFORM nrf54l)
elseif(BOARD MATCHES "mg24|efr32")
set(ZEPHCORE_PLATFORM mg24)
elseif(BOARD MATCHES "stm32wl|lora_e5")
set(ZEPHCORE_PLATFORM stm32wl)
elseif(BOARD MATCHES "^native_(sim|posix)")
set(ZEPHCORE_PLATFORM linux)
endif()
# ---- Capabilities from the board manifest ----------------------------------
# zephcore.yml (schema: scripts/board_manifest.py). Read by line match because
# this runs before Zephyr has set up Python; `board_manifest.py check` enforces
# the exact two-space-indented ` <capability>: true|false` form this relies on.
set(ZEPHCORE_BOARD_LIGHT_SLEEP FALSE)
set(ZEPHCORE_BOARD_WIFI FALSE)
zephcore_board_file(_zb_manifest zephcore.yml)
if(_zb_manifest)
file(STRINGS "${_zb_manifest}" _zb_ls REGEX "^ light_sleep: true[ \t]*$")
if(_zb_ls)
set(ZEPHCORE_BOARD_LIGHT_SLEEP TRUE)
endif()
file(STRINGS "${_zb_manifest}" _zb_wifi REGEX "^ wifi: true[ \t]*$")
if(_zb_wifi)
set(ZEPHCORE_BOARD_WIFI TRUE)
endif()
endif()