→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>:
spi_nand=sf probe; run spi_loadk spi_loadfdt nandargs addcons addmisc; if run configid_fixupfdt; then bootm ${loadaddr} - ${fdtaddr}; fi
spi_update=sf probe; sf erase 0 +${filesize};sf write ${loadaddr} 400 ${filesize}
</pre>
===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.