Skip to contentSkip to conversation

Boot from different partitions based on some condition

DISCUSSION Mats Jansson 3 participants 3 messages Dec 12, 2019 – Dec 16, 2019

lore
Share & tools
lore
#0 lore raw

Hi,

I want to set up for an upgrade of our embedded system, using a special kernel for the upgrade. The standard will be to load the system from mtd3 (kernel), mtd4 (devicetree) and mtd5 (rootfs).

When an update is to take place I want to run the upgrade system from mtd0.

So basically I need to have some sort of telling U-boot that it should launch the upgrade system instead of the standard system.

Any ideas how I set this up?
How to tell u-boot?
How to get u-boot to boot from another partition based on a condition like that?

Regards
Mats mailto:matsmanhav at tele2.se

#1 lore raw

Hello Mats,

Quoted 9 lines · Mats Jansson

Hi,

I want to set up for an upgrade of our embedded system, using a special kernel for the upgrade. The standard will be to load the system from mtd3 (kernel), mtd4 (devicetree) and mtd5 (rootfs).

When an update is to take place I want to run the upgrade system from mtd0.

Quoted 7 lines

So basically I need to have some sort of telling U-boot that it should launch the upgrade system instead of the standard system.

Any ideas how I set this up?
How to tell u-boot?
How to get u-boot to boot from another partition based on a condition like that?

The easiest way to instruct U-Boot to boot a different system (in your case from a different partition) is to set a U-Boot environment variable from within Linux. Your boot-script in U-Boot should then check this environment variable and boot into your upgrade system.

To do this, there are the envtools [1] found in the U-Boot sources in tools/env/. Alternatively, you can use libubootenv [2] which is a project separate from U-Boot but which archieves the same thing.

Both those packages contain an fw_setenv tool which you can use just like setenv on the U-Boot command-line. The only difference is that fw_setenv automatically saves the environment so you don't need any saveenv like command afterwards.

To make those tools work, you'll need to create a configuration file /etc/fw_env.config which tells the tool where the U-Boot environment is located. The example config [3] contains everything you need to know.

Quoted 3 lines

Regards
Mats mailto:matsmanhav at tele2.se

Hope this helps!

[1]: https://gitlab.denx.de/u-boot/u-boot/tree/master/tools/env
[2]: https://github.com/sbabic/libubootenv
[3]: https://gitlab.denx.de/u-boot/u-boot/blob/master/tools/env/fw_env.config

Signature · 1 line
Harald
#2 lore raw
In reply to Mats Jansson

Dear Mats,

Quoted 8 lines · In message <[email protected]> you wrote:

I want to set up for an upgrade of our embedded system, using a special kernel for the upgrade. The standard will be to load the system from mtd3 (kernel), mtd4 (devicetree) and mtd5 (rootfs).

When an update is to take place I want to run the upgrade system from mtd0.

Quoted 7 lines

So basically I need to have some sort of telling U-boot that it should launch the upgrade system instead of the standard system.

Any ideas how I set this up?
How to tell u-boot?
How to get u-boot to boot from another partition based on a condition like that?

In addition to Harald's advice you might also want to consider not reinventing the wheel yet agaib, but instead look into [1] where all these issues have already been solved (and tested, with many projects and a zillion devices in the field).

[1] https://sbabic.github.io/swupdate/

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Never underestimate the bandwidth of a station wagon full of tapes.
                                -- Dr. Warren Jackson, Director, UTCS