[PATCH 20/45] sandbox: Add a way to specify the sandbox executable
Heinrich Schuchardt
xypron.glpk at gmx.de
Mon Sep 26 08:49:17 CEST 2022
On 9/25/22 17:02, Simon Glass wrote:
> At present the sandbox executable is assumed to be arg[0] but this only
> works for a single jump (e.g. from SPL to U-Boot). Add a new arg to solve
> this issue, along with a detailed comment.
What is the impact on os_relaunch()?
With current origin/master it fails on SPL:
$ spl/u-boot-spl -S
U-Boot SPL 2022.10-rc5-00012-g435596d57f (Sep 26 2022 - 08:40:30 +0200)
Creating new bloblist size 400 at c000
Finished bloblist size 400 at c000
Finished bloblist size 400 at c000
Found existing bloblist size 400 at c000
U-Boot 2022.10-rc5-00012-g435596d57f (Sep 26 2022 - 08:40:30 +0200)
DRAM: 256 MiB
Core: 23 devices, 11 uclasses, devicetree: board
MMC:
Loading Environment from nowhere... OK
In: serial
Out: serial
Err: serial
Net: No ethernet found.
Hit any key to stop autoboot: 0
=> reset
resetting ...
Finished bloblist size 400 at bffd000
Failed to read RAM buffer '/tmp/u-boot.mem.LypddQ': -1
Expected bloblist at c000 not found (err=-2)
Creating new bloblist size 400 at c000
U-Boot 2022.10-rc5-00012-g435596d57f (Sep 26 2022 - 08:40:30 +0200)
u-boot: error: failed while parsing option: memory
try running with --help for more information.
Best regards
Heinrich
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> arch/sandbox/cpu/start.c | 30 ++++++++++++++++++++++++++++++
> arch/sandbox/include/asm/state.h | 3 ++-
> 2 files changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
> index 642be164a39..622df41f54c 100644
> --- a/arch/sandbox/cpu/start.c
> +++ b/arch/sandbox/cpu/start.c
> @@ -244,6 +244,36 @@ static int sandbox_cmdline_cb_jump(struct sandbox_state *state,
> }
> SANDBOX_CMDLINE_OPT_SHORT(jump, 'j', 1, "Jumped from previous U-Boot");
>
> +static int sandbox_cmdline_cb_program(struct sandbox_state *state,
> + const char *arg)
> +{
> + /*
> + * Record the program name to use when jumping to future phases. This
> + * is the original executable which holds all the phases. We need to
> + * use this instead of argv[0] since each phase is started by
> + * extracting a particular binary from the full program, then running
> + * it. Therefore in that binary, argv[0] contains only the
> + * current-phase executable.
> + *
> + * For example, sandbox TPL may be started using image file:
> + *
> + * ./image.bin
> + *
> + * but then TPL needs to run VPL, which it does by extracting the VPL
> + * image from the image.bin file.
> + *
> + * ./temp-vpl
> + *
> + * When VPL runs it needs access to the original image.bin so it can
> + * extract the next phase (SPL). This works if we use '-f image.bin'
> + * when starting the original image.bin file.
> + */
> + state->prog_fname = arg;
> +
> + return 0;
> +}
> +SANDBOX_CMDLINE_OPT_SHORT(program, 'p', 1, "U-Boot program name");
> +
> static int sandbox_cmdline_cb_memory(struct sandbox_state *state,
> const char *arg)
> {
> diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
> index fd42daad51c..49ea483d332 100644
> --- a/arch/sandbox/include/asm/state.h
> +++ b/arch/sandbox/include/asm/state.h
> @@ -71,7 +71,8 @@ struct sandbox_state {
> const char *parse_err; /* Error to report from parsing */
> int argc; /* Program arguments */
> char **argv; /* Command line arguments */
> - const char *jumped_fname; /* Jumped from previous U_Boot */
> + const char *jumped_fname; /* Jumped from previous U-Boot */
> + const char *prog_fname; /* U-Boot executable filename */
> uint8_t *ram_buf; /* Emulated RAM buffer */
> unsigned long ram_size; /* Size of RAM buffer */
> const char *ram_buf_fname; /* Filename to use for RAM buffer */
More information about the U-Boot
mailing list