fileX移植
ThreadX RTOS在被微軟收購后最近開源了,相關介紹在:https://docs.microsoft.com/en-us/azure/rtos/, 源碼在github。
之前在使用threadX RTOS,但是沒有用過它的文件系統fileX,從介紹可以看是FAT兼容(fat12,fat16,fat32,exfat),支持fail safe等。功能介紹:https://docs.microsoft.com/en-us/azure/rtos/filex/overview-filex
Azure RTOS FileX is a high-performance, file allocation table (FAT)-compatible file system that’s fully integrated with Azure RTOS ThreadX and available for all supported processors. Like Azure RTOS ThreadX, Azure RTOS FileX is designed to have a small footprint and high performance, making it ideal for today’s deeply embedded applications that require file management operations. FileX supports most physical media, including RAM, Azure RTOS USBX, SD CARD, and NAND/NOR flash memories via Azure RTOS LevelX.
- FAT 12/16/32 and exFAT support
- Multiple partition support
- Automatic scaling
- Endian neutral
- Long file name and 8.3 support
- Optional fault tolerance support
- Logical sector cache
- FAT entry cache
- Pre-allocation of clusters
- Contiguous file support
- Optional performance metrics
- Azure RTOS TraceX system analysis support
我是在SD卡使用FAT文件系統,fileX文檔很齊全,但是對移植方面沒有詳細介紹,具體步驟需要通過看例子和代碼摸索,源碼中包括了一個使用ram使用fileX的簡單例子,我們可以根據它寫與IO driver對接的代碼。以下給出了移植方面的過程以注意的地方。
通常在fx_port.h中定義移置 fileX所需的基本宏和函數,如mutex函數,時間更新周期,以及功能宏。
FX_DRIVER_INIT中獲取文件系統起始物理sector代碼:
4.? fileX內部使用的是邏輯sector(從文件系統的0號sector(即DBR)開始),需要在I/O driver中轉成物理sector。
物理sector地址 = fileX的邏輯sector地址 + 文件系統起始的物理sector地址(DBR地址,步聚3獲取的地址)
5.實現FX_DRIVER_BOOT_READ/FX_DRIVER_BOOT_WRITE,根據上面得到的bootsector,調用sd卡IO接口去讀寫。
?
6. 實現FX_DRIVER_READ/FX_DRIVER_WRITE,根據上面得到物理sector就可以去調用sd卡IO接口去讀寫。
7. 以上完成后,對接IO的部分就完成了,可以使用sample中的例子測試。
8. 如果要支持exfat,需要在定義FX_ENABLE_EXFAT。
?
總結
- 上一篇: 如何选择游戏配音与音乐?
- 下一篇: HDU 4022 Bombing(11年