Boot from different partitions based on some condition
Harald Seiler
hws at denx.de
Thu Dec 12 20:33:56 CET 2019
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 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
--
Harald
More information about the U-Boot
mailing list