NXP / swupdate-scripts

SWUpdate is a Linux Update agent with the goal to provide an efficient and safe way to update an embedded Linux system in field.
Other
2 stars 2 forks source link

Difficulty building image which can be flashed with uuu on an imx93 evk #4

Open mdeneen opened 8 months ago

mdeneen commented 8 months ago

Hi!

I've been using these scripts to build swupdate images to flash on an imx93 evk, so I am using the mickledore Yocto tree. I've run into several problems:

  1. The tools on my host, Ubuntu 22.04, are older than the host tools which Yocto uses. This causes problems with tools like resize2fs, as Yocto builds the rootfs with file system options which Ubuntu 22.04 does not know of. For the time being I have pointed resize2fs and e2fsck to their equivalents within the Yocto's build of the host tools.
  2. gnu parted is different, as well. Ubuntu 22.04 ships with GNU parted 3.4, the host tools uses version 3.5. Generating the MBR using parted 3.4 does not appear to work with these scripts, but I have not investigated this further.
  3. The image created will not flash with uuu, at least not 1.5.125-0-gaeb3490. I receive the following output:

`uuu -b emmc_all ./swu_slota_w_swu_rescue_imx93_emmc_20240304-172810.entire.sdcard uuu (Universal Update Utility) for nxp imx chips -- libuuu_1.5.125-0-gaeb3490

Success 0 Failure 1

1:1 1/ 1 [This wic have NOT terminate tag after ] SDPS: boot -scanterm -f ./swu_slota_w_swu_rescue_imx93_emmc_20240304-172810.entire.sdcard -scanlimited 0x800000`

The behavior is the same when using the script (assemble_base_image.sh) and when generating the image using the instructions defined in readme.txt. The wic file generated by Yocto itself can be flashed, so I know that the components which Yocto has built are valid. From what I understand, this message will occur when the boot image is missing, so I suspect that it may be at a location which uuu isn't looking at.

Which versions of e2fsprogs and gnu parted are recommended? Is the location of the boot image different for imx93?

mdeneen commented 8 months ago

By choosing imx-boot instead of the one named imx-boot-imx93evk-sd.bin-flash_singleboot, my image now flashes. The changes I made in pull request #5 is needed for this to function.

Toomoch commented 8 months ago

Hi, if I understood correctly there is no way to build a .swu directly with Yocto using these scripts, right? It seems that other BSP such as the variscite one have it integrated.

mdeneen commented 8 months ago

Correct, these scripts run outside of Yocto.

Toomoch commented 8 months ago

Assuming you're using BSP 6.1.55, have you ran into this issue?

ERROR: swupdate-2023.05-r0 do_patch: Applying patch '0001-mongoose-enable-cgi.patch' on target directory '/opt/yocto/imx-6.1.55-2.2.0-build/build_fsl-imx-xwayland/tmp/work/armv8a-poky-linux/swupdate/2023.05-r0/git'
CmdError('quilt --quiltrc /opt/yocto/imx-6.1.55-2.2.0-build/build_fsl-imx-xwayland/tmp/work/armv8a-poky-linux/swupdate/2023.05-r0/recipe-sysroot-native/etc/quiltrc push', 0, 'stdout: Applying patch 0001-mongoose-enable-cgi.patch
patching file mongoose/Makefile
Hunk #1 FAILED at 2.
1 out of 1 hunk FAILED -- rejects in file mongoose/Makefile
Patch 0001-mongoose-enable-cgi.patch does not apply (enforce with -f)

stderr: ')
ERROR: Logfile of failure stored in: /opt/yocto/imx-6.1.55-2.2.0-build/build_fsl-imx-xwayland/tmp/work/armv8a-poky-linux/swupdate/2023.05-r0/temp/log.do_patch.2354
ERROR: Task (/opt/yocto/imx-6.1.55-2.2.0-build/sources/meta-swupdate/recipes-support/swupdate/swupdate_2023.05.bb:do_patch) failed with exit code '1'
WARNING: cpio-native-2.13-r0 do_fetch: Failed to fetch URL https://ftp.gnu.org/gnu/cpio/cpio-2.13.tar.gz, attempting MIRRORS if available
WARNING: libconfig-1.7.3-r0 do_fetch: Failed to fetch URL https://hyperrealm.github.io/libconfig/dist/libconfig-1.7.3.tar.gz, attempting MIRRORS if available

I am aware this is related to meta-swupdate-imx and not this repo, but i'm just asking as you are also working with imx93evk. Thank you

mdeneen commented 8 months ago

Yes, I ran into that. I will fork / make a pull request in that repo as well. It was a fairly easy fix.

mdeneen commented 8 months ago

https://github.com/nxp-imx-support/meta-swupdate-imx/pull/2

TerryLv commented 8 months ago

Actually, I have some fixes on some issues found in these scripts. But the push is pending, as there is an issue in my push permission. I'll compare your fixes with my commits. Thanks!

Toomoch commented 7 months ago

Also found that the patch 0005-imx93-enable-env_redunand-bootcount-limit-lf-6.1.36-2.1.0.patch doesn't apply, it seems that the defconfig has been modified since 6.1.36-2.1.0

CmdError('quilt --quiltrc /opt/yocto/imx-6.1.55-2.2.0-build/build_fsl-imx-xwayland/tmp/work/imx93evk-poky-linux/u-boot-imx/2023.04-r0/recipe-sysroot-native/etc/quiltrc push', 0, 'stdout: Applying patch 0005-imx93-enable-env_redunand-bootcount-limit-lf-6.1.36-2.1.0.patch patching file configs/imx93_11x11_evk_defconfig Hunk #1 FAILED at 8. Hunk #2 succeeded at 16 with fuzz 1 (offset -2 lines). Hunk #3 FAILED at 190. 2 out of 3 hunks FAILED -- rejects in file configs/imx93_11x11_evk_defconfig Patch 0005-imx93-enable-env_redunand-bootcount-limit-lf-6.1.36-2.1.0.patch does not apply (enforce with -f) I'm curious if anyone else has this issue, or it may be from my end because I've been messing with u-boot bbappends in my layer. Do I open an issue on meta-swupdate-imx?

mdeneen commented 7 months ago

Also found that the patch 0005-imx93-enable-env_redunand-bootcount-limit-lf-6.1.36-2.1.0.patch doesn't apply, it seems that the defconfig has been modified since 6.1.36-2.1.0

I don't think that anything has changed with that default config. What git hash does sources/meta-imx/meta-bsp/recipes-bsp/u-boot/u-boot-imx-common_2023.04.inc point to? Mine points to 1e5b6c6bf246a38654d07e7e23f333ad0e7d42d0, which is the most recent commit in the mickledore branch.

I would suggest that you are either pointing to the wrong branch or you have made changes to the default config.

Toomoch commented 7 months ago

Also found that the patch 0005-imx93-enable-env_redunand-bootcount-limit-lf-6.1.36-2.1.0.patch doesn't apply, it seems that the defconfig has been modified since 6.1.36-2.1.0

I don't think that anything has changed with that default config. What git hash does sources/meta-imx/meta-bsp/recipes-bsp/u-boot/u-boot-imx-common_2023.04.inc point to? Mine points to 1e5b6c6bf246a38654d07e7e23f333ad0e7d42d0, which is the most recent commit in the mickledore branch.

I would suggest that you are either pointing to the wrong branch or you have made changes to the default config.

Weird, as 1e5b6c6bf246a38654d07e7e23f333ad0e7d42d0 is in the mickledore-6.1.36-2.1.0 branch, but i'm on mickledore-6.1.55-2.2.0 so I have SRCREV 49b102d98881fc28af6e0a8af5ea2186c1d90a5f. I thought you were building with mickledore-6.1.55-2.2.0 .

mdeneen commented 7 months ago

Interesting, I was building using the instructions from NXP and didn't appreciate that 6.1.55-2.2.0 was released. I will look into updating to that release and see how painful that is.

Toomoch commented 7 months ago

I switched to BSP 6.1.36 and tried to generate an image, it only was 8M in size (weird) and when I flash it, it throws this error, which you also encountered:

uuu (Universal Update Utility) for nxp imx chips -- libuuu_1.5.141

Success 0    Failure 1

1:1133   1/ 1 [This wic have NOT terminate tag after ] SDPS: boot -scanterm -f base_image_assembling/swu_doublecopy_rescue_imx93_sd_20240319.sdcard -scanlimited 0x800000

Here is the log file of the creation of the image:

arnau@5351d31bb259:/opt/yocto/imx-6.1.36-2.1.0-build/swupdate-scripts/base_image_assembling$ ./assemble_base_image.sh -d -b imx93
No output image name specified! Use default name!
Output image name is: swu_doublecopy_rescue_imx93_sd_20240319.sdcard
>>>> Check partition table file...DONE
>>>> Check slota boot partition mirror...DONE
>>>> Check slotb boot partition mirror...DONE
>>>> Check slota link...DONE
>>>> Check slotb link...DONE
>>>> Making header...
pad_base: 0
pad_filename: /opt/yocto/imx-6.1.36-2.1.0-build/swupdate-scripts/base_image_assembling/common/swu_dualslot_7.5G.pt
pad_size: 32K
output_pad_file: ./tmp.bin
32256 need to add to pad to 32768
pad_base: 32K
pad_filename: /opt/yocto/imx-6.1.36-2.1.0-build/swupdate-scripts/base_image_assembling/slota/imx-boot-imx93evk-sd.bin-flash_singleboot
pad_size: 8M
output_pad_file: ./tmp.bin
6383616 need to add to pad to 8388608
DONE
>>>> Making swupdate...
pad_base: 8M
pad_filename: /opt/yocto/imx-6.1.36-2.1.0-build/swupdate-scripts/base_image_assembling/slota/Image
pad_size: 38M
output_pad_file: ./tmp.bin
pad_start:40651264 (pad_base:8388608 + pad file size:32262656) > pad end: 39845888
Toomoch commented 7 months ago

I'm looking into generating a full image with both slots direcly with Yocto using a wks file, will update you if I manage to do so.

mdeneen commented 7 months ago

Yes, I ran into this as well. You're almost there!

The kernel built in the imx93 tree is larger than 32 megabytes. I get that it's uncompressed, but 32 megabytes seems rather excessive and I've not looked into why it is so big, but that is another matter entirely. Anyway, the space reserved for the kernel image and device tree files is 32 megabytes and you've used more than that. Adjust IMAGES_SWUPDATE= in boards/cfg_imx93_base.cfg to reserve more space.

I have

${WRK_DIR}/slota/Image:8M:48M ${WRK_DIR}/slota/myboard.dtb:48M:52M ${WRK_DIR}/slota/swupdate-image-myboard.cpio.gz.u-boot:52M:100M

The scripts should probably indicate that execution has ended due to an error, as it's kind of hidden in the output.

mdeneen commented 7 months ago

Hey, @Toomoch, I have submitted a pull request to meta-swupdate-imx with changes to u-boot's default config for imx93_11x11_evk which allow it to build against the 6.1.55_2.2.0 BSP.

https://github.com/nxp-imx-support/meta-swupdate-imx/pull/4

That tree needs some work and a 6.1.55 branch.

Toomoch commented 7 months ago

Hey, @Toomoch, I have submitted a pull request to meta-swupdate-imx with changes to u-boot's default config for imx93_11x11_evk which allow it to build against the 6.1.55_2.2.0 BSP.

nxp-imx-support/meta-swupdate-imx#4

That tree needs some work and a 6.1.55 branch.

Thanks! Have you managed to create a sdcard file that flashes with uuu in 6.1.55 with these patches? After using your tree, changing the allocation for Image and installing a newer version of e2fsprogs, I get a 6.2G image, but it still throws 1:1133 1/ 1 [This wic have NOT terminate tag after ] SDPS: boot -scanterm -f swu_doublecopy_rescue_imx93_sd_20240321.sdcard -scanlimited 0x800000

mdeneen commented 7 months ago

I have been able to use both 6.1.55 and 6.1.36. What are you using for IMAGES_HEADER in cfg_imx93_base.cfg ?

Toomoch commented 7 months ago

I have been able to use both 6.1.55 and 6.1.36. What are you using for IMAGES_HEADER in cfg_imx93_base.cfg ?

I haven't touched it as I thought it was already fine, here it is:

IMAGES_HEADER="
${IMAGE_PT_TBL_PATH}:0:32K
${WRK_DIR}/slota/imx-boot-imx93evk-sd.bin-flash_singleboot:32K:8M
"
mdeneen commented 7 months ago

Change imx-boot-imx93evk-sd.bin-flash_singleboot to imx-boot and you should be golden. I found this through trial and error.

Toomoch commented 7 months ago

Change imx-boot-imx93evk-sd.bin-flash_singleboot to imx-boot and you should be golden. I found this through trial and error.

Thank you very much, it worked! I noticed that you mentioned it earlier, but I didn't think it was that image in cfg_imx93_base.cfg.