Skip to content

Commit 09c90e3

Browse files
Alex VegaAlex Vega
authored andcommitted
feat(firmware): harden internal CV1 black-box tracing
Keep high-frequency diagnostics sampled so a sustained failure cannot overwrite hours of connection history. Record the isolated 3.0.30 build and physical evidence without changing the production release line. Tests: host audio/black-box ctest; pinned NCS 2.9.0 CV1 sysbuild; Android and iOS physical reconnect traces.
1 parent 0a18ffd commit 09c90e3

4 files changed

Lines changed: 81 additions & 17 deletions

File tree

‎omi/firmware/omi/STORAGE_FIRST_DEMO.md‎

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@ source, and the phone is a resumable synchronization peer.
1212
frame and prevents later frames from overtaking it.
1313
- Terminal SD failure may fall back to live BLE so simultaneous media failure
1414
does not force avoidable loss.
15-
- Live preview is disabled in this demo. This avoids duplicating the same audio
16-
through the live stream and subsequent ring drain until both paths share a
17-
capture identity that the apps can deduplicate.
15+
- Live preview is read from the newest bounded SD-ring slice. The legacy audio
16+
notification path is disabled, so there is still exactly one source for each
17+
frame and no cross-transport deduplication guess.
18+
- After a reconnect, current audio is read first. The app repairs the newest
19+
uncovered interval on a separate durable lane and leaves old history alone
20+
unless the user explicitly starts a bounded sync.
1821
- The existing bounded ring protocol remains the retrieval path: READ_BEGIN,
1922
exact sequence range, byte CRC, durable phone registration, then ADVANCE.
2023

21-
The demo reports firmware `3.0.29`. It must not be published as a production
22-
release. Flash it only onto the designated second CV1. Retain a hardware
23-
recovery path because an older OTA image may be rejected as a downgrade.
24+
The public-candidate demo reports firmware `3.0.29`. The isolated diagnostic
25+
line reports `3.0.30+101`, adds a 12-hour sampled trace and cumulative counters,
26+
and is compiled into the `codex/cv1-blackbox-diagnostics` branch only. Neither
27+
line is a production release. Retain a hardware recovery path because an older
28+
OTA image may be rejected as a downgrade.
2429

2530
## Build
2631

@@ -48,7 +53,7 @@ result.
4853
4. Repeat with app force-stop, phone reboot, CV1 reboot, weak RF, and a one-hour
4954
backlog.
5055
5. Compare recovered Opus frames against the reference timeline and the
51-
firmware's start/end ring sequence.
56+
firmware's start/end ring sequence.
5257

5358
Required outcomes:
5459

@@ -59,7 +64,55 @@ Required outcomes:
5964
recovered periods.
6065
- Storage saturation or terminal media failure is explicit in diagnostics.
6166

62-
This firmware intentionally sacrifices live transcription latency. Adding live
63-
preview requires one monotonic capture identity stored with each frame and sent
64-
in its BLE header, plus native Android/iOS deduplication before preview is
65-
enabled.
67+
## App contract
68+
69+
The storage-first firmware is only testable with an app that honors all of the
70+
following rules:
71+
72+
- never start the legacy live characteristic beside the SD-ring tail;
73+
- reconnect at the newest bounded ring head before repairing recent coverage;
74+
- preserve the active server conversation owner and preview across a transport
75+
replacement or process restart;
76+
- keep individual sequence WALs local and compact the completed lifecycle
77+
window into one canonical recording;
78+
- derive the canonical close from the server lifecycle in wall-clock time.
79+
Transcript offsets alone are invalid for this purpose because pendant VAD
80+
and disconnected intervals compress the audio clock;
81+
- run historical backlog only after an explicit user request. Charging is not
82+
authority to compete with live transcription.
83+
84+
The exact authenticated Android/iOS build and provisioning process is recorded
85+
in `app/e2e/CV1_BLACKBOX_DEVICE_TESTING.md`. Do not recreate Firebase files,
86+
bundle identifiers, or signing settings from memory.
87+
88+
## Current physical evidence
89+
90+
The diagnostic firmware has been flashed over the app DFU path and remained
91+
recoverable. A 12-hour firmware export reported no storage rejection, packet
92+
drop, microphone, notification, or sync error; two link-setup errors recovered
93+
and the final link negotiated 15 ms, MTU 498, 2M PHY, and DLE 251.
94+
95+
On the Samsung Android fixture, a forced 23.6-second radio outage reconnected
96+
without app relaunch. The replacement tail read the current 25-record head in
97+
1.9 seconds after app-level connection, then repaired the preceding 96-record
98+
gap. Live preview remained on the same owner. The same run exposed and fixed a
99+
wall-clock ownership defect: STT offsets closed the canonical source before
100+
speech captured after a recovered gap. The regression now uses the configured
101+
conversation-silence lifecycle edge for storage-authoritative close bounds.
102+
The corrected rerun compacted 27 ring WALs into one 69-second, 3,439-frame
103+
canonical file containing the before/offline/after markers in order.
104+
105+
On the iPhone fixture, process termination and relaunch preserved 5,342 frames
106+
across 46 ring fragments with no sequence gap and produced one 107-second
107+
canonical artifact. The production conversation contained the before,
108+
process-down, and recovered markers in order. The remaining negative first
109+
segment offset is a backend projection-origin defect, not firmware loss.
110+
111+
These are targeted reliability passes, not release qualification. The next
112+
gates are an overnight unplugged battery run, a user-authorized large backlog
113+
benchmark, a foreground/background/locked-screen matrix on both phones, and a
114+
wired fault-injection run once the JTAG adapter cable is available. The backend
115+
must also implement the app's existing `transcript_mode=replace` request
116+
atomically. Production currently appends the recovered canonical transcript to
117+
the original live segments, so audio durability passes while final transcript
118+
deduplication remains blocked outside this firmware/app branch.

‎omi/firmware/omi/omi.conf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ CONFIG_BT_DIS_MANUF="Based Hardware"
134134
CONFIG_BT_DIS_FW_REV=y
135135
CONFIG_BT_DIS_HW_REV=y
136136
CONFIG_BT_DIS_FW_REV_STR="3.0.30"
137-
CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="3.0.30+100"
137+
CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION="3.0.30+101"
138138
CONFIG_BT_DIS_HW_REV_STR="5.0"
139139

140140
#

‎omi/firmware/omi/src/lib/core/blackbox.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ static void response_complete(struct bt_conn *conn, void *user_data)
111111
ARG_UNUSED(conn);
112112
ARG_UNUSED(user_data);
113113
atomic_clear(&response_in_flight);
114-
memset(event_last_ms, 0, sizeof(event_last_ms));
115-
memset(event_seen, 0, sizeof(event_seen));
116114
}
117115

118116
static int notify_response(struct bt_conn *conn, uint16_t response_len)
@@ -309,6 +307,8 @@ static ssize_t blackbox_command_write(struct bt_conn *conn,
309307
uint32_t ttl_seconds = len >= 5U ? sys_get_le32(&command_data[1]) : BLACKBOX_TRACE_DEFAULT_TTL_SECONDS;
310308
ttl_seconds = CLAMP(ttl_seconds, 1U, BLACKBOX_TRACE_MAX_TTL_SECONDS);
311309
k_spinlock_key_t key = k_spin_lock(&state_lock);
310+
memset(event_last_ms, 0, sizeof(event_last_ms));
311+
memset(event_seen, 0, sizeof(event_seen));
312312
blackbox_trace_start(&trace, blackbox_now_ms(), ttl_seconds);
313313
(void) blackbox_trace_record(
314314
&trace, blackbox_now_ms(), BLACKBOX_EVENT_TRACE_STARTED, 0U, (int32_t) ttl_seconds, 0);
@@ -336,6 +336,8 @@ static ssize_t blackbox_command_write(struct bt_conn *conn,
336336
case BLACKBOX_COMMAND_CLEAR_TRACE: {
337337
k_spinlock_key_t key = k_spin_lock(&state_lock);
338338
blackbox_trace_clear(&trace);
339+
memset(event_last_ms, 0, sizeof(event_last_ms));
340+
memset(event_seen, 0, sizeof(event_seen));
339341
k_spin_unlock(&state_lock, key);
340342
response_len = build_ack(command, 0);
341343
break;
@@ -365,6 +367,8 @@ int blackbox_init(uint32_t reset_reason, uint32_t boot_count)
365367
atomic_clear(&counters[i]);
366368
}
367369
atomic_clear(&response_in_flight);
370+
memset(event_last_ms, 0, sizeof(event_last_ms));
371+
memset(event_seen, 0, sizeof(event_seen));
368372
blackbox_trace_init(&trace, trace_storage, ARRAY_SIZE(trace_storage));
369373
runtime_state.reset_reason = reset_reason;
370374
runtime_state.boot_count = boot_count;

‎omi/firmware/omi/src/lib/core/storage.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,14 @@ static int send_ring_info_response(struct bt_conn *conn)
413413
storage_status_cache_set(&info);
414414

415415
#ifdef CONFIG_OMI_ENABLE_BLACKBOX_DIAGNOSTICS
416-
blackbox_record(BLACKBOX_EVENT_SYNC_INFO, (int32_t) info.read_seq, (int32_t) (info.write_seq - info.read_seq));
416+
/*
417+
* INFO is the live-tail poll, not a state transition. Keep the exact
418+
* request count in BLACKBOX_COUNTER_SYNC_INFO, but sample its trace event
419+
* so a healthy connection cannot evict the disconnect/fault history that
420+
* this internal recorder exists to preserve.
421+
*/
422+
blackbox_record_rate_limited(
423+
BLACKBOX_EVENT_SYNC_INFO, (int32_t) info.read_seq, (int32_t) (info.write_seq - info.read_seq), 300000U);
417424
#endif
418425

419426
uint8_t response[31];
@@ -661,7 +668,7 @@ static uint8_t parse_storage_command(void *buf, uint16_t len)
661668
#ifdef CONFIG_OMI_ENABLE_BLACKBOX_DIAGNOSTICS
662669
blackbox_counter_add(BLACKBOX_COUNTER_SYNC_READ, 1U);
663670
blackbox_record_rate_limited(
664-
BLACKBOX_EVENT_SYNC_READ, (int32_t) pending_start_seq, (int32_t) pending_packet_count, 5000U);
671+
BLACKBOX_EVENT_SYNC_READ, (int32_t) pending_start_seq, (int32_t) pending_packet_count, 300000U);
665672
#endif
666673
read_request_pending = 1;
667674
return STORAGE_DEFERRED;
@@ -850,7 +857,7 @@ static void storage_write(void)
850857
if (err == 0) {
851858
blackbox_counter_add(BLACKBOX_COUNTER_SYNC_DONE, 1U);
852859
blackbox_record_rate_limited(
853-
BLACKBOX_EVENT_SYNC_DONE, transfer_end_status, (int32_t) current_read_seq, 5000U);
860+
BLACKBOX_EVENT_SYNC_DONE, transfer_end_status, (int32_t) current_read_seq, 300000U);
854861
} else {
855862
blackbox_counter_add(BLACKBOX_COUNTER_SYNC_ERROR, 1U);
856863
blackbox_record_rate_limited(BLACKBOX_EVENT_SYNC_ERROR, NOTIFY_DONE, err, 1000U);

0 commit comments

Comments
 (0)