mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
pkg/flashdb: add configurable sector size
This commit is contained in:
parent
bd75060bec
commit
3167d58e0d
@ -41,6 +41,15 @@ config MODULE_FLASHDB_KVDB_AUTO_UPDATE
|
||||
database. If the version changes, it will automatically trigger an upgrade action
|
||||
and update the new default KV collection to the current database.
|
||||
|
||||
config FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB
|
||||
int "Minimal virtual sector size in KiB for FlashDB"
|
||||
default 4
|
||||
help
|
||||
By default, KVDB will use 1 times the block size as the sector size, that is, 4096.
|
||||
At this time, the KVDB cannot store a KV longer than 4096. If you want to save, for example,
|
||||
a KV with a length of 10K, you can use the control function to set the sector size to 12K or
|
||||
larger.
|
||||
|
||||
config MODULE_FLASHDB_MTD
|
||||
|
||||
endif # PACKAGE_FLASHDB
|
||||
|
@ -26,12 +26,40 @@
|
||||
#define FAL_CFG_H
|
||||
|
||||
#include "board.h"
|
||||
#include "macros/units.h"
|
||||
#include "mtd_default.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB) || defined(DOXYGEN)
|
||||
/**
|
||||
* @brief Minimal virtual sector size in KiB for FlashDB
|
||||
*
|
||||
* This is just a reasonable default for an automatic partition configuration, hence "DEFAULT".
|
||||
* The "MIN" stands for a required minimum to guarantee an expected size of key value pairs.
|
||||
* The actually acceptable sector size must be a multiple of the physical sector size though.
|
||||
* Thus, it can be larger than the minimum required size.
|
||||
*
|
||||
* The default is 4 (4096).
|
||||
* FlashDB sector size is different from MTD sector size as it is a
|
||||
* virtual measure of granularity and not a device property.
|
||||
* The virtual sector size must be a multiple of the physical sector size.
|
||||
*
|
||||
* From the documentation of FLashDB:
|
||||
* The internal storage structure of FlashDB is composed of N sectors, and each formatting takes
|
||||
* sector as the smallest unit. A sector is usually N times the size of the Flash block.
|
||||
* For example, the block size of Nor Flash is generally 4096.
|
||||
*
|
||||
* By default, KVDB will use 1 times the block size as the sector size, that is, 4096.
|
||||
* At this time, the KVDB cannot store a KV longer than 4096. If you want to save, for example,
|
||||
* a KV with a length of 10K, you can use the control function to set the sector size to 12K or larger.
|
||||
*
|
||||
*/
|
||||
#define CONFIG_FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB 4
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Partition table is defined at compile time (not read from flash)
|
||||
*/
|
||||
@ -66,9 +94,15 @@ extern struct fal_flash_dev mtd_flash0;
|
||||
|
||||
#if !defined(FAL_PART0_LENGTH) || defined(DOXYGEN)
|
||||
/**
|
||||
* @brief Have at least the length of partition 0 defined
|
||||
* @brief Have at least the length of partition 0 defined, which must be at least two sectors
|
||||
* and a multiple of the virtual sector size.
|
||||
*
|
||||
* The virtual sector size is however bound to the physical sector size of @ref FAL_MTD.
|
||||
* So make sure that @ref CONFIG_FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB times 1024 is a multiple of the MTD sector size.
|
||||
* For example if the MTD sector size is 4KiB, then @ref CONFIG_FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB must be a multiple of 4.
|
||||
* If the MTD sector size is 1KiB, then you have all options for @ref CONFIG_FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB.
|
||||
*/
|
||||
#define FAL_PART0_LENGTH (2 * 4096u)
|
||||
#define FAL_PART0_LENGTH (2 * (CONFIG_FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB * KiB(1)))
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user