Skip to main content.
Navigation:
DENX
>
DULG
>
FlashFilesystemsUBIFS
Translations:
Edit
|
Attach
|
Raw
|
Ref-By
|
Printable
|
More
DULG
Sections of this site:
DENX Home
|
DULG
|
ELDK-5
|
Know
|
Training
|
U-Boot
|
U-Bootdoc
Topics
DULG Home
BoardSelect
Manual
FAQ
Application Notes
Changes
Index
List of pages in DULG
Search
%SECTION0{name=FlashFilesystemUBIFS}% UBI and UBIFS file systems UBIFS is a flash filesystem, which work on top of the Linux MTD layer. UBI itself is a software layer which basically is a volume management and wear-leveling layer. It provides so called UBI volumes which is a higher level abstraction than a MTD device. For more documentation about UBI/UBIFS see: * linux source:Documentation/filesystems/ubifs.txt * http://www.linux-mtd.infradead.org/doc/ubi.html This document illustrates the usage of UBI/UBIFS for the %BOARDNAME% board. %SECTION1{name=LinuxCreateDeviceFiles}% Create Device Files First we have to create some device files, which are necessary for using UBI/UBIFS: %INCLUDE{DULGData_%BOARD%.LinuxUbiCreateDeviceFiles}% %IF{ "%HAVE_UBI_NOR%" eq "true"}% %SECTION1{name=LinuxUbiOnNOR}% Using UBI on NOR Flash Erase the flash partition %INCLUDE{DULGData_%BOARD%.LinuxUbiDeletePartitionNor}% and attach it to UBI %INCLUDE{DULGData_%BOARD%.LinuxUbiAttachNor}% As this is done, we check if things are done correct: %INCLUDE{DULGData_%BOARD%.LinuxUbiInfoNor}% Now create a Volume on the UBI Device As we intend to create just a single volume, we use maximum size ("-m" option). %INCLUDE{DULGData_%BOARD%.LinuxUbiCreateVolumeNor}% Mount and use it: %INCLUDE{DULGData_%BOARD%.LinuxUbiMountVolumeNor}% %ENDIF% %IF{ "%HAVE_UBI_NAND%" eq "true"}% %SECTION1{name=LinuxUbiOnNAND}% Using UBI on NAND Flash: Erase the flash partition: %INCLUDE{DULGData_%BOARD%.LinuxUbiDeletePartitionNand}% and attach it to UBI: %INCLUDE{DULGData_%BOARD%.LinuxUbiAttachNand}% As this is done, we check if things are done correct: %INCLUDE{DULGData_%BOARD%.LinuxUbiInfoNand}% Create a Volume on the UBI Device: %INCLUDE{DULGData_%BOARD%.LinuxUbiCreateVolumeNand}% As we intend to create just a single volume, we use maximum size ("-m" option). Mount and use it: %INCLUDE{DULGData_%BOARD%.LinuxUbiMountVolumeNand}% Check with "-a" option: %INCLUDE{DULGData_%BOARD%.LinuxUbiInfoNorNand}% List which partitions we have mounted, and how many space we have available: %INCLUDE{DULGData_%BOARD%.LinuxUbidf}% %ENDIF% %SECTION1{name=LinuxUbiCreate}% Creating UBIFS File System Images %SECTION2{name=LinuxUbiDetermineParameters}% Determining the Parameters of the used Flash Types: The "mkfs.ubifs" requires a few parameters that describe the specific features of the underlying flash chips. The easiest way to determine these parameters is to run the "mtdinfo" utility on a running Linux system. %IF{ "%HAVE_UBI_NOR%" eq "true"}% /dev/mtd%UBI_NOR_PART% is NOR flash ,%ENDIF% %IF{ "%HAVE_UBI_NAND%" eq "true"}%/dev/mtd%UBI_NAND_PART% is NAND flash%ENDIF%: %INCLUDE{DULGData_%BOARD%.LinuxUbiMTDInfo}% %IF{ "%HAVE_UBI_NOR%" eq "true"}% %INCLUDE{DULGData_%BOARD%.LinuxUbiMTDInfoNor}% %ENDIF% %IF{ "%HAVE_UBI_NAND%" eq "true"}% %INCLUDE{DULGData_%BOARD%.LinuxUbiMTDInfoNand}% %ENDIF% The interesting parameters are: <pre> - min-io-size: corresponds to "Minimum input/output unit size" - max-leb-cnt: corresponds to "Amount of eraseblocks" </pre> One more needed parameter from the "ubinfo -a" command: <pre> - leb-size: corresponds to "Logical eraseblock size" </pre> %SECTION2{name=LinuxUbiCreateTestFS}% Create some Test File System Hierarchy %INCLUDE{DULGData_%BOARD%.LinuxUbiCreateTestFS}% %IF{ "%HAVE_UBI_NOR%" eq "true"}% Create UBIFS Images for "%UBI_NOR_NAME%" (NOR) %INCLUDE{DULGData_%BOARD%.LinuxUbiCreateImageNor}% %ENDIF% Create UBIFS Images for "%UBI_NAND_NAME%" (NAND) %INCLUDE{DULGData_%BOARD%.LinuxUbiCreateImageNand}% %SECTION2{name=LinuxUbiInstallImage}% Installing UBIFS images into existing UBI Volume: %IF{ "%HAVE_UBI_NOR%" eq "true"}% %INCLUDE{DULGData_%BOARD%.LinuxUbiInstallUbifsImageNor}% %ENDIF% %INCLUDE{DULGData_%BOARD%.LinuxUbiInstallUbifsImageNand}% %SECTION2{name=LinuxUbiInstallImagesEmpty}% Installing UBI images (if no UBI Volumes exist): If the UBI device is not already formatted to contain suitable volumes, we have to generate UBI images. An UBI image may contain one or more UBI volumes, which in turn may be used to store an UBIFS file system. This is done using the "ubinize" tool, which unfortunately is a bit weird to use: an input configuration ini-file defines all the UBI volumes - their characteristics and the contents, but it does not define the characteristics of the flash flash device - these have to be specified as command-line options. Also, we should keep in mind that we should no longer use "flash_eraseall" to erase the MTD device, as this has no knowledge about the UBI erase counters. Instead, we should use "ubiformat" to erase the flash and install a new UBI image. Unmount and detach previously used UBI devices: %IF{ "%HAVE_UBI_NOR%" eq "true"}% %INCLUDE{DULGData_%BOARD%.LinuxUbiUmountVolumeNor}% %ENDIF% %INCLUDE{DULGData_%BOARD%.LinuxUbiUmountVolumeNand}% Create UBI ini-file and create UBI images: Note: for the volume sizes we use the byte count previously determined by running "ubinfo -a" above. %IF{ "%HAVE_UBI_NOR%" eq "true"}% %INCLUDE{DULGData_%BOARD%.LinuxUbiIniFileNor}% %ENDIF% %INCLUDE{DULGData_%BOARD%.LinuxUbiIniFileNand}% Note that for the NAND device we must pass the "-s 2048" option to ubinize; if we don't, an attempt to attach the created UBI device will result in error messages like these: %INCLUDE{DULGData_%BOARD%.LinuxUbiAttachErrorNand}% For background information please see http://www.linux-mtd.infradead.org/faq/ubi.html#L_vid_offset_mismatch Erase MTD partitions and install UBI images: %IF{ "%HAVE_UBI_NOR%" eq "true"}% %INCLUDE{DULGData_%BOARD%.LinuxUbiFormatNor}% %ENDIF% %INCLUDE{DULGData_%BOARD%.LinuxUbiFormatNand}% Verify that it worked: %IF{ "%HAVE_UBI_NOR%" eq "true"}% %INCLUDE{DULGData_%BOARD%.LinuxUbiFormatVerifyNor}% %ENDIF% %INCLUDE{DULGData_%BOARD%.LinuxUbiFormatVerifyNand}%