很多嵌入式系統喜歡用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,
}
|