Loading...
Searching...
No Matches
fal_cfg.h File Reference

Flash Abstraction Layer partition configuration. More...

Detailed Description

Flash Abstraction Layer partition configuration.

FlashDB can only use a single MTD device, but allows for multiple named partitions on the MTD device.

This file pre-defines up to 4 partitions, if you need more edit this file or provide your own FAL_PART_TABLE.

Author
Benjamin Valentin benja.nosp@m.min..nosp@m.valen.nosp@m.tin@.nosp@m.ml-pa.nosp@m..com

Definition in file fal_cfg.h.

#include "board.h"
#include "macros/units.h"
#include "mtd_default.h"
+ Include dependency graph for fal_cfg.h:

Go to the source code of this file.

#define CONFIG_FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB   4
 Minimal virtual sector size in KiB for FlashDB.
 
#define FAL_PART_HAS_TABLE_CFG
 Partition table is defined at compile time (not read from flash)
 
#define FAL_FLASH_DEV_TABLE
 flash device table
 
#define FAL_MTD   mtd_default_get_dev(0)
 Default MTD to use for flashdb.
 
#define FAL_PART0_LABEL   "part0"
 Have at least the label of partition 0 defined.
 
#define FAL_PART0_LENGTH   (2 * (CONFIG_FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB * KiB(1)))
 Have at least the length of partition 0 defined, which must be at least two sectors and a multiple of the virtual sector size.
 
#define FAL_PART0_OFFSET   0
 Partition 0.
 
#define FAL_ROW_PART0
 Partition 0 compound definition.
 
#define FAL_PART1_OFFSET   (FAL_PART0_OFFSET + FAL_PART0_LENGTH)
 Partition 1.
 
#define FAL_ROW_PART1
 Partition 1 compound definition.
 
#define FAL_PART2_OFFSET   (FAL_PART1_OFFSET + FAL_PART1_LENGTH)
 Partition 2.
 
#define FAL_ROW_PART2
 Partition 2 compound definition.
 
#define FAL_PART3_OFFSET   (FAL_PART2_OFFSET + FAL_PART2_LENGTH)
 Partition 3.
 
#define FAL_ROW_PART3
 Partition 3 compound definition.
 
#define FAL_PART_TABLE
 Partition Table.
 
struct fal_flash_dev mtd_flash0
 FAL <-> MTD adapter.
 

Macro Definition Documentation

◆ CONFIG_FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB

#define CONFIG_FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB   4

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.

Definition at line 60 of file fal_cfg.h.

◆ FAL_FLASH_DEV_TABLE

#define FAL_FLASH_DEV_TABLE
Value:
{ \
}
struct fal_flash_dev mtd_flash0
FAL <-> MTD adapter.

flash device table

Definition at line 76 of file fal_cfg.h.

◆ FAL_MTD

#define FAL_MTD   mtd_default_get_dev(0)

Default MTD to use for flashdb.

Definition at line 85 of file fal_cfg.h.

◆ FAL_PART0_LABEL

#define FAL_PART0_LABEL   "part0"

Have at least the label of partition 0 defined.

Definition at line 92 of file fal_cfg.h.

◆ FAL_PART0_LENGTH

#define FAL_PART0_LENGTH   (2 * (CONFIG_FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB * KiB(1)))

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 FAL_MTD. So make sure that 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 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 CONFIG_FLASHDB_MIN_SECTOR_SIZE_DEFAULT_KiB.

Definition at line 105 of file fal_cfg.h.

◆ FAL_PART0_OFFSET

#define FAL_PART0_OFFSET   0

Partition 0.

Offset of partition 0

Definition at line 116 of file fal_cfg.h.

◆ FAL_PART1_OFFSET

#define FAL_PART1_OFFSET   (FAL_PART0_OFFSET + FAL_PART0_LENGTH)

Partition 1.

Offset of partition 1

Definition at line 135 of file fal_cfg.h.

◆ FAL_PART2_OFFSET

#define FAL_PART2_OFFSET   (FAL_PART1_OFFSET + FAL_PART1_LENGTH)

Partition 2.

Offset of partition 2

Definition at line 154 of file fal_cfg.h.

◆ FAL_PART3_OFFSET

#define FAL_PART3_OFFSET   (FAL_PART2_OFFSET + FAL_PART2_LENGTH)

Partition 3.

Offset of partition 3

Definition at line 173 of file fal_cfg.h.

◆ FAL_PART_HAS_TABLE_CFG

#define FAL_PART_HAS_TABLE_CFG

Partition table is defined at compile time (not read from flash)

Definition at line 66 of file fal_cfg.h.

◆ FAL_PART_TABLE

#define FAL_PART_TABLE
Value:
{ \
FAL_ROW_PART0 \
FAL_ROW_PART1 \
FAL_ROW_PART2 \
FAL_ROW_PART3 \
}

Partition Table.

Definition at line 187 of file fal_cfg.h.

◆ FAL_ROW_PART0

#define FAL_ROW_PART0
Value:
{ FAL_PART_MAGIC_WORD, FAL_PART0_LABEL, "fal_mtd", \
#define FAL_PART0_LABEL
Have at least the label of partition 0 defined.
Definition fal_cfg.h:92
#define FAL_PART0_OFFSET
Partition 0.
Definition fal_cfg.h:116
#define FAL_PART0_LENGTH
Have at least the length of partition 0 defined, which must be at least two sectors and a multiple of...
Definition fal_cfg.h:105

Partition 0 compound definition.

Definition at line 121 of file fal_cfg.h.

◆ FAL_ROW_PART1

#define FAL_ROW_PART1
Value:
{ FAL_PART_MAGIC_WORD, FAL_PART1_LABEL, "fal_mtd", \
FAL_PART1_OFFSET, FAL_PART1_LENGTH, 0 },
#define FAL_PART1_OFFSET
Partition 1.
Definition fal_cfg.h:135

Partition 1 compound definition.

Definition at line 140 of file fal_cfg.h.

◆ FAL_ROW_PART2

#define FAL_ROW_PART2
Value:
{ FAL_PART_MAGIC_WORD, FAL_PART2_LABEL, "fal_mtd", \
FAL_PART2_OFFSET, FAL_PART2_LENGTH, 0 },
#define FAL_PART2_OFFSET
Partition 2.
Definition fal_cfg.h:154

Partition 2 compound definition.

Definition at line 159 of file fal_cfg.h.

◆ FAL_ROW_PART3

#define FAL_ROW_PART3
Value:
{ FAL_PART_MAGIC_WORD, FAL_PART3_LABEL, "fal_mtd", \
FAL_PART3_OFFSET, FAL_PART3_LENGTH, 0 },
#define FAL_PART3_OFFSET
Partition 3.
Definition fal_cfg.h:173

Partition 3 compound definition.

Definition at line 178 of file fal_cfg.h.