Skip to contentSkip to conversation

pico-imx7d: Increase the CONFIG_ENV_OFFSET size

PATCH Superseded Fabio Estevam 10 participants 42 messages Nov 30, 2018 – Mar 15, 2019

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH v4 1/1 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.

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.

---
Changes since v3:
- Take the 69k u-boot.img offset into account when calculating CONFIG_BOARD_SIZE_LIMIT (Wolfgang)

 include/configs/pico-imx7d.h | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
include/configs/pico-imx7d.h +13 -1
index 2bc42a0..06ede3f 100644
@@ -134,7 +134,19 @@
 /* FLASH and 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.img offset
+ * CONFIG_BOARD_SIZE_LIMIT = 768k - 69k = 699k = 715776
+ *
+ * Currently CONFIG_BOARD_SIZE_LIMIT does not handle expressions, so
+ * write the direct value here
+ */
+#define CONFIG_BOARD_SIZE_LIMIT		715776
+
 #define CONFIG_SYS_FSL_USDHC_NUM		2
 
 #define CONFIG_SYS_MMC_ENV_DEV			0
Signature · 1 line
2.7.4
#1 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Quoted 8 lines · Fabio Estevam

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.

Quoted 7 lines

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.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750
#2 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

In reply to Fabio Estevam

Dear Fabio,

Quoted 5 lines · In message <[email protected]> you 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.

Quoted 7 lines

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.

This is IMHO the wrong approach. Why not fix this problem?

Quoted 7 lines

+ * CONFIG_BOARD_SIZE_LIMIT = CONFIG_ENV_OFFSET - u-boot.img offset
+ * CONFIG_BOARD_SIZE_LIMIT = 768k - 69k = 699k = 715776
+ *
+ * Currently CONFIG_BOARD_SIZE_LIMIT does not handle expressions, so
+ * write the direct value here
+ */
+#define CONFIG_BOARD_SIZE_LIMIT 715776

This looks ugly. I mean, have a look at the Makefile - we're calling AWK anyway, so why not make this evaluating expressions (and getting rid of a few unnneeded commands)?

Can you please try somthing like this (only minimally tested):

arch/arm/mach-imx/Makefile +7 -9
index 53d9e5f42b..a7f02f9996 100644
@@ -60,15 +60,13 @@ endif
 
 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
 BOARD_SIZE_CHECK = \
-        @actual=`wc -c $@ | awk '{print $$1}'`; \
-        limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
-        if test $$actual -gt $$limit; then \
-                echo "$@ exceeds file size limit:" >&2 ; \
-                echo "  limit:  $$limit bytes" >&2 ; \
-                echo "  actual: $$actual bytes" >&2 ; \
-                echo "  excess: $$((actual - limit)) bytes" >&2; \
-                exit 1; \
-        fi
+        @wc -c $@ | \
+        awk '{ if ($$1 > $(CONFIG_BOARD_SIZE_LIMIT)) { \
+                printf "%s exceeds file size limit:\n", $$2; \
+                printf "  limit:  %d bytes\n", $(CONFIG_BOARD_SIZE_LIMIT); \
+                printf "  actual: %d bytes\n", $$1; \
+                printf "  excess: %d bytes\n", $$1 - $(CONFIG_BOARD_SIZE_LIMIT); \
+                exit 1; } }' >&2;
 else
 BOARD_SIZE_CHECK =
 endif

If it works for you, then please feel free to include it in your patch v3.

Thanks!

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
There is is no reason for any individual to have a computer in  their
home.      -- Ken Olsen (President of Digital Equipment Corporation),
              Convention of the World Future Society, in Boston, 1977
author reviewer
#3 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Hi Wolfgang,

Quoted 1 line · Wolfgang Denk

This is IMHO the wrong approach. Why not fix this problem?

That would be much better indeed, but I don't have the necessary Makefile skills to fix it.

Quoted 1 line

Can you please try somthing like this (only minimally tested):

I tried it, thanks, but unfortunately It does not work for me.

Here is the complete patch I used, which consists of your proposal plus my changes:
http://dark-code.bulix.org/nhg8l0-515675

Then when I build the pico-imx7d_defconfig target I get the following error:

/bin/sh: 1: printf: CONFIG_ENV_OFFSET - (69 * 1024): 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
make: *** [u-boot-nodtb.bin] Error 1
make: *** Waiting for unfinished jobs....
LD spl/u-boot-spl
OBJCOPY spl/u-boot-spl-nodtb.bin
COPY spl/u-boot-spl.bin

#4 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Dear Fabio,

Quoted 5 lines · In message <CAOMZO5CEeErzL2MMpktmgoV5TyXGyMZB954fNhAMBSP60scD7g@mail.gmail.com>…
Quoted 2 lines

Can you please try somthing like this (only minimally tested):

I tried it, thanks, but unfortunately It does not work for me.

Quoted 7 lines

Here is the complete patch I used, which consists of your proposal plus my changes:
http://dark-code.bulix.org/nhg8l0-515675

Then when I build the pico-imx7d_defconfig target I get the following error:

/bin/sh: 1: printf: CONFIG_ENV_OFFSET - (69 * 1024): expected numeric value

I see -yes, this does not work as you are referencing a CPP macro here which does not get resolved. I don't see a trivial way around this, though - for the Makefile we would need $(CONFIG_ENV_OFFSET), but CPP would barf on this...

Can you live with something like this:

#define CONFIG_ENV_OFFSET (768 * 1024)
#define CONFIG_BOARD_SIZE_LIMIT ((768 * 1024) - (69 * 1024))

[or maybe even ((768 - 69) * 1024) ?]

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
He had quite a powerful intellect, but it  was  as  powerful  like  a
locomotive,  and  ran on rails and was therefore almost impossible to
steer.                          - Terry Pratchett, _Lords and Ladies_
author reviewer
#5 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Hi Wolfgang,

Quoted 4 lines · Wolfgang Denk

Can you live with something like this:

#define CONFIG_ENV_OFFSET (768 * 1024)
#define CONFIG_BOARD_SIZE_LIMIT ((768 * 1024) - (69 * 1024))

It does not work:

/bin/sh: 1: printf: ((768 * 1024) - (69 * 1024)): expected numeric value u-boot-nodtb.bin exceeds file size limit:
limit: 0 bytes
actual: 482968 bytes
excess: 482968 bytes

Quoted 1 line

[or maybe even ((768 - 69) * 1024) ?]

/bin/sh: 1: printf: ((768 - 69) * 1024): expected numeric value u-boot-nodtb.bin exceeds file size limit:
limit: 0 bytes
actual: 482968 bytes
excess: 482968 bytes
Makefile:1040: recipe for target 'u-boot-nodtb.bin' failed

Can we please go with the solution I sent, which is ugly but at least allows the board to boot?

#6 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Hello Fabio,

Quoted 23 lines · Fabio Estevam
Quoted 4 lines · Wolfgang Denk

Can you live with something like this:

#define CONFIG_ENV_OFFSET (768 * 1024)
#define CONFIG_BOARD_SIZE_LIMIT ((768 * 1024) - (69 * 1024))

It does not work:

/bin/sh: 1: printf: ((768 * 1024) - (69 * 1024)): expected numeric value u-boot-nodtb.bin exceeds file size limit:
limit: 0 bytes
actual: 482968 bytes
excess: 482968 bytes

Quoted 1 line

[or maybe even ((768 - 69) * 1024) ?]

/bin/sh: 1: printf: ((768 - 69) * 1024): expected numeric value u-boot-nodtb.bin exceeds file size limit:
limit: 0 bytes
actual: 482968 bytes
excess: 482968 bytes
Makefile:1040: recipe for target 'u-boot-nodtb.bin' failed

Quoted 2 lines

Can we please go with the solution I sent, which is ugly but at least allows the board to boot?

Agreed. It is better Wolfgang to send a tested solution before we change it one more time.

This fix should go in as the board is broken without it.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750
#7 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Dear Otavio,

Quoted 3 lines · In message <CAP9ODKr1JVMHqsGnPyJwYK3QtHAGXQ=Cv4Y8Zx0nQtxc4C4cAw@mail.gmail.com>…

Agreed. It is better Wolfgang to send a tested solution before we change it one more time.

My patch _was_ tested. I can only speculate that Fabio applied it manually, and made a mistake.

Quoted 1 line

This fix should go in as the board is broken without it.

Yes, agreed. But then, we are just one step away from a better fix.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It is a good thing for an uneducated man to read books of quotations.
                        - Sir Winston Churchill _My Early Life_ ch. 9
#8 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

In reply to Fabio Estevam

Dear Fabio,

Quoted 8 lines · In message <CAOMZO5DBvBag4qG7tRqHi1X1Dy7=bWfaQhN5wRCB2_WM1HhiGw@mail.gmail.com>…
Quoted 4 lines · Wolfgang Denk

Can you live with something like this:

#define CONFIG_ENV_OFFSET (768 * 1024)
#define CONFIG_BOARD_SIZE_LIMIT ((768 * 1024) - (69 * 1024))

Quoted 7 lines

It does not work:

/bin/sh: 1: printf: ((768 * 1024) - (69 * 1024)): expected numeric value u-boot-nodtb.bin exceeds file size limit:
limit: 0 bytes
actual: 482968 bytes
excess: 482968 bytes

Is there any chance you mis-applied my patch?

Apparently you still have a shell printf command in your code, most probably the old line

	limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`;

But this should not be present any more with my patch applied. Here again as reference:

arch/arm/mach-imx/Makefile +7 -9
index 53d9e5f42b..a7f02f9996 100644
@@ -60,15 +60,13 @@ endif
 
 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
 BOARD_SIZE_CHECK = \
-        @actual=`wc -c $@ | awk '{print $$1}'`; \
-        limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
-        if test $$actual -gt $$limit; then \
-                echo "$@ exceeds file size limit:" >&2 ; \
-                echo "  limit:  $$limit bytes" >&2 ; \
-                echo "  actual: $$actual bytes" >&2 ; \
-                echo "  excess: $$((actual - limit)) bytes" >&2; \
-                exit 1; \
-        fi
+        @wc -c $@ | \
+        awk '{ if ($$1 > $(CONFIG_BOARD_SIZE_LIMIT)) { \
+                printf "%s exceeds file size limit:\n", $$2; \
+                printf "  limit:  %d bytes\n", $(CONFIG_BOARD_SIZE_LIMIT); \
+                printf "  actual: %d bytes\n", $$1; \
+                printf "  excess: %d bytes\n", $$1 - $(CONFIG_BOARD_SIZE_LIMIT); \
+                exit 1; } }' >&2;
 else
 BOARD_SIZE_CHECK =
 endif

As you can see, with the patch there is NO printf called before the line which prints ""%s exceeds file size limit:\n", but in your output the error message comes before that.

I have tested this code, and it works for me.

Please check the code again!

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You don't have to worry about me. I might have been born yesterday...
but I stayed up all night.
author reviewer
#9 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Hi Wolfgang,

Quoted 1 line · Wolfgang Denk

Is there any chance you mis-applied my patch?

Ok, so I started again.

1. Applied the following patch:
http://dark-code.bulix.org/tualst-517948

2. make mproper; make make pico-pi-imx7d_defconfig; make

3. Build fails:

/bin/sh: 1: printf: ((768 - 69) * 1024): expected numeric value u-boot-nodtb.bin exceeds file size limit:
limit: 0 bytes
actual: 482952 bytes
excess: 482952 bytes

The reason for the failure is because there is an extra CONFIG_BOARD_SIZE_LIMIT check inside the main Makefile.

Your patch only covers arch/arm/mach-imx/Makefile.

If I remove the check from the main Makefile:

Makefile +0 -15
@@ -772,21 +772,6 @@ LDPPFLAGS += \
 #########################################################################
 #########################################################################
 
-ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
-BOARD_SIZE_CHECK = \
-       @actual=`wc -c $@ | awk '{print $$1}'`; \
-       limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
-       if test $$actual -gt $$limit; then \
-               echo "$@ exceeds file size limit:" >&2 ; \
-               echo "  limit:  $$limit bytes" >&2 ; \
-               echo "  actual: $$actual bytes" >&2 ; \
-               echo "  excess: $$((actual - limit)) bytes" >&2; \
-               exit 1; \
-       fi
-else
-BOARD_SIZE_CHECK =
-endif
-
 # Statically apply RELA-style relocations (currently arm64 only)
 # This is useful for arm64 where static relocation needs to be performed on
 # the raw binary, but certain simulators only accept an ELF file (but don't

Then I am able to successfully build it.

It seems we need to avoid the double CONFIG_BOARD_SIZE_LIMIT check.

Ideas?

Thanks

#10 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Dear Fabio,

Quoted 2 lines · In message <CAOMZO5DMopeGgVWZ4U23V=Br0UsfX-_Q7PXaYu7n+O8k4EEwUw@mail.gmail.com>…

Ok, so I started again.

Thanks!

Quoted 4 lines

The reason for the failure is because there is an extra CONFIG_BOARD_SIZE_LIMIT check inside the main Makefile.

Your patch only covers arch/arm/mach-imx/Makefile.

Argh...

Quoted 1 line

Then I am able to successfully build it.

Great.

Quoted 1 line

It seems we need to avoid the double CONFIG_BOARD_SIZE_LIMIT check.

IMO there is nothing architecture specific about this check, so we should probably patch the top level Makefile and remove the test in arch/arm/mach-imx/Makefile ?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Always borrow money from a pessimist; they don't expect  to  be  paid
back.
author reviewer
#11 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Hi Wolfgang,

Quoted 3 lines · Wolfgang Denk

IMO there is nothing architecture specific about this check, so we should probably patch the top level Makefile and remove the test in arch/arm/mach-imx/Makefile ?

It is not so simple, for the two following reasons:

1. The imx check has been introduced by:

commit 43e6f94cbcaf193aeedcf86e85a3ff4c79f66773

Author: Marcel Ziswiler <[email protected]>
Date:   Fri Nov 9 15:31:17 2018 +0100

imx: mkimage: add size check to the u-boot.imx make target

The make macro to check if the binary exceeds the board size limit is taken straight from the root Makefile.

Without this and e.g. enabled EFI Vybrid fails booting as the regular size limit check does not take the final u-boot.imx binary size into account which is bigger due to alignment as well as IMX header stuff.

2. For testing purpose, I removed the imx check and patched the main Makefile, but still got error:
u-boot-nodtb.bin exceeds file size limit:
limit: 0 bytes
actual: 482968 bytes
excess: 482968 bytes

How should we proceed?

#12 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Dear Fabio,

Quoted 7 lines · In message <CAOMZO5AC--JreCuyWA2+Kudwcp1UPaMpynkWzAKfinGhUtzhvw@mail.gmail.com>…

1. The imx check has been introduced by:

commit 43e6f94cbcaf193aeedcf86e85a3ff4c79f66773

Author: Marcel Ziswiler <[email protected]>
Date:   Fri Nov 9 15:31:17 2018 +0100
Quoted 8 lines

imx: mkimage: add size check to the u-boot.imx make target

The make macro to check if the binary exceeds the board size limit is taken straight from the root Makefile.

Without this and e.g. enabled EFI Vybrid fails booting as the regular size limit check does not take the final u-boot.imx binary size into account which is bigger due to alignment as well as IMX header stuff.

OK, so this is an additional (second) test run for a special configuration, but the code to perform the test has just been duplicated from the top level makefile (which is not a nice thing).

I think we should tun this code either into a Makefile function that is defined only once and can then be used elsewhere as well, or turn it into an external script unter scripts/

What do you think?

Quoted 6 lines

2. For testing purpose, I removed the imx check and patched the main Makefile, but still got error:
u-boot-nodtb.bin exceeds file size limit:
limit: 0 bytes
actual: 482968 bytes
excess: 482968 bytes

What is your exact build target / command sequence to get here?

The "limit: 0 bytes" clearly indicates that the definition of CONFIG_BOARD_SIZE_LIMIT is not known to Make at this point, or wrong.

In the meantime, having the patch applied both to the TL Makefile and to the imx one should work at least as good as the previous code.

Quoted 1 line

How should we proceed?

If I know how to repeat your exact test, I can try to fix that.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
PoB = "Prisoner of Bill" -- those held captive, unwillingly or other-
wise, by the contemptible Microsoft monopoly.
         -- Tom Christiansen in <[email protected]>
author reviewer
#13 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Hi Wolfgang,

Quoted 9 lines · Wolfgang Denk

OK, so this is an additional (second) test run for a special configuration, but the code to perform the test has just been duplicated from the top level makefile (which is not a nice thing).

I think we should tun this code either into a Makefile function that is defined only once and can then be used elsewhere as well, or turn it into an external script unter scripts/

What do you think?

Yes, I agree that we should avoid the specific imx duplication.

Quoted 1 line

If I know how to repeat your exact test, I can try to fix that.

Please follow these steps:

1. Apply the following patch:
http://dark-code.bulix.org/tualst-517948

2. Build pico pi mx7d target:

make mrproper
make pico-pi-imx7d_defconfig
make -j4

And then you will get the error:

/bin/sh: 1: printf: ((768 - 69) * 1024): expected numeric value u-boot-nodtb.bin exceeds file size limit:
limit: 0 bytes
actual: 482952 bytes
excess: 482952 bytes

Thanks

#14 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

So far, the use of CONFIG_BOARD_SIZE_LIMIT would only work with plain numeric constants. Extend it to allow for expressions, so one can for example use

	#define CONFIG_BOARD_SIZE_LIMIT	(768 << 10)

in the board configuration.

Cc Fabio Estevam <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vanessa Maegima <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc John Weber <[email protected]>
Cc Stefan Roese <[email protected]>

---

Note 1: As gawk lacks an eval function, we use bash's $((...))
mechanism to evaluate the expression. This has the additional benefit that it supports expressions like "<<" which awk does not understand. OK, one could replace awk by something better...
Note 2: This patch focusses on enabling this new feature. It does
not addres another issue that should be solved in a lter
commit: the duplication of the same code in Makefile and arch/arm/mach-imx/Makefile

 Makefile                   | 17 ++++++++---------
 arch/arm/mach-imx/Makefile | 17 ++++++++---------
 2 files changed, 16 insertions(+), 18 deletions(-)
Makefile +8 -9
index 0d11ff9797..d4c8f697cf 100644
@@ -774,15 +774,14 @@ LDPPFLAGS += \
 
 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
 BOARD_SIZE_CHECK = \
-	@actual=`wc -c $@ | awk '{print $$1}'`; \
-	limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
-	if test $$actual -gt $$limit; then \
-		echo "$@ exceeds file size limit:" >&2 ; \
-		echo "  limit:  $$limit bytes" >&2 ; \
-		echo "  actual: $$actual bytes" >&2 ; \
-		echo "  excess: $$((actual - limit)) bytes" >&2; \
-		exit 1; \
-	fi
+        @(echo $$(($(CONFIG_BOARD_SIZE_LIMIT))); wc -c $@ ) | \
+	awk 'BEGIN { getline limit } \
+	{ if ($$1 > limit) { \
+		printf "%s exceeds file size limit:\n", $$2; \
+		printf "  limit:  %d bytes\n", limit; \
+		printf "  actual: %d bytes\n", $$1; \
+		printf "  excess: %d bytes\n", $$1 - limit; \
+		exit 1; } }'
 else
 BOARD_SIZE_CHECK =
 endif
arch/arm/mach-imx/Makefile +8 -9
index 53d9e5f42b..230a5c73aa 100644
@@ -60,15 +60,14 @@ endif
 
 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
 BOARD_SIZE_CHECK = \
-        @actual=`wc -c $@ | awk '{print $$1}'`; \
-        limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
-        if test $$actual -gt $$limit; then \
-                echo "$@ exceeds file size limit:" >&2 ; \
-                echo "  limit:  $$limit bytes" >&2 ; \
-                echo "  actual: $$actual bytes" >&2 ; \
-                echo "  excess: $$((actual - limit)) bytes" >&2; \
-                exit 1; \
-        fi
+        @(echo $$(($(CONFIG_BOARD_SIZE_LIMIT))); wc -c $@ ) | \
+	awk 'BEGIN { getline limit } \
+	{ if ($$1 > limit) { \
+		printf "%s exceeds file size limit:\n", $$2; \
+		printf "  limit:  %d bytes\n", limit; \
+		printf "  actual: %d bytes\n", $$1; \
+		printf "  excess: %d bytes\n", $$1 - limit; \
+		exit 1; } }'
 else
 BOARD_SIZE_CHECK =
 endif
Signature · 1 line
2.19.1
#15 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Quoted 9 lines · Wolfgang Denk

So far, the use of CONFIG_BOARD_SIZE_LIMIT would only work with plain numeric constants. Extend it to allow for expressions, so one can for example use

        #define CONFIG_BOARD_SIZE_LIMIT (768 << 10)

in the board configuration.

Quoted 8 lines
Cc Fabio Estevam <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vanessa Maegima <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc John Weber <[email protected]>
Cc Stefan Roese <[email protected]>

Thanks for looking into this.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750
author reviewer
#16 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

In reply to Wolfgang Denk

Hi Wolfgang,

Quoted 10 lines · Wolfgang Denk

So far, the use of CONFIG_BOARD_SIZE_LIMIT would only work with plain numeric constants. Extend it to allow for expressions, so one can for example use

        #define CONFIG_BOARD_SIZE_LIMIT (768 << 10)

in the board configuration.

Still not working for me. I do see a warning now:

LD spl/u-boot-spl
/bin/sh: 1: arithmetic expression: expecting primary: ""((768 - 69) * 1024)""
COPY u-boot.bin
MKIMAGE u-boot.img
OBJCOPY spl/u-boot-spl-nodtb.bin
COPY spl/u-boot-spl.bin
CFGS spl/u-boot-spl.cfgout
MKIMAGE SPL
CFGCHK u-boot.cfg

It does allow the build to proceed, but it is not really detecting the overlap anymore.

For example: let's force the overlap by setting a very small CONFIG_BOARD_SIZE_LIMIT of only 1K:

#define CONFIG_ENV_OFFSET (768 * 1024)
#define CONFIG_BOARD_SIZE_LIMIT (1 * 1024)

/bin/sh: 1: arithmetic expression: expecting primary: ""(1 * 1024)""
COPY u-boot.bin
MKIMAGE u-boot.img

  LD      spl/drivers/usb/gadget/built-in.o
  LD      spl/drivers/built-in.o
  LD      spl/u-boot-spl

OBJCOPY spl/u-boot-spl-nodtb.bin
COPY spl/u-boot-spl.bin
CFGS spl/u-boot-spl.cfgout
MKIMAGE SPL
CFGCHK u-boot.cfg

It still allowed a successful build, but it should have thrown an error about the overlap.

#17 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Dear Fabio,

Quoted 12 lines · In message <CAOMZO5Co8KPCBx+gPS8w02cYJR2Ci9cpSKVQm3zy+JRgD1mtLw@mail.gmail.com>…

Still not working for me. I do see a warning now:

LD spl/u-boot-spl
/bin/sh: 1: arithmetic expression: expecting primary: ""((768 - 69) * 1024)""
COPY u-boot.bin
MKIMAGE u-boot.img
OBJCOPY spl/u-boot-spl-nodtb.bin
COPY spl/u-boot-spl.bin
CFGS spl/u-boot-spl.cfgout
MKIMAGE SPL
CFGCHK u-boot.cfg

I'm bulding with your modification:

include/configs/pico-imx7d.h +2 -1
index 2bc42a04a0..67ca700a2f 100644
@@ -134,7 +134,8 @@
 /* FLASH and environment organization */
 #define CONFIG_ENV_SIZE                        SZ_8K
 
-#define CONFIG_ENV_OFFSET                      (8 * SZ_64K)
+#define CONFIG_ENV_OFFSET              (768 * 1024)
+#define CONFIG_BOARD_SIZE_LIMIT                ((768 - 69) * 1024)
 #define CONFIG_SYS_FSL_USDHC_NUM               2
 
 #define CONFIG_SYS_MMC_ENV_DEV                 0

...

  LD      spl/common/spl/built-in.o
  CC      spl/lib/display_options.o
  LD      spl/lib/built-in.o
  LD      spl/u-boot-spl

OBJCOPY spl/u-boot-spl-nodtb.bin
COPY spl/u-boot-spl.bin
MKIMAGE SPL
OBJCOPY u-boot.srec
OBJCOPY u-boot-nodtb.bin
COPY u-boot.bin
SYM u-boot.sym
MKIMAGE u-boot.img
CHK include/config.h
CFG u-boot.cfg
===================== WARNING ====================== This board does not use CONFIG_DM_MMC. Please update the board to use CONFIG_DM_MMC before the v2019.04 release. Failure to update by the deadline may result in board removal. See doc/driver-model/MIGRATION.txt for more info.
====================================================
===================== WARNING ====================== This board does not use CONFIG_DM_USB. Please update the board to use CONFIG_DM_USB before the v2019.07 release. Failure to update by the deadline may result in board removal. See doc/driver-model/MIGRATION.txt for more info.
====================================================
CFGCHK u-boot.cfg

Quoted 8 lines

It does allow the build to proceed, but it is not really detecting the overlap anymore.

For example: let's force the overlap by setting a very small CONFIG_BOARD_SIZE_LIMIT of only 1K:

#define CONFIG_ENV_OFFSET (768 * 1024)
#define CONFIG_BOARD_SIZE_LIMIT (1 * 1024)

Please try it on the shell:

-> echo $(( ((768 - 69) * 1024) ))
715776
-> echo $(( (1 * 1024) ))
1024

Quoted 1 line

/bin/sh: 1: arithmetic expression: expecting primary: ""(1 * 1024)""

I tested this with /bin/bash, /bin/sh and even /bin/dash - they all work fine here.

Quoted 2 lines

It still allowed a successful build, but it should have thrown an error about the overlap.

It does for me, if I set the limit low:

OBJCOPY spl/u-boot-spl-nodtb.bin
COPY spl/u-boot-spl.bin
CFGS spl/u-boot-spl.cfgout
MKIMAGE SPL
OBJCOPY u-boot.srec
OBJCOPY u-boot-nodtb.bin
u-boot-nodtb.bin exceeds file size limit:
limit: 1024 bytes
actual: 480172 bytes
excess: 479148 bytes
make: *** [Makefile:1071: u-boot-nodtb.bin] Error 1

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" (I found it!) but "That's funny ..."
                                                      -- Isaac Asimov
author reviewer
#18 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Hi Wolfgang,

Quoted 6 lines · Wolfgang Denk

Please try it on the shell:

-> echo $(( ((768 - 69) * 1024) ))
715776
-> echo $(( (1 * 1024) ))
1024

This works fine.

Quoted 13 lines

It does for me, if I set the limit low:

OBJCOPY spl/u-boot-spl-nodtb.bin
COPY spl/u-boot-spl.bin
CFGS spl/u-boot-spl.cfgout
MKIMAGE SPL
OBJCOPY u-boot.srec
OBJCOPY u-boot-nodtb.bin
u-boot-nodtb.bin exceeds file size limit:
limit: 1024 bytes
actual: 480172 bytes
excess: 479148 bytes
make: *** [Makefile:1071: u-boot-nodtb.bin] Error 1

Previously I tested on a machine running Ubuntu 16.04 and today I also tested on another machine running Ubuntu 18.04.

The results are the same on both machines:

1. I get a "expecting primary" warning:

OBJCOPY u-boot-nodtb.bin
/bin/sh: 1: arithmetic expression: expecting primary: ""(1 * 1024)""
SYM u-boot.sym
COPY u-boot.bin
MKIMAGE u-boot.img

  LD      spl/drivers/usb/host/built-in.o
  LD      spl/drivers/built-in.o
  LD      spl/u-boot-spl

OBJCOPY spl/u-boot-spl-nodtb.bin
COPY spl/u-boot-spl.bin
CFGS spl/u-boot-spl.cfgout
MKIMAGE SPL

2. The overlap is not detected anymore. In the example below I forced
#define CONFIG_BOARD_SIZE_LIMIT (1 * 1024)

#19 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Dear Fabio,

Quoted 10 lines · In message <CAOMZO5Aovrx43cmykUH+Bu_O_vC0CCs2hLVXFwCxmC2JDaKOYg@mail.gmail.com>…

Previously I tested on a machine running Ubuntu 16.04 and today I also tested on another machine running Ubuntu 18.04.

The results are the same on both machines:

1. I get a "expecting primary" warning:

OBJCOPY u-boot-nodtb.bin
/bin/sh: 1: arithmetic expression: expecting primary: ""(1 * 1024)""

This makes really no sense to me. Can you please send me (off list) a git diff of the tree that is not building for you against the nearest mainline commit?

And please also the output of /"bin/sh --version".

I have:

-> /bin/sh --version
GNU bash, version 4.4.23(1)-release (x86_64-redhat-linux-gnu) Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

[Sorry, can't test build under Ubuntu ATM; our container gives strange errors, and I have to wait until tomorrow as I don't want to mess with the setup.]

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When some people discover the truth, they just can't  understand  why
everybody isn't eager to hear it.
author reviewer
#20 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Hi Wolfgang,

Quoted 3 lines · Wolfgang Denk

This makes really no sense to me. Can you please send me (off list) a git diff of the tree that is not building for you against the nearest mainline commit?

I am running top of tree mainline U-Boot + your patch from this thread, plus:

include/configs/pico-imx7d.h +2 -1
@@ -134,7 +134,8 @@
 /* FLASH and environment organization */
 #define CONFIG_ENV_SIZE                        SZ_8K
 
-#define CONFIG_ENV_OFFSET                      (8 * SZ_64K)
+#define CONFIG_ENV_OFFSET              (768 * 1024)
+#define CONFIG_BOARD_SIZE_LIMIT                (1 * 1024)
 #define CONFIG_SYS_FSL_USDHC_NUM               2
 
 #define CONFIG_SYS_MMC_ENV_DEV                 0

It does build fine, but as I have intentionally forced a small CONFIG_BOARD_SIZE_LIMIT I wanted it to fail, but it does not fail as shown below:

OBJCOPY u-boot-nodtb.bin
/bin/sh: 1: arithmetic expression: expecting primary: ""(1 * 1024)""
SYM u-boot.sym
COPY u-boot.bin
MKIMAGE u-boot.img
===================== WARNING ======================
This board does not use CONFIG_DM_MMC. Please update
the board to use CONFIG_DM_MMC before the v2019.04 release. Failure to update by the deadline may result in board removal. See doc/driver-model/MIGRATION.txt for more info.
====================================================
===================== WARNING ======================
This board does not use CONFIG_DM_USB. Please update
the board to use CONFIG_DM_USB before the v2019.07 release. Failure to update by the deadline may result in board removal. See doc/driver-model/MIGRATION.txt for more info.
====================================================
CFGCHK u-boot.cfg

As you can see there are two issues:

1. The warnin: /bin/sh: 1: arithmetic expression: expecting primary:
""(1 * 1024)""

2. It should have not built in this case. It should have detected the overlap and signalized the error

Quoted 1 line

And please also the output of /"bin/sh --version".

$ /bin/sh --version
/bin/sh: 0: Illegal option --

In my system /bin/sh points to bash:

$ ls -al /bin/sh
lrwxrwxrwx 1 root root 4 mai  2  2018 /bin/sh -> dash

/bin/bash --version
GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

I am able to reproduce this problem with a standalone script:

$ cat random.sh
#!/bin/bash
echo $(($RANDOM % 10))
$ ./random.sh
3

Worked fine with bash.

Now if I force it to dash:

$ cat random.sh
#!/bin/dash
echo $(($RANDOM % 10))
$ ./random.sh
./random.sh: 2: ./random.sh: arithmetic expression: expecting primary: " % 10"

Which is the same warning I get in U-Boot.

#21 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Fabio wrote...

Quoted 6 lines
$ /bin/sh --version
/bin/sh: 0: Illegal option --

In my system /bin/sh points to bash:

$ ls -al /bin/sh
lrwxrwxrwx 1 root root 4 mai  2  2018 /bin/sh -> dash

Just to pick up on the obvious… /bin/sh is showing as linked to dash not bash!

Using (( … )) for arithmetic expansion is a bashism [1]

[1] https://wiki.ubuntu.com/DashAsBinSh

-Andy.

author reviewer
#22 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Quoted 11 lines · Andy Pont

Fabio wrote...

$ /bin/sh --version
/bin/sh: 0: Illegal option --

In my system /bin/sh points to bash:

$ ls -al /bin/sh
lrwxrwxrwx 1 root root 4 mai  2  2018 /bin/sh -> dash

Just to pick up on the obvious… /bin/sh is showing as linked to dash not bash!

Yes, I meant bash.

Quoted 2 lines

Using (( … )) for arithmetic expansion is a bashism [1]

Correct:

$ cat random.sh
#!/bin/sh
echo $(($RANDOM % 10))
$ checkbashisms random.sh
possible bashism in random.sh line 2 ($RANDOM):
echo $(($RANDOM % 10))
author reviewer
#23 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Quoted 8 lines · Fabio Estevam
Quoted 6 lines · Andy Pont

Fabio wrote...

$ /bin/sh --version
/bin/sh: 0: Illegal option --
Quoted 7 lines
Quoted 5 lines

In my system /bin/sh points to bash:

$ ls -al /bin/sh
lrwxrwxrwx 1 root root 4 mai  2  2018 /bin/sh -> dash

Just to pick up on the obvious… /bin/sh is showing as linked to dash not bash!

Yes, I meant bash.

I meant 'dash' :-)

#24 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

In reply to Fabio Estevam

Fabio,

let me chime in (I had to do a quick ‘git grep’ on this, as I couldn’t ignore the mail traffic any longer)...

Quoted 15 lines · Fabio Estevam

Hi Wolfgang,

Quoted 3 lines · Wolfgang Denk

This makes really no sense to me. Can you please send me (off list) a git diff of the tree that is not building for you against the nearest mainline commit?

I am running top of tree mainline U-Boot + your patch from this thread, plus:

include/configs/pico-imx7d.h line 138

Quoted 6 lines
include/configs/pico-imx7d.h +2 -1
@@ -134,7 +134,8 @@
 /* FLASH and environment organization */
 #define CONFIG_ENV_SIZE                        SZ_8K
 
-#define CONFIG_ENV_OFFSET                      (8 * SZ_64K)
+#define CONFIG_ENV_OFFSET              (768 * 1024)
+#define CONFIG_BOARD_SIZE_LIMIT                (1 * 1024)

If you take a look at how CONFIG_BOARD_SIZE_LIMIT is used

	ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
	BOARD_SIZE_CHECK = \
	        @actual=`wc -c $@ | awk '{print $$1}'`; \
	        limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
	        if test $$actual -gt $$limit; then \
	                echo "$@ exceeds file size limit:" >&2 ; \
	                echo "  limit:  $$limit bytes" >&2 ; \
	                echo "  actual: $$actual bytes" >&2 ; \
	                echo "  excess: $$((actual - limit)) bytes" >&2; \
	                exit 1; \
	        fi
	else
	BOARD_SIZE_CHECK =
	endif

you will notice that there’s no arithmetic expansion on it prior to it being passed int a 'if -gt’ compare.

'git grep’ also shows that no other board is requesting an arithmetic expansion on this (i.e. everyone else just uses a constant).

Note that the C-preprocessor will not do arithmetic for you... So you’ll either have to change the Makefile or define this as an actual constant number.

Quoted 75 lines
include/configs/pico-imx7d.h +0 -0
 #define CONFIG_SYS_FSL_USDHC_NUM               2
 
 #define CONFIG_SYS_MMC_ENV_DEV                 0

It does build fine, but as I have intentionally forced a small CONFIG_BOARD_SIZE_LIMIT I wanted it to fail, but it does not fail as shown below:

OBJCOPY u-boot-nodtb.bin
/bin/sh: 1: arithmetic expression: expecting primary: ""(1 * 1024)""
SYM u-boot.sym
COPY u-boot.bin
MKIMAGE u-boot.img
===================== WARNING ======================
This board does not use CONFIG_DM_MMC. Please update
the board to use CONFIG_DM_MMC before the v2019.04 release. Failure to update by the deadline may result in board removal. See doc/driver-model/MIGRATION.txt for more info.
====================================================
===================== WARNING ======================
This board does not use CONFIG_DM_USB. Please update
the board to use CONFIG_DM_USB before the v2019.07 release. Failure to update by the deadline may result in board removal. See doc/driver-model/MIGRATION.txt for more info.
====================================================
CFGCHK u-boot.cfg

As you can see there are two issues:

1. The warnin: /bin/sh: 1: arithmetic expression: expecting primary:
""(1 * 1024)""

2. It should have not built in this case. It should have detected the overlap and signalized the error

Quoted 1 line

And please also the output of /"bin/sh --version".

$ /bin/sh --version
/bin/sh: 0: Illegal option --

In my system /bin/sh points to bash:

$ ls -al /bin/sh
lrwxrwxrwx 1 root root 4 mai  2  2018 /bin/sh -> dash

/bin/bash --version
GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

I am able to reproduce this problem with a standalone script:

$ cat random.sh
#!/bin/bash
echo $(($RANDOM % 10))
$ ./random.sh
3

Worked fine with bash.

Now if I force it to dash:

$ cat random.sh
#!/bin/dash
echo $(($RANDOM % 10))
$ ./random.sh
./random.sh: 2: ./random.sh: arithmetic expression: expecting primary: " % 10"

Which is the same warning I get in U-Boot.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

author reviewer
#25 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Hi Philipp,

Quoted 15 lines · Philipp Tomsich

If you take a look at how CONFIG_BOARD_SIZE_LIMIT is used

        ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
        BOARD_SIZE_CHECK = \
                @actual=`wc -c $@ | awk '{print $$1}'`; \
                limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
                if test $$actual -gt $$limit; then \
                        echo "$@ exceeds file size limit:" >&2 ; \
                        echo "  limit:  $$limit bytes" >&2 ; \
                        echo "  actual: $$actual bytes" >&2 ; \
                        echo "  excess: $$((actual - limit)) bytes" >&2; \
                        exit 1; \
                fi
        else
        BOARD_SIZE_CHECK =
        endif
Quoted 2 lines

you will notice that there’s no arithmetic expansion on it prior to it being passed int a 'if -gt’ compare.

Yes, this the current code. The patch Wolfgang submitted in this thread changed the Makefile.

Quoted 7 lines

'git grep’ also shows that no other board is requesting an arithmetic expansion on this (i.e. everyone else just uses a constant).

Note that the C-preprocessor will not do arithmetic for you... So you’ll either have to change the Makefile or define this as an actual constant number.

Yes, Wolfgang's patch changed the Makefile to allow arithmetic operation, but it does not work on my system.

author reviewer
#26 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

In reply to Fabio Estevam

Hi Wolfgang,

[Adding Andy]

Quoted 15 lines · Fabio Estevam

I am running top of tree mainline U-Boot + your patch from this thread, plus:

include/configs/pico-imx7d.h +2 -1
@@ -134,7 +134,8 @@
 /* FLASH and environment organization */
 #define CONFIG_ENV_SIZE                        SZ_8K
 
-#define CONFIG_ENV_OFFSET                      (8 * SZ_64K)
+#define CONFIG_ENV_OFFSET              (768 * 1024)
+#define CONFIG_BOARD_SIZE_LIMIT                (1 * 1024)
 #define CONFIG_SYS_FSL_USDHC_NUM               2
 
 #define CONFIG_SYS_MMC_ENV_DEV                 0
Quoted 6 lines

It does build fine, but as I have intentionally forced a small CONFIG_BOARD_SIZE_LIMIT I wanted it to fail, but it does not fail as shown below:

OBJCOPY u-boot-nodtb.bin
/bin/sh: 1: arithmetic expression: expecting primary: ""(1 * 1024)""

I read the link suggested by Andy Pont: https://wiki.ubuntu.com/DashAsBinSh

where it says:

"In Makefiles, you can set the following variable at the top:

SHELL = /bin/bash"

And by forcing the SHELL variable to bash, then your patch works fine here:

Makefile +1 -0
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+SHELL = /bin/bash
 VERSION = 2019
 PATCHLEVEL = 01
 SUBLEVEL =
#27 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Dear Fabio,

Quoted 2 lines · In message <CAOMZO5CnnmJrc9Y_9LQpxQYWQNcGeTUw=vgPtSpdmEPwavhU6g@mail.gmail.com>…
Quoted 2 lines

/bin/sh: 1: arithmetic expression: expecting primary: ""(1 * 1024)""

D*mn. I really thought I had tried this in a dash based environment, too. Sorry for causing such confusion.

Quoted 1 line

SHELL = /bin/bash"

Yes, if this is really a bash only feature that would be an easy way to fix it.

Quoted 1 line

And by forcing the SHELL variable to bash, then your patch works fine here:

Yes, this would work - but I'm not sure if everybody would appreciate such a change?

This should also work - replace the line

	@(echo $$(($(CONFIG_BOARD_SIZE_LIMIT))); wc -c $@ ) | \

by

	@(awk "END { print $$(echo $(CONFIG_BOARD_SIZE_LIMIT)) }" /dev/null; wc -c $@ ) | \

Can you please try this out?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Everyting looks interesting until you do it. Then you find it's  just
another job.                     - Terry Pratchett, _Moving Pictures_
author reviewer
#28 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Hi Wolfgang,

Quoted 10 lines · Wolfgang Denk

This should also work - replace the line

        @(echo $$(($(CONFIG_BOARD_SIZE_LIMIT))); wc -c $@ ) | \

by

        @(awk "END { print $$(echo $(CONFIG_BOARD_SIZE_LIMIT)) }" /dev/null; wc -c $@ ) | \

Can you please try this out?

I replaced it on the main Makefile and also in the imx one and it works as expected now.

When you send the v2, you can add:

Thanks

#29 lore raw

PATCH 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Dear Fabio,

Quoted 3 lines · In message <CAOMZO5BWH8g+h4pUBGzvgsS4Ae46kuREopx_0Fisyy7+KMq4Ug@mail.gmail.com>…

I replaced it on the main Makefile and also in the imx one and it works as expected now.

Thanks.

Quoted 3 lines

When you send the v2, you can add:

Done. Thanks for your patience.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Why should we subsidize intellectual curiosity?" - Ronald Reagan
#30 lore raw

PATCH v2 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

In reply to Wolfgang Denk

So far, the use of CONFIG_BOARD_SIZE_LIMIT would only work with plain numeric constants. Extend it to allow for expressions, so one can for example use

	#define CONFIG_BOARD_SIZE_LIMIT	(768 << 10)

in the board configuration.

Cc Fabio Estevam <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vanessa Maegima <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc John Weber <[email protected]>
Cc Stefan Roese <[email protected]>

---
v2: replace bashism for evaluating expressions in CONFIG_BOARD_SIZE_LIMIT
by another call to awk.

Note 1: As gawk lacks an eval function and we don't want to rely on
bash being used as shell, we use another call to awk to evaluate the expression. This has the disadvantage that we cannot use expressions like "<<" which awk does not understand. OK, one could replace awk by something better...

Note 2: This patch focusses on enabling this new feature. It does
not addres another issue that should be solved in a later
commit: the duplication of the same code in Makefile and arch/arm/mach-imx/Makefile

---
 Makefile                   | 17 ++++++++---------
 arch/arm/mach-imx/Makefile | 17 ++++++++---------
 2 files changed, 16 insertions(+), 18 deletions(-)
Makefile +8 -9
index 0d11ff9797..87eb0fd2b1 100644
@@ -774,15 +774,14 @@ LDPPFLAGS += \
 
 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
 BOARD_SIZE_CHECK = \
-	@actual=`wc -c $@ | awk '{print $$1}'`; \
-	limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
-	if test $$actual -gt $$limit; then \
-		echo "$@ exceeds file size limit:" >&2 ; \
-		echo "  limit:  $$limit bytes" >&2 ; \
-		echo "  actual: $$actual bytes" >&2 ; \
-		echo "  excess: $$((actual - limit)) bytes" >&2; \
-		exit 1; \
-	fi
+	@(awk "END{print $$(echo $(CONFIG_BOARD_SIZE_LIMIT))}" /dev/null; wc -c $@ ) | \
+	awk 'BEGIN { getline limit } \
+	{ if ($$1 > limit) { \
+		printf "%s exceeds file size limit:\n", $$2; \
+		printf "  limit:  %d bytes\n", limit; \
+		printf "  actual: %d bytes\n", $$1; \
+		printf "  excess: %d bytes\n", $$1 - limit; \
+		exit 1; } }'
 else
 BOARD_SIZE_CHECK =
 endif
arch/arm/mach-imx/Makefile +8 -9
index 53d9e5f42b..36d1ecc732 100644
@@ -60,15 +60,14 @@ endif
 
 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
 BOARD_SIZE_CHECK = \
-        @actual=`wc -c $@ | awk '{print $$1}'`; \
-        limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
-        if test $$actual -gt $$limit; then \
-                echo "$@ exceeds file size limit:" >&2 ; \
-                echo "  limit:  $$limit bytes" >&2 ; \
-                echo "  actual: $$actual bytes" >&2 ; \
-                echo "  excess: $$((actual - limit)) bytes" >&2; \
-                exit 1; \
-        fi
+	@(awk "END{print $$(echo $(CONFIG_BOARD_SIZE_LIMIT))}" /dev/null; wc -c $@ ) | \
+	awk 'BEGIN { getline limit } \
+	{ if ($$1 > limit) { \
+		printf "%s exceeds file size limit:\n", $$2; \
+		printf "  limit:  %d bytes\n", limit; \
+		printf "  actual: %d bytes\n", $$1; \
+		printf "  excess: %d bytes\n", $$1 - limit; \
+		exit 1; } }'
 else
 BOARD_SIZE_CHECK =
 endif
Signature · 1 line
2.19.2
#31 lore raw

PATCH v2 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Quoted 45 lines · Wolfgang Denk

So far, the use of CONFIG_BOARD_SIZE_LIMIT would only work with plain numeric constants. Extend it to allow for expressions, so one can for example use

	#define CONFIG_BOARD_SIZE_LIMIT	(768 << 10)

in the board configuration.

Cc Fabio Estevam <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vanessa Maegima <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc John Weber <[email protected]>
Cc Stefan Roese <[email protected]>

---
v2: replace bashism for evaluating expressions in CONFIG_BOARD_SIZE_LIMIT
by another call to awk.

Note 1: As gawk lacks an eval function and we don't want to rely on
bash being used as shell, we use another call to awk to evaluate the expression. This has the disadvantage that we cannot use expressions like "<<" which awk does not understand. OK, one could replace awk by something better...

Note 2: This patch focusses on enabling this new feature. It does
not addres another issue that should be solved in a later
commit: the duplication of the same code in Makefile and arch/arm/mach-imx/Makefile

---
 Makefile                   | 17 ++++++++---------
 arch/arm/mach-imx/Makefile | 17 ++++++++---------
 2 files changed, 16 insertions(+), 18 deletions(-)
Makefile +0 -0
index 0d11ff9797..87eb0fd2b1 100644
@@ -774,15 +774,14 @@ LDPPFLAGS += \
 
 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
 BOARD_SIZE_CHECK = \

Makefile LDPPFLAGS += \ · line 777

Quoted 10 lines
Makefile +1 -9
-	@actual=`wc -c $@ | awk '{print $$1}'`; \
-	limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
-	if test $$actual -gt $$limit; then \
-		echo "$@ exceeds file size limit:" >&2 ; \
-		echo "  limit:  $$limit bytes" >&2 ; \
-		echo "  actual: $$actual bytes" >&2 ; \
-		echo "  excess: $$((actual - limit)) bytes" >&2; \
-		exit 1; \
-	fi
+	@(awk "END{print $$(echo $(CONFIG_BOARD_SIZE_LIMIT))}" /dev/null; wc -c $@ ) | \

So this fails with awk being provided by mawk, not gawk:

$ mawk "END{print $(echo 0xE0000)}" /dev/null;
0
$ gawk "END{print $(echo 0xE0000)}" /dev/null;
917504

And then things fail as mawk doesn't like hex.

Now, at the end of the day, I'm now not sure I agree with this patch in concept. When CONFIG_BOARD_SIZE_LIMIT is moved to Kconfig it will be taking I would assume a hex input and so we don't have to worry about << at all.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181214/cafdb540/attachment.sig>
#32 lore raw

PATCH v2 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Tom,

Quoted 65 lines · Tom Rini
Quoted 45 lines · Wolfgang Denk

So far, the use of CONFIG_BOARD_SIZE_LIMIT would only work with plain numeric constants. Extend it to allow for expressions, so one can for example use

      #define CONFIG_BOARD_SIZE_LIMIT (768 << 10)

in the board configuration.

Cc Fabio Estevam <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vanessa Maegima <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc John Weber <[email protected]>
Cc Stefan Roese <[email protected]>

---
v2: replace bashism for evaluating expressions in CONFIG_BOARD_SIZE_LIMIT
by another call to awk.

Note 1: As gawk lacks an eval function and we don't want to rely on
bash being used as shell, we use another call to awk to evaluate the expression. This has the disadvantage that we cannot use expressions like "<<" which awk does not understand. OK, one could replace awk by something better...

Note 2: This patch focusses on enabling this new feature. It does
not addres another issue that should be solved in a later
commit: the duplication of the same code in Makefile and arch/arm/mach-imx/Makefile

---
 Makefile                   | 17 ++++++++---------
 arch/arm/mach-imx/Makefile | 17 ++++++++---------
 2 files changed, 16 insertions(+), 18 deletions(-)
Makefile +0 -0
index 0d11ff9797..87eb0fd2b1 100644
@@ -774,15 +774,14 @@ LDPPFLAGS += \
 
 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
 BOARD_SIZE_CHECK = \

Makefile LDPPFLAGS += \ · line 777

Quoted 10 lines
Makefile +1 -9
-     @actual=`wc -c $@ | awk '{print $$1}'`; \
-     limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
-     if test $$actual -gt $$limit; then \
-             echo "$@ exceeds file size limit:" >&2 ; \
-             echo "  limit:  $$limit bytes" >&2 ; \
-             echo "  actual: $$actual bytes" >&2 ; \
-             echo "  excess: $$((actual - limit)) bytes" >&2; \
-             exit 1; \
-     fi
+     @(awk "END{print $$(echo $(CONFIG_BOARD_SIZE_LIMIT))}" /dev/null; wc -c $@ ) | \

So this fails with awk being provided by mawk, not gawk:

$ mawk "END{print $(echo 0xE0000)}" /dev/null;
0
$ gawk "END{print $(echo 0xE0000)}" /dev/null;
917504
Quoted 6 lines

And then things fail as mawk doesn't like hex.

Now, at the end of the day, I'm now not sure I agree with this patch in concept. When CONFIG_BOARD_SIZE_LIMIT is moved to Kconfig it will be taking I would assume a hex input and so we don't have to worry about << at all.

Sorry to warm up an old thread, but I have some slightly new input on this.

I can understand you disliking the concept of this patch regarding U-Boot proper size check (if CONFIG_BOARD_SIZE_LIMIT moves to Kconfig).

However, I think for SPL this is different: SPL often starts with one single small SRAM shared for code + data. In this case, the size available for the SPL binary often can be calculated like this:

CONFIG_SPL_MAX_SIZE = SRAM_SIZE - SYS_MALLOC_F_LEN - GENERATED_GBL_DATA_SIZE - STACKSIZE;

Being like that, it cannot just be moved to Kconfig and by definition is not a hardcoded single hex number but changes depending on other options.

I see two ways out here:
a) continue the way of this patch until it works for all shells/awks or
b) implement SPL binary size check using 4 constants instead of 1 (see above)

I'm willing to code this through, as I am hitting this limit on socfpga, so I could need a decision ;-)

Regards,
Simon

#33 lore raw

PATCH v2 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Quoted 90 lines · Simon Goldschmidt

Tom,

Quoted 65 lines · Tom Rini
Quoted 45 lines · Wolfgang Denk

So far, the use of CONFIG_BOARD_SIZE_LIMIT would only work with plain numeric constants. Extend it to allow for expressions, so one can for example use

      #define CONFIG_BOARD_SIZE_LIMIT (768 << 10)

in the board configuration.

Cc Fabio Estevam <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Vanessa Maegima <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc John Weber <[email protected]>
Cc Stefan Roese <[email protected]>

---
v2: replace bashism for evaluating expressions in CONFIG_BOARD_SIZE_LIMIT
by another call to awk.

Note 1: As gawk lacks an eval function and we don't want to rely on
bash being used as shell, we use another call to awk to evaluate the expression. This has the disadvantage that we cannot use expressions like "<<" which awk does not understand. OK, one could replace awk by something better...

Note 2: This patch focusses on enabling this new feature. It does
not addres another issue that should be solved in a later
commit: the duplication of the same code in Makefile and arch/arm/mach-imx/Makefile

---
 Makefile                   | 17 ++++++++---------
 arch/arm/mach-imx/Makefile | 17 ++++++++---------
 2 files changed, 16 insertions(+), 18 deletions(-)
Makefile +0 -0
index 0d11ff9797..87eb0fd2b1 100644
@@ -774,15 +774,14 @@ LDPPFLAGS += \
 
 ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
 BOARD_SIZE_CHECK = \

Makefile LDPPFLAGS += \ · line 777

Quoted 10 lines
Makefile +1 -9
-     @actual=`wc -c $@ | awk '{print $$1}'`; \
-     limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
-     if test $$actual -gt $$limit; then \
-             echo "$@ exceeds file size limit:" >&2 ; \
-             echo "  limit:  $$limit bytes" >&2 ; \
-             echo "  actual: $$actual bytes" >&2 ; \
-             echo "  excess: $$((actual - limit)) bytes" >&2; \
-             exit 1; \
-     fi
+     @(awk "END{print $$(echo $(CONFIG_BOARD_SIZE_LIMIT))}" /dev/null; wc -c $@ ) | \

So this fails with awk being provided by mawk, not gawk:

$ mawk "END{print $(echo 0xE0000)}" /dev/null;
0
$ gawk "END{print $(echo 0xE0000)}" /dev/null;
917504
Quoted 6 lines

And then things fail as mawk doesn't like hex.

Now, at the end of the day, I'm now not sure I agree with this patch in concept. When CONFIG_BOARD_SIZE_LIMIT is moved to Kconfig it will be taking I would assume a hex input and so we don't have to worry about << at all.

Sorry to warm up an old thread, but I have some slightly new input on this.

I can understand you disliking the concept of this patch regarding U-Boot proper size check (if CONFIG_BOARD_SIZE_LIMIT moves to Kconfig).

However, I think for SPL this is different: SPL often starts with one single small SRAM shared for code + data. In this case, the size available for the SPL binary often can be calculated like this:

CONFIG_SPL_MAX_SIZE = SRAM_SIZE - SYS_MALLOC_F_LEN - GENERATED_GBL_DATA_SIZE - STACKSIZE;

Being like that, it cannot just be moved to Kconfig and by definition is not a hardcoded single hex number but changes depending on other options.

Quoted 6 lines

I see two ways out here:
a) continue the way of this patch until it works for all shells/awks or
b) implement SPL binary size check using 4 constants instead of 1 (see above)

I'm willing to code this through, as I am hitting this limit on socfpga, so I could need a decision ;-)

OK, so a few thoughts here.
- What's the portable way to do hex-based math? If we really need it?
- Really, CONFIG_{SPL,TPL}_MAX_SIZE is not user configurable, it's the SoC/design imposed limit. CONFIG_BOARD_MAX_SIZE is somewhat configurable as that tends to also include "don't grow past X or we overwrite Y and break things".

Part of the problem area is that we need to take N values, which are #defined, and use that to see if our final result is too large. Prior to needing device tree stuff, OK, we can get the linker on our side to enforce this (well enough that we can fudge the rest, ie artificially lower SRAM size a little and comment on why). With DTBs and such, we need to take a look at the final result too, of each stage.

So yes, I think we need to figure out some portable way to deal with checking all constants. And we'll Kconfig what we can/should Kconfig, and #define what we need to define and (ugh) calculate and use what must be done that way. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190308/97e12096/attachment.sig>
#34 lore raw

PATCH v2 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Quoted 2 lines · Tom Rini

OK, so a few thoughts here.
- What's the portable way to do hex-based math? If we really need it?

Use printf(3) to convert to/from hex, and standard shell arithmetic with $(( )).

Looks horrible, but something like:

v=$(( $( printf "%d\n" 0xa0 ) + $( printf "%d\n" 0x10 ) )) printf "v = %d (%x)\n" $v $v

... maybe arranged into some sh helper functions.

Martin

#35 lore raw

PATCH v2 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Quoted 8 lines · Martin Husemann
Quoted 2 lines · Tom Rini

OK, so a few thoughts here.
- What's the portable way to do hex-based math? If we really need it?

Quoted 7 lines

Use printf(3) to convert to/from hex, and standard shell arithmetic with $(( )).

Looks horrible, but something like:

v=$(( $( printf "%d\n" 0xa0 ) + $( printf "%d\n" 0x10 ) )) printf "v = %d (%x)\n" $v $v

Can we just assume that awk is available? After all, AWK is defined in the top-level Makefile...

Quoted 9 lines

... maybe arranged into some sh helper functions.

Martin
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#36 lore raw

PATCH v2 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Philipp Tomsich <[email protected]> schrieb am Fr., 8. März 2019, 18:53:

Quoted 11 lines
Quoted 11 lines · Martin Husemann
Quoted 2 lines · Tom Rini

OK, so a few thoughts here.
- What's the portable way to do hex-based math? If we really need it?

Use printf(3) to convert to/from hex, and standard shell arithmetic with $(( )).

Quoted 8 lines
Quoted 4 lines

Looks horrible, but something like:

v=$(( $( printf "%d\n" 0xa0 ) + $( printf "%d\n" 0x10 ) )) printf "v = %d (%x)\n" $v $v

Can we just assume that awk is available? After all, AWK is defined in the top-level Makefile...

I guess we can, but see Toms mail from mid of December: not all awk flavours seem to supper hey numbers. So I guess the next round on this patch should try to test different shells as well as different awk's...

Regards,
Simon

#37 lore raw

PATCH v2 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

In reply to Philipp Tomsich
Quoted 11 lines · Philipp Tomsich
Quoted 11 lines · Martin Husemann
Quoted 2 lines · Tom Rini

OK, so a few thoughts here.
- What's the portable way to do hex-based math? If we really need it?

Use printf(3) to convert to/from hex, and standard shell arithmetic with $(( )).

Quoted 7 lines
Quoted 4 lines

Looks horrible, but something like:

v=$(( $( printf "%d\n" 0xa0 ) + $( printf "%d\n" 0x10 ) )) printf "v = %d (%x)\n" $v $v

Can we just assume that awk is available? After all, AWK is defined in the top-level Makefile...

No, we can't exactly. In sum, gawk and mawk behave differently and mawk doesn't do hex and yes, we run into that in the wild. Whatever we do here needs to be POSIX shell happy (or something more strict than that?) as it needs to work on macOS and Free/Net/OpenBSD and anything else that we can otherwise be building on.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190308/9587c88d/attachment.sig>
#38 lore raw

PATCH v2 1/1 Enable expression support for CONFIG_BOARD_SIZE_LIMIT

In reply to Martin Husemann
Quoted 7 lines · Martin Husemann
Quoted 2 lines · Tom Rini

OK, so a few thoughts here.
- What's the portable way to do hex-based math? If we really need it?

Use printf(3) to convert to/from hex, and standard shell arithmetic with $(( )).

Quoted 7 lines

Looks horrible, but something like:

v=$(( $( printf "%d\n" 0xa0 ) + $( printf "%d\n" 0x10 ) )) printf "v = %d (%x)\n" $v $v

... maybe arranged into some sh helper functions.

dash, bash, mksh, zsh, all ksh-compatible shells in fact, support hex numbers on arithmetic expressions, no need for conversion.

author reviewer
#39 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

In reply to Fabio Estevam

Hi Stefano,

Quoted 11 lines · Fabio Estevam

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.

Also, in order to prevent this same problem in the future, use CONFIG_BOARD_SIZE_LIMIT, which will detect the overlap in build-time.

Quoted 8 lines

CONFIG_BOARD_SIZE_LIMIT does not accept math expressions, so declare CONFIG_ENV_OFFSET with its direct value instead.

---
Changes since v3:
- Take the 69k u-boot.img offset into account when calculating CONFIG_BOARD_SIZE_LIMIT (Wolfgang)

Could you please consider applying this version?

Wolfgang's patch causes breakage on some systems as reported by Tom and I would prefer we fix the critical problem soon independently of Wolgang's fix.

Thanks

#40 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Quoted 23 lines · Fabio Estevam

Hi Stefano,

Quoted 11 lines · Fabio Estevam

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.

Also, in order to prevent this same problem in the future, use CONFIG_BOARD_SIZE_LIMIT, which will detect the overlap in build-time.

Quoted 8 lines

CONFIG_BOARD_SIZE_LIMIT does not accept math expressions, so declare CONFIG_ENV_OFFSET with its direct value instead.

---
Changes since v3:
- Take the 69k u-boot.img offset into account when calculating CONFIG_BOARD_SIZE_LIMIT (Wolfgang)

Quoted 5 lines

Could you please consider applying this version?

Wolfgang's patch causes breakage on some systems as reported by Tom and I would prefer we fix the critical problem soon independently of Wolgang's fix.

Yes, I agree with you - we could have a follow up patch when Wolfgang's patch will be merged.

Best regards,
Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
author reviewer
#41 lore raw

PATCH v4 1/1 pico-imx7d: Increase the CONFIG_ENV_OFFSET size

Hi Stefano,

Quoted 2 lines · Stefano Babic

Yes, I agree with you - we could have a follow up patch when Wolfgang's patch will be merged.

Yes, I will send a follow up patch after Wolfgang's patch is accepted.

Thanks