当前位置: 首页 > news >正文

FlashDB / Easyflash触发GC导致系统卡死的解决方法分享

FlashDB / Easyflash触发GC导致系统卡死的解决方法分享

遇到的问题:启动后单片机打印这样的log

Bootthismcu....[SFUD]Find a Winbond W25Q32BV flash chip.Size is4194304bytes.[SFUD]norflash0 flash device is initialize success.flashDB_myDataSet_construct.OK[D/FAL](fal_flash_init:49)Flash device|norflash0|addr:0x00000000|len:0x00400000|blk_size:0x00001000|initialized finish.[I/FAL]====================FAL partition table====================[I/FAL]|name|flash_dev|offset|length|[I/FAL]-------------------------------------------------------------[I/FAL]|fdb_kvdb1|norflash0|0x00000000|0x00002000|[I/FAL]|fdb_tsdb0|norflash0|0x00002000|0x00040000|[I/FAL]|fdb_tsdb1|norflash0|0x00042000|0x00040000|[I/FAL]=============================================================[I/FAL]Flash AbstractionLayer(V0.5.99)initialize success.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1801)The oldest addr is @0x00000000[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1817)KVDB size is8192bytes.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1161)**The remain empty sector is0,GC threshold is1.**[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(sch)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(chipID_crc32)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(user_brightness)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(bootCount)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(bootCount)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(bootCount)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(bootCount)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(bootCount)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(bootCount)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(bootCount)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(bootCount)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(bootCount)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(bootCount)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(bootCount)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(bootCount)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT need move,collect it.[FlashDB][kv][env][fdb_kvdb1](../Core/FlashDB-master/src/fdb_kvdb.c:1130)KV(mode_auto)is garbage NOT

把KVDB分区从2个sector更改为4个sector后,问题暂时可以解决,但是不知道是否会再次发生
别人的解决方法:

芯片:SMT32F429
操作系统:RTT 5.0.0
文件系统:littlefs + romfs
flashdb:kvdb + 文件模式 使用
使用场景
分配5个扇区情况
创建一个线程,1秒写入一次当前时间戳至kvdb数据库中
发现如果分配五个扇区,前四个扇区都可以正常读写。
当五个扇区都写满的时候,需要搬运数据到第0扇区去。
日志如下,没有空扇区了。
The remain empty sector is 1, GC threshold is 1.
这个日志已出现,系统就会卡死,看门狗复位
尝试debug调试,总是调到没有使用的函数里面,函数地址
0x00000xx开头。
解决方法
经过不断尝试,ps打印当前线程状态时,发现时间戳保存线程的最大使用率高达81%.一般来说都要控制在75%左右合适。
分析是不是应该堆栈不够导致系统卡死
将该线程从2048改为4096后,不会出现卡死问题了。线程的最大使用率变为51%

分析
flshdb在扇区都满的情况下,会进行Collect操作。这个操作是在当前线程完成的,会增加占用率。
然而这个运行操作并不是会频繁出现的,所以很难判断到是堆栈不够导致的问题。
建议
能否增加一个异步模式来专门执行gc与Collect操作?
就像ulog的异步线程的方式那样。
写入数据库并不要求实时性,只需要确保数据的准确就好了。
异步方式需要一个缓冲区,缓冲区满了才能传入数据,可能导致缓冲区未满时掉电,导致数据缺失了一部分。
但是这个情况,可以添加一个函数,立刻刷新缓冲区。然后给用户使用。 用户自己实现掉电保存与硬件。
所以可以增加一个异步线程的选项,提供用户使用。看用户是选择实时,还是效率。
原作者:用户名由3_15位

http://www.zskr.cn/news/115798.html

相关文章:

  • llm范式(ReAct、Plan-and-Execute)
  • 基于Vue.js和SpringBoot的新能源汽车充电站管理系统外文翻译
  • 51、Linux网络工具配置与网络连接搭建指南
  • WebPShop:Photoshop终极WebP解决方案,5分钟快速上手
  • 思源宋体体积优化指南:从20MB到8MB的实战方法
  • 如何快速解决Edge-TTS语音合成地区访问限制问题
  • Tiled瓦片碰撞蒙版终极指南:让游戏角色不再穿墙
  • EmotiVoice能否替代真人配音?实测结果告诉你
  • 2025年评价高的550℃脱硝催化剂品牌厂家排行榜 - 行业平台推荐
  • 实验室超纯水机厂家哪家好?Top前三如何选? - 品牌推荐大师
  • Next.js认证系统终极指南:基于Clerk的完整多租户解决方案
  • ModEngine2 架构重构:运行时注入技术的核心实现原理深度解析
  • AlphaPose完全指南:多人姿态估计实战宝典与性能优化终极方案
  • 在线图片转ico
  • 2025 年 12 月电机驱动厂家权威推荐榜:高效节能与智能控制技术领先品牌深度解析 - 品牌企业推荐师(官方)
  • NetBox拓扑视图插件:5分钟实现智能网络拓扑可视化
  • OpenVidu开源视频会议平台从零搭建完整教程
  • Quill编辑器文本格式化终极指南:快速掌握字体大小控制技巧
  • 2025年中国数字人公司排名权威推荐,十大知名厂商深度解析,为何集之互动脱颖而出? - 速递信息
  • 2025年热门的厨房排油烟风机/铝制屋顶风机优质厂家推荐榜单 - 行业平台推荐
  • UG\NX二次开发 使用ufun获取nx主窗口,并显示标题
  • 员工考评体系怎么建?覆盖组织需求与员工发展的实用方案
  • 线上绩效考核系统方案怎么落地?HR 实操全流程指南
  • 风传WindSend:重新定义跨设备文件传输的智能解决方案
  • 【赵渝强老师】部署MongoDB复制集
  • feishu2md:解放双手的飞书文档转换神器,让格式转换变得简单高效
  • 31、Nagios CGI配置详解
  • 避开绩效考核误区:实时反馈系统的正确打开方式
  • 2025 年 12 月假山制作厂家权威推荐榜:园林景观点睛之选,仿真自然与艺术造型的匠心品牌深度解析 - 品牌企业推荐师(官方)
  • IndexTTS2配置文件深度解析:从入门到精通的参数调优指南