[PATCH 0/7] 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(-)

This is printed twice but we only need one message, since there is very little processing in between them. Drop the first one.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/spl/spl.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/common/spl/spl.c b/common/spl/spl.c index 12b00e2a407..7fe0812799f 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -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:

Add notes about how to make binman produce verbose logging when building.
Add a comment on how to do this.
Signed-off-by: Simon Glass sjg@chromium.org ---
Makefile | 1 + tools/binman/README | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile index c2b7046ce3b..66f441f23aa 100644 --- a/Makefile +++ b/Makefile @@ -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) \ diff --git a/tools/binman/README b/tools/binman/README index a00c9026163..45f0a0c2cd3 100644 --- a/tools/binman/README +++ b/tools/binman/README @@ -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 ---------------

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.)
Signed-off-by: Simon Glass sjg@chromium.org ---
README | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/README b/README index afa33dc7f30..582bfb00348 100644 --- a/README +++ b/README @@ -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: ======================

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.)
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/arm/mach-nexell/Makefile | 2 +- arch/arm/mach-nexell/cmd_boot_linux.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/arch/arm/mach-nexell/Makefile b/arch/arm/mach-nexell/Makefile index 10b3963ed10..8113624cac3 100644 --- a/arch/arm/mach-nexell/Makefile +++ b/arch/arm/mach-nexell/Makefile @@ -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 diff --git a/arch/arm/mach-nexell/cmd_boot_linux.c b/arch/arm/mach-nexell/cmd_boot_linux.c index f2dedfe1625..730550cd389 100644 --- a/arch/arm/mach-nexell/cmd_boot_linux.c +++ b/arch/arm/mach-nexell/cmd_boot_linux.c @@ -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); }

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
On 16.01.21 22:54, Simon Glass wrote:
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.)
Signed-off-by: Simon Glass sjg@chromium.org
arch/arm/mach-nexell/Makefile | 2 +- arch/arm/mach-nexell/cmd_boot_linux.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/arch/arm/mach-nexell/Makefile b/arch/arm/mach-nexell/Makefile index 10b3963ed10..8113624cac3 100644 --- a/arch/arm/mach-nexell/Makefile +++ b/arch/arm/mach-nexell/Makefile @@ -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 diff --git a/arch/arm/mach-nexell/cmd_boot_linux.c b/arch/arm/mach-nexell/cmd_boot_linux.c index f2dedfe1625..730550cd389 100644 --- a/arch/arm/mach-nexell/cmd_boot_linux.c +++ b/arch/arm/mach-nexell/cmd_boot_linux.c @@ -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); }

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.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/sandbox/cpu/state.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index b2901b7a8ca..f9b4b4c045e 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -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;

On 1/16/21 10:54 PM, Simon Glass wrote:
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.
Signed-off-by: Simon Glass sjg@chromium.org
arch/sandbox/cpu/state.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index b2901b7a8ca..f9b4b4c045e 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -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);
return -EIO; }os_free(buf);
- 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);
if (!state->state_fdt) { puts("No memory to create FDT\n"); return -ENOMEM;state->state_fdt = os_malloc(size);
@@ -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)
This if is superfluous. os_free() checks for NULL.
os_free(state->ram_buf);
is missing here.
Best regards
Heinrich
free(state->state_fdt);
os_free(state->state_fdt);
memset(state, '\0', sizeof(*state));
return 0;

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.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/sandbox/cpu/state.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index f9b4b4c045e..f9919149103 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -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) {

These two returns use the same string so are not distinguishable with LOG_ERROR_RETURN. Fix it.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/bootm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/bootm.c b/common/bootm.c index 8298693900d..48a5b04cd7a 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -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;
participants (3)
-
Heinrich Schuchardt
-
Simon Glass
-
Stefan Bosch