You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Completely refactored the EEPROM directory architecture from a partition-based system to a key-value storage system with dynamic block allocation. The new implementation provides a more flexible and efficient way to store and retrieve data in EEPROM.
Notes
Public API: The public API is only in middleware/inc/eeprom_directory.h. All other header files (eeprom_alloc.h, eeprom_storage.h, eeprom_directory_struct.h) are internal implementation details and should not be used directly by application code.
The old partition-based API is completely replaced. Old code using eeprom_get_base_address() etc. will need to be migrated.
Maximum value size is 16 bytes (4 blocks × 4 bytes per block)
Keys are fixed 4-byte arrays, not null-terminated strings
The allocation table and key map are persisted in EEPROM
Memory layout: Allocation table (64 bytes) → Key map (1536 bytes) → Data space (2048 bytes)
Test Cases
Single byte value storage and retrieval
Multi-block value storage (up to 16 bytes)
Key overwrite behavior
Value deletion and block reuse
Error handling (null pointers, not found, allocation failures)
Allocation table state verification
To Do
Optimize memory allocation
Add unit tests
...
Checklist
It can be helpful to check the Checks and Files changed tabs.
Please reach out to your Project Lead if anything is unclear.
Please request reviewers and ping on slack only after you've gone through this whole checklist.
No merge conflicts
All checks passing
Remove any non-applicable sections of this template
Assign the PR to yourself
Request reviewers & ping on Slack
PR is linked to the ticket (fill in the closes line below)
The EEPROM Directory API provides a simple interface for managing a key-value directory stored on an EEPROM device. This API allows you to persistently store, retrieve, and delete values associated with fixed-size (4-byte) keys, with values up to 16 bytes in size.
Key Features
Key-Value Storage: Store 4-byte keys with values up to 16 bytes
Persistence: Data is stored on EEPROM and persists across power cycles
Block-Based Management: Data is managed in 4-byte blocks
Automatic Memory Management: Block allocation and deallocation are handled automatically
Inputs and Outputs
Inputs
Key: A fixed-size 4-byte key (not a null-terminated string)
Example: "tsms", "dcnt", "name"
Value: Data up to 16 bytes (4 blocks) in size
Example: 21, "sogo"
M24C32 Device: Pointer to the EEPROM device interface
m24c32_t
Outputs
Status Code: Error code of type eeprom_status_t
EEPROM_OK: Success
EEPROM_ERROR_NOT_FOUND: Key not found
EEPROM_ERROR_ALLOCATION: Memory allocation failed
EEPROM_ERROR_TOO_BIG: Data size exceeds 16 bytes
Other error codes (see eeprom_status.h)
Retrieved Data: For get_directory_value() function, a pointer to a dynamically allocated buffer (caller must free)
API Functions
1. directory_init() - Initialize Directory
Initializes the directory structure and loads the allocation table and key map from EEPROM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Completely refactored the EEPROM directory architecture from a partition-based system to a key-value storage system with dynamic block allocation. The new implementation provides a more flexible and efficient way to store and retrieve data in EEPROM.
Notes
middleware/inc/eeprom_directory.h. All other header files (eeprom_alloc.h,eeprom_storage.h,eeprom_directory_struct.h) are internal implementation details and should not be used directly by application code.eeprom_get_base_address()etc. will need to be migrated.Test Cases
To Do
Checklist
It can be helpful to check the
ChecksandFiles changedtabs.Please reach out to your Project Lead if anything is unclear.
Please request reviewers and ping on slack only after you've gone through this whole checklist.
Closes # (issue #329 )