[U-Boot] [PATCH] Enable expression support for CONFIG_BOARD_SIZE_LIMIT

Philipp Tomsich philipp.tomsich at theobroma-systems.com
Thu Dec 6 14:50:20 UTC 2018


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)...

> On 06.12.2018, at 15:41, Fabio Estevam <festevam at gmail.com> wrote:
> 
> Hi Wolfgang,
> 
> On Thu, Dec 6, 2018 at 12:23 PM Wolfgang Denk <wd at denx.de> wrote:
> 
>> 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:
> 
> --- a/include/configs/pico-imx7d.h
> +++ b/include/configs/pico-imx7d.h
> @@ -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.

> #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
> 
>> 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



More information about the U-Boot mailing list