raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.24k stars 837 forks source link

Need a way to reserve flash sectors #1378

Open peterharperuk opened 1 year ago

peterharperuk commented 1 year ago

The BT code uses two sectors at the end of flash for saving pairing info. As more people need to use flash it will get harder to coordinate flash allocations. We need some sort of API that allocates flash memory at runtime to avoid clashes?

peterharperuk commented 1 year ago

@kilograham

geurtv commented 1 year ago

Alternatively or additionally maybe provide a more generalized storage callback interface, with some default implementations. This way the user can decide where and how stuff should be stored. For instance if a filesystem is already used (like littlefs or fatfs) the user might want to store configuration values in files. Something like:

struct storage_interface {
    void* user_data;
    size_t (*load_value)(void* udata, const char* key, void* buffer, size_t size);
    void (*store_value)(void* udata, const char* key, const void* buffer, size_t size);
    // ... more? get_value_size?
};