Skip to contentSkip to conversation

ubifs: allow loading to above 4GiB

PATCH Superseded Ben Dooks 3 participants 4 messages May 10, 2023 – Jun 6, 2023 UBI file system (UBIFS)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH 1/1 ubifs: allow loading to above 4GiB

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

---
 cmd/ubifs.c           | 2 +-
 fs/ubifs/ubifs.c      | 4 ++--
 include/ubifs_uboot.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
cmd/ubifs.c +1 -1
index 6a01d0988a..33fff6500e 100644
@@ -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) {
fs/ubifs/ubifs.c +2 -2
index d3026e3101..609bdbf603 100644
@@ -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) {
include/ubifs_uboot.h +1 -1
index b025779d59..db8a29e9bb 100644
@@ -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);
Signature · 1 line
2.39.2
#1 lore raw

Hello Ben,

Quoted 11 lines · Ben Dooks

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

Quoted 6 lines
---
 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

Quoted 47 lines
cmd/ubifs.c +1 -1
index 6a01d0988a..33fff6500e 100644
@@ -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) {
fs/ubifs/ubifs.c +2 -2
index d3026e3101..609bdbf603 100644
@@ -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) {
include/ubifs_uboot.h +1 -1
index b025779d59..db8a29e9bb 100644
@@ -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);
Signature · 3 lines
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: [email protected]
#2 lore raw
Quoted 65 lines · Heiko Schocher

Hello Ben,

Quoted 11 lines · Ben Dooks

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

Quoted 6 lines
---
  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
Quoted 1 line

Please fix it, thanks!

I've just sent v2 with the debug print sorted.

Signature · 4 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html
#3 lore raw

Hello Ben,

Quoted 66 lines · Ben Dooks
Quoted 65 lines · Heiko Schocher

Hello Ben,

Quoted 11 lines · Ben Dooks

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

Quoted 6 lines

---
  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
Quoted 3 lines
Quoted 1 line

Please fix it, thanks!

I've just sent v2 with the debug print sorted.

Yep, saw it, azure build runs:

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

Thanks!

bye,
Heiko

Signature · 3 lines
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: [email protected]