sw-description sample file to update the alternate rootfs

1,904 views
Skip to first unread message

Philip Balister

unread,
Feb 29, 2016, 2:44:06 PM2/29/16
to swupdate
I'm working with a Xilinx Zynq board that has u-boot and emmc. I'd like to have two rootfs partitions and have the active partition run swupdate. How do  I make a sw-description file that tells sw update to decide which partition is inactive and load the new rootfs there. Looking at the docs, I can see how to load to a specific partition (and made sure this works).

It is not clear to me what the next step is to alternate between two rootfs, without the update package knowing in advance which is active.

Philip

Bjørn Forsman

unread,
Feb 29, 2016, 2:53:31 PM2/29/16
to Philip Balister, swupdate
Here is one way to do it. I run swupdate with arguments
"--select=stable,part${_partno}", where ${_partno} is initialized
based on a parsing /proc/cmdline:

_cur_mmcpart=$(sed 's|.*root=/dev/mmcblk2p\(.\).*|\1|' /proc/cmdline)
if [ "$_cur_mmcpart" -eq 1 ]; then
_partno=2
else
_partno=1
fi
SWUPDATE_EXTRA_ARGS=--select=stable,part${_partno}

This provides the desired ping-pong effect between the two partitions.

Best regards,
Bjørn Forsman

Philip Balister

unread,
Feb 29, 2016, 3:19:49 PM2/29/16
to swupdate, philip....@gmail.com
On Monday, February 29, 2016 at 2:53:31 PM UTC-5, Bjørn Forsman wrote:
On 29 February 2016 at 20:44, Philip Balister <philip....@gmail.com> wrote:
> I'm working with a Xilinx Zynq board that has u-boot and emmc. I'd like to
> have two rootfs partitions and have the active partition run swupdate. How
> do  I make a sw-description file that tells sw update to decide which
> partition is inactive and load the new rootfs there. Looking at the docs, I
> can see how to load to a specific partition (and made sure this works).
>
> It is not clear to me what the next step is to alternate between two rootfs,
> without the update package knowing in advance which is active.

Here is one way to do it. I run swupdate with arguments
"--select=stable,part${_partno}", where ${_partno} is initialized
based on a parsing /proc/cmdline:


Is the select argument documented somewhere? I think I can see what to do, just curious if I am missing something in the docs. Thanks for the quick reply.

Philip

Bjørn Forsman

unread,
Feb 29, 2016, 3:33:50 PM2/29/16
to Philip Balister, swupdate
On 29 February 2016 at 21:19, Philip Balister <philip....@gmail.com> wrote:
> On Monday, February 29, 2016 at 2:53:31 PM UTC-5, Bjørn Forsman wrote:
>>
>> On 29 February 2016 at 20:44, Philip Balister <philip....@gmail.com>
>> wrote:
>> > I'm working with a Xilinx Zynq board that has u-boot and emmc. I'd like
>> > to
>> > have two rootfs partitions and have the active partition run swupdate.
>> > How
>> > do I make a sw-description file that tells sw update to decide which
>> > partition is inactive and load the new rootfs there. Looking at the
>> > docs, I
>> > can see how to load to a specific partition (and made sure this works).
>> >
>> > It is not clear to me what the next step is to alternate between two
>> > rootfs,
>> > without the update package knowing in advance which is active.
>>
>> Here is one way to do it. I run swupdate with arguments
>> "--select=stable,part${_partno}", where ${_partno} is initialized
>> based on a parsing /proc/cmdline:
>
> Is the select argument documented somewhere? I think I can see what to do,
> just curious if I am missing something in the docs. Thanks for the quick
> reply.

I thought so, but I cannot find it at the moment. (Maybe I found it in
mailing list archives?) Stefano knows.

Best regards,
Bjørn Forsman

Stefano Babic

unread,
Feb 29, 2016, 5:15:32 PM2/29/16
to Bjørn Forsman, Philip Balister, swupdate
Hi Philip, hi Bjørn,
This is documented under "Software collections" in
doc/source/swupdate.rst. I remember the dual-copy option was already
discussed in the ML and it should be somewhere. In
examples/description/multi-copy, such a case is covered. The dual-copy
option is a special case of selections, because swupdate really supports
multiple copies of the software, and each of them can have a different
description how to install. But having two identical copies is one of
the most used approach.

This is an example I recently used to test the streaming feature on a
twister board, one of the hardware I use for testing. There are two
copies of the software (kernel in two MTDs, two ubi volumes for rootfs).
In case of eMMC, you have simply two partitions:

software =
{
version = "0.1.0";

twister = {
hardware-compatibility: [ "revA"];
stable : {
copy1 : {
images: (
{
filename = "core-image-full-cmdline.ubifs";
type = "ubivol";
volume = "rootfs1"
installed-directly = true;
},
{
filename = "uImage";
type = "flash";
device = "/dev/mtd7";
}

);
scripts: (
{
filename = "test.lua";
type = "lua";
}
);
uboot: (
{
name = "rootfs";
value = "rootfs1";
}
);
};
copy2 : {
images: (
{
filename = "core-image-full-cmdline.ubifs";
type = "ubivol";
volume = "rootfs2"
installed-directly = true;
},
{
filename = "uImage";
type = "flash";
device = "/dev/mtd8";
}
);
scripts: (
{
filename = "test.lua";
type = "lua";
}
);
uboot: (
{
name = "rootfs";
value = "rootfs2";
}
);
};
};
}
}

Maybe I can push this into examples/description, naming it as dual-copy
of something like that.

The active package must be determined before calling swupdate. This
makes sense, because there could be more ways to do this, and how can
depend on the target. Let's simplify and a simple way is to check where
is mounted / - again, something more complicate can be necessary.

Then you run swupdate -e "stable,copy2" if the active package runs on
"copy1", and swupdate -e "stable,copy1" in the other case. In the
example, I use the U-Boot variable "name" to inform U-Boot to switch,
and this variable is used in U-Boot script to set the bootargs variable.

Best regards,
Stefano Babic

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

kapla...@gmail.com

unread,
May 11, 2017, 3:14:29 PM5/11/17
to swupdate, bjorn....@gmail.com, philip....@gmail.com, sba...@denx.de
So, swupdate does not have built-in support for the "ping-pong" effect to always update the unused partition in an A/B setup?

One has to add an external script like the one suggested by Bjorn?

Stefano Babic

unread,
May 12, 2017, 4:26:19 AM5/12/17
to kapla...@gmail.com, swupdate, bjorn....@gmail.com, philip....@gmail.com, sba...@denx.de
Hi Kaplan,

On 11/05/2017 21:14, kapla...@gmail.com wrote:
> So, swupdate does not have built-in support for the "ping-pong" effect to always update the unused partition in an A/B setup?
>

There is no detection of the running system. This is also because the
"ping-pong" (double-copy) is a very common use case, but not the only
one. I can state that it does not work in all cases.

It is much more simple, because it is project specific, to detect this
before starting SWUpdate and passing it as parameter.

> One has to add an external script like the one suggested by Bjorn?

Alexander Kaplan

unread,
May 12, 2017, 12:20:56 PM5/12/17
to Stefano Babic, philip....@gmail.com, swupdate, bjorn....@gmail.com
Hi Stefano,

thank you for reply!

Is there a way to detect the active partition in suricatta mode?

E.g. via a script handler and the pass it in to swupdate?

Best
Alex Kaplan

Stefano Babic

unread,
May 12, 2017, 1:41:42 PM5/12/17
to Alexander Kaplan, Stefano Babic, philip....@gmail.com, swupdate, bjorn....@gmail.com
Hi Alex,

On 12/05/2017 18:20, Alexander Kaplan wrote:
> Hi Stefano,
>
> thank you for reply!
>
> Is there a way to detect the active partition in suricatta mode?
>
> E.g. via a script handler and the pass it in to swupdate?
>

No - the script handler is called after sw-description is parsed, while
the "collection" (aka which partition / copy should be updated) must be
known at the time of parsing.

Best regards,
Stefano Babic

> Best
> Alex Kaplan
>
>
> On May 12, 2017 1:26 AM, "Stefano Babic" <sba...@denx.de
> <mailto:sba...@denx.de>> wrote:
>
> Hi Kaplan,
>
> On 11/05/2017 21:14, kapla...@gmail.com
> <mailto:kapla...@gmail.com> wrote:
> > So, swupdate does not have built-in support for the "ping-pong"
> effect to always update the unused partition in an A/B setup?
> >
>
> There is no detection of the running system. This is also because the
> "ping-pong" (double-copy) is a very common use case, but not the only
> one. I can state that it does not work in all cases.
>
> It is much more simple, because it is project specific, to detect this
> before starting SWUpdate and passing it as parameter.
>
> > One has to add an external script like the one suggested by Bjorn?
>
> Best regards,
> Stefano Babic
>
> --
> =====================================================================
> DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-53 <tel:%2B49-8142-66989-53> Fax:
> +49-8142-66989-80 <tel:%2B49-8142-66989-80> Email: sba...@denx.de
> <mailto:sba...@denx.de>
> =====================================================================
>
>
> --
> 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 post to this group, send email to swup...@googlegroups.com
> <mailto:swup...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Alexander Kaplan

unread,
May 12, 2017, 2:33:47 PM5/12/17
to Stefano Babic, Philip Balister, swupdate, Bjørn Forsman
OK, thanks for the fast reply.


> To post to this group, send email to swup...@googlegroups.com

> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages