Comments (17)
写入两个数据还是正常的,当写入到第三个数据,fdb_tsl_iter_by_time就不会触发到回调函数。
do {
read_tsl(db, &tsl);
if (tsl.status != FDB_TSL_UNUSED) {
if ((from <= to && tsl.time >= from && tsl.time <= to)
|| (from > to && tsl.time <= from && tsl.time >= to)) {
/* iterator is interrupted when callback return true */
if (cb(&tsl, cb_arg)) {
goto __exit;
}
} else {
goto __exit;
}
}
} while ((tsl.addr.index = get_tsl_addr(§or, &tsl)) != FAILED_ADDR);
上面代码中,tsl.time为-1。
from flashdb.
写入第三个,fdb_tsl_append 有返回错误嘛?
from flashdb.
写入第三个,fdb_tsl_append 有返回错误嘛?
没有返回错误
static bool storage_data_append(void *data, uint32_t len)
{
struct fdb_blob blob;
if (fdb_tsl_append(&storage_db, fdb_blob_make(&blob, data, len)) != FDB_NO_ERR) {
LOG_ERROR("storage data append failed");
return false;
}
return true;
}
我没有看到有错误的log打印
from flashdb.
要不你单步调试先分析一下?
from flashdb.
要不你单步调试先分析一下?
我是用移远的opensdk移植的,没有在线debug的功能……;
刚刚测试发现:fdb_tsl_query_count、fdb_tsl_iter_by_time都是不行的,当数据大于三条的时候;但是fdb_tsl_iter这个函数就能把数据迭代出来,打印的tsl->time是正确的序号,tsl->status也都是2(FDB_TSL_WRITE)。
发现情况有点像:[https://github.com//issues/10#issuecomment-653344273]
以前我用flashdb移植到华大的MCU的,也小批量过生产过的,只是以前的业务每条的数据比较小,现在的每条数据几K的大小。
from flashdb.
我使用的版本是4e56774
from flashdb.
我把fdb_tsl_iter_by_time函数中:
/* search the first start TSL address */
tsl.addr.index = search_start_tsl_addr(db, start, end, from, to);
/* search all TSL */
修改成以前的版本:
/* search the first start TSL address */
// tsl.addr.index = search_start_tsl_addr(db, start, end, from, to);
while (start <= end) {
tsl.addr.index = start + ((end - start) / 2 + 1) / LOG_IDX_DATA_SIZE * LOG_IDX_DATA_SIZE;
read_tsl(db, &tsl);
if (tsl.time < from) {
start = tsl.addr.index + LOG_IDX_DATA_SIZE;
} else {
end = tsl.addr.index - LOG_IDX_DATA_SIZE;
}
}
tsl.addr.index = start;
/* search all TSL */
就可以工作了。
from flashdb.
以前的版本是具体哪个版本?
from flashdb.
以前的版本是具体哪个版本?
1.1.2 7062902
from flashdb.
你的分区大小是按照什么样配置的,我按照你的配置试试
from flashdb.
你的分区大小是按照什么样配置的,我按照你的配置试试
fal_cfg.h:
#define FACTORY_KV_DB_ADDR 0
#define FACTORY_KV_DB_SIZE (32 * 1024)
#define CONFIG_KV_DB_ADDR (FACTORY_KV_DB_ADDR + FACTORY_KV_DB_SIZE)
#define CONFIG_KV_DB_SIZE (64 * 1024)
#define FAULT_TS_DB_ADDR (CONFIG_KV_DB_ADDR + CONFIG_KV_DB_SIZE)
#define FAULT_TS_DB_SIZE (512 * 1024)
/* ===================== Flash device Configuration ========================= */
extern struct fal_flash_dev nor_flash;
/* flash device table */
#define FAL_FLASH_DEV_TABLE \
{ \
&nor_flash, \
}
/* ====================== Partition Configuration ========================== */
#ifdef FAL_PART_HAS_TABLE_CFG
/* partition table */
#define FAL_PART_TABLE \
{ \
{FAL_PART_MAGIC_WORD, "factory_kvdb", "norflash", FACTORY_KV_DB_ADDR, FACTORY_KV_DB_SIZE, 0}, \
{FAL_PART_MAGIC_WORD, "config_kvdb", "norflash", CONFIG_KV_DB_ADDR, CONFIG_KV_DB_SIZE, 0}, \
{FAL_PART_MAGIC_WORD, "storage_tsdb", "norflash", FAULT_TS_DB_ADDR, FAULT_TS_DB_SIZE, 0}, \
}
#endif /* FAL_PART_HAS_TABLE_CFG */
#endif /* _FAL_CFG_H_ */
port.c
#define FLASH_ERASE_MIN_SIZE (16 * 1024)
static int init(void);
static int read(long offset, uint8_t *buf, size_t size);
static int write(long offset, const uint8_t *buf, size_t size);
static int erase(long offset, size_t size);
// 1.定义 flash 设备
struct fal_flash_dev nor_flash = {
.name = NOR_FLASH_DEV_NAME,
.addr = 0,
.len = 0, // 初始化时赋值
.blk_size = FLASH_ERASE_MIN_SIZE,
.ops = {init, read, write, erase},
.write_gran = 1,
};
static int init(void)
{
ql_norflash_get_addr((unsigned char *)SYS_FLASH_DB_PARTITION_NAME, (unsigned int *)&nor_flash.addr,
(unsigned int *)&nor_flash.len);
return 1;
}
static int read(long offset, uint8_t *buf, size_t size)
{
int32_t ret;
unsigned int addr;
addr = nor_flash.addr + offset;
ret = ql_norflash_do_read((unsigned char *)SYS_FLASH_DB_PARTITION_NAME, addr, (unsigned int)buf,
(unsigned int)size);
// LOG_DEBUG("[read ret->%d] addr->%08x offset->%08x size->%08x", ret, nor_flash.addr, offset, size);
return ret == 0 ? (int)size : -1;
}
static int write(long offset, const uint8_t *buf, size_t size)
{
int32_t ret;
unsigned int addr;
addr = nor_flash.addr + offset;
ret = ql_norflash_do_write((unsigned char *)SYS_FLASH_DB_PARTITION_NAME, addr, (unsigned int)buf,
(unsigned int)size);
// LOG_DEBUG("[write ret->%d] addr->%08x offset->%08x size->%08x", ret, nor_flash.addr, offset, size);
return ret == 0 ? (int)size : -1;
}
static int erase(long offset, size_t size)
{
int32_t ret;
unsigned int addr;
addr = nor_flash.addr + offset;
ret = ql_norflash_do_erase((unsigned char *)SYS_FLASH_DB_PARTITION_NAME, addr, size);
return ret == 0 ? (int)size : -1;
}
from flashdb.
我尝试增加你的场景的测试用例,但是还是没有复现你的问题,帮忙确认下咱们用法是否完全一致
另外,你也可以在
- 使用
fdb_tsl_iter
迭代时,把 TSL1: 700KB, TSL2: 800KB, TSL3: 900KB 信息 fdb_tsl_query_count
对应的使用条件补充一下
大致如下:
TSL | 长度 | 存储地址 | 扇区索引(如:0、1、2) |
---|---|---|---|
TSL1 | 700KB | xxyy | xxyy |
TSL2 | 800KB | xxyy | xxyy |
TSL3 | 900KB | xxyy | xxyy |
fdb_tsl_query_count
的入参:
from
: ?to
: ?
from flashdb.
我尝试增加你的场景的测试用例,但是还是没有复现你的问题,帮忙确认下咱们用法是否完全一致
另外,你也可以在
- 使用
fdb_tsl_iter
迭代时,把 TSL1: 700KB, TSL2: 800KB, TSL3: 900KB 信息fdb_tsl_query_count
对应的使用条件补充一下大致如下:
TSL 长度 存储地址 扇区索引(如:0、1、2)
TSL1 700KB xxyy xxyy
TSL2 800KB xxyy xxyy
TSL3 900KB xxyy xxyy
fdb_tsl_query_count
的入参:
from
: ?to
: ?
get_time函数我是封装成 ++seq;
插入3条数据后,from是0,to是3
from flashdb.
++seq 这种方式我测试过也是没有复现
你把 TSL 的地址信息及时间信息 dump 出来再看下?
TSL | 长度 | 存储地址 | 扇区索引(如:0、1、2) |
---|---|---|---|
TSL1 | 700KB | xxyy | xxyy |
TSL2 | 800KB | xxyy | xxyy |
TSL3 | 900KB | xxyy | xxyy |
from flashdb.
我把fdb_tsl_iter_by_time函数中:
/* search the first start TSL address */ tsl.addr.index = search_start_tsl_addr(db, start, end, from, to); /* search all TSL */
修改成以前的版本:
/* search the first start TSL address */ // tsl.addr.index = search_start_tsl_addr(db, start, end, from, to); while (start <= end) { tsl.addr.index = start + ((end - start) / 2 + 1) / LOG_IDX_DATA_SIZE * LOG_IDX_DATA_SIZE; read_tsl(db, &tsl); if (tsl.time < from) { start = tsl.addr.index + LOG_IDX_DATA_SIZE; } else { end = tsl.addr.index - LOG_IDX_DATA_SIZE; } } tsl.addr.index = start; /* search all TSL */
就可以工作了。
朱总,我遇到了同样的问题,换回旧版本就函数,就可以工作了,用的time_t的时间戳.
from flashdb.
我把fdb_tsl_iter_by_time函数中:
/* search the first start TSL address */ tsl.addr.index = search_start_tsl_addr(db, start, end, from, to); /* search all TSL */
修改成以前的版本:
/* search the first start TSL address */ // tsl.addr.index = search_start_tsl_addr(db, start, end, from, to); while (start <= end) { tsl.addr.index = start + ((end - start) / 2 + 1) / LOG_IDX_DATA_SIZE * LOG_IDX_DATA_SIZE; read_tsl(db, &tsl); if (tsl.time < from) { start = tsl.addr.index + LOG_IDX_DATA_SIZE; } else { end = tsl.addr.index - LOG_IDX_DATA_SIZE; } } tsl.addr.index = start; /* search all TSL */
就可以工作了。
朱总,我遇到了同样的问题,换回旧版本就函数,就可以工作了,用的time_t的时间戳.
@ZakiLiu 需要你们提供一下具体的测试场景呢,我这边的测试用例可能还没覆盖到你们的场景
from flashdb.
我把fdb_tsl_iter_by_time函数中:
/* search the first start TSL address */ tsl.addr.index = search_start_tsl_addr(db, start, end, from, to); /* search all TSL */
修改成以前的版本:
/* search the first start TSL address */ // tsl.addr.index = search_start_tsl_addr(db, start, end, from, to); while (start <= end) { tsl.addr.index = start + ((end - start) / 2 + 1) / LOG_IDX_DATA_SIZE * LOG_IDX_DATA_SIZE; read_tsl(db, &tsl); if (tsl.time < from) { start = tsl.addr.index + LOG_IDX_DATA_SIZE; } else { end = tsl.addr.index - LOG_IDX_DATA_SIZE; } } tsl.addr.index = start; /* search all TSL */
就可以工作了。
朱总,我遇到了同样的问题,换回旧版本就函数,就可以工作了,用的time_t的时间戳.
@ZakiLiu 需要你们提供一下具体的测试场景呢,我这边的测试用例可能还没覆盖到你们的场景
朱总,你试试每次查找,from和to都是同一个时间戳的场景。
from flashdb.
Related Issues (20)
- 出现crc32 failed, 测试程序boot_count总是读取失败, 但是测试程序temp的read/write是正常的 HOT 2
- KVDB在写满后再次写入失败,需要写入第二次 HOT 1
- 请教 KVDB 掉电异常后的恢复方法
- 测试tsdb连续保存累计数达一定数量后出现前面部分数据丢失的现象 HOT 2
- 用文件作为存储后端,有锁首次初始化时,_fdb_kv_load 中调用 fdb_kv_set_default 死锁 HOT 2
- 老化擦写Flash的KV后,读取一个不存在的KV或者写一个不存在的KV,Flash耗时长
- check the current timestamp, MUST more than the last save timestamp HOT 4
- 是否支持STM32G0B1RCT6 HOT 6
- 分区越大,插入速度越慢 HOT 2
- sfud_flash_def.h 部分有误 HOT 4
- KVDB Demo 运行出错 HOT 1
- linux的demo程序第一次运行都会卡住 HOT 2
- Error: The KV (@0x0000FF4F) CRC32 check failed!
- Support wear balance
- tsdb
- FR:tsdb读取最新一条数据内容 HOT 1
- TSDB能否调整为递增序列式。 HOT 1
- V2.1.0使用tsdb遇到一个问题,假如tsdb刚好全部写满的时候重启了,再次开机 初始化tsdb的时候,会出现oldest sectors is 0x00000FFF, current using sector is 0xFFFFFFFF, 导致后续无法写入 HOT 1
- 迭代器无法遍历所有键值对 HOT 2
- FDB_GC_EMPTY_SEC_THRESHOLD我想问这个能设置成0吗,我现在只想分配2个扇区给flashDB
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flashdb.