Use of swupdate under x86_64 yocto platform

99 views
Skip to first unread message

Benoit SANSONI

unread,
Aug 3, 2023, 8:09:51 AM8/3/23
to swup...@googlegroups.com
Hi,

I am currently working on a x86_64 platform under yocto and also I am using SWupdate.
I produced a .swu file by using a wic image and declare the sw-description as defined below :

software =
{
   version = "0.1.0";

   board = {
       hardware-compatibility: [ "1.0" ];

       files: (
          {
             filename = "core-image-minimal.wic.gz";
             type = "raw";
             compressed = "zlib";
             device = "/dev/sda";
          }
        );
      };
}

So my .swu gather the sw-description and the core-image-minimal.wic.gz.

I upgrade my disk /dev/sda by using the following command and the /root is mounted to /dev/sda3 :

root@gateway:~# swupdate -i ./core-image-minimal-gateway.swu -H board:1.0 -v  
SWUpdate v2023.05

Licensed under GPLv2. See source distribution for detailed copyright notices.

[TRACE] : SWUPDATE running :  [print_registered_bootloaders] : Registered bootloaders:
[TRACE] : SWUPDATE running :  [print_registered_bootloaders] : none loaded.
[INFO ] : SWUPDATE running :  [main] : Using default bootloader interface: none
[INFO ] : SWUPDATE running :  [main] : Running on board Revision 1.0
[INFO ] : SWUPDATE running :  [print_registered_handlers] : Registered handlers:
[INFO ] : SWUPDATE running :  [print_registered_handlers] : dummy
[INFO ] : SWUPDATE running :  [print_registered_handlers] : lua
[INFO ] : SWUPDATE running :  [print_registered_handlers] : raw
[INFO ] : SWUPDATE running :  [print_registered_handlers] : rawfile
[INFO ] : SWUPDATE running :  [print_registered_handlers] : shellscript
[INFO ] : SWUPDATE running :  [print_registered_handlers] : preinstall
[INFO ] : SWUPDATE running :  [print_registered_handlers] : postinstall
[DEBUG] : SWUPDATE running :  [read_module_settings] : No config settings found for module versions
[TRACE] : SWUPDATE running :  [listener_create] : creating socket at /tmp/swupdateprog
[TRACE] : SWUPDATE running :  [network_initializer] : Main loop daemon
[TRACE] : SWUPDATE running :  [listener_create] : creating socket at /tmp/sockinstctrl
[TRACE] : SWUPDATE running :  [network_thread] : Incoming network request: processing...
[INFO ] : SWUPDATE started :  Software Update started !
[TRACE] : SWUPDATE running :  [network_initializer] : Software update started
[TRACE] : SWUPDATE running :  [extract_file_to_tmp] : Found file
[TRACE] : SWUPDATE running :  [extract_file_to_tmp] : filename sw-description
[TRACE] : SWUPDATE running :  [extract_file_to_tmp] : size 234
[DEBUG] : SWUPDATE running :  [parse_cfg] : Parsing config file /tmp/sw-description
[TRACE] : SWUPDATE running :  [get_common_fields] : Version 0.1.0
[TRACE] : SWUPDATE running :  [parse_hw_compatibility] : Accepted Hw Revision : 1.0
[TRACE] : SWUPDATE running :  [_parse_files] : Found compressed File: core-image-minima.wic.gz -->  (/dev/sda)
[TRACE] : SWUPDATE running :  [parse] : Number of found artifacts: 1
[TRACE] : SWUPDATE running :  [parse] : Number of scripts: 0
[TRACE] : SWUPDATE running :  [parse] : Number of steps to be run: 1
[TRACE] : SWUPDATE running :  [check_hw_compatibility] : Hardware board Revision: 1.0
[TRACE] : SWUPDATE running :  [check_hw_compatibility] : Hardware compatibility verified
[DEBUG] : SWUPDATE running :  [preupdatecmd] : Running Pre-update command
[TRACE] : SWUPDATE running :  [extract_files] : Found file
[TRACE] : SWUPDATE running :  [extract_files] : filename core-image-minimal.wic.gz
[TRACE] : SWUPDATE running :  [extract_files] : size 302207161 required
[TRACE] : SWUPDATE running :  [extract_padding] : Expecting 200 padding bytes at end-of-file
[TRACE] : SWUPDATE running :  [network_initializer] : Valid image found: copying to FLASH
[INFO ] : SWUPDATE running :  Installation in progress
[TRACE] : SWUPDATE running :  [install_single_image] : Found installer for stream core-image-minimal.wic.gz raw
[INFO ] : SWUPDATE successful ! SWUPDATE successful !
[TRACE] : SWUPDATE running :  [network_initializer] : Main thread sleep again !
[INFO ] : No SWUPDATE running :  Waiting for requests...
[INFO ] : SWUPDATE running :  [endupdate] : SWUpdate was successful !
[DEBUG] : SWUPDATE running :  [postupdate] : Running Post-update command

After the update, when I typed reboot nothing happened (no board rebooting) and these kind of messages are delivered by the kernel :

[  129.144308] EXT4-fs error (device sda3): ext4_lookup:1836: inode #5553: comm (ea-dhcp6): iget: checksum invalid
[  129.223268] EXT4-fs error (device sda3): ext4_lookup:1836: inode #298: comm systemd-udevd: iget: checksum invalid


The ext4 filesystem is mounted and reflashed in live.
It seems that SWUpdate does not use any "pivot" method.

What is the right process to update a disk with an image (.wic or .ext4) when a partition is already mounted as root ?
Is it possible ?

Thanks in advance for your help
Benoit

Stefano Babic

unread,
Aug 3, 2023, 9:10:48 AM8/3/23
to Benoit SANSONI, swup...@googlegroups.com
Hi,
Take a breath and think about. What you are trying to do is described in
the attached picture.

See in archive, too:

https://groups.google.com/g/swupdate/c/khIZyYPIa68/m/8ZQCPunyAQAJ

Best regards,
Stefano Babic
images.jpeg

Benoit SANSONI

unread,
Aug 3, 2023, 9:17:00 AM8/3/23
to swupdate
It is exactly what I am trying to explain.
Very good picture. ;-)

I am going to have a look at you link.

Best Regards
Benoit

Benoit SANSONI

unread,
Aug 3, 2023, 9:56:04 AM8/3/23
to swupdate
As far as I understood the method is to use an other rootfs or another disk (usb).
But I already find out a pivot mechanism in OpenWRT for example that can updating current file system or device, using a tmpfs rootfs during the upgrade only.

Can SWupdate use this mechanism  ?

Benoit SANSONI

unread,
Aug 3, 2023, 12:44:06 PM8/3/23
to swupdate
well, I would like to have your advice.

I use the systemctl switch-root before mounting an .ext4 rootfs to /tmp/mnt for example in loop device.*
the .swu image is include in the .ext4 file.

I seems that it can be a solution :

root@board:~# mount ./core-image-minimal.ext4 /tmp/rootfs/
[15062.142021] loop1: detected capacity change from 0 to 1429504
[15062.145195] EXT4-fs (loop1): mounted filesystem with ordered data mode. Opts: (null). Quota mode: disabled.
root@board:~# cp core-image-minimal.swu /tmp/rootfs/home/root
root@board:~# systemctl --no-block --force switch-root /tmp/rootfs
...
root@board:~# mount |grep root
/home/root/core-image-minimal.ext4 on / type ext4 (rw,relatime)   <= I am in my rootfs.

Now I run swupdate in this environment that allow me to flash my /dev/sda without having a second rootfs.

Thanks
Benoit

Stefano Babic

unread,
Aug 3, 2023, 12:49:34 PM8/3/23
to Benoit SANSONI, swupdate
Hi Benoit,

On 03.08.23 18:44, Benoit SANSONI wrote:
> well, I would like to have your advice.
>
> I use the systemctl switch-root before mounting an .ext4 rootfs to
> /tmp/mnt for example in loop device.*
> the .swu image is include in the .ext4 file.
>

You should first check what you want to achieve. Of course, neither
openWRT nor current distro are replacing the block device how you were
attempting before. And yes, SWUpdate can do it: SWUpdate is a framework,
you should understand and write your own concept. SWUpdate will simply
do what you ask it, even destroy the complete system (as you already
experienced).

> I seems that it can be a solution :
>
> root@board:~# mount ./core-image-minimal.ext4 /tmp/rootfs/
> [15062.142021] loop1: detected capacity change from 0 to 1429504
> [15062.145195] EXT4-fs (loop1): mounted filesystem with ordered data
> mode. Opts: (null). Quota mode: disabled.

This could be you have a rootfs on tmpfs that disappear after a reboot.
It does not work when rootfs increase and becomes beigger than available
RAM.

> root@board:~# cp core-image-minimal.swu /tmp/rootfs/home/root
> root@board:~# systemctl --no-block --force switch-root /tmp/rootfs
> ...
> root@board:~# mount |grep root
> /home/root/core-image-minimal.ext4 on / type ext4 (rw,relatime)   <= I
> am in my rootfs.
>
> Now I run swupdate in this environment that allow me to flash my
> /dev/sda without having a second rootfs.

You *have* a seconf rootfs, like openWRT *has* a second rootfs.

Best regards,
Stefano Babic
> https://groups.google.com/g/swupdate/c/khIZyYPIa68/m/8ZQCPunyAQAJ <https://groups.google.com/g/swupdate/c/khIZyYPIa68/m/8ZQCPunyAQAJ>
>
> Best regards,
> Stefano Babic
>
> --
> You received this message because you are subscribed to the Google
> Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swupdate+u...@googlegroups.com
> <mailto:swupdate+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/swupdate/4c87747b-4921-4f12-8987-aea52f3e667en%40googlegroups.com <https://groups.google.com/d/msgid/swupdate/4c87747b-4921-4f12-8987-aea52f3e667en%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=====================================================================

Reply all
Reply to author
Forward
0 new messages