fatfs 异常断电问题


临界段

When write operation to the FAT file system is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure can be collapted. Following images shows the critical section on the FatFs module.

当对FAT文件系统的写操作由于默写意外而中断,如突然断电,不正确的磁盘移除或不可恢复的磁盘错误,FAT结构可以被毁坏。下面的图片显示了FatFs的临界段。

 

f_sync解决fatfs文件掉电数据丢失问题

An interruption in the red section can cause a cross link; as a result, the file/directory being changed may be lost. There is one or more possibility listed below when an interruption in the yellow section is occured.

红色区域的中断会导致一个交叉链接,结果,正在修改的文件/目录可能会丢失。而黄色区域中断可能导致的效果在下面列出:

 

  • File data being rewrited is collapted. 正在重写的文件数据被毁坏
  • A file being appended returns initial state. 正在添加内容的文件回到初始状态
  • A file created as new is gone. 丢失新建的文件
  • A file created as new or in overwritten remains with length of zero. 一个新建或覆盖的文件保持长度为0
  • Efficiency of disk use gets worse due to lost chain. 因为丢失关联,磁盘的使用效率变坏。

Each case does not affect the files that not in write mode open. To minimize risk of data loss, the critical section can be minimized like shown in Figure 5 by minimizing the time that file is opened in write mode or using f_sync function properly.

在文件不是用写模式打开时,这些情况不会发生。为了最小化磁盘数据的丢失,临界段可以像图表5显示的那样最小化,通过最小化文件处于写模式打开的时间或者适当的使用f_sync函数。

[转自]http://blog.sina.com.cn/s/blog_66ffe2770100w2p7.html
也可参考官方手册
http://elm-chan.org/fsw/ff/00index_e.html

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
LVGL是一个开源的图形库,用于创建嵌入式GUI应用程序。它提供了丰富的图形元素和交互功能,可以在各种嵌入式平台上使用。在LVGL中,可以使用文件系统抽象模块来读取文件、图片和字体等资源。LVGL支持多种文件系统,其中包括FatFS。 要在LVGL中使用FatFS文件系统,首先需要在项目配置中添加LVGL的文件系统接口。在LVGL的配置文件lv_conf.h中,可以找到以下配置项: ```c // File system interface #define LV_USE_FS_IF 1 #if LV_USE_FS_IF #define LV_FS_IF_FATFS 'S' #define LV_FS_IF_PC '\0' #define LV_FS_IF_POSIX '\0' #endif ``` 将LV_USE_FS_IF配置为1,表示启用LVGL的文件系统接口。然后,将LV_FS_IF_FATFS配置为'S',表示使用FatFS作为文件系统接口。 在项目中,还需要添加相应的解码库来实现图片的显示。LVGL会自动调用文件系统接口来读取文件系统中的文件。 总结起来,要在LVGL中使用FatFS文件系统,需要进行以下步骤: 1. 在LVGL的配置文件lv_conf.h中启用文件系统接口,并将接口配置为FatFS。 2. 添加相应的解码库来实现图片的显示。 希望以上信息对您有帮助! #### 引用[.reference_title] - *1* *2* *3* [ESP32开发学习 LVGL Littlevgl 使用文件系统](https://blog.csdn.net/cnicfhnui/article/details/118972851)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值