mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 05:31:32 +00:00
pxe: prepend fdtdir to DTB name irrespective of source
The directory name from an fdtdir directive in a PXE config file should
always be pre-pended to the DTB filename; it shouldn't matter whether
the DTB filename came from the $fdtfile environment variable, or whether
it was constructed dynamically from ${soc}-${board}.dtb. Fix the code to
always prepend the directory name.
Reported-by: Dennis Gilmore <dennis@ausil.us>
Fixes: c61d94d860
("pxe: implement fdtdir extlinux.conf tag")
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Dennis Gilmore <dennis@ausil.us>
Tested-by: Dennis Gilmore <dennis@ausil.us>
This commit is contained in:
parent
102c051fcc
commit
e22361af07
1 changed files with 39 additions and 36 deletions
|
@ -700,44 +700,47 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
|
||||||
if (label->fdt) {
|
if (label->fdt) {
|
||||||
fdtfile = label->fdt;
|
fdtfile = label->fdt;
|
||||||
} else if (label->fdtdir) {
|
} else if (label->fdtdir) {
|
||||||
fdtfile = getenv("fdtfile");
|
char *f1, *f2, *f3, *f4, *slash;
|
||||||
/*
|
|
||||||
* For complex cases, it might be worth calling a
|
|
||||||
* board- or SoC-provided function here to provide a
|
|
||||||
* better default:
|
|
||||||
*
|
|
||||||
* if (!fdtfile)
|
|
||||||
* fdtfile = gen_fdtfile();
|
|
||||||
*
|
|
||||||
* If this is added, be sure to keep the default below,
|
|
||||||
* or move it to the default weak implementation of
|
|
||||||
* gen_fdtfile().
|
|
||||||
*/
|
|
||||||
if (!fdtfile) {
|
|
||||||
char *soc = getenv("soc");
|
|
||||||
char *board = getenv("board");
|
|
||||||
char *slash;
|
|
||||||
|
|
||||||
len = strlen(label->fdtdir);
|
f1 = getenv("fdtfile");
|
||||||
if (!len)
|
if (f1) {
|
||||||
slash = "./";
|
f2 = "";
|
||||||
else if (label->fdtdir[len - 1] != '/')
|
f3 = "";
|
||||||
slash = "/";
|
f4 = "";
|
||||||
else
|
} else {
|
||||||
slash = "";
|
/*
|
||||||
|
* For complex cases where this code doesn't
|
||||||
len = strlen(label->fdtdir) + strlen(slash) +
|
* generate the correct filename, the board
|
||||||
strlen(soc) + 1 + strlen(board) + 5;
|
* code should set $fdtfile during early boot,
|
||||||
fdtfilefree = malloc(len);
|
* or the boot scripts should set $fdtfile
|
||||||
if (!fdtfilefree) {
|
* before invoking "pxe" or "sysboot".
|
||||||
printf("malloc fail (FDT filename)\n");
|
*/
|
||||||
return 1;
|
f1 = getenv("soc");
|
||||||
}
|
f2 = "-";
|
||||||
|
f3 = getenv("board");
|
||||||
snprintf(fdtfilefree, len, "%s%s%s-%s.dtb",
|
f4 = ".dtb";
|
||||||
label->fdtdir, slash, soc, board);
|
|
||||||
fdtfile = fdtfilefree;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
len = strlen(label->fdtdir);
|
||||||
|
if (!len)
|
||||||
|
slash = "./";
|
||||||
|
else if (label->fdtdir[len - 1] != '/')
|
||||||
|
slash = "/";
|
||||||
|
else
|
||||||
|
slash = "";
|
||||||
|
|
||||||
|
len = strlen(label->fdtdir) + strlen(slash) +
|
||||||
|
strlen(f1) + strlen(f2) + strlen(f3) +
|
||||||
|
strlen(f4) + 1;
|
||||||
|
fdtfilefree = malloc(len);
|
||||||
|
if (!fdtfilefree) {
|
||||||
|
printf("malloc fail (FDT filename)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(fdtfilefree, len, "%s%s%s%s%s%s",
|
||||||
|
label->fdtdir, slash, f1, f2, f3, f4);
|
||||||
|
fdtfile = fdtfilefree;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fdtfile) {
|
if (fdtfile) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue