Implementing dual copy update scheme

1,577 views
Skip to first unread message

Sourabh Hegde

unread,
Dec 18, 2021, 3:30:10 PM12/18/21
to swupdate

Hi All,

I am new to SWUpdate framework and trying my best to understand the concepts.

My aim is to implement dual-copy update scheme and I have few doubts regarding this.

1. Following some previous conversations, I came across that normal output image format like .wic, .wic.gz, .wic.xz cannot be used to build .swu image. Does that mean the image files which are part of .swu should not contain these image formats?If yes, then can you please let me know the reason for this?

2. I am using core-image-minimal to build minimal system and it creats .wic.xz image to flash to SD card and boot it using this SD card. To have dual copy scheme I have modified .wks file as below:

# long-description: Creates a partitioned SD card image.

part fsbl1 --source rawcopy --sourceparams="file=u-boot-spl.stm32" --part-name "fsbl1" --ondisk mmcblk --align 1 --size 256k
part fsbl2 --source rawcopy --sourceparams="file=u-boot-spl.stm32" --part-name "fsbl2" --ondisk mmcblk --align 1 --size 256k
part ssbl --source rawcopy --sourceparams="file=u-boot.itb" --part-name "ssbl" --ondisk mmcblk --align 1 --size 2M
part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --label root --part-name "rootfs_a" --fixed-size 256 --active
part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --label root --part-name "rootfs_b" --fixed-size 256

bootloader --ptable gpt

So this should create 2 partitions to have 2 rootfs. Please correct it if there are any mistakes.

And a recipe called "core-image-swupdate" which includes swupdate and swupdate-www package to add SWUpdate client on the device. Is it possible to have the output of this recipe to be .wic.xz image? core-image-swupdate requires " recipes-extended/images/swupdate-image.inc" and this swupdate-image.inc includes IMAGE_FSTYPES="ext4.gz.u-boot". What is this image format? Can I use this image format to directly boot from SD card? Or do I need to use to some kind of create_sdcard.sh script to prepare bootable SD card image file? For example, meta-swupdate-boards uses emmcsetup.lua script to handle dual-copy approach. A bit of explanation on how to handle this would be helpful.

As per my understanding, I can use above mentioned .wks file and create .wic image from core-image-swupdate recipe. So that I can copy this image to SD card and boot the device. Since core-image-swupdate recipe includes swupdate packages and using this swupdate client will be installed on the device. Then, a separate recipe "core-image-swu" which will create .swu update file. And this recipe will include files sw-description and core-image-swupdate.ext4.gz (or .wic?). Again, please feel free to correct me here.

Please let me know if you need further information and if anything is confusing.

Thanks in advance. Your help will be much appreciated.

Regards,
Sourabh

P.S. Sorry for the long post but this would really help me to proceed further.

Sourabh Hegde

unread,
Dec 19, 2021, 8:12:04 AM12/19/21
to swupdate
Hi,

Addition to above post.

2. Do I need to have 2 boot partitions also? If yes then should I include it in .wks file or using IMAGE_BOOT_FILES variable to have 2 copies of kernel: kernel_a and kernel_b, 2 copies of dtb: dtb_a and dtb_b and the uboot.env file that contains uboot's variables and their data?

3. And during next reboot how will SWUpdate select the updated partition to boot? Is this handled by the bootloader logic?

Regards,
Sourabh

Keshava Kumar

unread,
Dec 20, 2021, 4:14:46 AM12/20/21
to swupdate

Hi  Sourabh, 

I have been working in SWupdate from some time now. 

I will try to explain you as per my knowledge. 

When you are trying to add support for new board, you can refer to below meta layer: 

It gives example on how to create swu image. 

When you are going for Dual copy, suggested to keep 2 copies of all the partition where you want dual support. If your requirement is to have 2 copies of kernel,  you should keep 2 copies of kernel. 

Coming core-image-minimal, you are not making *.swu image from core-image-minimal, but you are specifying what all images should be part of your swu image in your swupdate bb layer. 
You can inherit swupdate in your class and specify the images you want to be part of swupdate: 

Everything is easy when you use meta-swupdate-boards. 


Thanks, 
Keshava
Module Lead, Happiest Minds

Sourabh Hegde

unread,
Dec 20, 2021, 1:35:27 PM12/20/21
to swupdate
Hi Keshava,

Thank you for taking time to share your knowledge.

Regarding having 2 boot partitions, it's only required if I am doing updates to bootloader right? in most of the cases for dual-copy scheme we will have 1 boot partition and 2 rootfs partitions. Because handling updates to boot partition may be complicated and involves some kind of pre-bootloader to load updated bootloader. Please correct me if I am wrong here.

In sw-description we specify "device" along with images. But how will we know which is the current active partition and which one to update? Do we need to use some scripts or modify the u-boot env to pass the bootargs?

Thanks in advance.

Regards,
Sourabh

Keshava Kumar

unread,
Dec 21, 2021, 4:16:39 AM12/21/21
to swupdate
Hi Sourabh, 

I had a impression you are referring Linux image (uImage/zImage/Image and dtb) when you mentioned boot partition. 

So your Linux image resides within rootfs?

If yes, then having dual copy for rootfs should be enough. 

So for handing active/stand-by partition, modify u-boot and handle a update status. Based on the status you can choose the active/ standby partition. 

SWUpdate gives hooks to change environment variable from sw-description directly.

Thanks, 
Keshava  

Sourabh Hegde

unread,
Dec 21, 2021, 8:14:50 AM12/21/21
to swupdate
Hi Keshava,

Thanks for the update.

Do you have any reference script to modify u-boot and handling update status or any link which will be useful? I am not quite sure how to change these configurations.

Does hook mean by using embedded scripts within sw-description?

Kind Regards,
Sourabh

Sourabh Hegde

unread,
Dec 21, 2021, 9:56:32 AM12/21/21
to swupdate
Hi Keshava,

Regarding the Linux image. I am using below .wks file and using wic.xz. to boot from SD card.

part fsbl1 --source rawcopy --sourceparams="file=u-boot-spl.stm32" --part-name "fsbl1" --ondisk mmcblk --align 1 --size 256k
part fsbl2 --source rawcopy --sourceparams="file=u-boot-spl.stm32" --part-name "fsbl2" --ondisk mmcblk --align 1 --size 256k
part ssbl --source rawcopy --sourceparams="file=u-boot.itb" --part-name "ssbl" --ondisk mmcblk --align 1 --size 2M
part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --label root_A --part-name "rootfs_A" --align 4096 --use-uuid --active
part /rootfsB --source rootfs --ondisk mmcblk0 --fstype=ext4 --label root_B --part-name "rootfs_B" --align 4096 --use-uuid

bootloader --ptable gpt

my understanding is this will create 2 partitions for rootfs and will load rootfs files to them. And in my machine conf I have something like:
IMAGE_INSTALL:append = " kernel-devicetree kernel-image-fitimage virtual/bootloader "

Regards,
Sourabh

Keshava Kumar

unread,
Dec 22, 2021, 12:52:52 AM12/22/21
to swupdate
Hi Sourabh, 

Please check below URL: 

Here, there is example of bootenv attribute. Using this, you can change any environment variable. 

Thanks, 
Keshava

Sourabh Hegde

unread,
Dec 22, 2021, 2:31:59 AM12/22/21
to swupdate
Hi Keshava,

Thanks for the information.

Suppose I want to change the default configuration once I have coped SWUpdate package to my board. Where should I run the "menuconfig" and how these changes take place? Do I need to bitbake new image and copy them to my device?

For checking hardware compatibility we need to have a file in etc/hwrevision. Is this location available  inside rootfs of the build image?

Thanks in advance

Kind Regards,
Sourabh
Reply all
Reply to author
Forward
0 new messages