Skip to content

pm_static.yml missing explicit storage partition — NVS can be overwritten as firmware grows #5400

Closed

Description

@omi-discord-vector

Problem

omi/firmware/boards/omi/pm_static.yml does not define an explicit storage partition for NVS (Non-Volatile Storage). The firmware uses Zephyr's settings subsystem with NVS backend:

CONFIG_SETTINGS=y
CONFIG_SETTINGS_NVS=y
CONFIG_NVS=y

Without an explicit partition, Zephyr's Partition Manager places NVS automatically — typically at the end of the application flash region. The app partition spans 0xF200 to 0x100000 (959 KB), which is the entire remaining internal flash with no reserved area for NVS.

Risk

As firmware grows (especially with WiFi/networking enabled via CONFIG_OMI_ENABLE_WIFI=y which adds WPA supplicant, TCP/IP stack, etc.), the application binary can overwrite the NVS storage area, causing:

  1. settings_load() reads garbage/corrupted data on next boot
  2. RTC epoch, mic gain, dim ratio, IMU time base — all corrupted or lost
  3. Device may boot with wrong settings or crash during settings_set() due to size mismatches
  4. Symptoms: random boot failures, settings not persisting, incorrect timestamps

This is silent data corruption — the device still boots but settings are garbage.

Settings at risk

From settings.c, stored in NVS under omi/ namespace:

  • dim_ratio (1 byte)
  • mic_gain (1 byte)
  • rtc_timestamp (struct rtc_time)
  • rtc_epoch (8 bytes, with u32 backward compat)
  • lsm6dsl_time_base (16 bytes, with 12-byte legacy compat)

Proposed Fix

Add explicit settings_storage partition to pm_static.yml:

settings_storage:
  address: 0xF8000
  end_address: 0x100000
  region: flash_primary
  size: 0x8000

Shrink app accordingly:

app:
  address: 0xF200
  end_address: 0xF8000
  region: flash_primary
  size: 0xE5E00

Reserves 32 KB for NVS. App shrinks from 959 KB to 927 KB.

Additional Considerations

  • Existing devices may need NVS migration strategy
  • nRF5340 has 1 MB internal flash: MCUboot (64 KB) + app (927 KB) + NVS (32 KB) = 1023 KB fits
  • OTA secondary slot is on external flash — not affected

Discovered via Discord codebase analysis.

Activity

  1. added
    bug
    p2
    on Mar 10, 2026
  2. Aiowuka commented on Sep 9, 2026

    @Aiowuka
    Contributor

    @josancamon19 @kodjima33 — I re-checked this against current main and it still appears unresolved: CONFIG_SETTINGS_NVS=y / CONFIG_NVS=y are enabled, while omi/firmware/boards/omi/pm_static.yml still allocates the app through 0x100000 and the repository has no explicit settings_storage partition.

    Would you approve a US$20 bounty for a focused fix under the documented Omi bounty process?

    Before changing the flash layout, I’d like maintainer confirmation on the intended upgrade/migration behavior for existing devices. If an explicit NVS reservation is still desired, proposed scope is:

    • reserve an explicit settings/NVS partition and adjust the app span accordingly;
    • keep MCUboot/secondary-slot constraints valid;
    • add build/map or other repository-appropriate regression checks that prove the partition layout;
    • document any migration/compatibility implication agreed here.

    I will not make a speculative flash-layout change before that scope is confirmed. AI assistance is being used for investigation/implementation, with the change reviewed and validated before PR submission. I’ll wait for bounty and migration-scope confirmation before implementing.

  3. added a commit that references this issue on Nov 8, 2026
    d3a35f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugp2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions