cmd: pxe: support INITRD and FDT selection with FIT

Since the commit d5ba6188df ("cmd: pxe_utils: Check fdtcontroladdr
in label_boot") the FDT or the FDTDIR label is required in extlinux.conf
and the fallback done by bootm command for device tree present is no more
performed when FIT is used for kernel.

When the labels FDT or FDTDIR are absent or if the device tree file is
absent, the PXE command in U-Boot uses the default U-Boot device tree
selected by fdtcontroladdr = gd->fdt_blob, it is the "Scenario 3".

With this patch the bootm FIP fallback is no more possible with
the extlinux.conf when only "kernel" label is present and is a FIP:

  kernel <path>#<conf>[#<extra-conf[#...]]

As the U-Boot FDT is selected in the third bootm argument the device
tree from FIP is not used as it was done previously.

This patch adds a new field kernel_label to save the full kernel label.
The FDT bootm parameters use the kernel address (to avoid to load a
second time the same FIP) and the config when this full label is reused
for "fdt" or "initrd" label.

This FIP support in extlinux.conf is restored when the "FDT" label
can be found and select the same FIP (identical file and configuration):

  kernel <path>#<conf>[#<extra-conf[#...]]
  fdt <path>#<conf>[#<extra-conf[#...]]

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Change-Id: I4662774cdd525de1992f84f0ea97255e2e43d8c2
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/u-boot/+/268490
Reviewed-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: CIBUILD <MDG-smet-aci-builds@list.st.com>
This commit is contained in:
Patrick Delaunay
2022-09-30 11:22:19 +02:00
parent 20db66cc65
commit a46e065f82
3 changed files with 26 additions and 2 deletions

View File

@ -268,6 +268,9 @@ static void label_destroy(struct pxe_label *label)
if (label->name)
free(label->name);
if (label->kernel_label)
free(label->kernel_label);
if (label->kernel)
free(label->kernel);
@ -449,6 +452,7 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
int len = 0;
ulong kernel_addr;
void *buf;
bool fdt_use_kernel = false, initrd_use_kernel = false;
label_print(label);
@ -466,6 +470,13 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
return 1;
}
/* For FIT, the label can be identical to kernel one */
if (label->fdt && !strcmp(label->kernel_label, label->fdt))
fdt_use_kernel = true;
if (label->initrd && !strcmp(label->kernel_label, label->initrd))
initrd_use_kernel = true;
if (get_relfile_envaddr(cmdtp, label->kernel, "kernel_addr_r") < 0) {
printf("Skipping %s for failure retrieving kernel\n",
label->name);
@ -485,7 +496,9 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
bootm_argv[1] = fit_addr;
}
if (label->initrd) {
if (initrd_use_kernel) {
bootm_argv[2] = bootm_argv[1];
} else if (label->initrd) {
if (get_relfile_envaddr(cmdtp, label->initrd, "ramdisk_addr_r") < 0) {
printf("Skipping %s for failure retrieving initrd\n",
label->name);
@ -563,7 +576,9 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
bootm_argv[3] = env_get("fdt_addr_r");
/* if fdt label is defined then get fdt from server */
if (bootm_argv[3]) {
if (fdt_use_kernel) {
bootm_argv[3] = bootm_argv[1];
} else if (bootm_argv[3]) {
char *fdtfile = NULL;
char *fdtfilefree = NULL;
@ -1081,6 +1096,10 @@ static int parse_label_kernel(char **c, struct pxe_label *label)
if (err < 0)
return err;
/* copy the kernel label to compare with FDT / INITRD when FIT is used */
label->kernel_label = strdup(label->kernel);
if (!label->kernel_label)
return -ENOMEM;
s = strstr(label->kernel, "#");
if (!s)
return 1;

View File

@ -28,6 +28,7 @@
* Create these with the 'label_create' function given below.
*
* name - the name of the menu as given on the 'menu label' line.
* kernel_label - the kernel label, including FIT config if present.
* kernel - the path to the kernel file to use for this label.
* append - kernel command line to use when booting this label
* initrd - path to the initrd to use for this label.
@ -39,6 +40,7 @@ struct pxe_label {
char num[4];
char *name;
char *menu;
char *kernel_label;
char *kernel;
char *config;
char *append;

View File

@ -169,6 +169,9 @@ fdt <path> - if this label is chosen, use tftp to retrieve the fdt blob
at <path>. it will be stored at the address indicated in
the fdt_addr_r environment variable, and that address will
be passed to bootm.
For FIT image, the device tree can be provided with the same value
than kernel, including configuration:
<path>#<conf>[#<extra-conf[#...]]
fdtdir <path> - if this label is chosen, use tftp to retrieve a fdt blob
relative to <path>. If the fdtfile environment variable