Problem with flashing ubi volumes in uboot

I use the Colibri imx7 with the toradex uboot version 2016.11
I added new enviroment parameters to generate additional volumes in the partition ubi

Partition overview

Additional volumes
addvolume1=ubi part ubi; ubi createvol kernel ${nand_kernel_size}; ubi createvol dtb ${nand_devicetree_size}; ubi createvol rootfs ${nand_rootfs_size}; ubi createvol update_rootfs ${nand_rootfs_size};

addvolume2=ubi part ubi; ubi createvol dtsapp ${nand_dtsvolume_size}; ubi createvol update_dtsapp ${nand_dtsvolume_size}; ubi createvol dtscfg ${nand_dtsvolume_size}; ubi createvol update_dtscfg ${nand_dtsvolume_size};

We have a separate flash command for each ubi volume
See below some examples
flashKernel=ubi part ubi; ubi remove kernel; ubi createvol kernel ${nand_kernel_size}; dhcp ${loadaddr} ${path_tftp}${img_kernel}; ubi write ${loadaddr} kernel ${filesize};

flashDeviceTree=ubi part ubi; ubi remove dtb; ubi createvol dtb ${nand_devicetree_size}; dhcp ${loadaddr} ${path_tftp}${img_devicetree}; ubi write ${loadaddr} dtb ${filesize};

flashRootFs=ubi part ubi; ubi remove rootfs; ubi createvol rootfs ${nand_rootfs_size}; ubi remove update_rootfs; ubi createvol update_rootfs ${nand_rootfs_size}; dhcp ${loadaddr} ${path_tftp}${img_rootfs}; ubi write ${loadaddr} rootfs ${filesize};

All flash commands are working, but with the Kernel and the Devicetree flash I have a problem. When I make a run flashKernel and boot the system I receive the error : **ERROR: Did not find a cmdline Flattened Device Tree Could not find a valid device tree **

And when I flash the devicetree and start the system I receive the error message: Bad Linux ARM zImage magic!

Strange is, I don’t have this problem, when I erase the complete ubi part and make all volumes new und then flash the kernel, but as soon as I have booted the system and press reset and try to do the flash command I have the described problem.

I allready have tried to make the volumes static, but this did not change anything

What exact hardware and software versions of things are you talking about?

We use the Colibri iMX7d V1.1d with the toradex uboot branch 2016.11-toradex (commit 30a12087 20.12.2017)

Which kernel did you flash? Which kernel branch are you using to compile? Could you share the output of git show in the branch you are compiling from?

I have cloned the toradex repository onto a private GItLab server.
The Kernel I use is the toradex_4.9-1.0.x-imx-next with the last commit:

And we use buildroot (Version 2018.05.x)

Could you try to reset after flashing the kernel instead of doing boot?

When I do it the first time it does not matter if I do direct modeboot or reset.
But as soon as the kernel was loaded once I can not flash only the kernel or the devicetree.

But I can do a run flashAll (creates and flashes all volumes new). This I normaly have also to do twice, because the first time I receive the UBI init error 22.

When I do it a second time I don’t have any problem.

Can you test if the latest toradex_4.9-2.3.x-imx-next shows the same behaviour? Thanks.

I found the problem. I made the command ubi part ubi more then once, One time for each flash command and once during the boot command.

When I do the ubi part ubi only once during a uboot session I don’t have any problem.

Perfect that it works. Thanks for the feedback.