Boot from different partitions based on some condition

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@tele2.se

Hello Mats,
On Thu, 2019-12-12 at 16:49 +0100, Mats Jansson wrote:
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?
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.
Regards Mats mailto:matsmanhav@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

Dear Mats,
In message 1024408647.20191212164918@tele2.se 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.
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
participants (3)
-
Harald Seiler
-
Mats Jansson
-
Wolfgang Denk