Second UBIFS volume on VF50?

Hello Stefan, Can you show the script for U-boot to create a second ubifs volume? We would like to have separate volume for data/logging apart from the rootfs. The result would be a LEB volume, such as ‘/data’ that an application can read / write to, which retains wear leveling, etc. We only need from scratch, no migration cases.

The basic commands required are documented in this article, so I do not go further into that: How to make partitions on SLC NAND flash which uses ubifs? - Toradex Community

To integrate it into the Toradex flashing process (which is usually triggered using run setupdate && run update) an adapted flash_blk.scr is required. The script is different between the jethro/morty branch (2.6/2.7 release series) and earlier versions (V2.5 and earlier: flash_blk.scr) since back then only one UBI volume has been used, the rootfs, where also the kernel and device tree has been stored in. With V2.6 and newer the kernel and device tree live in a separate UBI volume, so the scripts are not interchangeable! But it should be fairly easy to adopt the script for the older version.

The script has a fair amount of upgrade logic, some might be not needed for a module which gets written the first time, but some are needed depending on how old the modules are you received from Toradex (e.g. boot block/config block migration to the new ECC format might still be required).

However, this example will just make a clean slate for the main area. Instead of upgrading the UBI volume layout it just cleans the UBI partition (using nand erase.part) and recreates all required UBI volumes from scratch:

V2.6/V2.7: Replace setenv prepare_ubi ... with:

setenv prepare_ubi 'nand erase.part ubi && ubi part ubi && ubi create kernel 0x800000 static && ubi create dtb 0x20000 static && ubi create data 0x2000000 dynamic && ubi create rootfs 0 dynamic'

For V2.5 and earlier, replace setenv update_rootfs ... with:

setenv prepare_ubi 'nand erase.part ubi && ubi part ubi && ubi create data 0x2000000 dynamic && ubi create rootfs 0 dynamic'

To test/during development you can recreate the script using mkimage commands manually (see U-Boot Scripting Capabilities) and replace the one present on a prepared SD-card. If you are using OpenEmbedded, you can replace the script in the meta-toradex(-demos) repository so that OpenEmbedded will create the script from scratch.

To get Linux to mount the partition a custom /etc/fstab will be required, e.g. by adding a line such as

ubi0:data            /mnt                 ubifs      defaults