I recently switched from FATFS to LittleFS (LFS) on an STM32 . LittleFS is a fail-safe file system designed for microcontrollers:
The only problem I had with LFS is that I could not edit the file system in a Windows environment because it is not recognized by Windows. There is a FUSE driver for Linux, but I’m developing under Windows, so I needed an interface from where I could format the SD card to LFS, browse, edit, add and remove files. So I decided to write a file explorer for LFS in Windows.
- Automatically detects, mount and unmount LFS formatted disks.
- Mount binary files (See Mounting binary files section).
- Format any accessible disk to LFS.
- Delete a volume (Deletes the table of contents).
- Automatically detects the operating system disk and prevents formatting the operating system disk (Requires elevated rights. See Disk List description).
- Define custom LFS configuration parameters when mounting or formatting a disk.
- Browse folders.
- Drag and drop, single or multiple, files and folders from Windows explorer to LFSE.
- Create new folders.
- Rename and delete files and folders.
- View and edit files with the default associated Windows program.
- View and edit files with a specific Windows program.
- Grid view or detail view (file size).
Following is a list of features that I still want to implement:
- Migrate from a previous version of LFS (LFS_MIGRATE).
- Drag and drop, single or multiple, files and folders from LFSE to Windows explorer.
- Folder and file search.
- Cut, copy and paste folders and files inside LFSE.
The toolbar has 4 buttons:
- Refresh – This will refresh the disk list. If an LFS formatted disk is selected, it will refresh the contents of the current directory of the LFS formatted disk.
- New folder – It will create a new folder in the current directory of the LFS formatted disk. This button is enabled when an LFS formatted disk is selected.
- Delete – It will delete the selected item from the LFS formatted disk. This cannot be undone. This button is enabled when an item is selected from an LFS formatted disk. You cannot delete the current “.” or parent “..” directories.
- Detail view/Icon view – Switch between detail and icon view for the disk contents. This button is enabled when an LFS formatted disk is selected.
2. Disk list
The disk list will contain all the detected logical disks.
This icon indicates that the disk is accessible and LFS formatted. Click on this icon to display the disk contents. Right click on this icon to display its popup menu.
This icon indicates that the disk is either not accessible or not LFS formatted. Right click on this icon to display its popup menu.
This icon indicates that the disk is the operating system disk and cannot be formatted to LFS. LFSE needs elevated rights (administrator) to detect the operating system disk.
The Format dialog
The format dialog makes provision for all the LFS configuration parameters. It will display the detected disk size and automatically calculate the block count based on the disk size and block size. You can also save the current configuration parameters as the default, which will be loaded the next you you format a disk.
3. Disk contents
The contents of the selected LFS formatted disk will be displayed here.
Double click on a folder to view it’s contents. Double click on the current (“.”) or parent (“..”) folder to browse to the current or parent folder. Right click on this icon to display its popup menu.
Double click on a file to open it with the default Windows program. LFS is not recognised by Windows and therefore it cannot access the file directly from the LFS formatted drive. A temporary file, with the same name, is created in the application directory (temp) from where it is launched in Windows. LFSE will automatically update any changes to the temporary file to the original file. Right click on this icon to display its popup menu.
The shortcut keys apply to the contents area only:
- Ctrl+A = Select all
- Shift+Del = Delete selected
- Del = Delete selected
Mounting binary files
You will need a tool that is capable of mounting a binary file as a virtual logical drive. I’ve tested it with OSFMount:
- Download and install OSFMount.
- Go to “File”->”Mount new virtual disk…” and select your binary file containing the LFS data and click “Next”.
- Select “Mount entire image as virtual disk” and click “Next”.
- Uncheck the “Read-only drive” checkbox and set “Write mode” to “Direct” if you would like to write to the FS.
- Set the “Drive emulation” to “Logical Drive Emulation”, set the “Drive type” to “HDD” and set the “Drive letter” to “Auto”.
- Click “Mount”.
- Your binary should now be mounted as a logical drive.
- Open LFSE (you might need to run LFSE as administrator) and proceed as normal.
I will add the option to load binary files directly from LFSE at a later stage.
LFS supports the following debug information:
A log file is created, inside the application directory, for each debug item. The log files are overwritten whenever an LFS formatted disk is selected (mounted). In addition to the LFS debug information, LFSE creates its own log file, also inside the application directory, with warnings and errors. The LFSE log file is overwritten every time the application is started.
I initially wrote the LittleFS Explorer (LFSE) in Qt. But I am more familiar with Delphi VCL controls, and although the Qt version is fully functional, I decided to switch to Delphi for further development.
Now you might be asking: “Delphi?”
Well, Delphi Community Edition is free (so is QT and C# community edition and…) and once again I am more familiar with Delphi VCL controls. Especially in an application like this where I need to take control of visual controls and override the enforced Windows manifest. I’m proficient in C# but would not want to implement low level disk access in C# with all its managed memory restrictions.
For the Delphi version, I compiled the LittleFS C source into a C DLL using CodeBlocks and MinGW and called the DLL functions from the Delphi application. I’ve added a couple of my own functions to the DLL to assist in the implementation. I’ve also basically completed a File System Driver (FSD) for LittleFS in Windows. If time allows, I will upload the Qt version, FSD and sources.
Version info and testing
The revision history of LFSE and its DLL can be found on the GitHub repository.
The version of the LFS source used in the DLL can be seen in the about dialog.
LFSE and its DLL was compiled for 32-bit platforms only, but can be used on a 64-bit platform.
I’ve tested LFSE with an SD card on a 64-bit platform running Windows 10 Professional. I will appreciate your feedback on other platforms and Windows operating systems.