Change Nand partition table and software update issues related to the update partition

Hi Leonid,

Not really similar.

My issue is related to my previous asked question:
Can’t apply partition table modifications on U-Boot

Below is how I’m proceeding:

1- Change mtdparts variable and define new indexes on ccimx6ul_common.h U-boot header file

2- Then compiling the new U-boot:

bitbake -f -c compile u-boot-dey

bitbake -c deploy u-boot-dey

3- After flashing this new bootloader .imx to the device

4- Reset the board so it boots on this new bootloader

5- # env default -a
And I can see with a printenv that mtdparts changed with new partition table

6- # saveenv

7- Erase partition and flash images of kernel, recovery and rootfs
Till here all is going well

8- When I want to wipe the update partition as the following:

setenv recovery_command wipe_update

#saveenv
#run recoverycmd

I have an issue when rebooting in recovery mode to wipe the update partition and it’s the same issue when trying to perform a software update.

Below is the log:
ubi2: attaching mtd12
ubi2: scanning is finished
ubi2: empty MTD device detected
ubi2: attached mtd12 (name “update”, size 85 MiB)
ubi2: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
ubi2: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
ubi2: VID header offset: 2048 (aligned 2048), data offset: 4096
ubi2: good PEBs: 680, bad PEBs: 0, corrupted PEBs: 0
ubi2: user volume: 0, internal volumes: 1, max. volumes count: 128
ubi2: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 2412561497
ubi2: available PEBs: 634, total reserved PEBs: 46, PEBs reserved for bad PEB handling: 40
ubi2: background thread “ubi_bgt2d” started, PID 208
ERROR: Could not mount ‘update’ partition, volume not found
ubi2: detaching mtd12
ubi2: mtd12 is detached
rmdir: ‘/mnt/update’: No such file or directory
/etc/rpm-postinsts/100-u-boot-fw-utils: line 52: arithmetic syntax error
run-parts: /etc/rpm-postinsts/100-u-boot-fw-utils: exit status 2
Error opening /dev/fb0: No such file or directory
[RECOVERY] Starting recovery…
Cannot parse config file ‘/etc/fw_env.config’: Invalid argument
Error: environment not initialized
Cannot parse config file ‘/etc/fw_env.config’: Invalid argument
Error: environment not initialized
[RECOVERY] [ERROR] No command found
[RECOVERY] The system will now reboot in 10 seconds
reboot: Restarting system

It’s sure that I’m missing something in the way to do (change NAND partition table & software update) related to the update partition but I can’t find what (Maybe missing to update device tree file after this change ??).

Could you please help to resolve my issue ?

Thanks in advance.

Regards.

YC

2 Likes

Hi,

After performing some tests, I’ve noticed that I’m not facing always this issue.

When the number of my partitions is <= 10 every thing is going well (recovery mode can wipe update partition).

But in the case of the number of partitions is > 10 I’m facing systematically the issue:
etc/rpm-postinsts/100-u-boot-fw-utils: line 52: arithmetic syntax error
run-parts: /etc/rpm-postinsts/100-u-boot-fw-utils: exit status 2
Error opening /dev/fb0: No such file or directory
[RECOVERY] Starting recovery…
Cannot parse config file ‘/etc/fw_env.config’: Invalid argument
Error: environment not initialized
Cannot parse config file ‘/etc/fw_env.config’: Invalid argument
Error: environment not initialized
[RECOVERY] [ERROR] No command found
[RECOVERY] The system will now reboot in 10 seconds
reboot: Restarting system

Do you know what’s the relationship with this max number fixed to 10 partitions ?

Regards.

YC

I will assume this is a CC6UL running Digi Embedded Yocto. In Digi Embedded Yocto, the recovery process is a bit different than the Android one, but we provide a binary and an API to make it easy. By default, if you setup the module using the install script, everything should be ready and configured to work out of the box. In the case of MTD partition updates or flash-erase actions, you will have to reconfigure the update partition to make it available again. To do that just follow these steps:

  1. Boot Digi Embedded Yocto

  2. Issue the following command:

    root@ccimx6ulsbc:~# recovery-reboot -w -T 1

    Where “-w” means to format and create the update partition and “-T 1” means to delay 1 second.

  3. After 1 second the device should reboot into recovery mode and execute the requested action:

    . . .


    • Warning: Booting into recovery mode… *

    . . .

    [RECOVERY] Starting recovery…
    [RECOVERY] Wipe ‘update’ partition requested
    [RECOVERY] Partition ‘update’ successfully erased!
    reboot: Restarting system
    . . .

  4. In the next boot the update partition should be already available to use from normal boot and recovery boot:

    root@ccimx6ulsbc:~# mount
    ubi1_0 on / type ubifs (rw,relatime)
    devtmpfs on /dev type devtmpfs (rw,relatime,size=90288k,nr_inodes=22572,mode=755)
    proc on /proc type proc (rw,relatime)
    sysfs on /sys type sysfs (rw,relatime)
    debugfs on /sys/kernel/debug type debugfs (rw,relatime)
    tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
    tmpfs on /var/volatile type tmpfs (rw,relatime)
    ubi2:update on /mnt/update type ubifs (rw,relatime)
    devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)

According to your comment, the update process has problems to wipe the update partition because it can’t find the volume called ‘update’:
ERROR: Could not mount ‘update’ partition, volume not found I can’t remember if this was a critical error. It may be, if you try to update from that partition, that is, if you are supposed to have a UBIFS in that partition and the *.swu file in it. If you put the *.swu file in a microSD card or a USB stick, that error shouldn’t be critical.

I’m more concerned about the other error:
Cannot parse config file ‘/etc/fw_env.config’: Invalid argument

I don’t understand why you changed this file. This is telling Linux where is the U-Boot environment located and should not be changed unless the same change is done in U-Boot but there should be no good reason to change the location of the environment. A user would normally want to change the rest of the partitions but not the U-Boot one and the environment one unless you know what you are doing.

Issue comes from the grep of ERASEBLOCK & MTDSIZE in u-boot-fw-utils_%.bbappend file.

If the number of partitions is less than 10 (0-9) the issue doesn’t appear.

Else the grep shows not only mtd1 line but also mtd10, mtd11, mtd12,…

To fix the issue grep on exact pattern with this option:

grep -w

Hi Leonid,

Thanks for your answer.

The issue is all about the total number of partitions.

I haven’t change fw_env.config file it’s automatically installed by adding u-boot-fw-utils package to the image.

I added an answer explaining how I fixed this issue.

Regards.

YC