More understanding about sw-description file

867 views
Skip to first unread message

peter john

unread,
Sep 14, 2023, 8:25:57 AM9/14/23
to swup...@googlegroups.com
Hi Team,
Firstly i would like to say am new to this swupdate. 

I am using code from https://github.com/sbabic/swupdate/ to parse my sw-description file.

Format which is specified in documentation is as below, 


software =
{
        version = "0.1.0";
        description = "Firmware update for XXXXX Project";
        hardware-compatibility: [ "1.0" ];
        images: (
                {
                        filename = "rootfs.ubifs";
                        volume = "rootfs";
                },
                {
                        filename = "swupdate.ext3.gz.u-boot";
                        volume = "fs_recovery";
                },
                {
                        filename = "sdcard.ext3.gz";
                        device = "/dev/mmcblk0p1";
                        compressed = "zlib";
                }
        );

        files: (
                {
                        filename = "README";
                        path = "/README";
                        device = "/dev/mmcblk0p1";
                        filesystem = "vfat"
                }
        );

        scripts: (
                {
                        filename = "erase_at_end";
                        type = "lua";
                },
                {
                        filename = "display_info";
                        type = "lua";
                }
        );
}


Now once after building i am using my python script to parse this sw-description file.
In python script using jsonlibconfig libconfig to parse this sw-description file and while writing back to file, format is getting changed as mentioned below,


software = {
       version = "0.1.0";
       description = "Firmware update for XXXXX Project";
       hardware-compatibility: [
        "1.0"
       ];
       images = (
               {
                       filename = "rootfs.ubifs";
                       volume = "rootfs";
               },
               {
                       filename = "swupdate.ext3.gz.u-boot";
                       volume = "fs_recovery";
               },
               {
                       filename = "sdcard.ext3.gz";
                        device = "/dev/mmcblk0p1";
                       compressed = "zlib";
               }
       );

       files = (
               {
                       filename = "README";
                       path = "/README";
                        device = "/dev/mmcblk0p1";
                       filesystem = "vfat"
               }
       );

       scripts = (
               {
                       filename = "erase_at_end";
                       type = "lua";
               },
               {
                       filename = "display_info";
                       type = "lua";
               }
       );
}

Please confirm if this format is acceptable ?

Thanks.

Stefano Babic

unread,
Sep 14, 2023, 11:25:19 AM9/14/23
to peter john, swup...@googlegroups.com
If you are not doing yourself, but your script is just a wrapper for
jsonlibconfig, you should read from roadmap.rst file:

Parser
======

SWUpdate supports two parsers : libconfig and JSON. It would be nice
if tools can be used to convert from one format to the other one.
Currently, due to some specialties in libconfig, a manual conversion is
still required.


In other words, there are cases where it does not work.

The issue is that the tool changes an array of one element in a scalr
when converting to json. This is unsupported in libconfig, and to be
compatible with both, replacing to scalar is not allowed.

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/CAOn_YWj4%2BcaXUeCF0HeHwyrmvu9DYDj0LY6AKXiGXFRZNWchdg%40mail.gmail.com <https://groups.google.com/d/msgid/swupdate/CAOn_YWj4%2BcaXUeCF0HeHwyrmvu9DYDj0LY6AKXiGXFRZNWchdg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Stefano Babic

unread,
Sep 15, 2023, 3:21:41 AM9/15/23
to peter john, swup...@googlegroups.com
Hi Peter,

please never drop the ML from your replies.

On 15.09.23 05:10, peter john wrote:
> Hi Stefano,
>
> Thank you for information, as mentioned below we could see : is getting
> replaced with = , for example files: ( converted to files = ( so will it
> affect anything ?

No, replacing : with = is not the real problem. In fact, the file you
generated is correct and can be interpreted by SWUpdate.

When I run:

jsonlibconfig --target json --pretty --file sw-description

I get this one:


{
"software": {
"version": "0.1.0",
"description": "Firmware update for XXXXX Project",
"hardware-compatibility": [
"1.0"
],
"images": [
{
"filename": "rootfs.ubifs",
"volume": "rootfs"
},
{
"filename": "swupdate.ext3.gz.u-boot",
"volume": "fs_recovery"
},
{
"filename": "sdcard.ext3.gz",
"device": "/dev/mmcblk0p1",
"compressed": "zlib"
}
],
"files": {
"filename": "README",
"path": "/README",
"device": "/dev/mmcblk0p1",
"filesystem": "vfat"
},
"scripts": [
{
"filename": "erase_at_end",
"type": "lua"
},
{
"filename": "display_info",
"type": "lua"
}
]
}
}


the problem is for files:

"files": {
"filename": "README",
"path": "/README",
"device": "/dev/mmcblk0p1",
"filesystem": "vfat"
},

This should be an array, the jsonlibconfig tool finds that it is an
array of just an element and switches to scalar, but this cannot be
interpreted by SWUpdate.

By the way, SWUpdate can parse directly a JSON file, why do you need to
convert it ? I just use the jsonlibconfig tool to test both parsers.

So the converted JSON above does not work, but just fixing the array
issue with:

{
"software": {
"version": "0.1.0",
"description": "Firmware update for XXXXX Project",
"hardware-compatibility": [
"1.0"
],
"images": [
{
"filename": "rootfs.ubifs",
"volume": "rootfs"
},
{
"filename": "swupdate.ext3.gz.u-boot",
"volume": "fs_recovery"
},
{
"filename": "sdcard.ext3.gz",
"device": "/dev/mmcblk0p1",
"compressed": "zlib"
}
],
"files": [
{
"filename": "README",
"path": "/README",
"device": "/dev/mmcblk0p1",
"filesystem": "vfat"
}],
"scripts": [
{
"filename": "erase_at_end",
"type": "lua"
},
{
"filename": "display_info",
"type": "lua"
}
]
}
}

It works directly into SWUpdate without any need of conversion. SWUpdate
runs the parser in sequence, and you will just see:

[ERROR] : SWUPDATE failed [0] ERROR parser.c : parse_cfg : 979 :
/tmp/sw-description:1 - syntax error

Because liconfig parser stops with error (of course), but then the JSON
parser is called and it succeed.

Best regards,
Stefano Babic

>
> Thank You.
>
>
>
>
>
> On Thu, 14 Sept, 2023, 8:55 pm Stefano Babic,
> <mailto:swupdate%2Bunsu...@googlegroups.com>
> > <mailto:swupdate+u...@googlegroups.com
> <mailto:swupdate%2Bunsu...@googlegroups.com>>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/swupdate/CAOn_YWj4%2BcaXUeCF0HeHwyrmvu9DYDj0LY6AKXiGXFRZNWchdg%40mail.gmail.com <https://groups.google.com/d/msgid/swupdate/CAOn_YWj4%2BcaXUeCF0HeHwyrmvu9DYDj0LY6AKXiGXFRZNWchdg%40mail.gmail.com> <https://groups.google.com/d/msgid/swupdate/CAOn_YWj4%2BcaXUeCF0HeHwyrmvu9DYDj0LY6AKXiGXFRZNWchdg%40mail.gmail.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/swupdate/CAOn_YWj4%2BcaXUeCF0HeHwyrmvu9DYDj0LY6AKXiGXFRZNWchdg%40mail.gmail.com?utm_medium=email&utm_source=footer>>.
>

Reply all
Reply to author
Forward
0 new messages