[U-Boot] [PATCH v2] pico-imx7d: Increase the CONFIG_ENV_OFFSET size

U-Boot binary has grown in such a way that it goes beyond the reserved area for the environment variables.
Running "saveenv" causes U-Boot to hang because of this overlap.
Fix this problem by increasing the CONFIG_ENV_OFFSET size.
Signed-off-by: Fabio Estevam festevam@gmail.com --- Changes since v1: - Reword the commit log (Stefano)
include/configs/pico-imx7d.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h index 2bc42a0..120111d 100644 --- a/include/configs/pico-imx7d.h +++ b/include/configs/pico-imx7d.h @@ -134,7 +134,7 @@ /* FLASH and environment organization */ #define CONFIG_ENV_SIZE SZ_8K
-#define CONFIG_ENV_OFFSET (8 * SZ_64K) +#define CONFIG_ENV_OFFSET (12 * SZ_64K) #define CONFIG_SYS_FSL_USDHC_NUM 2
#define CONFIG_SYS_MMC_ENV_DEV 0

Hi Fabio,
On 30.11.18 11:15, Fabio Estevam wrote:
U-Boot binary has grown in such a way that it goes beyond the reserved area for the environment variables.
Running "saveenv" causes U-Boot to hang because of this overlap.
Fix this problem by increasing the CONFIG_ENV_OFFSET size.
Signed-off-by: Fabio Estevam festevam@gmail.com
Changes since v1:
Reword the commit log (Stefano)
include/configs/pico-imx7d.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h index 2bc42a0..120111d 100644 --- a/include/configs/pico-imx7d.h +++ b/include/configs/pico-imx7d.h @@ -134,7 +134,7 @@ /* FLASH and environment organization */ #define CONFIG_ENV_SIZE SZ_8K
-#define CONFIG_ENV_OFFSET (8 * SZ_64K) +#define CONFIG_ENV_OFFSET (12 * SZ_64K)
I find this hard to read: (12 * SZ_64K). Wouldn't (768 * SZ_1K) be better?
And I found using CONFIG_BOARD_SIZE_LIMIT quite handy, as it detects such increased image growths beyond its limit upon build time. Perhaps you could add this as well? This should do it for this board:
#define CONFIG_BOARD_SIZE_LIMIT CONFIG_ENV_OFFSET
Thanks, Stefan

Hi Stefan,
On Fri, Nov 30, 2018 at 8:29 AM Stefan Roese sr@denx.de wrote:
-#define CONFIG_ENV_OFFSET (8 * SZ_64K) +#define CONFIG_ENV_OFFSET (12 * SZ_64K)
I find this hard to read: (12 * SZ_64K). Wouldn't (768 * SZ_1K) be better?
Yes, this is a good idea, but it does not work in conjunction with your suggestion below.
And I found using CONFIG_BOARD_SIZE_LIMIT quite handy, as it detects such increased image growths beyond its limit upon build time. Perhaps you could add this as well? This should do it for this board:
#define CONFIG_BOARD_SIZE_LIMIT CONFIG_ENV_OFFSET
Thanks for this suggestion.
I was not aware of CONFIG_BOARD_SIZE_LIMIT, which is very helpful!
The only issue I see with this approach is that it does not accept expressions like (768 * SZ_1K):
SYM u-boot.sym /bin/sh: 1: printf: (768 * SZ_1K): expected numeric value u-boot-nodtb.bin exceeds file size limit: limit: 0 bytes actual: 482952 bytes excess: 482952 bytes Makefile:1040: recipe for target 'u-boot-nodtb.bin' failed
So I will hardcode CONFIG_ENV_OFFSET and use CONFIG_BOARD_SIZE_LIMIT:
#define CONFIG_ENV_OFFSET 786432 /* Detect overlap between U-Boot image and environment area in build-time */ #define CONFIG_BOARD_SIZE_LIMIT CONFIG_ENV_OFFSET
IMHO it is better to get an error in build time when U-Boot and env area overlaps than providing a pretty CONFIG_ENV_OFFSET format :-)
Thanks!

Hi Fabio,
On 30.11.18 11:58, Fabio Estevam wrote:
On Fri, Nov 30, 2018 at 8:29 AM Stefan Roese sr@denx.de wrote:
-#define CONFIG_ENV_OFFSET (8 * SZ_64K) +#define CONFIG_ENV_OFFSET (12 * SZ_64K)
I find this hard to read: (12 * SZ_64K). Wouldn't (768 * SZ_1K) be better?
Yes, this is a good idea, but it does not work in conjunction with your suggestion below.
And I found using CONFIG_BOARD_SIZE_LIMIT quite handy, as it detects such increased image growths beyond its limit upon build time. Perhaps you could add this as well? This should do it for this board:
#define CONFIG_BOARD_SIZE_LIMIT CONFIG_ENV_OFFSET
Thanks for this suggestion.
I was not aware of CONFIG_BOARD_SIZE_LIMIT, which is very helpful!
Yes, I also only found out about this a few months ago. Always something new to learn... ;)
The only issue I see with this approach is that it does not accept expressions like (768 * SZ_1K):
SYM u-boot.sym /bin/sh: 1: printf: (768 * SZ_1K): expected numeric value u-boot-nodtb.bin exceeds file size limit: limit: 0 bytes actual: 482952 bytes excess: 482952 bytes Makefile:1040: recipe for target 'u-boot-nodtb.bin' failed
So I will hardcode CONFIG_ENV_OFFSET and use CONFIG_BOARD_SIZE_LIMIT:
#define CONFIG_ENV_OFFSET 786432 /* Detect overlap between U-Boot image and environment area in build-time */ #define CONFIG_BOARD_SIZE_LIMIT CONFIG_ENV_OFFSET
IMHO it is better to get an error in build time when U-Boot and env area overlaps than providing a pretty CONFIG_ENV_OFFSET format :-)
I agree. I'm using hex values like this 0x80000, which look better to my eyes (personal taste). Perhaps the Makefile logic handling BOARD_LIMIT_SIZE can be improved to support other expressions as well.
Thanks, Stefan

Dear Fabio,
In message CAOMZO5B3Dbub=XVMLKgDUQhkS7to8YsJeqsBmJE56y+itA2aMg@mail.gmail.com you wrote:
I find this hard to read: (12 * SZ_64K). Wouldn't (768 * SZ_1K) be better?
...
The only issue I see with this approach is that it does not accept expressions like (768 * SZ_1K):
This is why I always prefer to use expressions that are both readable and computable, like (768 << 10).
#define CONFIG_ENV_OFFSET 786432
Would
#define CONFIG_ENV_OFFSET (768 << 10)
or at least
#define CONFIG_ENV_OFFSET (768 * 1024)
work?
/* Detect overlap between U-Boot image and environment area in build-time */ #define CONFIG_BOARD_SIZE_LIMIT CONFIG_ENV_OFFSET
Note this is only correct if the U-Boot image gets written at offset zero - is this the case?
IMHO it is better to get an error in build time when U-Boot and env area overlaps than providing a pretty CONFIG_ENV_OFFSET format :-)
Agreed!
[Please ignore my previous message - working through the list sequentially is not optimal...]
Best regards,
Wolfgang Denk

Hi Wolfgang,
On Fri, Nov 30, 2018 at 11:13 AM Wolfgang Denk wd@denx.de wrote:
This is why I always prefer to use expressions that are both readable and computable, like (768 << 10).
#define CONFIG_ENV_OFFSET 786432
Would
#define CONFIG_ENV_OFFSET (768 << 10)
or at least
#define CONFIG_ENV_OFFSET (768 * 1024)
work?
CONFIG_BOARD_SIZE_LIMIT does not accept such definitions and it fails like this:
/bin/sh: 1: printf: (768 << 10): expected numeric value u-boot-nodtb.bin exceeds file size limit: limit: 0 bytes actual: 482952 bytes excess: 482952 bytes
That is the reason I used #define CONFIG_ENV_OFFSET 786432
/* Detect overlap between U-Boot image and environment area in build-time */ #define CONFIG_BOARD_SIZE_LIMIT CONFIG_ENV_OFFSET
Note this is only correct if the U-Boot image gets written at offset zero - is this the case?
That is a good point!
In this case SPL is flashed at offset 1k and u-boot.img is flashed at offset 69k.
So I guess I should hardcode CONFIG_BOARD_SIZE_LIMIT to 768k - 69k = 699k = 715776.
#define CONFIG_ENV_OFFSET 715776 /* Detect overlap between U-Boot image and environment area in build-time */ #define CONFIG_BOARD_SIZE_LIMIT CONFIG_ENV_OFFSET
participants (3)
-
Fabio Estevam
-
Stefan Roese
-
Wolfgang Denk