Add new partition in Flash NAND with TEZI

I need to add a new partition in UBIFS or an mtd before the /dev/mtd of UBI, but any change of image.json or customizing image_type_tezi.bbclass doesn’t finish the installation via Tezi.

Log Tezi:

Finished with exit code: 0
Running Command:  "/usr/sbin/ubiattach" ("-p", "/dev/mtd5")
Finished with exit code: 0
Running Command:  "/usr/sbin/ubimkvol" ("/dev/ubi0", "-N", "kernel", "-n", "0", "-s", "12288KiB", "-t", "static")
Finished with exit code: 0
Raw flash file "zImage"
Running Write Command: sh ("-o", "pipefail", "-c", "cat 'zImage' | pv -b -n 2>/var/volatile/pvpipe | ubiupdatevol /dev/ubi0_0 --size=6704016 -")
Progress: "Limage Embedded Linux Reference Image: Writing raw files"
Write pipe stderr output: ""
Finished writing after 8.024 seconds, 8117136 bytes total so far.
Running Command:  "/usr/sbin/ubimkvol" ("/dev/ubi0", "-N", "dtb", "-n", "1", "-s", "128KiB", "-t", "static")
Finished with exit code: 0
Progress: "Limage Embedded Linux Reference Image: Writing raw files"
Raw flash file "imx6ull-colibri-eval-v3.dtb"
Running Write Command: sh ("-o", "pipefail", "-c", "cat 'imx6ull-colibri-eval-v3.dtb' | pv -b -n 2>/var/volatile/pvpipe | ubiupdatevol /dev/ubi0_1 --size=53610 -")
[  118.687359] UBIFS error (ubi0:3 pid 292): ubifs_mount: can't format empty UBI volume: read-only UBI volume
[  118.702885] UBIFS error (ubi0:3 pid 292): ubifs_mount: can't format empty UBI volume: read-only UBI volume
Write pipe stderr output: ""
Finished writing after 0.143 seconds, 8170746 bytes total so far.
Running Command:  "/usr/sbin/ubimkvol" ("/dev/ubi0", "-N", "m4firmware", "-n", "2", "-s", "896KiB", "-t", "static")
Finished with exit code: 0
Running Command:  "/usr/sbin/ubimkvol" ("/dev/ubi0", "-N", "rootfs", "-n", "3", "-s", "358400KiB", "-t", "static")
Finished with exit code: 0
Progress: "Limage Embedded Linux Reference Image: Creating filesystem (ubifs)"
Running Command:  "/usr/sbin/mkfs.ubifs" ("/dev/ubi0_3")
Output: "Error: ubi_leb_change_start failed\n       Read-only file system (error 30)\n"
Finished with exit code: 255
Running Command:  "mount" ("-t", "ubifs", "/dev/ubi0_3", "/run/media/tmp")
Output: "mount: mounting /dev/ubi0_3 on /run/media/tmp failed: Read-only file system\n"
Finished with exit code: 255
Running Command:  "/usr/sbin/ubidetach" ("-p", "/dev/mtd5")
Error: "Error mounting file system\nmount: mounting /dev/ubi0_3 on /run/media/tmp failed: Read-only file system\n"
No error script found
Finished with exit code: 0
Error: Timeout reached, aborting... 

Partial image.json UBI Block:

        {
            "name": "ubi",
            "ubivolumes": [
                {
                    "name": "kernel",
                    "size_kib": 12288,
                    "type": "static",
                    "content": {
                        "rawfile": {
                            "filename": "zImage",
                            "size": 5
                        }
                    }
                },
                {
                    "name": "dtb",
                    "content": {
                        "rawfiles": [
                            {
                                "filename": "imx6ull-colibri-eval-v3.dtb",
                                "product_ids": "0036"
                            },
                            {
                                "filename": "imx6ull-colibri-wifi-eval-v3.dtb",
                                "product_ids": "0040"
                            },
                            {
                                "filename": "imx6ull-colibri-eval-v3.dtb",
                                "product_ids": "0044"
                            },
                            {
                                "filename": "imx6ull-colibri-wifi-eval-v3.dtb",
                                "product_ids": "0045"
                            }
                        ]
                    },
                    "size_kib": 128,
                    "type": "static"
                },
                {
                    "name": "m4firmware",
                    "size_kib": 896,
                    "type": "static"
                },
                {
                    "name": "rootfs",
                    "size_kib": 358400,
                    "type": "static",
                    "content": {
                        "filesystem_type": "ubifs",
                        "filename": "limage-colibri-imx6ull.tar.xz",
                        "uncompressed_size": 199.77734375
                    }
                },
                {
                    "name": "data",
                    "size_kib": 50120,
                    "type": "static",
                    "content": { }
                }
            ]

Colibri iMX6ULL 256MB V1.1A
IRIS Carrier Board V1.1A
Linux BSP 5.7.1

I would want to use F2FS, so if I could create another mtd that would be ideal!

{
    "config_format": "2",
    "autoinstall": false,
    "name": "Limage Embedded Linux Reference Image",
    "description": "Image with graphical interface using X11",
    "version": "5.7.1-devel-20230201191850+build.0",
    "release_date": "2023-02-01",
    "u_boot_env": "u-boot-initial-env",
    "prepare_script": "prepare.sh",
    "wrapup_script": "wrapup.sh",
    "marketing": "marketing.tar",
    "icon": "toradexlinux.png",
    "license": "LA_OPT_NXP_SW.html",
    "supported_product_ids": [
        "0036",
        "0040",
        "0044",
        "0045"
    ],
    "mtddevs": [
        {
            "name": "u-boot1",
            "content": {
                "rawfile": {
                    "filename": "u-boot-nand.imx",
                    "size": 1
                }
            }
        },
        {
            "name": "u-boot2",
            "content": {
                "rawfile": {
                    "filename": "u-boot-nand.imx",
                    "size": 1
                }
            }
        },
        {
            "name": "u-boot-env",
            "erase": true,
            "content": {}
        },
        {
            "name": "data",
            "content": {}
        },
        {
            "name": "ubi",
            "ubivolumes": [
                {
                    "name": "kernel",
                    "size_kib": 12288,
                    "type": "static",
                    "content": {
                        "rawfile": {
                            "filename": "zImage",
                            "size": 5
                        }
                    }
                },
                {
                    "name": "dtb",
                    "content": {
                        "rawfiles": [
                            {
                                "filename": "imx6ull-colibri-eval-v3.dtb",
                                "product_ids": "0036"
                            },
                            {
                                "filename": "imx6ull-colibri-wifi-eval-v3.dtb",
                                "product_ids": "0040"
                            },
                            {
                                "filename": "imx6ull-colibri-eval-v3.dtb",
                                "product_ids": "0044"
                            },
                            {
                                "filename": "imx6ull-colibri-wifi-eval-v3.dtb",
                                "product_ids": "0045"
                            }
                        ]
                    },
                    "size_kib": 128,
                    "type": "static"
                },
                {
                    "name": "m4firmware",
                    "size_kib": 896,
                    "type": "static"
                },
                {
                    "name": "rootfs",
                    "size_kib": 358400,
                    "type": "static",
                    "content": {
                        "filesystem_type": "ubifs",
                        "filename": "Limage-X11-Image-colibri-imx6ull.tar.xz",
                        "uncompressed_size": 199.77734375
                    }
                }
                }
            ]
        }
    ]
}

Hi @cleitonbueno,

After some investigation, it turns out you won’t be able to change these partitions with Tezi, either with the BB class or the image.json.

MTD devices are only created in run-time and there are some options on how to do it. Our modules have the partitions defined in the u-boot config file and u-boot injects these partition tables into the Linux device tree while booting the kernel.

You can check the MTD parts being passed through u-boot here:
https://git.toradex.com/cgit/u-boot-toradex.git/tree/configs/colibri-imx6ull_defconfig?h=toradex_imx_v2020.04_5.4.70_2.3.0#n46

When Tezi is running on your device, these MTD partitions are already defined.

So in order to do that you will need to test if it’s possible to change the MTD by changing these configs or by recompiling u-boot.

Best Regards,
Hiago.

Hi

Are you sure F2FS works on raw NAND?

In your json you try to put rootfs to UBI static volume. You need dynamic UBI volume for UBIFS and rootfs. "type": "static" line should be removed from rootfs volume definition, or replace there static with dynamic. Dynamic is for UBIFS, static is for /dev/ubi0_N, which you cat read as file and write with ubiupdatevol.

It is possible to create new MTD volume, but you won’t be able to TEZI it in single step from single UBI MTD partitioned Colibri to 2 or more MTD partitions instead of former one. First step needs to either replace U-Boot or set mtdparts in U-Boot environment, reboot and then TEZI according to your new MTD partitions scheme. Since TEZI seems erasing everything (I’m not sure about all TEZI features), your first step should be TEZIing TEZI software back to flash with modified u-boot-initial-env , which would change mtdparts to your custom MTD partitions set.

Even if above works and suits you, I don’t recommend it. You loose UBI erase counters, which perhaps isn’t important for fresh modules, but it is valuable reprogramming old modules. Taking unknown to be fresh or not module, you don’t know in advance is it partitioned according to new MTD partitions scheme or not, etc etc… And the most dangerous is loosing U-Boot environment, which will reset mtdparts to U-Boot compile time default one, and thus break your MTD partitions scheme. Modifying U-Boot for that new MTD partitions scheme would be more safe, but you still will need to TEZI two times, one time to program modified U-Boot, and 2nd time to program the rest.

Edward

I wanted to prepare this layout for F2FS testing!

You are right about the UBI and UBIFS using type(static and dynamic), this attached image.json I changed to not expose the client, but in the rootfs label with “static” we would do a dd of a rootfs.ext4 file

The @hfranco.tx idea via Bootloader seems to work, let’s test it, my solution was to use prepare_script.sh to check the layout of /proc/mtd before programming the image, and yes, we may have to do it in two steps.

Thank you for the tips!

I will be changing Layout via BOotloader, sent reply soon.