Skip to content

Commit 32aa48c

Browse files
author
Santhosh Kumar K
committed
docs(linux): Kernel: Add UBIFS documentation
Add instructions to generate UBI image for OSPI/QSPI NOR/NAND flashes. Signed-off-by: Santhosh Kumar K <[email protected]>
1 parent 2fb012f commit 32aa48c

File tree

2 files changed

+250
-48
lines changed
  • source/linux/Foundational_Components/Kernel/Kernel_Drivers

2 files changed

+250
-48
lines changed

source/linux/Foundational_Components/Kernel/Kernel_Drivers/QSPI.rst

Lines changed: 239 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,248 @@ or via command line arguments):
420420
$ dd if=/dev/mtd6 of=tmp_read.txt bs=num count=1 # read to num bytes to flash
421421
$ diff tmp_read.txt tmp_write.txt # should be NULL
422422
423+
.. note::
424+
425+
Make sure UBIFS filesystem is enabled in the kernel (refer to `this
426+
section <#enabling-qspi-driver-configurations>`__ for more information).
427+
428+
.. linux_ubifs_start
429+
430+
.. rubric:: Unsorted Block Image File System (UBIFS)
431+
:name: linux-ubifs
432+
433+
UBIFS is a flash file system for unmanaged flash memory devices. UBIFS works on
434+
top of an UBI layer, which is itself on top of MTD (Memory Technology Device)
435+
layer. UBI + UBIFS takes care of wear leveling, bad-block management, etc.
436+
423437
.. rubric:: Using UBIFS on flash
424438
:name: using-ubifs-on-flash
425439

426-
Make sure UBIFS filesystem is enabled in the kernel (refer to `this
427-
section <#enabling-qspi-driver-configurations>`__ for more information).
440+
.. rubric:: Required Software for UBI image creation
441+
:name: linux-required-software-ubifs
442+
443+
Building a UBI File System requires two applications, :command:`ubinize` and
444+
:command:`mkfs.ubifs`. Both are both provided by ``mtd-utils`` package.
445+
446+
.. code-block:: console
447+
448+
$ sudo apt-get install mtd-utils
449+
450+
.. rubric:: Building a UBI File System image
451+
:name: linux-building-ubi-file-system
452+
453+
Step 1: Create a directory containing the files and directories for the file
454+
system. It is important that the directory size is smaller than the ``rootfs``
455+
partition in the flash.
456+
457+
Step 2: Create a file named :file:`ubinize.cfg` and add the contents below.
458+
459+
.. code-block:: text
460+
461+
[ubifs]
462+
mode=ubi
463+
image=rootfs.ubifs
464+
vol_id=0
465+
vol_type=dynamic
466+
vol_name=rootfs
467+
vol_flags=autoresize
468+
469+
.. linux_ubifs_end
470+
471+
.. linux_args_detail_start
472+
473+
.. rubric:: mkfs.ubifs
474+
:name: linux-mkfs-ubifs
475+
476+
:command:`mkfs.ubifs` is used to create UBI File System image, which is
477+
specifically generated for a flash memory device, like Serial NOR, NAND and
478+
Parallel NAND.
479+
480+
Syntax
481+
482+
.. code-block:: console
483+
484+
mkfs.ubifs -r <root_dir> -o <output_image> [options]
485+
486+
Some key options to use:
487+
488+
1. ``-m <min_io_size>``: specifies the minimum I/O size (in bytes) of the flash
489+
device.
490+
491+
2. ``-e <leb_size>``: specifies the logical eraseblock (LEB) size, which is the
492+
usable portion of an eraseblock in UBI (physical eraseblock - UBI overhead)
493+
494+
3. ``-c <max_leb>``: specifies the maximum number of logical eraseblocks (LEBs) the
495+
filesystem can use.
496+
497+
4. ``-x <compression>``: specifies the compression method to use. Default is
498+
``zlib``
499+
500+
5. ``-F``: used to force the filesystem to "fixup" all the free space which it
501+
is going to use. Note, this flag makes the first mount very slow, because
502+
the "free space fixup" procedure takes time.
503+
504+
For more details:
505+
506+
.. code-block:: console
507+
508+
mkfs.ubifs --help
509+
510+
.. rubric:: ubinize
511+
:name: linux-ubinize
512+
513+
:command:`ubinize` is used to create UBI image for one or more UBIFS images.
514+
515+
.. code-block:: console
516+
517+
ubinize [options] -o <output_image> <configuration_file>
518+
519+
Some key options to use:
520+
521+
1. ``-m <min_io_size>``: specifies the minimum I/O size (in bytes) of the flash
522+
device.
523+
524+
2. ``-p <peb_size>``: specifies the physical eraseblock size, which is the
525+
total size of an eraseblock in the flash device.
526+
527+
3. ``-s <sub_page_size>``: specifies the sub-page size. Usually equivalent to
528+
the minimum I/O size.
529+
530+
4. ``-O <vid_hdr_offset>``: specifies the offset of the VID (Volume Identifier)
531+
header within the physical eraseblock.
532+
533+
For more details:
534+
535+
.. code-block:: console
536+
537+
ubinize --help
538+
539+
.. linux_args_detail_end
540+
541+
.. ifconfig:: CONFIG_part_variant in ('AM64X')
542+
543+
Step 3: Generate .ubifs image
544+
545+
.. code-block:: console
546+
547+
$ mkfs.ubifs -r /path/to/directory -o rootfs.ubifs -m 16 -e 262016 -c 219
548+
549+
Step 4: Generate .ubi image
550+
551+
.. code-block:: console
552+
553+
$ ubinize -o rootfs.ubi -m 16 -p 262144 -s 16 -O 64 ubinize.cfg
554+
555+
.. ifconfig:: CONFIG_part_variant in ('AM62X')
556+
557+
Step 3: Generate .ubifs image
558+
559+
For OSPI NOR:
560+
561+
.. code-block:: console
562+
563+
$ mkfs.ubifs -r /path/to/directory -o rootfs.ubifs -m 16 -e 262016 -c 219
564+
565+
For OSPI NAND:
566+
567+
.. code-block:: console
568+
569+
$ mkfs.ubifs -r /path/to/directory -o rootfs.ubifs -m 2048 -e 126976 -c 743
570+
571+
Step 4: Generate .ubi image
572+
573+
For OSPI NOR:
574+
575+
.. code-block:: console
576+
577+
$ ubinize -o rootfs.ubi -m 16 -p 262144 -s 16 -O 64 ubinize.cfg
578+
579+
For OSPI NAND:
580+
581+
.. code-block:: console
582+
583+
$ ubinize -o rootfs.ubi -m 2048 -p 131072 -s 2048 -O 2048 ubinize.cfg
584+
585+
.. ifconfig:: CONFIG_part_variant in ('AM62AX')
586+
587+
Step 3: Generate .ubifs image
588+
589+
.. code-block:: console
590+
591+
$ mkfs.ubifs -r /path/to/directory -o rootfs.ubifs -m 2048 -e 126976 -c 743
592+
593+
Step 4: Generate .ubi image
594+
595+
.. code-block:: console
596+
597+
$ ubinize -o rootfs.ubi -m 2048 -p 131072 -s 2048 -O 2048 ubinize.cfg
598+
599+
.. ifconfig:: CONFIG_part_variant in ('AM62PX', 'J7200')
600+
601+
Step 3: Generate .ubifs image
602+
603+
.. code-block:: console
604+
605+
$ mkfs.ubifs -r /path/to/directory -o rootfs.ubifs -m 16 -e 262016 -c 219
606+
607+
Step 4: Generate .ubi image
608+
609+
.. code-block:: console
610+
611+
$ ubinize -o rootfs.ubi -m 16 -p 262144 -s 16 -O 64 ubinize.cfg
612+
613+
.. ifconfig:: CONFIG_part_variant in ('J721E')
614+
615+
Step 3: Generate .ubifs image
616+
617+
.. code-block:: console
618+
619+
$ mkfs.ubifs -r /path/to/directory -o rootfs.ubifs <MKUBIFS ARGS>
620+
621+
Step 4: Generate .ubi image
622+
623+
.. code-block:: console
624+
625+
$ ubinize -o rootfs.ubi <UBINIZE ARGS> ubinize.cfg
626+
627+
.. ifconfig:: CONFIG_part_variant in ('J721S2', 'J784S4', 'J742S2', 'J722S')
628+
629+
Step 3: Generate .ubifs image
630+
631+
For OSPI NOR:
632+
633+
.. code-block:: console
634+
635+
$ mkfs.ubifs -r /path/to/directory -o rootfs.ubifs -m 16 -e 262016 -c 219
636+
637+
For OSPI NAND:
638+
639+
.. code-block:: console
640+
641+
$ mkfs.ubifs -r /path/to/directory -o rootfs.ubifs -m 4096 -e 253952 -c 369
642+
643+
Step 4: Generate .ubi image
644+
645+
For OSPI NOR:
646+
647+
.. code-block:: console
648+
649+
$ ubinize -o rootfs.ubi -m 16 -p 262144 -s 16 -O 64 ubinize.cfg
650+
651+
For OSPI NAND:
652+
653+
.. code-block:: console
654+
655+
$ ubinize -o rootfs.ubi -m 16 -p 262144 -s 4096 -O 4096 ubinize.cfg
656+
657+
Step 5: Flash rootfs.ubi to ``ospi.rootfs`` or ``ospi_nand.rootfs`` partition
658+
in the flash
659+
660+
.. code-block:: console
661+
662+
# EVM Linux
663+
664+
$ ubiformat -f rootfs.ubi /dev/mtdX
428665
429666
.. code-block:: console
430667

source/linux/Foundational_Components/Kernel/Kernel_Drivers/Storage/NAND.rst

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -164,49 +164,11 @@ Information regarding NAND booting and booting the kernel and file
164164
system from NAND can be found in the U-boot User Guide NAND
165165
section.
166166

167+
.. include:: ../QSPI.rst
168+
:start-after: .. linux_ubifs_start
169+
:end-before: .. linux_ubifs_end
167170

168-
.. rubric:: **NAND Based File system**
169-
:name: nand-based-file-system
170-
171-
The bootloader and u-boot partitions don't use any filesystem. The
172-
images are flased directly to NAND flash.
173-
174-
The Filesystem though uses UBIFS filesystem. NAND flash is prone to
175-
bit-flips. UBI + UBIFS takes care of the bit-flips issue and as well as
176-
many other things like wear leveling, bad-block management, etc.
177-
178-
.. rubric:: Required Software for UBI image creation
179-
:name: required-software-ubifs
180-
181-
Building a UBI file system requires two applications, ubinize and
182-
mkfs.ubifs. Both are both provided by mtd-utils package.
183-
(sudo apt-get install mtd-utils).
184-
185-
.. rubric:: Building a UBI File system image
186-
:name: building-ubi-file-system
187-
188-
When building a UBI file system you need to have a directory that
189-
contains the exact files and directories layout that you plan to use for
190-
your file system. This is similar to the files and directories layout
191-
you will use to copy a file system onto a SD card for booting purposes.
192-
It is important that your file system size is smaller than the file
193-
system partition in the NAND.
194-
195-
Next you need a file named ubinize.cfg. Below contains the exact
196-
contents of ubinize.cfg you should use. However, replace **<name>**
197-
with a name of your choosing. e.g. rootfs
198-
199-
ubinize.cfg contents:
200-
201-
::
202-
203-
[ubifs]
204-
mode=ubi
205-
image=<name>.ubifs
206-
vol_id=0
207-
vol_type=dynamic
208-
vol_name=rootfs
209-
vol_flags=autoresize
171+
Step 3:
210172

211173
To build a UBI files system requires the below two commands. The
212174
symbol **<directory path>** should be replaced with the path to
@@ -217,12 +179,16 @@ many other things like wear leveling, bad-block management, etc.
217179
**<UBINIZE ARGS>** are board specific. Replace these values with the
218180
values seen in the below table based on the TI EVM you are using.
219181

182+
.. include:: ../QSPI.rst
183+
:start-after: .. linux_args_detail_start
184+
:end-before: .. linux_args_detail_end
185+
220186
Commands to execute:
221187

222-
::
188+
.. code-block:: console
223189
224-
~# mkfs.ubifs -r <directory path> -o <name>.ubifs <MKUBIFS ARGS>
225-
~# ubinize -o <name>.ubi <UBINIZE ARGS> ubinize.cfg
190+
~# mkfs.ubifs -r <directory path> -o <name>.ubifs <MKUBIFS ARGS>
191+
~# ubinize -o <name>.ubi <UBINIZE ARGS> ubinize.cfg
226192
227193
Once these commands are executed <name>.ubi can then be flashed into
228194
the NAND's file-system partition.
@@ -526,4 +492,3 @@ http://www.linux-mtd.infradead.org/doc/ubi.html
526492
http://www.linux-mtd.infradead.org/doc/ubifs.html
527493
https://wiki.linaro.org/Flash%20memory
528494
https://lwn.net/Articles/428584/
529-

0 commit comments

Comments
 (0)