I am in the process of integrating swupdate - https://github.com/sbabic/meta-swupdate. I'm still new to Yocto.
The board is custom hardware based on i.MX8MP. Below is what I have done for the integration
Now I have the swupdate binary in the rootfs. I created the sw-description file (attached). I'm trying to copy a dummy.txt to an emmc partition to test out the swupdate integration. however I'm facing the following errors when I run the swupdate -
oot@imx8mp-ridevision-1as:~# swupdate -i SWUpdate.swu -e stable,copy1 Swupdate v2021.11.0 Licensed under GPLv2. See source distribution for detailed copyright notices. [INFO ] : SWUPDATE started : Software Update started ! [ERROR] : SWUPDATE failed  ERROR : Configuration file /etc/fw_env.config wrong or corrupted [INFO ] : SWUPDATE running : Installation in progress [ERROR] : SWUPDATE failed  ERROR : I cannot open /tmp/datadst//run/media/mmcblk2p1/dummy.txt 2 [ERROR] : SWUPDATE failed  ERROR : Configuration file /etc/fw_env.config wrong or corrupted [ERROR] : SWUPDATE failed  Installation failed ! [ERROR] : SWUPDATE failed  ERROR : Configuration file /etc/fw_env.config wrong or corrupted [INFO ] : No SWUPDATE running : Waiting for requests...
For me it appears that I'm missing to connect the libubootenv. I don't have the /etc/fw_env file on the rootfs. If I add a dummy file, still the error happens. The online documentation (https://sbabic.github.io/swupdate/building-with-yocto.html#) shows that libubootenv is builtin and we just need to add
PREFERRED_PROVIDER_u-boot-fw-utils = “libubootenv”
to local.conf. This I have done. However I'm suspecting that we need to add a recipe for libubootenv as done in the examples repo https://github.com/sbabic/meta-swupdate-boards .
I fail to understand if a recipe is required for libbootenv, if so then how to add the recipe. Also I couldn't find the config
in menuconfig of swupdate, are we expected to edit the config.in from the build folders of Yocto? (shouldn't be doing this, maybe ok for testing.)
Any pointers on how to resolve the fw_env dependency..?
Thank you very much for the response. Much appreciated.
I needed two of those patches and the libubootenv recipe was missing in the "hardknott" branch of swupdate. I had to copy over the recipe from Zeus branch of swupdate. The SWUpdate functionality is now working.
I also had to save the uboot environment to emmc using the command "saveenv" from uboot.
I am now looking into how to populate the uboot environment from emmc (not use the default environment) and how to program the environment in emmc when commissioning a virgin board.
You don't need to do "I also had to save the uboot environment to emmc using the command "saveenv" from uboot."
Please check the patch 2000-u-boot-append-emmc-L5.4.70-2.3.0.patch
In this patch, tell swupdate where is default u-boot environment.
When first run, no u-boot environment in emmc, swupdate will take the u-boot-imx-initial-env and save to the emmc.
When yocto build u-boot, it will output u-boot-imx-initial-env. Just let swupdate know the u-boot default environment file name and location.
swupdate, actually the fw_printenv/fw_setenv has the mechanism to deal with the first run without environment in emmc.
Usage fw_setenv [OPTION]
-h, : print this help
-c, --config <filename> : configuration file (old fw_env.config)
-f, --defenv <filename> : default environment if no one found
-V, : print version and exit
-s, --script <filename> : read variables to be set from a script
Please read the link provided by Qmiler carefully. Those patches take care everything including the issue you are facing.
--- sources/meta-swupdate/recipes-support/swupdate/swupdate/defconfig.orig 2021-06-16 14:31:55.465842921 +0800
+++ sources/meta-swupdate/recipes-support/swupdate/swupdate/defconfig 2021-06-13 08:43:56.923883195 +0800
@@ -49,15 +49,17 @@ CONFIG_UBOOT=y
# CONFIG_BOOTLOADER_NONE is not set
# CONFIG_BOOTLOADER_GRUB is not set
# CONFIG_SSL_IMPL_NONE is not set
# CONFIG_SSL_IMPL_MBEDTLS is not set
-# CONFIG_DOWNLOAD is not set
Thank you very much. I have now provided the default ENV file for swupdate and I can see that the swupdate does update the ENV variables in EMMC if it doesn't exist.
I am now very close to finishing the solution for firmware update mechanism, I need to figure out the below-
I'm trying to keep the uboot environment variables in a separate partition. I think the uboot and swupdate are both doing this but I cannot figure out which partition has the uboot environment.
output of lsblk from the target -
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT mtdblock0 31:0 0 16M 0 disk mmcblk2 179:0 0 7.3G 0 disk |-mmcblk2p1 179:1 0 83.2M 0 part /run/media/mmcblk2p1 |-mmcblk2p2 179:2 0 1.7G 0 part / |-mmcblk2p3 179:3 0 83.2M 0 part /run/media/mmcblk2p3 |-mmcblk2p4 179:4 0 1K 0 part |-mmcblk2p5 179:5 0 1.7G 0 part /run/media/mmcblk2p5 `-mmcblk2p6 179:6 0 1G 0 part /run/media/mmcblk2p6 mmcblk2boot0 179:32 0 4M 1 disk mmcblk2boot1 179:64 0 4M 1 disk
From uboot's code I can see that ENV offset is 0x400000, that is after the initial 4MB. I'm assuming this is stored after uboot's code which is mmcblk2boot0, its size is 4MB. This points that the uboot ENV will be stored in mmcblk2boot1, if I dump the mmcblk2boot1 partition, I don't see the variables that I created. It appears that the ENV data is hashed or encrypted.
mmcblk2p1 is the partition where zImage, dtb files are stored. mmcblk2p3 is the copy of mmcblk2p1. mmcblk2p2 is the rootfs, mmcblk2p5 is the copy rootfs. mmcblk2p6 is a dummy data partition.
strings /dev/mmcblk2boot1 | grep linux_var, doesn't give any output whereas strings "/dev/mmcblk2 | grep linux_var" prints linux_var=test which is what I expect. Any pointers on how the uboot ENV is stored?
I was planning to create a separate partition for uboot ENV variables. I feel this is not required because the mmcblk2boot1 is for the ENV variables. Correct me if I'm wrong. Currently I do not have redundant uboot or redundant ENV configured.
Hi @BiyongSUN and @Qmiller ,
I need your help understanding in which partition is the uboot environment stored.
I have my uboot's defconfig as -
CONFIG_ENV_SIZE=0x4000 CONFIG_ENV_OFFSET=0x400000 CONFIG_ENV_SECT_SIZE=0x10000 CONFIG_ENV_IS_NOWHERE=y CONFIG_ENV_IS_IN_MMC=y CONFIG_SYS_MMC_ENV_DEV=2 CONFIG_SYS_MMC_ENV_PART=0
The mmcblk2p1 which holds the kernel image and the dtb file, starts at location 8388608 (8MB which is after mmcblk2boot0 and mmcblk2boot1, these are of size 4MB). If uboot Environment is stored at offset 0x400000, eMMC Device is 2 and partition 0. It should be located in mmcblk2boot1 partition. But I'm unable to find the variables in this partition (tried by printing the strings in the partition). I'm assuming that variables will be stored as linear strings (key=value type) in mmcblk2boot1 partition. Is it not the case?
I tried to create a separate partition through meta-freescale/wic/imx-imx-boot-bootpart.wks.in
part --source rawcopy --sourceparams="file=u-boot-imx-initial-env-sd" --ondisk mmcblk --no-table --align 8192 --size 64K
I tried to create a partition of 64KB using the file u-boot-imx-initial-env-sd as an input hoping that the uboot environment variables will be programmed to this partition, I don't see any partitions being created.
Since swupdate will be adding variables to uboot environment, I thought of moving it to a separate partition. If I leave the default settings, the whole system works fine but I can't point out which partition has the uboot environment and if it is safe to leave it like that. I'm thinking if uboot gets corrupted during updating the environment variables.
Please see patch file in this link: