SquashFS is one of the most popular compressed read-only filesystems for Linux operating system. It is widely used in embedded systems to compress entire filesystems, inodes, and directories.
In 2009, support for SquashFS merged into the mainline kernel as part of Linux 2.6.9. But so far, open-source Universal Bootloader (U-Boot) did not support SquashFS, leading to an inability to load kernel images or Device Tree Blobs from a SquashFS filesystem in U-Boot.
SquashFS Support To U-Boot
Now, SquashFS support has finally been added to U-Boot owing to a contribution by João Marcos Costa, an intern working at Bootlin company. Support for SquashFS is now available in upstream U-Boot, which you can find in fs/squashfs/ in the U-Boot source code.
More specifically, the contribution includes a new SquashFS filesystem driver, commands, support for zlib decompression in the driver, and scripts to test its commands.
To use the SquashFS filesystem, you also first need to enable its support, which in return adds SquashFS driver and provides SquashFS U-Boot commands.
The command includes
sqfsls to list files from a typical Linux root filesystem.
Find your dream job
=> sqfsls mmc 0:1 bin/ boot/ dev/ etc/ lib/ <SYM> lib32 <SYM> linuxrc media/ mnt/ opt/ proc/ root/ run/ sbin/ sys/ tmp/ usr/ var/ 2 file(s), 16 dir(s)
sqfsload to load Linux kernel images and Device Tree blobs from files.
=> sqfsload mmc 0:1 $kernel_addr_r /boot/zImage 6160384 bytes read in 433 ms (13.6 MiB/s) => sqfsload mmc 0:1 0x81000000 /boot/am335x-boneblack.dtb 40817 bytes read in 11 ms (3.5 MiB/s) => setenv bootargs console=ttyO0,115200n8 => bootz $kernel_addr_r - 0x81000000 ## Flattened Device Tree blob at 81000000 Booting using the fdt blob at 0x81000000 Loading Device Tree to 8fff3000, end 8fffff70 ... OK Starting kernel ... [ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 4.19.79 ([email protected]) (gcc version 7.3.1 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05)) #1 SMP Fri May 29 18:26:39 CEST 2020 [ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d
Since the SquashFS driver code is new, you may also encounter a few bugs or limitations, which you can report to resolve as soon as possible.
In addition to SquashFS contributions, João has also submitted code to add support for LZO and ZSTD decompression.