Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / firmware / findfamily-tracker / prj.conf

prj.conf105 lines · 5.1 KiBRaw
1# FindFamily UWB tracker — nRF52833 (Qorvo DWM3001C module)
2
3# PSA crypto needs a few KB of stack, and the main loop is where the epoch id is
4# derived and the beacon started (both moved off the Bluetooth RX thread, whose stack
5# is far too small for either — doing them inline in a GATT callback faults).
6CONFIG_MAIN_STACK_SIZE=4096
7
8# --- Bluetooth ------------------------------------------------------------
9CONFIG_BT=y
10CONFIG_BT_PERIPHERAL=y
11CONFIG_BT_DEVICE_NAME="FF Tracker"
12CONFIG_BT_DEVICE_APPEARANCE=0
13# Two connection slots, not one. The switch to beacon mode happens while the binding
14# phone is still attached, and starting a *connectable* advertisement needs a free slot —
15# with a single slot it fails with -ENOMEM and the tracker ends up advertising nothing.
16CONFIG_BT_MAX_CONN=2
17
18# The crowd-finding beacon is [16B epochId][1B battery] of service data under a
19# 128-bit UUID = 35 bytes on air, past the 31-byte legacy limit, so it has to be an
20# extended advertisement. Pairing mode stays legacy (21 bytes) so the phone can find
21# it with default scan settings.
22CONFIG_BT_EXT_ADV=y
23# Three advertising sets: the legacy pairing set, the extended beacon (data, not
24# connectable), and a connectable set that runs alongside the beacon so the owner can write
25# UWB session params while crowd-finding. See beacon_param in src/tracker_ble.c for why
26# connectability cannot live on the beacon set itself.
27CONFIG_BT_EXT_ADV_MAX_ADV_SET=3
28CONFIG_BT_CTLR_ADV_EXT=y
29
30CONFIG_BT_GATT_DYNAMIC_DB=y
31# A client on the default 23-byte ATT MTU sends the 48-byte provisioning blob as a long
32# write in ~20-byte chunks, so there must be room to queue at least three of them.
33CONFIG_BT_ATT_PREPARE_COUNT=6
34# Must fit the 48-byte provisioning write in a single ATT operation when the client does
35# negotiate a larger MTU (the app asks for one).
36CONFIG_BT_BUF_ACL_RX_SIZE=69
37CONFIG_BT_L2CAP_TX_MTU=65
38
39# --- Crypto (PSA / nrf_security) -----------------------------------------
40# Epoch ids must be byte-identical to TrackerProtocol.epochId on the phone and
41# tracker_epoch_id on the server, so use the same primitives: HMAC-SHA256 and
42# HKDF-SHA256. CONFIG_NRF_SECURITY is deliberately not set: it is def_bool y once
43# PSA_CRYPTO selects the Nordic provider, and assigning it directly is an error.
44CONFIG_PSA_CRYPTO=y
45CONFIG_PSA_WANT_ALG_SHA_256=y
46CONFIG_PSA_WANT_ALG_HMAC=y
47CONFIG_PSA_WANT_ALG_HKDF=y
48CONFIG_PSA_WANT_KEY_TYPE_HMAC=y
49CONFIG_PSA_WANT_KEY_TYPE_DERIVE=y
50CONFIG_HEAP_MEM_POOL_SIZE=4096
51
52# --- Persistence ---------------------------------------------------------
53# The provisioning blob and the time base have to survive a reset, or the tracker
54# beacons ids no owner is looking for.
55CONFIG_NVS=y
56CONFIG_FLASH=y
57CONFIG_FLASH_MAP=y
58CONFIG_FLASH_PAGE_LAYOUT=y
59CONFIG_SETTINGS=y
60CONFIG_SETTINGS_NVS=y
61
62# --- Board I/O -----------------------------------------------------------
63CONFIG_GPIO=y
64
65# Hardware watchdog, fed by the main loop. A hung tracker advertises nothing, so a hang
66# takes crowd-finding down with it and stays down until someone resets the board by hand.
67# This turns that into a few seconds of downtime. See watchdog_init() in src/main.c.
68CONFIG_WATCHDOG=y
69
70# --- Logging over the on-board J-Link CDC UART ---------------------------
71CONFIG_LOG=y
72CONFIG_CONSOLE=y
73CONFIG_UART_CONSOLE=y
74CONFIG_LOG_MODE_DEFERRED=y
75CONFIG_LOG_BUFFER_SIZE=4096
76
77# Deferred logging processes every message on one thread, created at
78# K_LOWEST_APPLICATION_THREAD_PRIO (14 here) unless told otherwise — below both UWB threads,
79# so a busy UWB thread erased the record of what it was doing. Raising that thread above them
80# is the fix; CONFIG_LOG_MODE_IMMEDIATE is not. Immediate mode "is processed in the context of
81# the call" (Kconfig.mode), i.e. a LOG_INF from the Bluetooth RX thread sits in uart_poll_out
82# for milliseconds per line, which is what made every GATT connection fail with Android
83# status 133. A separate thread cannot do that to it: the RX thread is cooperative
84# (K_PRIO_COOP(CONFIG_BT_RX_PRIO), hci_core.c) so no preemptible priority preempts it.
85#
86# 3 rather than something higher: above both UWB threads (6 and 7) and level with the Qorvo
87# MAC's NORMAL band, which timeslicing then shares with rather than starving.
88CONFIG_LOG_PROCESS_THREAD_CUSTOM_PRIORITY=y
89CONFIG_LOG_PROCESS_THREAD_PRIORITY=3
90
91# CONFIG_LOG_PRINTK is deliberately left at its default (y), so printk() stays inside the
92# logging subsystem. Turning it off would make the ff_uwb_start() markers synchronous, but
93# it also sends them to *the console* — the CDC UART, the path that drops lines (see below).
94# The lossless path is CONFIG_LOG_BACKEND_RTT, and a log backend only ever sees LOG_*, never
95# printk. Bring-up markers therefore go through LOG_INF, which reaches both backends.
96
97# Also log over SEGGER RTT. The CDC UART path loses lines — a capture that should have held
98# ~120 once-per-second beacon messages held 46 — which is bad enough to have produced
99# contradictory evidence while debugging (a GATT write the phone reported as successful and
100# the firmware appeared never to receive). RTT goes over the debug probe and doesn't drop.
101CONFIG_USE_SEGGER_RTT=y
102CONFIG_LOG_BACKEND_RTT=y
103CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=4096
104
105CONFIG_REBOOT=y