[elbe-devel] Elbe and SWupdate

esad ergül esadergul at gmail.com
Tue Apr 26 08:50:13 CEST 2022


Hi,

I build an efi based image with Elbe and use dual copy(A/B) approach to
always have a running system on the device. The hard disk image (Buster)
has 3 partitions (efi,root1,config). The other 2 partitions(root2,data) are
created during the first init procedure. As updater client I want to use
the SWUpdate (from the official Debian repository) which can do atomic
updates. For updating I created swu image file as described in the
documentation (
https://sbabic.github.io/swupdate/sw-description.html#software-collections-and-operation-modes).
When I update the device, SWupdate says that the installation is successful
and does not give an error message. But switching between root partitions
does not happen because SWUpdate somehow did not create the environment
variables on the grub environment block. That's why the grub bootloader
can't read a variable from the environment block and change the default
menu entry in the grub configuration file. What I noticed is that the file
structure of the Efi partition is different from standard Debian.  The Efi
partition that the Elbe created has only the BOOTX64.EFI
(boot/efi/EFI/BOOT/BOOTX64.efi) file. Standard Debian has here grubx64.efi
and grub.cfg file which contains the partition UUID where the actual
grub.cfg file with the menu entries is located.

For testing I installed standard Debian (Buster) on VM and manually
partitioned it using the dual copy approach. (2 scenarios -->
Boot|Root1,Root2,Data and Root1|Root2|Data)
SWUpdate was able to set the environment variables on the environment block
here. So the grub can switch between root partitions because it could load
the variables.

My questions are;
1)Why does SWupdate not write the variables on the grub environment block ?
2)Is it possible that the path of the environment block file is wrong ? If
so, where should the grub directory be installed ? How can I adjust the
elbe xml file for it so that the grub bootloader is configured correctly
and SWupdate can find the GRUB environment block?
3) Are there any example update scenarios with Elbe and SWUpdate?

Can anyone please let me know how I should resolve it?

Best regards,
Esad Ergül


*sw-description*

software = {
    version = "0.1.0";
    hardware-compatibility = ["Test","1.0"];

    rootfs: {
        copy1: {
            images: (
                {
                    filename = "root.img.gz.enc";
                    device = "/dev/sda2";
                    compressed = "zlib";
                    encrypted = true;
                    ivt = "";
                    installed-directly = true;
                    type = "raw";
                    sha256 = "1213213123***";
                }
            );
            bootenv: (
                {
                    name = "boot_entry";
                    value = "0";
                }
            );
            scripts: (
                {
                    filename = "update.sh";
                    type = "shellscript";
                    sha256 = "1213213123***";
                }
            );
        };
        copy2: {
            images: (
                {
                    filename = "root.img.gz.enc";
                    device = "/dev/sda4";
                    compressed = "zlib";
                    encrypted = true;
                    ivt = "";
                    installed-directly = true;
                    type = "raw";
                    sha256 = "1213213123***";
                }
            );
            bootenv: (
                {
                    name = "boot_entry";
                    value = "1";
                }
            );
            scripts: (
                {
                    filename = "update.sh";
                    type = "shellscript";
                    sha256 = "1213213123***";
                }
            );
        };
    };
};



*elbe-xml*

<ns0:RootFileSystem xmlns:ns0="https://www.linutronix.de/projects/Elbe"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
created="2009-05-20T08:50:56" revision="6" xsi:schemaLocation="
http://www.tglx.de/~bene/.RFS dbsfed.xsd">

  <project>
    <name>Test device</name>
    <version>1.0</version>
    <description>
      Test
    </description>
    <buildtype>amd64</buildtype>
    <mirror>
      <primary_host>IP</primary_host>
      <primary_path>debian_mirror/debian-buster</primary_path>
      <primary_proto>http</primary_proto>
      <url-list>
        -------------
        <url>
          <binary>http://IP/debian_mirror/debian-buster
buster-backports-sloppy main contrib non-free</binary>
          <source>http://IP/debian_mirror/debian-buster
buster-backports-sloppy main contrib non-free</source>
        </url>
-------------
      </url-list>
    </mirror>
-----------
<suite>buster</suite>
    <noauth />



  </project>

  <target>
----------------

    <package>
      <tar>
        <name>nfsroot.tar.gz</name>
      </tar>
    </package>

    <images>
      <gpthd>
        <name>target.img</name>
        <size>6800MiB</size>
        <grub-install />
        <partition>
          <size>200MB</size>
          <label>EFI</label>
        <bootable>true</bootable>
        </partition>
        <partition>
          <size>6200MiB</size>
          <label>ROOT</label>
        </partition>
        <partition>
          <size>300MiB</size>
          <label>CONFIG</label>
        </partition>
      </gpthd>
    </images>

    <fstab>
      <bylabel>
        <label>EFI</label>
        <mountpoint>/boot/efi</mountpoint>
        <fs>
          <type>vfat</type>
        </fs>
      </bylabel>

      <bylabel>
        <label>ROOT</label>
        <mountpoint>/</mountpoint>
        <fs>
          <type>ext4</type>
          <tune2fs />
          <passno>0</passno>
        </fs>
        <options>ro</options>
      </bylabel>

      <bylabel>
        <label>CONFIG</label>
        <mountpoint>/nand</mountpoint>
        <fs>
          <type>ext4</type>
          <tune2fs />
          <passno>0</passno>
        </fs>
        <options>discard</options>
      </bylabel>

      <bylabel>
        <label>DATA</label>
        <mountpoint>/data</mountpoint>
        <fs>
          <type>ext4</type>
          <tune2fs />
          <passno>0</passno>
        </fs>
        <options>nofail,discard</options>
      </bylabel>

-----
    </fstab>

    <finetuning>
-------------------
      <command>find /boot -name "vmlinuz*" |sort -nr |head -1 |xargs -I {}
ln -s {} /boot/vmlinuz </command>
      <command>find /boot -name "initrd*" |sort -nr |head -1 |xargs -I {}
ln -s {} /boot/initrd.img </command>

    </finetuning>

    <pkg-list>

      <!-- packages -->
-------------
      <!-- GRUB -->
      <pkg>grub-efi-amd64</pkg>
      <pkg>efibootmgr</pkg>
      <pkg>shim-signed</pkg>
--------------
    <!-- Linux Kernel -->
      <pkg>linux-image-rt-amd64</pkg>
--------------
    <!-- Updater Client -->
      <pkg>swupdate</pkg>

    </pkg-list>

  </target>
</ns0:RootFileSystem>

*SWUpdate log*

Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [network_thread] : Incoming network request: processing...
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [INFO ] : SWUPDATE started
:  Software Update started !
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [network_initializer] : Software update started
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_file_to_tmp] : Found file
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_file_to_tmp] :         filename sw-description
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_file_to_tmp] :         size 1946
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_file_to_tmp] : Found file
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_file_to_tmp] :         filename sw-description.sig
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_file_to_tmp] :         size 2088
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [network_thread] :
Incoming network request: processing...
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [swupdate_verify_file] : Verified OK
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [get_common_fields] : Version 0.1.0
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [parse_hw_compatibility] : Accepted Hw Revision : Touch-it-XELO
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [parse_hw_compatibility] : Accepted Hw Revision : 1.0
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [_parse_images] : Found compressed Image: root.img.gz.enc in device :
/dev/sda4 for handler raw (installed from stream)
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [_parse_scripts] : Found Script: update.sh
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [_parse_bootloader] : Bootloader var: boot_entry = 1
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [check_hw_compatibility] : Hardware Touch-it-XELO Revision: 1.0
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [check_hw_compatibility] : Hardware compatibility verified
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_files] : Found file
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_files] :         filename root.img.gz.enc
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_files] :         size 1354798528 required
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_files] : Installing STREAM root.img.gz.enc, 1354798528 bytes
Apr 25 16:25:26 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [install_single_image] : Found installer for stream root.img.gz.enc raw
Apr 25 16:25:26 PanelComputer swupdate[860]: START Software Update started !
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [network_initializer] :
Software update started
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [extract_file_to_tmp] :
Found file
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [extract_file_to_tmp] :
     filename sw-description
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [extract_file_to_tmp] :
     size 1946
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [extract_file_to_tmp] :
Found file
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [extract_file_to_tmp] :
     filename sw-description.sig
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [extract_file_to_tmp] :
     size 2088
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [swupdate_verify_file] :
Verified OK
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [get_common_fields] :
Version 0.1.0
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [parse_hw_compatibility] :
Accepted Hw Revision : Touch-it-XELO
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [parse_hw_compatibility] :
Accepted Hw Revision : 1.0
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [_parse_images] : Found
compressed Image: root.img.gz.enc in device : /dev/sda4 for handler raw
(installed from stream)
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [_parse_scripts] : Found
Script: update.sh
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [_parse_bootloader] :
Bootloader var: boot_entry = 1
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [check_hw_compatibility] :
Hardware Touch-it-XELO Revision: 1.0
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [check_hw_compatibility] :
Hardware compatibility verified
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [extract_files] : Found
file
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [extract_files] :
 filename root.img.gz.enc
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [extract_files] :
 size 1354798528 required
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [extract_files] :
Installing STREAM root.img.gz.enc, 1354798528 bytes
Apr 25 16:25:26 PanelComputer swupdate[860]: RUN [install_single_image] :
Found installer for stream root.img.gz.enc raw
Apr 25 16:27:59 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_files] : END INSTALLING STREAMING
Apr 25 16:27:59 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_files] : Found file
Apr 25 16:27:59 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_files] :         filename update.sh
Apr 25 16:27:59 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_files] :         size 1902 required
Apr 25 16:27:59 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [extract_padding] : Expecting 20 padding bytes at end-of-file
Apr 25 16:27:59 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [network_initializer] : Valid image found: copying to FLASH
Apr 25 16:27:59 PanelComputer swupdate.sh[860]: [INFO ] : SWUPDATE running
:  Installation in progress
Apr 25 16:27:59 PanelComputer swupdate[860]: RUN [extract_files] : END
INSTALLING STREAMING
Apr 25 16:27:59 PanelComputer swupdate[860]: RUN [extract_files] : Found
file
Apr 25 16:27:59 PanelComputer swupdate[860]: RUN [extract_files] :
 filename update.sh
Apr 25 16:27:59 PanelComputer swupdate[860]: RUN [extract_files] :
 size 1902 required
Apr 25 16:27:59 PanelComputer swupdate[860]: RUN [extract_padding] :
Expecting 20 padding bytes at end-of-file
Apr 25 16:27:59 PanelComputer swupdate[860]: RUN [network_initializer] :
Valid image found: copying to FLASH
Apr 25 16:27:59 PanelComputer swupdate[860]: RUN Installation in progress
Apr 25 16:27:59 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [read_lines_notify] : call do_preinst
Apr 25 16:27:59 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [read_lines_notify] : do_preinst
Apr 25 16:27:59 PanelComputer swupdate[860]: RUN [read_lines_notify] : call
do_preinst
Apr 25 16:27:59 PanelComputer swupdate[860]: RUN [read_lines_notify] :
do_preinst
Apr 25 16:27:59 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [run_system_cmd] : /tmp/scripts/update.sh preinst  command returned 0
Apr 25 16:27:59 PanelComputer swupdate[860]: RUN [run_system_cmd] :
/tmp/scripts/update.sh preinst  command returned 0
Apr 25 16:27:59 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [read_lines_notify] : call do_postinst
Apr 25 16:27:59 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [read_lines_notify] : do_postinst
Apr 25 16:27:59 PanelComputer swupdate[860]: RUN [read_lines_notify] : call
do_postinst
Apr 25 16:27:59 PanelComputer swupdate[860]: RUN [read_lines_notify] :
do_postinst
Apr 25 16:28:00 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [run_system_cmd] : /tmp/scripts/update.sh postinst  command returned 0
Apr 25 16:28:00 PanelComputer swupdate[860]: RUN [run_system_cmd] :
/tmp/scripts/update.sh postinst  command returned 0
Apr 25 16:28:00 PanelComputer swupdate.sh[860]: [INFO ] : SWUPDATE
successful ! SWUPDATE successful !
Apr 25 16:28:00 PanelComputer swupdate.sh[860]: [TRACE] : SWUPDATE running
:  [network_initializer] : Main thread sleep again !
Apr 25 16:28:00 PanelComputer swupdate.sh[860]: [INFO ] : No SWUPDATE
running :  Waiting for requests...
Apr 25 16:28:00 PanelComputer swupdate[860]: SUCCESS SWUPDATE successful !
Apr 25 16:28:00 PanelComputer swupdate[860]: RUN [network_initializer] :
Main thread sleep again !
Apr 25 16:28:00 PanelComputer swupdate[860]: IDLE Waiting for requests...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20220426/d9db3671/attachment-0001.htm>


More information about the elbe-devel mailing list