sw-description file not getting sha256

579 views
Skip to first unread message

Oosman Saeed

unread,
Aug 25, 2022, 8:07:06 AM8/25/22
to swup...@googlegroups.com

I am trying to build a signed swu file for my board using yocto/bitbake. The swu that gets created is signed, but the sha256 is not getting set in the sw-description file.

(below omitting some folders and files, showing relevant directory tree)

My build directory for yocto:

build-dir
  +conf
     bblayers.conf
     local.conf
In my layers dir:

meta-swupdate
   +classes
   +conf
   +recipes-core
   +recpies-devtools
   +...other recipes
   README
meta-variscite-fslc
  +conf
  +dynamic-layers
      +swupdate
         +swupdate
      +var-image-swu
         +imx8mm-var-dart
            sw-description
         update.sh
      swupdate_%d.bbappend
meta-mylayer
  +conf
     layer.conf
  +recipes-blahblah
  +wic
      my-wks.in

By adding this to my build-dir/conf/local.conf

WKS_FILE = "my-wks.in"

I can get it to use my-wks.in (to setup the paritions like I want it to).

Then adding these to my build-dir/conf/local.conf

SWUPDATE_SIGNING = "RSA"
SWUPDATE_PRIVATE_KEY = "/tmp/rsakey"
SWUPDATE_IMAGES = "var-image-swupdate update.sh"

makes it create a swu file (var-image-swu-imx8mm-var-dart.swu)

I generated my keys like this:

openssl genrsa -out /tmp/rsakey
openssl rsa -in /tmp/rsakey -out /tmp/rsakey.pub -outform PEM -pubout

But when I look inside the swu file, I do not see sha256 for my image file. And when I try to install this swu, I get this error:

swupdate -i /var-image-swu-imx8mm-var-dart.swu --hwrevision "imx8mm-var-dart:1.0" --key /rsakey.pub

ERROR] : SWUPDATE failed [0] ERROR core/parser.c : check_missing_hash : 76 : Hash not set for var-image-swupdate-imx8mm-var-dart.tar.gz Type archive                          
[ERROR] : SWUPDATE failed [0] ERROR core/swupdate.c : install_from_file : 335 : failed to parse sw-description! 

    
So obviously sha256 hash is missing, how do I get it to add the hash in my sw-description file?

I tried to follow the steps here - https://sbabic.github.io/swupdate/building-with-yocto.html -  but I don't understand what to do to make it update my sw-description file with the sha256 hashes.

Note that I can manually edit sw-description file in this layer here:

meta-variscite-fslc
  +conf
  +dynamic-layers
      +swupdate
         +swupdate
      +var-image-swu
         +imx8mm-var-dart
            sw-description

and add the sha256 hashes myself, then the swu that is generated successfully gets installed. But I think the sw-description file is supposed to get those hashes automagically inserted, and that magic is not happening. Not sure what I am missing.

Thanks

Oosman -

unread,
Aug 25, 2022, 9:54:48 AM8/25/22
to swupdate
Manually adding sha256 like this works:
meta-variscite-fslc/dynamic-layers/swupdate/var-image-swu/imx8mm-var-dart/sw-description

software =
{
version = "0.1.0";

imx8mm-var-dart = {
hardware-compatibility: [ "1.0" ];

files: (
{
filename = "var-image-swupdate-imx8mm-var-dart.tar.gz";
type = "archive";
compressed = true;
device = "/dev/update";
filesystem = "ext4";
preserve-attributes = true;
sha256 = "30d156e3b41de7cabf271a975dd373152bf5f79ae5b6f86a797561114189fdfe";
path = "/";
}
)

scripts: (
{
filename = "update.sh";
type = "shellscript";
sha256 = "3144bafaf8fe3e93f2a4300e8e49a5ab6a380a4f4a939f7a04857b61a0923653";
}
);
};
}

Oosman -

unread,
Aug 25, 2022, 9:56:14 AM8/25/22
to swupdate
I take that back, it goes forward but eventually complains and fails:

[TRACE] : SWUPDATE running :  [run_system_cmd] : /tmp/scripts/update.sh preinst  command returned 0                                                                                  
[TRACE] : SWUPDATE running :  [install_single_image] : Found installer for stream var-image-swupdate-imx8mm-var-dart.tar.gz archive                                                  
[TRACE] : SWUPDATE running :  [install_archive_image] : Installing file var-image-swupdate-imx8mm-var-dart.tar.gz on /tmp/datadst//, preserving attributes                            
[WARN ] : SWUPDATE running :  [copyfile] : compressed argument: boolean form is deprecated, use the string form                                                                      
[ERROR] : SWUPDATE failed [0] ERROR core/cpio_utils.c : copyfile : 595 : HASH mismatch : 30d156e3b41de7cabf271a975dd373152bf5f79ae5b6f86a797561114189fdfe <--> 0ced23ec67cb9a9be9116f7
[ERROR] : SWUPDATE failed [0] ERROR handlers/archive_handler.c : install_archive_image : 314 : Error copying extracted file                                                          
[TRACE] : SWUPDATE running :  [install_single_image] : Installer for archive not successful !           

Oosman -

unread,
Aug 25, 2022, 11:09:52 AM8/25/22
to swupdate
Answering my own question, after looking at the code, I realize I need to prefix @

software =
{
version = "0.1.0";

imx8mm-var-dart = {
hardware-compatibility: [ "1.0" ];

files: (
{
filename = "var-image-swupdate-imx8mm-var-dart.tar.gz";
type = "archive";
compressed = true;
device = "/dev/update";
filesystem = "ext4";
preserve-attributes = true;
sha256 = "@var-image-swupdate-imx8mm-var-dart.tar.gz";
path = "/";
}
)

scripts: (
{
filename = "update.sh";
type = "shellscript";
sha256 = "@update.sh";
}
);
};
}

Now I still need to figure out how to override this file from my layer.

Oosman -

unread,
Aug 25, 2022, 5:02:57 PM8/25/22
to swupdate
Complete steps that made update work for me:


In my layer, add files, keeping same folder structure as in the layer I am overriding:

meta-mylayer
  +conf
    layer.conf          # add BBFILES, see below
  +dynamic-layers
    +sw-update
      +var-image-swu
        +imx8mm-var-dar
           sw-description       # <-- file I want to replace with my own
         update.sh               # <-- file I want to replace with my own
      var-image-swu.bbappend    # <-- overrides the recipe  
meta-variscite-fslc
  +conf
  +dynamic-layers
    +sw-update
      +var-image-swu
          +imx8mm-var-dart
             sw-description    # <-- need to overide this file
           update.sh        # <-- need to overide this file
      var-image-swu.bb        # <--original recipe

##
var-image-swu.bbappend:
#
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI = " \
    file://sw-description \
    file://update.sh \
"
##
layer.conf:
#
BBFILES := "${BBFILES} ${LAYERDIR}/recipes-*/*/*.bb \
            ${LAYERDIR}/recipes-*/*/*.bbappend \
            ${LAYERDIR}/dynamic-layers/*/*.bbappend"     # <-- add this path to search for bbappend files
##
my sw-description file:
software =
{
    version = "0.1.0";

    imx8mm-var-dart = {
        hardware-compatibility: [ "1.0" ];

        files: (
            {
                filename = "var-image-swupdate-imx8mm-var-dart.tar.gz";
                type = "archive";
                compressed = true;
                device = "/dev/update";
                filesystem = "ext4";
                preserve-attributes = true;
                sha256 = "@var-image-swupdate-imx8mm-var-dart.tar.gz";        # <-- add this line

                path = "/";
            }
        )

        scripts: (
            {
                filename = "update.sh";
                type = "shellscript";
                sha256 = "@update.sh";                        # <-- add this line
            }
        );
    };
}
#
build/conf/local.conf
#
WKS_FILE = "nextgen.wks.in"
SWUPDATE_SIGNING = "RSA"
SWUPDATE_PRIVATE_KEY = "/tmp/rsakey"        # <-- see below for genertation of private key
SWUPDATE_IMAGES = "var-image-swupdate-imx8mm-var-dart update.sh sw-description.sig" # <-- these 3 files are in the swu payload, hashes will get gernated and @filename will be replaced with hash
#

On the target device, to update:
swupdate -v -i /var-image-swu-imx8mm-var-dart.swu --hwrevision "imx8mm-var-dart:1.0" --key /rsakey.pub
(after copying swu file and public key to the / dir)

Keys were generated on host machine like this


openssl genrsa -out /tmp/rsakey
openssl rsa -in /tmp/rsakey -out /tmp/rsakey.pub -outform PEM -pubout

then public key was scp'ed over to the target device



Reply all
Reply to author
Forward
0 new messages