Ex-fat in Linux and OpenWrt
Author : Roy Subhajeet
INTRODUCTION
exFAT (Extensible File Allocation Table) is a file system introduced by Microsoft in 2006 and optimized for flash memory such as USB flash drives and ..
exFAT is proprietary, and Microsoft owns patents on several elements of its design.
Companies can integrate exFAT into a specific group of consumer devices, including cameras, camcorders, and digital photo frames for a . Mobile phones, PCs, and networks have a different volume pricing model.
The above was valid till August 2019 .
But On 28 August 2019, Microsoft published the exFAT specification and released the patent to the OIN (Open Invention Network ) members. Based on these, Linux kernel developers have begun development to add support of exFAT to the kernel.
But the licensing terms remain ambiguous.
And companies looking to integrate exfat should take legal counsel opinion on the subject or contact Microsoft or OIN directly .
For additional information please also see the link below:
Current Versions of exfat drivers Available under Linux :
Samsung’s GPL version:
Samsung Corporation developed versions for exFat support initially for Android Operating system which were later merged into main line Linux with GPL2 License .
There are two versions available in Linux which are developed by Samsung Electronics under GPL2 license.
- Ex-fat with Fuse: this is based on Fuse and mostly available for Debian, Ubuntu.
Note: Fuse enables user space utility to implement the file system code without integrating the code into kernel
- Ex fat no Fuse
Ex fat no Fuse is the version which is integrated in Kernel
Below are some important points about Samsung’s ex fat versions of the drivers
- There are advantages of using Samsung’s no-fuse version over Fuse version as the former is known to be faster in operation.
- The Samsung version (even though is functional) still is quite old while Samsung moved forward with exfat drivers and current version is 11 compared to 0.9 in Openwrt CC .
Microsoft Version:
The specification of exFat is already made Open Source by Microsoft but they also claimed to release a kernel driver in future. But it’s still not available currently.
Ex-fat in Open-wrt :
As openwrt fetches its feeds from mainline kernel utilities, so it also benefits from most kernel loadable drivers .
The version available in Openwrt CC is ex-fat-no-fuse .
i.e. it is implemented as loadable kernel module and is integrated in kernel.
- Exfat in Openwrt can be enabled by enabling CONFIG_BUILD_PATENTED flag from make menuconfig .
*** it’s still ambiguous about the license consideration of exfat , so its kept under CONFIG_BUILD_PATENTED
DEPENDS:=+kmod-nls-base @BUILD_PATENTED
please see :
- TO enable exfat we have to enable CONFIG_BUILD_PATENTED by enabling the global flag from make menuconfig
BUILD WITH EXFAT NO FUSE
*** in some version of openwrt it might be already enabled by default , but in latest openwrt LEDE it might be disabled .
Save and exit make menuconfig
Enable ex-fat kernel module (NO FUSE)
Once this flag is enabled run make menuconfig again .
GOTO Kernel Modules —> Filesystem
Enable kmod-fs-exfat
Build the system using make V=s
TEST EX-FAT MOUNTING
Format a SD drive (128 GB ) in windows and insert the board .
- To mount the drive
- This will mount the drive to /mnt with all its contents
\
- To unmount use below command
To format the to exfat in Linux
exfat-utils will need to be ported into openwrt which is currently not ported even in LEDE versions.
Exfat-utils depend on Fuse and even if they are ported will mean we won’t be able to use kernel version of exfat driver without FUSE and may affect performance.
Please see:
Conclusion:
- Basic operations on exfat SDCARD can be achieved under openwrt like mounting /reading/writing a file .
- More test have to be done to understand the performance of exfat basic drivers .
- Formatting the SDCARD into exfat in Linux may require porting of additional utilities which depends on FUSE and makes system slower .
- Exfat drivers are very old Samsung drivers which were developed for Android and ported to Linux and may have bugs .
- License terms have ambiguity as before August 2019 , exfat was totally patented to Microsoft but now MSFT has released the spec as Open source contribution but only with plans to release Microsoft version of code later .
- Even though Samsung version comes under GPL2 license still there is some ambiguity and may lead to potential legal issues later .
- Suggest to contact MSFT or OIN directly on this subject.
Porting exfat-utils into Openwrt
This section provides details on how to port exfat utils onto Openwrt .
In the scope of this documentation , version 1.1.1 of exfat utils will be ported to Openwrt .
Porting steps
Download package of exfat-utils from
Place the extracted folder under packages
Now run make menuconfig and got to Utilities
Then Filesystems
Enable exfat and exfat-utils
Save and exit make menuconfig
Details of exfat-utils code/patches and Makefiles
The Makefile in the package exfat-fuse fetches the code directly from git URL
and commit number 156a819d58b6d3b8dd72973649cfec582417e05f
Which corresponds to tag 1,1,1 Rest of the Makefile should be self-explanatory .
There are two patches in the patches folder under exfat-fuse
- 101-use_module.patch
Fixes a compilation error related to C99 compilers .
- 102-sconstructfix.patch
As the Scontruct build file is for normal PC linux , so the path for intall directory is modified to be of Openwrt rootfs instead of PC /sbin
****Scontruct is similar to Makefile
TESTING EXFAT UTILS FUSE
We can do the same tests as yesterday’s update using but there is no need to change permissions or using /etc infront of executables .
We can use the utilities directly .
BINARY WITH EXFAT UTILS FUSE
Prerequisite :
- clone master branch and build normally :
- follow section “Ex-fat in Open-wrt” (page 4 ) to enable kmod-fs-exfat
- Follow section “Porting exfat-utils into Openwrt : (Page 12) to enable exfat utils 1.1.1
- Place sdsize application from downloaded package into /package
CONCLUSION :
It can be concluded that both FAT and exfat filesystems can coexist in Linux and the SDCARD size can be determined before mounting the SDCARD using code similar to sdsize .
Once the size of the SDCARD is known we can mount using respective filesystem commands .