From db3667413d99b8ec1b1e7e9b34c20a8883ec413d Mon Sep 17 00:00:00 2001 From: Anton Leontiev Date: Tue, 3 Sep 2019 10:52:24 +0300 Subject: cmd: pxe: Use internal FDT if retrieving from FDTDIR fails As FDTDIR label doesn't specify exact file to be loaded, it should not fail if no file exists in the directory. In this case try to boot with internal FDT if it exists. Signed-off-by: Anton Leontiev --- cmd/pxe_utils.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'cmd/pxe_utils.c') diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c index 8716e782f6a..235522f4bbc 100644 --- a/cmd/pxe_utils.c +++ b/cmd/pxe_utils.c @@ -451,11 +451,14 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label) /* * fdt usage is optional: - * It handles the following scenarios. All scenarios are exclusive + * It handles the following scenarios. * - * Scenario 1: If fdt_addr_r specified and "fdt" label is defined in - * pxe file, retrieve fdt blob from server. Pass fdt_addr_r to bootm, - * and adjust argc appropriately. + * Scenario 1: If fdt_addr_r specified and "fdt" or "fdtdir" label is + * defined in pxe file, retrieve fdt blob from server. Pass fdt_addr_r to + * bootm, and adjust argc appropriately. + * + * If retrieve fails and no exact fdt blob is specified in pxe file with + * "fdt" label, try Scenario 2. * * Scenario 2: If there is an fdt_addr specified, pass it along to * bootm, and adjust argc appropriately. @@ -521,9 +524,13 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label) free(fdtfilefree); if (err < 0) { - printf("Skipping %s for failure retrieving fdt\n", - label->name); - goto cleanup; + bootm_argv[3] = NULL; + + if (label->fdt) { + printf("Skipping %s for failure retrieving FDT\n", + label->name); + goto cleanup; + } } } else { bootm_argv[3] = NULL; -- cgit v1.2.3 From 1a62d64c7de7e7de3facf221eb8408ddfb675cb8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 10:33:47 -0700 Subject: cli: Support macro processing with a fixed-size buffer At present cli_simple_process_macros() requires that the caller provide an output buffer that is exactly CONFIG_SYS_CBSIZE bytes in length. This makes sense since it is designed to be used from the command line. But we also want to use it for bootargs substitution. Update the function to allow the caller to specify the buffer size. Also return an error if the buffer is exhausted. The caller can ignore that if preferred. Signed-off-by: Simon Glass --- cmd/pxe_utils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cmd/pxe_utils.c') diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c index 235522f4bbc..b9d9a5786c2 100644 --- a/cmd/pxe_utils.c +++ b/cmd/pxe_utils.c @@ -322,7 +322,8 @@ static int label_localboot(struct pxe_label *label) if (label->append) { char bootargs[CONFIG_SYS_CBSIZE]; - cli_simple_process_macros(label->append, bootargs); + cli_simple_process_macros(label->append, bootargs, + sizeof(bootargs)); env_set("bootargs", bootargs); } @@ -430,7 +431,8 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label) strcat(bootargs, ip_str); strcat(bootargs, mac_str); - cli_simple_process_macros(bootargs, finalbootargs); + cli_simple_process_macros(bootargs, finalbootargs, + sizeof(finalbootargs)); env_set("bootargs", finalbootargs); printf("append: %s\n", finalbootargs); } -- cgit v1.2.3