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
or 2000-u-boot-append-emmc-LF_v5.10.9_1.0.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_UBOOT_FWENV="/etc/fw_env.config"
-CONFIG_UBOOT_DEFAULTENV="/etc/u-boot-initial-env"
+CONFIG_UBOOT_DEFAULTENV="/etc/u-boot-imx-initial-env"
# CONFIG_SSL_IMPL_NONE is not set
CONFIG_SSL_IMPL_OPENSSL=y
# CONFIG_SSL_IMPL_MBEDTLS is not set
-# CONFIG_DOWNLOAD is not set