很多嵌入式系统喜欢用fatfs, 但是如果是使用flash作为介质,在erase和平衡处理上会变得比较麻烦!
LittleFS是一个高度完整的嵌入式文件系统,实现了磨损平衡支持。
开源地址:
https://github.com/armmbed/mbed-littlefs
具有几个优点:
1:断电恢复能力 - 要求文件系统保持一致,并将数据刷新到底层存储。
2:平均磨损 - 通常情况下,存储支持每块数量有限的擦除,因此使用整个存储设备对于可靠性非常重要。
3:微小的占地面积 - 物联网设备受到ROM和RAM的限制。占地面积小可以节省资金。
项目工程中,自带了测试脚本。
功能测试 - mbed test -n 'features-filesystem-littlefs-tests-filesystem-*'。
重新测试 - mbed test -n 'features-filesystem-littlefs-tests-filesystem_retarget-*'。
磨平测试 - mbed test -n 'features-filesystem-littlefs-tests-filesystem_recovery-wear_leveling'。
模拟功率弹性测试mbed test -n 'features-filesystem-littlefs-tests-filesystem_recovery-resilience'。
硬件功率弹性测试mbed test -n 'features-filesystem-littlefs-tests-filesystem_recovery-resilience_functional'
对于硬件平台的移植也非常简单,只要实现几个简单的接口函数就可以了。
const struct lfs_config cfg = {
// block device operations
.read = user_provided_block_device_read,
.prog = user_provided_block_device_prog,
.erase = user_provided_block_device_erase,
.sync = user_provided_block_device_sync,
// block device configuration
.read_size = 16,
.prog_size = 16,
.block_size = 4096,
.block_count = 128,
.lookahead = 128,
}
|