登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
模力方舟
AI 队友
登录
注册
Gitee 年度开源项目评选中~
代码拉取完成,页面将自动刷新
开源项目
>
工业软件
>
IOT/物联网/边缘计算
&&
捐赠
捐赠前请先登录
取消
前往登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
157
Star
1.2K
Fork
438
GVP
朱天龙 (Armink)
/
FlashDB
代码
Issues
70
Pull Requests
0
Wiki
统计
流水线
服务
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
SBOM
我知道了,不再自动展开
更新失败,请稍后重试!
移除标识
内容风险标识
本任务被
标识为内容中包含有代码安全 Bug 、隐私泄露等敏感信息,仓库外成员不可访问
FlashDB比easyFlash占用更大
待办的
#ICX4WX
dzx815
创建于
2025-09-09 15:52
 如上图easyflash占用情况  如上图FlashDB占用情况 测试部分代码如下 ``` void test_env(void) { uint32_t i_boot_times = 0; char *c_old_boot_times, c_new_boot_times[11] = {0}; /* get the boot count number from Env */ c_old_boot_times = ef_get_env("boot_times"); RT_ASSERT(c_old_boot_times); i_boot_times = atol(c_old_boot_times); /* boot count +1 */ i_boot_times ++; rt_kprintf("The system now boot %d times\n", i_boot_times); /* interger to string */ sprintf(c_new_boot_times,"%ld", i_boot_times); /* set and store the boot count number to Env */ LOG_DEBU("%s\n",c_old_boot_times); ef_set_env("boot_times", c_new_boot_times); c_old_boot_times = ef_get_env("CTO123456"); i_boot_times = atol(c_old_boot_times); LOG_DEBU("cto flow total:%d\n",i_boot_times); sprintf(c_new_boot_times,"%ld", i_boot_times+10); ef_set_env("CTO123456", c_new_boot_times); ef_save_env(); } /*******************test flashdb*******************************/ #include <flashdb.h> static uint32_t boot_count = 0; static struct fdb_kvdb kvdb = { 0 }; static time_t boot_time[10] = {0, 1, 2, 3}; /* default KV nodes */ static struct fdb_default_kv_node default_kv_table[] = { {"username", "armink", 0}, /* string KV */ {"password", "123456", 0}, /* string KV */ {"boot_count", &boot_count, sizeof(boot_count)}, /* int type KV */ {"boot_time", &boot_time, sizeof(boot_time)}, /* int array type KV */ }; static void lock(fdb_db_t db) { __disable_irq(); } static void unlock(fdb_db_t db) { __enable_irq(); } void testflashDB(){ fdb_err_t result; #ifdef FDB_USING_KVDB { /* KVDB Sample */ struct fdb_default_kv default_kv; default_kv.kvs = default_kv_table; default_kv.num = sizeof(default_kv_table) / sizeof(default_kv_table[0]); /* set the lock and unlock function if you want */ fdb_kvdb_control(&kvdb, FDB_KVDB_CTRL_SET_LOCK, (void *)lock); fdb_kvdb_control(&kvdb, FDB_KVDB_CTRL_SET_UNLOCK, (void *)unlock); /* Key-Value database initialization * * &kvdb: database object * "env": database name * "fdb_kvdb1": The flash partition name base on FAL. Please make sure it's in FAL partition table. * Please change to YOUR partition name. * &default_kv: The default KV nodes. It will auto add to KVDB when first initialize successfully. * NULL: The user data if you need, now is empty. */ result = fdb_kvdb_init(&kvdb, "env", "fdb_kvdb1", &default_kv, NULL); if (result != FDB_NO_ERR) { rt_kprintf("FDB_NO_ERR\n", boot_count); return; } struct fdb_blob blob; /* run basic KV samples */ fdb_kv_get_blob(&kvdb, "boot_count",fdb_blob_make(&blob, &boot_count, sizeof(boot_count))); /* the blob.saved.len is more than 0 when get the value successful */ if (blob.saved.len > 0) { rt_kprintf("get the 'boot_count' value is %d\n", boot_count); } else { rt_kprintf("get the 'boot_count' failed\n"); } ++boot_count; fdb_kv_set_blob(&kvdb, "boot_count", fdb_blob_make(&blob, &boot_count, sizeof(boot_count))); } #endif /* FDB_USING_KVDB */ } ```
 如上图easyflash占用情况  如上图FlashDB占用情况 测试部分代码如下 ``` void test_env(void) { uint32_t i_boot_times = 0; char *c_old_boot_times, c_new_boot_times[11] = {0}; /* get the boot count number from Env */ c_old_boot_times = ef_get_env("boot_times"); RT_ASSERT(c_old_boot_times); i_boot_times = atol(c_old_boot_times); /* boot count +1 */ i_boot_times ++; rt_kprintf("The system now boot %d times\n", i_boot_times); /* interger to string */ sprintf(c_new_boot_times,"%ld", i_boot_times); /* set and store the boot count number to Env */ LOG_DEBU("%s\n",c_old_boot_times); ef_set_env("boot_times", c_new_boot_times); c_old_boot_times = ef_get_env("CTO123456"); i_boot_times = atol(c_old_boot_times); LOG_DEBU("cto flow total:%d\n",i_boot_times); sprintf(c_new_boot_times,"%ld", i_boot_times+10); ef_set_env("CTO123456", c_new_boot_times); ef_save_env(); } /*******************test flashdb*******************************/ #include <flashdb.h> static uint32_t boot_count = 0; static struct fdb_kvdb kvdb = { 0 }; static time_t boot_time[10] = {0, 1, 2, 3}; /* default KV nodes */ static struct fdb_default_kv_node default_kv_table[] = { {"username", "armink", 0}, /* string KV */ {"password", "123456", 0}, /* string KV */ {"boot_count", &boot_count, sizeof(boot_count)}, /* int type KV */ {"boot_time", &boot_time, sizeof(boot_time)}, /* int array type KV */ }; static void lock(fdb_db_t db) { __disable_irq(); } static void unlock(fdb_db_t db) { __enable_irq(); } void testflashDB(){ fdb_err_t result; #ifdef FDB_USING_KVDB { /* KVDB Sample */ struct fdb_default_kv default_kv; default_kv.kvs = default_kv_table; default_kv.num = sizeof(default_kv_table) / sizeof(default_kv_table[0]); /* set the lock and unlock function if you want */ fdb_kvdb_control(&kvdb, FDB_KVDB_CTRL_SET_LOCK, (void *)lock); fdb_kvdb_control(&kvdb, FDB_KVDB_CTRL_SET_UNLOCK, (void *)unlock); /* Key-Value database initialization * * &kvdb: database object * "env": database name * "fdb_kvdb1": The flash partition name base on FAL. Please make sure it's in FAL partition table. * Please change to YOUR partition name. * &default_kv: The default KV nodes. It will auto add to KVDB when first initialize successfully. * NULL: The user data if you need, now is empty. */ result = fdb_kvdb_init(&kvdb, "env", "fdb_kvdb1", &default_kv, NULL); if (result != FDB_NO_ERR) { rt_kprintf("FDB_NO_ERR\n", boot_count); return; } struct fdb_blob blob; /* run basic KV samples */ fdb_kv_get_blob(&kvdb, "boot_count",fdb_blob_make(&blob, &boot_count, sizeof(boot_count))); /* the blob.saved.len is more than 0 when get the value successful */ if (blob.saved.len > 0) { rt_kprintf("get the 'boot_count' value is %d\n", boot_count); } else { rt_kprintf("get the 'boot_count' failed\n"); } ++boot_count; fdb_kv_set_blob(&kvdb, "boot_count", fdb_blob_make(&blob, &boot_count, sizeof(boot_count))); } #endif /* FDB_USING_KVDB */ } ```
评论 (
0
)
登录
后才可以发表评论
状态
待办的
待办的
进行中
已完成
已关闭
负责人
未设置
标签
未设置
标签管理
里程碑
未关联里程碑
未关联里程碑
Pull Requests
未关联
未关联
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
未关联
分支 (1)
标签 (7)
master
2.1.1
2.1.0
2.0.0
1.1.2
1.1.1
1.1.0
1.0.0
开始日期   -   截止日期
-
置顶选项
不置顶
置顶等级:高
置顶等级:中
置顶等级:低
优先级
不指定
严重
主要
次要
不重要
参与者(1)
C
1
https://gitee.com/Armink/FlashDB.git
git@gitee.com:Armink/FlashDB.git
Armink
FlashDB
FlashDB
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册