Hi all!
Maybe I wanted to make some "special" behavior, but I don't think so.
Let me describe, what I wanted to achieve. Lets assume, that your HW is
running on version 0.3.0 and you wanted to upgrade it to version 0.5.0.
But some important changes are in the version 0.4.0. So what you wanted
to achieve is, that the users which are update to new version had
version 0.4.0 installed. I think, I can't use "install-if-higher" which
won't check the minimal required version.
According to docu
https://sbabic.github.io/swupdate/sw-description.html#scripts there are
schell/lua script supported. So I created a "shell" script, which should
do this checking in "preinstall" step.
> Scripts runs in the order they are put into the sw-description file.
The result of a script is valuated by SWUpdate, that stops the update
with an error if the result is <> 0.
scripts: (
{
filename = "test.sh";
type = "preinstall";
data = "0.5.0";
}
);
// test.sh
#!/bin/sh
logger -t swupdate.sh "xxx"
exit 0
This is just an example to do a version check before flashing.
[TRACE] : SWUPDATE running : [extract_files] : size 1328288 Not
required: skipping
[TRACE] : SWUPDATE running : [extract_files] : Found file
[TRACE] : SWUPDATE running : [extract_files] : filename test.sh
[TRACE] : SWUPDATE running : [extract_files] : size 761 required
[TRACE] : SWUPDATE running : [extract_padding] : Expecting up to 512
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 : [__run_cmd] : /tmp/scripts/test.sh 0.5.0
command returned 0
[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 !
So why it didn't continue in flashing? When the script exited with 1,
there was an error. SO basically any kind of script will stop the
flashing, or am I wrong???
So Maybe I placed the script into wrong position of sw-description. So I
moved into "image" section.
copy1: {
images: (
{
filename = "@@ROOTFS_IMAGE@@";
sha256 = "$swupdate_get_sha256(@@ROOTFS_IMAGE@@)";
type = "raw";
compressed = "zlib";
device = "/dev/@@ROOT_PART_NAME_A@@";
installed-directly = true;
},
{
filename = "@@BOOTLOADER_IMAGE@@";
type = "raw";
device = "/dev/@@BOOT_PART_NAME_A@@";
offset = "@@IMX_BOOT_SEEK@@K";
sha256 = "$swupdate_get_sha256(@@BOOTLOADER_IMAGE@@)";
name = "boot-container";
version = "@@IMX_BOOT_VERSION@@";
}
);
scripts: (
{
filename = "test.sh";
type = "preinstall";
data = "@@VERSION@@";
}
);
bootenv: (
{
name = "toggle_partition";
Then I have an parsing error:
[TRACE] : SWUPDATE running : [start_delta_downloader] : Starting
Internal process for downloading chunks
[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 3259
[DEBUG] : SWUPDATE running : [parse_cfg] : Parsing config file
/tmp/sw-description
[TRACE] : SWUPDATE running : [get_common_fields] : Version 0.9.0
[TRACE] : SWUPDATE running : [get_common_fields] : reboot_required 1
[ERROR] : SWUPDATE failed [0] ERROR parser.c : parser : 1051 : Found
nothing to install
[DEBUG] : SWUPDATE running : [parse_json] : Parsing config file
/tmp/sw-description
[ERROR] : SWUPDATE failed [0] ERROR parser.c : parse_json : 1137 : JSON
File corrupted
[ERROR] : SWUPDATE failed [0] ERROR parser.c : parse : 164 : no parser
available to parse sw-description!
[ERROR] : SWUPDATE failed [0] ERROR stream_interface.c : extract_files :
182 : Compatible SW not found
[ERROR] : SWUPDATE failed [1] Image invalid or corrupted. Not installing ...
swupdate_image_write failed: Connection reset by peer
[ERROR] : SWUPDATE failed [0] ERROR install_from_file.c : endupdate : 55
: SWUpdate *failed* !
So what am I doing wrong, or how to make this working.
Many thanks,
Andy