→Creating and flashing a UBI root file system image
{{ImportantMessage|text=Please note that MTD partition index may change depending of flash device availability, flash device size, u-boot environment variables or kernel device driver load order. Always take care of looking inside <code>/proc/mtd</code> to match your specific layout}}
=== Flashing the root file system from a tarball archive ===
This example is using a <code>tarball</code> compressed archive to be extracted into a formatted and mounted UBI File System.
* Format and initialize ''nand-ubi'' partition, which in our case is <code>mtd7</code>, using [[Memory Tecnology Device (MTD)#UBI|UBI]] with:
You can now safely reboot or turn off the system.
=== Creating and flashing a UBI root file system image ===
This example is using the <code>UBI tools</code> for creating an UBI File System image.
* Prepare and initialize a ''UBI'' image to be flashed with:
<pre>
mkfs.ubifs
ubinize
</pre>
E.g. preparing an image for a 512MB SLC NAND with:
ubinize: volume size was not specified in section "rootfs", assume minimum to fit image "xuelk-2.0.1_lynx-image-core-sbc-lynx.ubifs"41140224 bytes (39.2 MiB)
root@sbc-lynx:~# ls -la xuelk-2.0.1_lynx-image-core-sbc-lynx.img
-rw-r--r-- 1 root root 42729472 Mar 2 2020 xuelk-2.0.1_lynx-image-core-sbc-lynx.img
root@sbc-lynx:~#
</pre>
Then, the ''UBI image'' can be directly flashed on NAND using <code>ubiformat</code>:
ubi0: available PEBs: 0, total reserved PEBs: 8000, PEBs reserved for bad PEB handling: 160
=> ubifsmount ubi0:rootfs
=> ubifsls
<DIR> 4816 Wed Oct 04 07:27:18 2017 bin
<DIR> 160 Fri Sep 29 14:38:33 2017 dev
<DIR> 5168 Wed Oct 04 07:27:36 2017 etc
<DIR> 4760 Tue Oct 03 16:38:32 2017 lib
<DIR> 160 Fri Sep 29 14:38:33 2017 mnt
<DIR> 160 Fri Sep 29 14:38:33 2017 run
<DIR> 160 Fri Sep 29 14:38:34 2017 tmp
<DIR> 160 Fri Sep 29 14:38:33 2017 sys
<DIR> 744 Fri Sep 29 15:18:32 2017 var
<DIR> 672 Fri Sep 29 15:08:41 2017 usr
<DIR> 320 Wed Oct 04 07:27:03 2017 boot
<DIR> 224 Wed Oct 04 07:27:01 2017 home
<DIR> 160 Fri Sep 29 14:38:33 2017 proc
<DIR> 5176 Wed Oct 04 07:27:20 2017 sbin
<DIR> 160 Fri Sep 29 14:38:33 2017 media
=>
</pre>
You can now safely boot the system.
=== u.boot configuration ===
In U-Boot environment check the following variable, which must contain the same MTD partition number used above
===U-Boot===
The following example shows how to store a U-Boot image in NOR flash replacing the existing one (version <code>xuelk-2.0.0</code>). The variable <code>uboot</code> is edited to select a specific U-Boot image which is download from the TFTP server (version <code>xuelk-2.0.2</code>)over the Ethernet connection.