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

Support 128bit write granularity for kvdb #250

Merged
merged 4 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/fdb_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#ifdef FDB_USING_FAL_MODE
/* the flash write granularity, unit: bit
* only support 1(nor flash)/ 8(stm32f2/f4)/ 32(stm32f1) */
* only support 1(nor flash)/ 8(stm32f2/f4)/ 32(stm32f1)/ 64(stm32f7)/ 128(stm32h5) */
#define FDB_WRITE_GRAN /* @note you must define it for a value */
#endif

Expand Down
11 changes: 7 additions & 4 deletions src/fdb_kvdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#error "Please configure flash write granularity (in fdb_cfg.h)"
#endif

#if FDB_WRITE_GRAN != 1 && FDB_WRITE_GRAN != 8 && FDB_WRITE_GRAN != 32 && FDB_WRITE_GRAN != 64
#error "the write gran can be only setting as 1, 8, 32 and 64"
#if FDB_WRITE_GRAN != 1 && FDB_WRITE_GRAN != 8 && FDB_WRITE_GRAN != 32 && FDB_WRITE_GRAN != 64 && FDB_WRITE_GRAN != 128
#error "the write gran can be only setting as 1, 8, 32, 64 and 128"
#endif

/* magic word(`F`, `D`, `B`, `1`) */
Expand Down Expand Up @@ -103,8 +103,8 @@ struct sector_hdr_data {
uint32_t magic; /**< magic word(`E`, `F`, `4`, `0`) */
uint32_t combined; /**< the combined next sector number, 0xFFFFFFFF: not combined */
uint32_t reserved;
#if (FDB_WRITE_GRAN == 64)
uint8_t padding[4]; /**< align padding for 64bit write granularity */
#if (FDB_WRITE_GRAN == 64) || (FDB_WRITE_GRAN == 128)
uint8_t padding[4]; /**< align padding for 64bit and 128bit write granularity */
#endif
};
typedef struct sector_hdr_data *sector_hdr_data_t;
Expand All @@ -119,6 +119,9 @@ struct kv_hdr_data {
#if (FDB_WRITE_GRAN == 64)
uint8_t padding[4]; /**< align padding for 64bit write granularity */
#endif
#if (FDB_WRITE_GRAN == 128)
uint8_t padding[12]; /**< align padding for 128bit write granularity */
#endif
};
typedef struct kv_hdr_data *kv_hdr_data_t;

Expand Down
4 changes: 2 additions & 2 deletions src/fdb_tsdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

#if defined(FDB_USING_TSDB)

#if (FDB_WRITE_GRAN == 64)
#error "Flash 64 bits write granularity is not supported in TSDB yet!"
#if (FDB_WRITE_GRAN == 64) || (FDB_WRITE_GRAN == 128)
#error "Flash 64 or 128 bits write granularity is not supported in TSDB yet!"
#endif

/* magic word(`T`, `S`, `L`, `0`) */
Expand Down