[U-Boot] [PATCH] warp7: Fix U-Boot corruption after saving the environment
Pierre-Jean Texier
pjtexier at koncepto.io
Mon Oct 21 16:43:09 UTC 2019
Hello Fabio,
Le 21/10/2019 à 16:22, Fabio Estevam a écrit :
> U-Boot binary has grown in such a way that it goes beyond the reserved
> area for the environment variables.
>
> Running "saveenv" followed by a "reset" causes U-Boot to hang because
> of this overlap.
On top-of master 32ded50 ("spl: mmc: make eMMC HW boot
partition configuration optional ")
I am not able to reproduce the described behavior.
See above:
---------
=> env set foo bar
=> env save
Saving Environment to MMC... Writing to MMC(0)... OK
=> reset
resetting ...
U-Boot 2019.10-00750-g32ded50 (Oct 21 2019 - 17:42:20 +0200)
CPU: Freescale i.MX7S rev1.2 800 MHz (running at 792 MHz)
CPU: Extended Commercial temperature grade (-20C to 105C) at 41C
Reset cause: POR
Model: Warp i.MX7 Board
Board: WARP7 in secure mode OPTEE DRAM 0x9d000000-0xa0000000
DRAM: 464 MiB
MMC: FSL_SDHC: 1, FSL_SDHC: 0
Loading Environment from MMC... OK
In: serial at 30860000
Out: serial at 30860000
Err: serial at 30860000
SEC0: RNG instantiated
Net: usb_ether
Warning: usb_ether (eth0) using random MAC address - 4a:fd:63:75:a8:29
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0(part 0) is current device
switch to partitions #0, OK
mmc0(part 0) is current device
8417416 bytes read in 125 ms (64.2 MiB/s)
Booting from mmc ...
29058 bytes read in 11 ms (2.5 MiB/s)
Kernel image @ 0x80800000 [ 0x000000 - 0x807088 ]
## Flattened Device Tree blob at 83000000
Booting using the fdt blob at 0x83000000
Using Device Tree in place at 83000000, end 8300a181
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0
Did you change anything in your configuration?
Thanks !
Pierre-Jean
>
> Fix this problem by increasing the CONFIG_ENV_OFFSET size.
>
> Also, in order to prevent this same problem in the future, use
> CONFIG_BOARD_SIZE_LIMIT, which will detect the overlap in build-time.
>
> CONFIG_BOARD_SIZE_LIMIT does not accept math expressions, so declare
> CONFIG_ENV_OFFSET with its direct value instead.
>
> Signed-off-by: Fabio Estevam <festevam at gmail.com>
> ---
> include/configs/warp7.h | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/include/configs/warp7.h b/include/configs/warp7.h
> index 73541fe176..d103567cf4 100644
> --- a/include/configs/warp7.h
> +++ b/include/configs/warp7.h
> @@ -132,7 +132,18 @@
> /* environment organization */
> #define CONFIG_ENV_SIZE SZ_8K
>
> -#define CONFIG_ENV_OFFSET (8 * SZ_64K)
> +/* Environment starts at 768k = 768 * 1024 = 786432 */
> +#define CONFIG_ENV_OFFSET 786432
> +/*
> + * Detect overlap between U-Boot image and environment area in build-time
> + *
> + * CONFIG_BOARD_SIZE_LIMIT = CONFIG_ENV_OFFSET - u-boot-dtb.imx offset
> + * CONFIG_BOARD_SIZE_LIMIT = 768k - 1k = 767k = 785408
> + *
> + * Currently CONFIG_BOARD_SIZE_LIMIT does not handle expressions, so
> + * write the direct value here
> + */
> +#define CONFIG_BOARD_SIZE_LIMIT 785408
> #define CONFIG_SYS_FSL_USDHC_NUM 1
>
> #define CONFIG_SYS_MMC_ENV_DEV 0
>
--
Pierre-Jean Texier
Embedded Linux Engineer
https://koncepto.io
More information about the U-Boot
mailing list