Skip to content
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 .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: false
matrix:
write_gran: [1, 8, 32, 64, 128]
write_gran: [1, 8, 32, 64, 128, 256]
env:
TEST_BSP_ROOT: ../AutoTestBsp
UTEST_RUNNER_PATH: ../UtestRunner
Expand Down
2 changes: 1 addition & 1 deletion inc/fdb_cfg_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

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

Expand Down
13 changes: 8 additions & 5 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 && FDB_WRITE_GRAN != 128
#error "the write gran can be only setting as 1, 8, 32, 64 and 128"
#if FDB_WRITE_GRAN != 1 && FDB_WRITE_GRAN != 8 && FDB_WRITE_GRAN != 32 && FDB_WRITE_GRAN != 64 && FDB_WRITE_GRAN != 128 && FDB_WRITE_GRAN != 256
#error "the write gran can be only setting as 1, 8, 32, 64, 128 and 256"
#endif

/* magic word(`F`, `D`, `B`, `1`) */
Expand Down Expand Up @@ -109,6 +109,8 @@ struct sector_hdr_data {
uint32_t reserved;
#if (FDB_WRITE_GRAN == 64) || (FDB_WRITE_GRAN == 128)
uint8_t padding[4]; /**< align padding for 64bit and 128bit write granularity */
#elif (FDB_WRITE_GRAN == 256)
uint8_t padding[20]; /**< align padding for 256bit write granularity */
#endif
};
typedef struct sector_hdr_data *sector_hdr_data_t;
Expand All @@ -122,9 +124,10 @@ struct kv_hdr_data {
uint32_t value_len; /**< value length */
#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 */
#elif (FDB_WRITE_GRAN == 128)
uint8_t padding[12]; /**< align padding for 128bit write granularity */
#elif (FDB_WRITE_GRAN == 256)
uint8_t padding[15]; /**< align padding for 256bit write granularity */
#endif
};
typedef struct kv_hdr_data *kv_hdr_data_t;
Expand Down
19 changes: 18 additions & 1 deletion tests/fdb_tsdb_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@
#define TEST_ITER1_SECTORS 5
#define TEST_ITER1_COUNT (TEST_ITER1_SECTORS * _TSIL_PER_SECTOR)

/* TSLs per sector when blob is logbuf-sized string */
#define _TSIL_LOGBUF_ALIGN_SZ FDB_WG_ALIGN(sizeof(logbuf))
#define _TSIL_PER_SECTOR_STR ((TEST_SECTOR_SIZE - _TSIL_SEC_HDR_SZ) \
/ (_TSIL_IDX_DATA_SZ + _TSIL_LOGBUF_ALIGN_SZ))

/* Cap at 256 to avoid timeout on small write granularities (e.g. gran=1/8/32),
* while still being dynamic enough to avoid ring-buffer wrap-around on large
* granularities (e.g. gran=64/128/256). */
#define TEST_TS_COUNT ((_TSIL_PER_SECTOR_STR * 14) < 256 \
? (_TSIL_PER_SECTOR_STR * 14) : 256)


struct test_tls_data {
int data;
fdb_time_t time;
Expand Down Expand Up @@ -153,9 +165,14 @@ static void test_fdb_tsl_iter_by_time(void)
static void test_fdb_tsl_query_count(void)
{
fdb_time_t from = 0, to = TEST_TS_COUNT * TEST_TIME_STEP;
uint32_t count;

fdb_reboot();
uassert_true(fdb_tsl_query_count(&test_tsdb, from, to, FDB_TSL_WRITE) == TEST_TS_COUNT);
count = fdb_tsl_query_count(&test_tsdb, from, to, FDB_TSL_WRITE);
rt_kprintf("query_count from=%d to=%d => %u, expected=%u\n",
(int)from, (int)to, (unsigned)count, TEST_TS_COUNT);

uassert_true(count == TEST_TS_COUNT);
}

static bool est_fdb_tsl_set_status_cb(fdb_tsl_t tsl, void *arg)
Expand Down