Skip to contentSkip to conversation

Various minor fixes

PATCH Superseded Simon Glass 3 participants 10 messages Jan 16, 2021 – Jan 18, 2021

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Various minor fixes

This series collects a few minor fixes and improvements that have been hanging around in a branch for a while.

Simon Glass (7):
spl: Drop duplicate 'Jumping to U-Boot' message
binman: Indicate how to make binman verbose
doc: Add a note about how to produce 'md' output using hexdump
s5p4418_nanopi2: Bring in some dead code
sandbox: Avoid using malloc() for system state
sandbox: Write out bloblist when existing
bootm: Fix duplicate debugging in bootm_process_cmdline()

 Makefile                              |  1 +
 README                                |  4 ++++
 arch/arm/mach-nexell/Makefile         |  2 +-
 arch/arm/mach-nexell/cmd_boot_linux.c | 14 ++++++++------
 arch/sandbox/cpu/state.c              | 21 +++++++++++++--------
 common/bootm.c                        |  2 +-
 common/spl/spl.c                      |  1 -
 tools/binman/README                   |  4 +++-
 8 files changed, 31 insertions(+), 18 deletions(-)
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
#1 lore raw

PATCH 1/7 spl: Drop duplicate 'Jumping to U-Boot' message

This is printed twice but we only need one message, since there is very little processing in between them. Drop the first one.

---

 common/spl/spl.c | 1 -
 1 file changed, 1 deletion(-)
common/spl/spl.c +0 -1
index 12b00e2a407..7fe0812799f 100644
@@ -693,7 +693,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 #endif
 	switch (spl_image.os) {
 	case IH_OS_U_BOOT:
-		debug("Jumping to U-Boot\n");
 		break;
 #if CONFIG_IS_ENABLED(ATF)
 	case IH_OS_ARM_TRUSTED_FIRMWARE:
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
#2 lore raw

PATCH 2/7 binman: Indicate how to make binman verbose

In reply to Simon Glass

Add notes about how to make binman produce verbose logging when building.

Add a comment on how to do this.

---

 Makefile            | 1 +
 tools/binman/README | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)
Makefile +1 -0
index c2b7046ce3b..66f441f23aa 100644
@@ -1326,6 +1326,7 @@ u-boot.ldr:	u-boot
 # binman
 # ---------------------------------------------------------------------------
 # Use 'make BINMAN_DEBUG=1' to enable debugging
+# Use 'make BINMAN_VERBOSE=3' to set vebosity level
 default_dt := $(if $(DEVICE_TREE),$(DEVICE_TREE),$(CONFIG_DEFAULT_DEVICE_TREE))
 quiet_cmd_binman = BINMAN  $@
 cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \
tools/binman/README +3 -1
index a00c9026163..45f0a0c2cd3 100644
@@ -637,7 +637,8 @@ Logging
 
 Binman normally operates silently unless there is an error, in which case it
 just displays the error. The -D/--debug option can be used to create a full
-backtrace when errors occur.
+backtrace when errors occur. You can use BINMAN_DEBUG=1 when building to select
+this.
 
 Internally binman logs some output while it is running. This can be displayed
 by increasing the -v/--verbosity from the default of 1:
@@ -649,6 +650,7 @@ by increasing the -v/--verbosity from the default of 1:
    4: detailed information about each operation
    5: debug (all output)
 
+You can use BINMAN_VERBOSE=5 (for example) when building to select this.
 
 Hashing Entries
 ---------------
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
#3 lore raw

PATCH 3/7 doc: Add a note about how to produce 'md' output using hexdump

In reply to Simon Glass

Comparing a hex dump on the U-Boot command line with the contents of a file on the host system is fairly easy and convenient to do manually if it is small. But the format used hexdump by default differs from that shown by U-Boot. Add a note about how to make them the same.

(For large dumps, writing the data to the network with tftpput, or to a USB stick with ext4save is easiest.)

---

 README | 4 ++++
 1 file changed, 4 insertions(+)
README +4 -0
index afa33dc7f30..582bfb00348 100644
@@ -3274,6 +3274,10 @@ TODO.
 
 For now: just type "help <command>".
 
+Note that the format of 'md' can be emulated from linux with:
+
+   hexdump -v -e '"%08.8_ax: " 16/1 "%02x " "   "' -e '16/1 "%_p" "\n" ' fname
+
 
 Environment Variables:
 ======================
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
#4 lore raw

PATCH 4/7 s5p4418_nanopi2: Bring in some dead code

In reply to Simon Glass

This code is still using the old command typedef. It was not noticed since this file is not currently built. It is using a non-existent option in the Makefile.

Fix it up and add it to the build.

(This is offered as an act of service in the hope of receiving a free beer at some point.)

---

 arch/arm/mach-nexell/Makefile         |  2 +-
 arch/arm/mach-nexell/cmd_boot_linux.c | 14 ++++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)
arch/arm/mach-nexell/Makefile +1 -1
index 10b3963ed10..8113624cac3 100644
@@ -10,4 +10,4 @@ obj-y				+= nx_gpio.o
 obj-y				+= tieoff.o
 obj-$(CONFIG_ARCH_S5P4418)	+= reg-call.o
 obj-$(CONFIG_ARCH_S5P4418)	+= nx_sec_reg.o
-obj-$(CONFIG_CMD_BOOTL)		+= cmd_boot_linux.o
+obj-y				+= cmd_boot_linux.o
arch/arm/mach-nexell/cmd_boot_linux.c +8 -6
index f2dedfe1625..730550cd389 100644
@@ -5,11 +5,13 @@
  */
 
 #include <common.h>
+#include <bootstage.h>
 #include <bootm.h>
 #include <command.h>
-#include <environment.h>
+#include <env.h>
 #include <errno.h>
 #include <image.h>
+#include <log.h>
 #include <fdt_support.h>
 
 #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_CLI_FRAMEWORK)
@@ -18,7 +20,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static bootm_headers_t linux_images;
 
-static void boot_go_set_os(cmd_tbl_t *cmdtp, int flag, int argc,
+static void boot_go_set_os(struct cmd_tbl *cmdtp, int flag, int argc,
 			   char * const argv[],
 			   bootm_headers_t *images)
 {
@@ -66,8 +68,8 @@ static void boot_start_lmb(bootm_headers_t *images)
 
 	lmb_init(&images->lmb);
 
-	mem_start = getenv_bootm_low();
-	mem_size = getenv_bootm_size();
+	mem_start = env_get_bootm_low();
+	mem_size = env_get_bootm_size();
 
 	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
 
@@ -79,7 +81,7 @@ static void boot_start_lmb(bootm_headers_t *images)
 static inline void boot_start_lmb(bootm_headers_t *images) { }
 #endif
 
-int do_boot_linux(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_boot_linux(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
 {
 	boot_os_fn *boot_fn;
 	bootm_headers_t *images = &linux_images;
@@ -126,7 +128,7 @@ U_BOOT_CMD(bootl, CONFIG_SYS_MAXARGS, 1, do_boot_linux,
 #endif
 
 #if defined(CONFIG_CMD_BOOTD) && !defined(CONFIG_CMD_BOOTM)
-int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_bootd(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
 {
 	return run_command(env_get("bootcmd"), flag);
 }
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
#5 lore raw

PATCH 4/7 s5p4418_nanopi2: Bring in some dead code

Hi Simon,

thanks a lot for your patch. I have just applied and tested it with the NanoPC-T2 board (is similar to the NanoPi2-board and therefore s5p4418_nanopi2_defconfig can be used). Unfortunately the bootl-cmd is not working out of the box:
nanopi2# bootl
FDT and ATAGS support not compiled in - hanging
### ERROR ### Please RESET the board ###

Therefore my suggestion is to remove cmd_boot_linux.c since the bootl-cmd is not required (friendlyARM's LUbuntu is booted by the bootz-cmd).

Regards
Stefan

Quoted 84 lines · Simon Glass

This code is still using the old command typedef. It was not noticed since this file is not currently built. It is using a non-existent option in the Makefile.

Fix it up and add it to the build.

(This is offered as an act of service in the hope of receiving a free beer at some point.)

---

  arch/arm/mach-nexell/Makefile         |  2 +-
  arch/arm/mach-nexell/cmd_boot_linux.c | 14 ++++++++------
  2 files changed, 9 insertions(+), 7 deletions(-)
arch/arm/mach-nexell/Makefile +1 -1
index 10b3963ed10..8113624cac3 100644
@@ -10,4 +10,4 @@ obj-y				+= nx_gpio.o
  obj-y				+= tieoff.o
  obj-$(CONFIG_ARCH_S5P4418)	+= reg-call.o
  obj-$(CONFIG_ARCH_S5P4418)	+= nx_sec_reg.o
-obj-$(CONFIG_CMD_BOOTL)		+= cmd_boot_linux.o
+obj-y				+= cmd_boot_linux.o
arch/arm/mach-nexell/cmd_boot_linux.c +8 -6
index f2dedfe1625..730550cd389 100644
@@ -5,11 +5,13 @@
   */
 
  #include <common.h>
+#include <bootstage.h>
  #include <bootm.h>
  #include <command.h>
-#include <environment.h>
+#include <env.h>
  #include <errno.h>
  #include <image.h>
+#include <log.h>
  #include <fdt_support.h>
 
  #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_CLI_FRAMEWORK)
@@ -18,7 +20,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
  static bootm_headers_t linux_images;
 
-static void boot_go_set_os(cmd_tbl_t *cmdtp, int flag, int argc,
+static void boot_go_set_os(struct cmd_tbl *cmdtp, int flag, int argc,
  			   char * const argv[],
  			   bootm_headers_t *images)
  {
@@ -66,8 +68,8 @@ static void boot_start_lmb(bootm_headers_t *images)
 
  	lmb_init(&images->lmb);
 
-	mem_start = getenv_bootm_low();
-	mem_size = getenv_bootm_size();
+	mem_start = env_get_bootm_low();
+	mem_size = env_get_bootm_size();
 
  	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
 
@@ -79,7 +81,7 @@ static void boot_start_lmb(bootm_headers_t *images)
  static inline void boot_start_lmb(bootm_headers_t *images) { }
  #endif
 
-int do_boot_linux(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_boot_linux(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
  {
  	boot_os_fn *boot_fn;
  	bootm_headers_t *images = &linux_images;
@@ -126,7 +128,7 @@ U_BOOT_CMD(bootl, CONFIG_SYS_MAXARGS, 1, do_boot_linux,
  #endif
 
  #if defined(CONFIG_CMD_BOOTD) && !defined(CONFIG_CMD_BOOTM)
-int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_bootd(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
  {
  	return run_command(env_get("bootcmd"), flag);
  }
#6 lore raw

PATCH 5/7 sandbox: Avoid using malloc() for system state

In reply to Simon Glass

This state is not accessible to the running U-Boot but at present it is allocated in the emulated SDRAM. This doesn't seem very useful. Adjust it to allocate from the OS instead.

---

 arch/sandbox/cpu/state.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
arch/sandbox/cpu/state.c +8 -8
index b2901b7a8ca..f9b4b4c045e 100644
@@ -29,17 +29,17 @@ static int state_ensure_space(int extra_size)
 		return 0;
 
 	size = used + extra_size;
-	buf = malloc(size);
+	buf = os_malloc(size);
 	if (!buf)
 		return -ENOMEM;
 
 	ret = fdt_open_into(blob, buf, size);
 	if (ret) {
-		free(buf);
+		os_free(buf);
 		return -EIO;
 	}
 
-	free(blob);
+	os_free(blob);
 	state->state_fdt = buf;
 	return 0;
 }
@@ -55,7 +55,7 @@ static int state_read_file(struct sandbox_state *state, const char *fname)
 		printf("Cannot find sandbox state file '%s'\n", fname);
 		return -ENOENT;
 	}
-	state->state_fdt = malloc(size);
+	state->state_fdt = os_malloc(size);
 	if (!state->state_fdt) {
 		puts("No memory to read sandbox state\n");
 		return -ENOMEM;
@@ -77,7 +77,7 @@ static int state_read_file(struct sandbox_state *state, const char *fname)
 err_read:
 	os_close(fd);
 err_open:
-	free(state->state_fdt);
+	os_free(state->state_fdt);
 	state->state_fdt = NULL;
 
 	return ret;
@@ -244,7 +244,7 @@ int sandbox_write_state(struct sandbox_state *state, const char *fname)
 	/* Create a state FDT if we don't have one */
 	if (!state->state_fdt) {
 		size = 0x4000;
-		state->state_fdt = malloc(size);
+		state->state_fdt = os_malloc(size);
 		if (!state->state_fdt) {
 			puts("No memory to create FDT\n");
 			return -ENOMEM;
@@ -302,7 +302,7 @@ int sandbox_write_state(struct sandbox_state *state, const char *fname)
 err_write:
 	os_close(fd);
 err_create:
-	free(state->state_fdt);
+	os_free(state->state_fdt);
 
 	return ret;
 }
@@ -420,7 +420,7 @@ int state_uninit(void)
 		os_unlink(state->jumped_fname);
 
 	if (state->state_fdt)
-		free(state->state_fdt);
+		os_free(state->state_fdt);
 	memset(state, '\0', sizeof(*state));
 
 	return 0;
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
#7 lore raw

PATCH 5/7 sandbox: Avoid using malloc() for system state

Quoted 72 lines · Simon Glass

This state is not accessible to the running U-Boot but at present it is allocated in the emulated SDRAM. This doesn't seem very useful. Adjust it to allocate from the OS instead.

---

  arch/sandbox/cpu/state.c | 16 ++++++++--------
  1 file changed, 8 insertions(+), 8 deletions(-)
arch/sandbox/cpu/state.c +7 -7
index b2901b7a8ca..f9b4b4c045e 100644
@@ -29,17 +29,17 @@ static int state_ensure_space(int extra_size)
  		return 0;
 
  	size = used + extra_size;
-	buf = malloc(size);
+	buf = os_malloc(size);
  	if (!buf)
  		return -ENOMEM;
 
  	ret = fdt_open_into(blob, buf, size);
  	if (ret) {
-		free(buf);
+		os_free(buf);
  		return -EIO;
  	}
 
-	free(blob);
+	os_free(blob);
  	state->state_fdt = buf;
  	return 0;
  }
@@ -55,7 +55,7 @@ static int state_read_file(struct sandbox_state *state, const char *fname)
  		printf("Cannot find sandbox state file '%s'\n", fname);
  		return -ENOENT;
  	}
-	state->state_fdt = malloc(size);
+	state->state_fdt = os_malloc(size);
  	if (!state->state_fdt) {
  		puts("No memory to read sandbox state\n");
  		return -ENOMEM;
@@ -77,7 +77,7 @@ static int state_read_file(struct sandbox_state *state, const char *fname)
  err_read:
  	os_close(fd);
  err_open:
-	free(state->state_fdt);
+	os_free(state->state_fdt);
  	state->state_fdt = NULL;
 
  	return ret;
@@ -244,7 +244,7 @@ int sandbox_write_state(struct sandbox_state *state, const char *fname)
  	/* Create a state FDT if we don't have one */
  	if (!state->state_fdt) {
  		size = 0x4000;
-		state->state_fdt = malloc(size);
+		state->state_fdt = os_malloc(size);
  		if (!state->state_fdt) {
  			puts("No memory to create FDT\n");
  			return -ENOMEM;
@@ -302,7 +302,7 @@ int sandbox_write_state(struct sandbox_state *state, const char *fname)
  err_write:
  	os_close(fd);
  err_create:
-	free(state->state_fdt);
+	os_free(state->state_fdt);
 
  	return ret;
  }

arch/sandbox/cpu/state.c int state_uninit(void) · line 422

Quoted 3 lines
arch/sandbox/cpu/state.c +0 -0
@@ -420,7 +420,7 @@ int state_uninit(void)
  		os_unlink(state->jumped_fname);
 
  	if (state->state_fdt)

This if is superfluous. os_free() checks for NULL.

     os_free(state->ram_buf);

is missing here.

Best regards

Heinrich

Quoted 6 lines
arch/sandbox/cpu/state.c +1 -1
-		free(state->state_fdt);
+		os_free(state->state_fdt);
  	memset(state, '\0', sizeof(*state));
 
  	return 0;
#8 lore raw

PATCH 6/7 sandbox: Write out bloblist when existing

In reply to Simon Glass

Sandbox provides a way to write out its emulated memory on exit. This makes it possible to pass a bloblist from one phase (e.g. SPL) to the next.

However the bloblist is not closed off, so the checksum is generally invalid. Fix this by finishing up the bloblist before writing the memory file.

---

 arch/sandbox/cpu/state.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/sandbox/cpu/state.c +5 -0
index f9b4b4c045e..f9919149103 100644
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <bloblist.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <log.h>
@@ -398,8 +399,12 @@ int state_uninit(void)
 {
 	int err;
 
+	log_info("Writing sandbox state\n");
 	state = &main_state;
 
+	/* Finish the bloblist, so that it is correct before writing memory */
+	bloblist_finish();
+
 	if (state->write_ram_buf) {
 		err = os_write_ram_buf(state->ram_buf_fname);
 		if (err) {
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog
#9 lore raw

PATCH 7/7 bootm: Fix duplicate debugging in bootm_process_cmdline()

In reply to Simon Glass

These two returns use the same string so are not distinguishable with LOG_ERROR_RETURN. Fix it.

---

 common/bootm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/bootm.c +1 -1
index 8298693900d..48a5b04cd7a 100644
@@ -585,7 +585,7 @@ int bootm_process_cmdline(char *buf, int maxlen, int flags)
 	if (IS_ENABLED(CONFIG_BOOTARGS_SUBST) && (flags & BOOTM_CL_SUBST)) {
 		ret = process_subst(buf, maxlen);
 		if (ret)
-			return log_msg_ret("silent", ret);
+			return log_msg_ret("subst", ret);
 	}
 
 	return 0;
Signature · 1 line
2.30.0.284.gd98b1dd5eaa7-goog