[PATCH] ubifs: allow loading to above 4GiB

Heiko Schocher hs at denx.de
Mon Jun 5 09:45:24 CEST 2023


Hello Ben,

On 10.05.23 15:41, Ben Dooks wrote:
> The ubifsload command is truncating any address above 4GiB as it casts
> this address to an u32, instead of using an unsigned long which most of
> the other load commands do. Change this to an unsigned long to allow
> loading into high memory for boards which use these areas.
> 
> Fixes the following error:
> 
> => ubifsload 0x2100000000 /boot/Image.lzma
> Loading file '/boot/Image.lzma' to addr 0x00000000...
> Unhandled exception: Store/AMO access fault
> 
> Signed-off-by: Ben Dooks <ben.dooks at sifive.com>
> ---
>  cmd/ubifs.c           | 2 +-
>  fs/ubifs/ubifs.c      | 4 ++--
>  include/ubifs_uboot.h | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)

just started azure build and it drops errors:

https://dev.azure.com/hs0298/hs/_build/results?buildId=105&view=results

for example
https://dev.azure.com/hs0298/hs/_build/results?buildId=103&view=results

2023-06-05T07:34:39.9304987Z + tools/buildman/buildman -o /tmp/vexpress_ca9x4 -w -E -W -e --board
vexpress_ca9x4
2023-06-05T07:34:45.4735755Z Building current source for 1 boards (1 thread, 2 jobs per thread)
2023-06-05T07:34:45.4735947Z
2023-06-05T07:34:45.4736063Z Starting build...
2023-06-05T07:34:45.4736188Z
2023-06-05T07:34:45.4736233Z
2023-06-05T07:35:02.4142452Z     0    0    0 /1       -1      (starting)
2023-06-05T07:35:02.4150636Z
2023-06-05T07:35:02.4150787Z        arm:  +   vexpress_ca9x4
2023-06-05T07:35:02.4150964Z +In file included from include/linux/printk.h:4,
2023-06-05T07:35:02.4151140Z +                 from include/common.h:20,
2023-06-05T07:35:02.4152527Z +                 from cmd/ubifs.c:14:
2023-06-05T07:35:02.4152796Z +cmd/ubifs.c: In function 'do_ubifs_load':
2023-06-05T07:35:02.4153181Z +cmd/ubifs.c:136:15: error: format '%x' expects argument of type
'unsigned int', but argument 3 has type 'long unsigned int' [-Werror=format=]
2023-06-05T07:35:02.4153550Z +  136 |         debug("Loading file '%s' to address 0x%08x (size
%d)\n", filename, addr, size);
2023-06-05T07:35:02.4153758Z +      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2023-06-05T07:35:02.4154045Z +include/log.h:155:21: note: in definition of macro 'pr_fmt'
2023-06-05T07:35:02.4154220Z +  155 | #define pr_fmt(fmt) fmt
2023-06-05T07:35:02.4154344Z +      |                     ^~~
2023-06-05T07:35:02.4154571Z +include/log.h:272:9: note: in expansion of macro 'debug_cond'
2023-06-05T07:35:02.4155974Z +  272 |         debug_cond(_DEBUG, fmt, ##args)
2023-06-05T07:35:02.4156144Z +      |         ^~~~~~~~~~
2023-06-05T07:35:02.4156393Z +cmd/ubifs.c:136:9: note: in expansion of macro 'debug'
2023-06-05T07:35:02.4156541Z +      |         ^~~~~
2023-06-05T07:35:02.4156769Z +cmd/ubifs.c:136:50: note: format string is defined here
2023-06-05T07:35:02.4156947Z +      |                                               ~~~^
2023-06-05T07:35:02.4157068Z +      |                                                  |
2023-06-05T07:35:02.4157202Z +      |                                                  unsigned int
2023-06-05T07:35:02.4157341Z +      |                                               %08lx
2023-06-05T07:35:02.4157475Z +cc1: all warnings being treated as errors
2023-06-05T07:35:02.4157660Z +make[2]: *** [scripts/Makefile.build:256: cmd/ubifs.o] Error 1
2023-06-05T07:35:02.4157845Z +make[1]: *** [Makefile:1853: cmd] Error 2
2023-06-05T07:35:02.4158061Z +make: *** [Makefile:177: sub-make] Error 2

Please fix it, thanks!

bye,
Heiko
> 
> diff --git a/cmd/ubifs.c b/cmd/ubifs.c
> index 6a01d0988a..33fff6500e 100644
> --- a/cmd/ubifs.c
> +++ b/cmd/ubifs.c
> @@ -111,7 +111,7 @@ static int do_ubifs_load(struct cmd_tbl *cmdtp, int flag, int argc,
>  	char *filename;
>  	char *endp;
>  	int ret;
> -	u32 addr;
> +	unsigned long addr;
>  	u32 size = 0;
>  
>  	if (!ubifs_mounted) {
> diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
> index d3026e3101..609bdbf603 100644
> --- a/fs/ubifs/ubifs.c
> +++ b/fs/ubifs/ubifs.c
> @@ -925,12 +925,12 @@ void ubifs_close(void)
>  }
>  
>  /* Compat wrappers for common/cmd_ubifs.c */
> -int ubifs_load(char *filename, u32 addr, u32 size)
> +int ubifs_load(char *filename, unsigned long addr, u32 size)
>  {
>  	loff_t actread;
>  	int err;
>  
> -	printf("Loading file '%s' to addr 0x%08x...\n", filename, addr);
> +	printf("Loading file '%s' to addr 0x%08lx...\n", filename, addr);
>  
>  	err = ubifs_read(filename, (void *)(uintptr_t)addr, 0, size, &actread);
>  	if (err == 0) {
> diff --git a/include/ubifs_uboot.h b/include/ubifs_uboot.h
> index b025779d59..db8a29e9bb 100644
> --- a/include/ubifs_uboot.h
> +++ b/include/ubifs_uboot.h
> @@ -21,7 +21,7 @@ int ubifs_init(void);
>  int uboot_ubifs_mount(char *vol_name);
>  void uboot_ubifs_umount(void);
>  int ubifs_is_mounted(void);
> -int ubifs_load(char *filename, u32 addr, u32 size);
> +int ubifs_load(char *filename, unsigned long addr, u32 size);
>  
>  int ubifs_set_blk_dev(struct blk_desc *rbdd, struct disk_partition *info);
>  int ubifs_ls(const char *dir_name);
> 

-- 
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de


More information about the U-Boot mailing list