Repository navigation
feat - add VAD feature for Omi device and improve power consumption - #6950
Conversation
…ad_trigger # Conflicts: # omi/firmware/omi/src/settings.c
Greptile SummaryThis PR adds a software VAD gate and T5838 hardware AAD (Acoustic Activity Detection) to reduce power consumption on the Omi device, along with SPI/SD PM gating between flushes, DCDC converter enablement, a configurable watchdog timeout, and boot-time stale-file cleanup.
Confidence Score: 2/5Not safe to merge — loss of CONFIG_BT=y disables Bluetooth entirely, and two additional P1 issues leave stated power-saving goals incomplete. A P0 bug (missing CONFIG_BT=y) would render the device unreachable over BLE. Two P1 issues (sd_write_pause never wired, hardcoded debug log level) further reduce confidence. The VAD/AAD logic itself is reasonably structured but integration gaps must be addressed before shipping. omi/firmware/omi/omi.conf (CONFIG_BT=y missing), omi/firmware/omi/src/aad.c (sd_write_pause not called), omi/firmware/omi/src/sd_card.c (hardcoded LOG_LEVEL_DBG), omi/firmware/omi/src/lib/core/transport.c (silent adv failure) Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
MIC[Mic Callback\nmic_handler] --> AAD{CONFIG_OMI_ENABLE_T5838_AAD?}
AAD -- yes --> PROC[aad_process_audio]
AAD -- no --> CODEC
PROC --> AVG[Compute avg_abs_amplitude]
AVG --> VOICE{avg >= VAD_THRESHOLD?}
VOICE -- yes --> STREAK[Increment voice_streak]
STREAK --> DEB{streak >= DEBOUNCE_FRAMES?}
DEB -- yes --> REC[State: RECORDING\nFlush pre-roll queue]
DEB -- no --> PREROLL_STORE
VOICE -- no --> RESET_STREAK[Reset voice_streak]
RESET_STREAK --> HOLD{Recording and silent >= HOLD_MS?}
HOLD -- yes --> SLEEP[State: SLEEP\nvad_sleeping=true]
HOLD -- no --> CHECK_REC
SLEEP --> PREROLL_STORE[Store in pre-roll ring]
PREROLL_STORE --> DISCARD[Return false - discard frame]
CHECK_REC{is_recording?}
CHECK_REC -- no --> PREROLL_STORE
REC --> CHECK_REC
CHECK_REC -- yes --> PREROLL_FLUSH{pre-roll flush pending?}
PREROLL_FLUSH -- yes --> BACKLOG[Push live frame to backlog\nFlush one pre-roll frame]
BACKLOG --> DISCARD
PREROLL_FLUSH -- no --> BACKLOG_CHK{live backlog count > 0?}
BACKLOG_CHK -- yes --> FLUSH_BACKLOG[Flush one backlog frame\nQueue current frame]
FLUSH_BACKLOG --> DISCARD
BACKLOG_CHK -- no --> CODEC[codec_receive_pcm\nReturn true]
WAKE_ISR[T5838 WAKE Pin ISR] --> ATOMIC[atomic_set wake_pending]
ATOMIC --> SEM[k_sem_give aad_sem]
SEM --> THREAD[AAD Thread\naad_thread_fn]
THREAD --> CONSUMED[atomic_set wake_consumed]
CONSUMED --> PROC
|
| break; | ||
| } | ||
|
|
||
| char path[64]; |
There was a problem hiding this comment.
Hardcoded
LOG_LEVEL_DBG will flood production logs
LOG_MODULE_REGISTER(sd_card, LOG_LEVEL_DBG) forces debug-level logging for the SD card module unconditionally, regardless of CONFIG_LOG_DEFAULT_LEVEL. The SD worker path now logs every flush with LOG_DBG, which will generate significant log traffic in production builds and slow down the SD thread.
| char path[64]; | |
| LOG_MODULE_REGISTER(sd_card, CONFIG_LOG_DEFAULT_LEVEL); |
| @@ -0,0 +1,45 @@ | |||
| /* | |||
There was a problem hiding this comment.
…asedHardware#6950) This PR introduces a voice-activity based recording pipeline to reduce power usage and improve offline reliability. The main direction is to gate audio forwarding by VAD state, add pre-roll handling, and coordinate mic/SD behavior during sleep and wake transitions. What changed **1. VAD/AAD pipeline** - Added VAD gate configs and runtime state flow (sleep vs recording) - Added debounce, hold, and threshold-based voice detection - Added pre-roll buffering and flush when transitioning from sleep to recording - Introduced software-managed AAD flow integration path and related state logic **2. Microphone runtime mode switching** - Added stereo and mono-left mic modes - Added APIs for mic pause/resume and dynamic mode switching - Updated processing path to handle both stereo interleaved and mono input correctly **3. SD card and offline storage behavior** - Added SD suspend/resume requests tied to VAD sleep state in offline mode - Added boot-time cleanup for stale temporary/truncated audio files - Reduced file rotation interval to improve file lifecycle behavior **4. Transport and settings stability** - Adjusted BLE settings load order to run after bt_enable path - Made advertising-start failure non-fatal so offline recording can continue - Updated settings initialization to load application subtree in the correct phase **5. Boot/runtime robustness** - Added configurable watchdog timeout via Kconfig - Added boot-stage logging improvements for better startup diagnostics - Kept system progressing even when specific optional subsystems fail






This PR introduces a voice-activity based recording pipeline to reduce power usage and improve offline reliability.
The main direction is to gate audio forwarding by VAD state, add pre-roll handling, and coordinate mic/SD behavior during sleep and wake transitions.
What changed
1. VAD/AAD pipeline
2. Microphone runtime mode switching
3. SD card and offline storage behavior
4. Transport and settings stability
5. Boot/runtime robustness