Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a cut down NVS partition if it is readonly (IDFGH-14558) #15317

Open
taliesin opened this issue Feb 2, 2025 · 1 comment
Open

Allow a cut down NVS partition if it is readonly (IDFGH-14558) #15317

taliesin opened this issue Feb 2, 2025 · 1 comment
Assignees
Labels
Status: Reviewing Issue is being reviewed Type: Feature Request Feature request for IDF

Comments

@taliesin
Copy link

taliesin commented Feb 2, 2025

Is your feature request related to a problem?

I'd like to use a readonly NVS partition to provide factory data. The NVS generation tool insists on having at least 3 pages of 4096 bytes (0x3000). IMHO the extra pages are only necessary for writing data to the NVS.

I cut down the generated NVS image to 4096 bytes and flashed it to the partition (type data, subtype nvs), nvs_tool.py can read this cut-down version, but nvs_open_from_partition() fails with error ESP_ERR_NVS_NO_FREE_PAGES.

A readonly NVS partition could ignore the missing empty pages from my point of view.

Describe the solution you'd like.

The runtime code in nvs_flash should ignore missing empty pages for read-only partitions.

Describe alternatives you've considered.

No response

Additional context.

No response

@taliesin taliesin added the Type: Feature Request Feature request for IDF label Feb 2, 2025
@github-actions github-actions bot changed the title Allow a cut down NVS partition table if it is readonly Allow a cut down NVS partition table if it is readonly (IDFGH-14558) Feb 2, 2025
@espressif-bot espressif-bot added the Status: Opened Issue is new label Feb 2, 2025
@taliesin taliesin changed the title Allow a cut down NVS partition table if it is readonly (IDFGH-14558) Allow a cut down NVS partition if it is readonly (IDFGH-14558) Feb 2, 2025
@taliesin
Copy link
Author

taliesin commented Feb 2, 2025

The fix is a one-liner, I usually do pull requests, but in this case the documentation effort is probably more work
than the actual fix. Not sure if you want to go down that road ...

diff --git a/components/nvs_flash/src/nvs_pagemanager.cpp b/components/nvs_flash/src/nvs_pagemanager.cpp
index 9bbe32c98a..10a5786cba 100644
--- a/components/nvs_flash/src/nvs_pagemanager.cpp
+++ b/components/nvs_flash/src/nvs_pagemanager.cpp
@@ -125,7 +125,7 @@ esp_err_t PageManager::load(Partition *partition, uint32_t baseSector, uint32_t
     }
 
     // partition should have at least one free page
-    if (mFreePageList.empty()) {
+    if (!partition->get_readonly() && mFreePageList.empty()) {
         return ESP_ERR_NVS_NO_FREE_PAGES;
     }

@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed Status: In Progress Work is in progress and removed Status: Opened Issue is new Status: Reviewing Issue is being reviewed Status: In Progress Work is in progress labels Feb 5, 2025
espressif-bot pushed a commit to espressif/esp-idf-nvs-partition-gen that referenced this issue Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Reviewing Issue is being reviewed Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

3 participants