Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-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). |
| 6 | CONFIG_MAIN_STACK_SIZE=4096 |
| 7 | |
| 8 | # --- Bluetooth ------------------------------------------------------------ |
| 9 | CONFIG_BT=y |
| 10 | CONFIG_BT_PERIPHERAL=y |
| 11 | CONFIG_BT_DEVICE_NAME="FF Tracker" |
| 12 | CONFIG_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. |
| 16 | CONFIG_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. |
| 22 | CONFIG_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. |
| 27 | CONFIG_BT_EXT_ADV_MAX_ADV_SET=3 |
| 28 | CONFIG_BT_CTLR_ADV_EXT=y |
| 29 | |
| 30 | CONFIG_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. |
| 33 | CONFIG_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). |
| 36 | CONFIG_BT_BUF_ACL_RX_SIZE=69 |
| 37 | CONFIG_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. |
| 44 | CONFIG_PSA_CRYPTO=y |
| 45 | CONFIG_PSA_WANT_ALG_SHA_256=y |
| 46 | CONFIG_PSA_WANT_ALG_HMAC=y |
| 47 | CONFIG_PSA_WANT_ALG_HKDF=y |
| 48 | CONFIG_PSA_WANT_KEY_TYPE_HMAC=y |
| 49 | CONFIG_PSA_WANT_KEY_TYPE_DERIVE=y |
| 50 | CONFIG_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. |
| 55 | CONFIG_NVS=y |
| 56 | CONFIG_FLASH=y |
| 57 | CONFIG_FLASH_MAP=y |
| 58 | CONFIG_FLASH_PAGE_LAYOUT=y |
| 59 | CONFIG_SETTINGS=y |
| 60 | CONFIG_SETTINGS_NVS=y |
| 61 | |
| 62 | # --- Board I/O ----------------------------------------------------------- |
| 63 | CONFIG_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. |
| 68 | CONFIG_WATCHDOG=y |
| 69 | |
| 70 | # --- Logging over the on-board J-Link CDC UART --------------------------- |
| 71 | CONFIG_LOG=y |
| 72 | CONFIG_CONSOLE=y |
| 73 | CONFIG_UART_CONSOLE=y |
| 74 | CONFIG_LOG_MODE_DEFERRED=y |
| 75 | CONFIG_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. |
| 88 | CONFIG_LOG_PROCESS_THREAD_CUSTOM_PRIORITY=y |
| 89 | CONFIG_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. |
| 101 | CONFIG_USE_SEGGER_RTT=y |
| 102 | CONFIG_LOG_BACKEND_RTT=y |
| 103 | CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=4096 |
| 104 | |
| 105 | CONFIG_REBOOT=y |