[PATCH] board/km: fix setting of pram variable

Stefan Roese sr at denx.de
Fri Feb 5 11:11:11 CET 2021


(Added Niel to Cc)

On 05.02.21 10:55, Holger Brunck wrote:
> The pram variable is evaluated in common/board_r.c as a unsigned long
> and not as a string using a hex formataion. This incorrect setting
> leads to a wrong calculation of preserved RAM for u-boot. This is fixed
> now. The pram variable is now a unsigned long specifying the amount of
> kB of preserved RAM.
> 
> Signed-off-by: Holger Brunck <holger.brunck at hitachi-powergrids.com>
> CC: Stefan Roese <sr at denx.de>
> ---
>   board/keymile/common/common.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
> index df507e2..7343d47 100644
> --- a/board/keymile/common/common.c
> +++ b/board/keymile/common/common.c
> @@ -60,7 +60,7 @@ int set_km_env(void)
>   		strict_strtoul(p, 16, &rootfssize);
>   	pram = (rootfssize + CONFIG_KM_RESERVED_PRAM + CONFIG_KM_PHRAM +
>   		CONFIG_KM_PNVRAM) / 0x400;
> -	sprintf((char *)buf, "0x%x", pram);
> +	sprintf((char *)buf, "%u", pram);
>   	env_set("pram", (char *)buf);

I've commented to Niel as well before:

Why don't you switch to using a different env_set_foo() API instead?
Like env_set_ulong() in this case? Or env_set_hex() in the HEX case.
This could also be done for some other env_set cases in this file as
well to reduce code size and complexity.

Thanks,
Stefan


More information about the U-Boot mailing list