The Raspberry Pi has the "tryboot" feature where it can boot from a different partition enabling failsafe A/B updates. After boot the firmware sets 'partition' property in /chosen/bootloader.
Set the env variable boot_partition accordingly to allow boards to create a bootcmd based on the boot partition. Signed-off-by: Gregor Herburger <[email protected]> Tested-by: Peter Robinson <[email protected]> --- board/raspberrypi/rpi/rpi.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index 1da5df92351c..8354fec833cc 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -480,6 +480,20 @@ static void set_serial_number(void) env_set("serial#", serial_string); } +static void set_boot_partition_fdt(void) +{ + void *fdtp = (void *)gd->fdt_blob; + u32 partition; + + partition = fdt_getprop_u32_default(fdtp, "/chosen/bootloader", "partition", 1); + if (!partition) { + printf("Failed to the get partition property.\n"); + return; + } + + env_set_ulong("boot_partition", partition); +} + int misc_init_r(void) { set_fdt_addr(); @@ -489,6 +503,7 @@ int misc_init_r(void) set_board_info(); #endif set_serial_number(); + set_boot_partition_fdt(); return 0; } -- 2.47.3
