I made progress in it.
To generate swu file I taken
imx-image-core-imx8ulp-9x9-lpddr4-evk-20240716174730.rootfs.ext4
Image
u-boot-imx8ulp-9x9-lpddr4-evk.bin
and made sw-description file
software =
{
version = "1.0";
description = "Firmware update example";
hardware-compatibility: [ "1.0", "1.2", "1.3"];
imx8ulpevk: {
images: (
{
filename = "rootfs.ext4";
sha256 = "SHA256_CHECKSUM_OF_ROOTFS";
compressed = "zlib";
device = "/dev/mmcblk1p2";
installed-directly = true;
hook = "preinst";
},
{
filename = "uImage";
sha256 = "SHA256_CHECKSUM_OF_UIMAGE";
device = "/dev/mmcblk1p1";
installed-directly = true;
},
{
filename = "u-boot.bin";
sha256 = "SHA256_CHECKSUM_OF_UBOOT";
device = "/dev/mmcblk0boot0";
installed-directly = true;
}
);
scripts: (
{
filename = "env_set_bootslot.sh";
sha256 = "SHA256_CHECKSUM_OF_SCRIPT";
type = "postinstall";
}
);
}
}
and made env_set_bootslot.sh
#!/bin/sh
# Get the current boot slot
CURRENT_SLOT=$(fw_printenv -n boot_slot)
# Toggle the boot slot
if [ "$CURRENT_SLOT" = "A" ]; then
NEW_SLOT="B"
else
NEW_SLOT="A"
fi
# Set the new boot slot
fw_setenv boot_slot $NEW_SLOT
# Update other related environment variables if necessary
fw_setenv boot_partition /dev/mmcblk0p${NEW_SLOT}
and ran below generate_swu.sh
#!/bin/bash
MODE="RSA-PKCS-1.5"
PRODUCT_NAME="myproduct"
CONTAINER_VER="1.0"
IMAGES="rootfs.ext4 uImage u-boot.bin env_set_bootslot.sh"
FILES="sw-description sw-description.sig $IMAGES"
# Sign the sw-description
if [ x"$MODE" == "xRSA-PKCS-1.5" ]; then
openssl dgst -sha256 -sign priv.pem sw-description > sw-description.sig
elif [ x"$MODE" == "xRSA-PSS" ]; then
openssl dgst -sha256 -sign priv.pem -sigopt rsa_padding_mode:pss \
-sigopt rsa_pss_saltlen:-2 sw-description > sw-description.sig
else
openssl cms -sign -in sw-description -out sw-description.sig -signer mycert.cert.pem \
-inkey mycert.key.pem -outform DER -nosmimecap -binary
fi
# Package the files into a SWU container
for i in $FILES; do
echo $i
done | cpio -ov -H crc > ${PRODUCT_NAME}_${CONTAINER_VER}.swu
than image is generated with .swu extention
but when I update it on webserver it is giving logs like
[network_thread] : Incoming network request: processing...
Software Update started !
[network_initializer] : Software update started
[extract_file_to_tmp] : Found file
[extract_file_to_tmp] : filename sw-description
[extract_file_to_tmp] : size 1086
[extract_file_to_tmp] : Found file
[extract_file_to_tmp] : filename sw-description.sig
[extract_file_to_tmp] : size 256
[swupdate_verify_file] : Verify signed image: Read 1086 bytes
ERROR swupdate_rsa_verify.c : verify_final : 99 : EVP_DigestVerifyFinal failed, error 0x200008a 0
[swupdate_verify_file] : Error Verifying Data
ERROR stream_interface.c : extract_files : 183 : Compatible SW not found
Image invalid or corrupted. Not installing ...
[network_initializer] : Main thread sleep again !
Waiting for requests...
ERROR mongoose_interface.c : upload_handler : 625 : Writing to IPC fails due to Broken pipe
[network_thread] : Incoming network request: processing...
Software Update started !
[network_initializer] : Software update started
[extract_file_to_tmp] : Found file
[extract_file_to_tmp] : filename sw-description
[extract_file_to_tmp] : size 1086
[extract_file_to_tmp] : Found file
[extract_file_to_tmp] : filename sw-description.sig
[extract_file_to_tmp] : size 256
[swupdate_verify_file] : Verify signed image: Read 1086 bytes
ERROR swupdate_rsa_verify.c : verify_final : 99 : EVP_DigestVerifyFinal failed, error 0x200008a 0
[swupdate_verify_file] : Error Verifying Data
ERROR stream_interface.c : extract_files : 183 : Compatible SW not found
Image invalid or corrupted. Not installing ...
[network_initializer] : Main thread sleep again !
Waiting for requests...
Is this correct way to build swu image?