omi icon indicating copy to clipboard operation
omi copied to clipboard

Use smaller files on the SD card #1650 (Firmware ONLY)

Open harshithsunku opened this issue 4 months ago • 6 comments

Audio Chunking System for Firmware

Overview

This PR introduces a time-based audio chunking system that improves file management, power efficiency, and remote chunk handling via Bluetooth GATT. The system records audio in configurable time-based chunks rather than continuous large files.

Features Added in PR

1. Time-Based Audio Chunking

  • Audio recorded in 5-minute chunks (configurable via CHUNK_DURATION_CYCLES)
  • Simple filename format: audio/chunk_NNNNN.bin
  • Persistent counter ensures unique filenames across device reboots

2. Configurable System

  • New Kconfig option: CONFIG_OMI_ENABLE_AUDIO_CHUNKING
  • Centralized configuration in src/sdcard_config.h
  • Backward compatible with legacy file system when disabled

3. Chunk Lifecycle Management

  • Create: Automatic chunk creation and rotation during recording
  • Stream: Send chunk files over Bluetooth to connected devices
  • Delete: Remove chunks after successful upload
  • Monitor: Query chunk counters and status via GATT characteristics

4. Bluetooth GATT Integration

  • New characteristics for chunk counter retrieval
  • Chunk streaming request characteristic
  • Chunk deletion request characteristic

Configuration

Enable chunking in your project config:

CONFIG_OMI_ENABLE_AUDIO_CHUNKING=y

Adjust chunk duration in src/sdcard_config.h:

#define CHUNK_DURATION_CYCLES 600  // 5 minutes (600 × 500ms)

Testing

  • Verified chunk creation, rotation, streaming, and deletion
  • Counter persistence validated across reboots
  • GATT characteristics tested with debug APP, Video attached

harshithsunku avatar Sep 20 '25 10:09 harshithsunku

Please list all features you have supported with this PR, including your tests, to make sure the firmware fulfills the ticket requirements.

e.g., features: list audio files, transfer the audio bytes (of one file), delete audio file.

@harshithsunku

beastoin avatar Sep 21 '25 03:09 beastoin

Please list all features you have supported with this PR, including your tests, to make sure the firmware fulfills the ticket requirements.

e.g., features: list audio files, transfer the audio bytes (of one file), delete audio file.

@harshithsunku

Hi @beastoin ,

I’ve implemented audio file chunking into 5-minute segments and added a few new GATT BLE characteristics:

  • List chunk file range
  • Delete chunk file
  • Download chunk file

For validation and testing, I used my custom built debug tool instead of the mobile app (since I haven’t made app-side changes yet). Here’s a screenshot of the tool in action:

OMI Debug Tool

This shows the chunking flow — receiving 440-byte packets, assembling them into files (e.g., ~43 kB for a 10 second chunk), and supporting operations like streaming, downloading, and deletion.

I’ll be tied up with other work for the next two days, but I’ll resume this shortly. Only unit testing is pending — I’ll update with the final PR in a couple of days.

harshithsunku avatar Sep 28 '25 06:09 harshithsunku

Hi @beastoin ,

I’ve done UT and validated the audio chunking and GATT characteristics firmware changes using my debug tool. A short video demonstration is shown below.

https://github.com/user-attachments/assets/5f484434-35a5-4602-9464-d5481cc8327d

harshithsunku avatar Oct 01 '25 14:10 harshithsunku

Hi @beastoin ,

Could you please review this PR, Firmware changes are done and tested.

Thanks.

harshithsunku avatar Oct 03 '25 14:10 harshithsunku

yeah, looks solid. btw, will let you know soon.

beastoin avatar Oct 09 '25 03:10 beastoin

yeah, looks solid. btw, will let you know soon.

Hi @beastoin,

Any update on this.

Thanks.

harshithsunku avatar Nov 11 '25 07:11 harshithsunku

man @harshithsunku,

updates: we have a lot of improvements on sd cards for omi cv1 that i think we could use for devkit as well. so let's go this way:

@TuEmb will help you on this PR with his view on the sd card improvements for omi cv1. you guys will work closely to find the best solution and make PRs that can work for both (we don't need to centralize all the code implementation, but the solution should be).

no worries about the bounties; they're still locked on you, if you do a good job and tu approves your PR, we can pay the bounties. and sorry since my room for this PR is not enough to help us go faster.

close this PR for now, it's too old so we might need a fresh view on the issue. make the final PRs then let me know.

timeframe: 2 weeks.

beastoin avatar Dec 03 '25 10:12 beastoin

man @harshithsunku,

updates: we have a lot of improvements on sd cards for omi cv1 that i think we could use for devkit as well. so let's go this way:

@TuEmb will help you on this PR with his view on the sd card improvements for omi cv1. you guys will work closely to find the best solution and make PRs that can work for both (we don't need to centralize all the code implementation, but the solution should be).

no worries about the bounties; they're still locked on you, if you do a good job and tu approves your PR, we can pay the bounties. and sorry since my room for this PR is not enough to help us go faster.

close this PR for now, it's too old so we might need a fresh view on the issue. make the final PRs then let me know.

timeframe: 2 weeks.

Thanks @bestoin! @TuEmb I’ll sync with you on the SD card improvements—let me know the next steps, and share your Discord or any other preferred way to coordinate.

harshithsunku avatar Dec 13 '25 11:12 harshithsunku

@harshithsunku ping me on Discord

#tu301096

TuEmb avatar Dec 13 '25 12:12 TuEmb