[PATCH v1 07/11] siemens: capricorn: add logic to U-Boot to avoid zig-zag boot
Heiko Schocher
hs at nabladev.com
Mon Jan 26 06:30:23 CET 2026
Hello Peng,
On 26.01.26 02:29, Peng Fan wrote:
> On Sat, Jan 24, 2026 at 06:54:48AM +0100, Heiko Schocher wrote:
>> add logic in board code for detecting the real boot
>> partition and set a local hush shell variable fallback
>> which can be used later in boot variables for detecting
>> a ROMbootloader fallback case.
>
> Typo: ROM bootloader
Fixed
>
>>
>> We use the local hush shell variable, as we do not want
>> to save in any case the fallback variable in U-Boot
>> Environment, as the default Environment is may saved
>
> Typo: maybe
Fixed
>
>> in boards, which are downgraded to older U-Boot versions.
>>
>> And than the board code does not run, and fallback never
>> gets the correct value.
>>
>> Introduce also hush shell variable envvers to value "v2_"
>> so we can use them in Environment for running different
>> versions of variables between new and old U-Boot images.
>>
>> Signed-off-by: Heiko Schocher <hs at nabladev.com>
>> Signed-off-by: Walter Schweizer <walter.schweizer at siemens.com>
>> ---
>>
>> board/siemens/capricorn/Kconfig | 2 ++
>> board/siemens/capricorn/board.c | 43 +++++++++++++++++++++++++++------
>> 2 files changed, 37 insertions(+), 8 deletions(-)
>>
>> diff --git a/board/siemens/capricorn/Kconfig b/board/siemens/capricorn/Kconfig
>> index fe230971e97..d6d1aad75b2 100644
>> --- a/board/siemens/capricorn/Kconfig
>> +++ b/board/siemens/capricorn/Kconfig
>> @@ -1,5 +1,7 @@
>> if TARGET_CAPRICORN
>>
>> +config HUSH_INIT_VAR
>> + def_bool y
>>
>> config SYS_BOARD
>> default "capricorn"
>> diff --git a/board/siemens/capricorn/board.c b/board/siemens/capricorn/board.c
>> index 390a7b0d841..d4f26b6ff7f 100644
>> --- a/board/siemens/capricorn/board.c
>> +++ b/board/siemens/capricorn/board.c
>> @@ -5,6 +5,7 @@
>> * Copyright 2019 Siemens AG
>> *
>> */
>> +#include <cli_hush.h>
>> #include <command.h>
>> #include <dm.h>
>> #include <env.h>
>> @@ -29,6 +30,7 @@
>> #include "../common/board.h"
>> #include "../common/eeprom.h"
>> #include "../common/factoryset.h"
>> +#include <firmware/imx/sci/sci.h>
>>
>> #define GPIO_PAD_CTRL \
>> ((SC_PAD_CONFIG_NORMAL << PADRING_CONFIG_SHIFT) | \
>> @@ -373,23 +375,48 @@ __weak int mmc_map_to_kernel_blk(int dev_no)
>>
>> void board_late_mmc_env_init(void)
>> {
>> - char cmd[32];
>> - char mmcblk[32];
>> u32 dev_no = mmc_get_env_dev();
>>
>> if (!check_mmc_autodetect())
>> return;
>>
>> env_set_ulong("mmcdev", dev_no);
>> +}
>> +
>> +#if defined(CONFIG_HUSH_INIT_VAR)
>> +int hush_init_var(void)
>> +{
>> + sc_misc_bt_t boot_type;
>>
>> - /* Set mmcblk env */
>> - sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw",
>> - mmc_map_to_kernel_blk(dev_no));
>> - env_set("mmcroot", mmcblk);
>> + if (sc_misc_get_boot_type(-1, &boot_type) != 0) {
>> + puts("boottype cannot be retrieved\n");
>> + return 0;
>> + }
>> +
>> + /*
>> + * Set here explicitly a hush shell variable, so if a saveenv
>> + * happens, this variable is *not* saved in U-Boot environment.
>> + *
>> + * This is for devices which are already in the field essential,
>> + * as if such a device breaks, the cutsomer gets a new device
>> + * with a new U-Boot version (and so a new U-Boot environment).
>> + *
>> + * But the customer makes a downgrade to an older U-bootversion,
>
> Typo: U-Boot version.
Fixed.
>
>
> Otherwise:
>
> Reviewed-by: Peng Fan <peng.fan at nxp.com>
Many thanks for your review of all the patches!
I worked in all your comments for the series, try to make a test which Benjamin
requested yesterday for patch:
"env: add w flags for net config in explicit write mode"
https://patchwork.ozlabs.org/project/uboot/patch/20260124054040.7597-1-hs@nabladev.com/
and wait for more comments before I resend v2.
Thanks!
bye,
Heiko
>
--
Nabla Software Engineering
HRB 40522 Augsburg
Phone: +49 821 45592596
E-Mail: office at nabladev.com
Geschäftsführer : Stefano Babic
More information about the U-Boot
mailing list