fdtoverlay: provide better error message for missing /__symbols__

This was added because trying to apply overlay on dtb without knowing a lot
about the subject can be frustrating with strange error messages.

Before this, it will tell you:
`Failed to apply 'overlay.dtbo': FDT_ERR_BADOFFSET`

This message is similar to what's shown in `u-boot` when
trying to apply overlay

Signed-off-by: Amjad Alsharafi <amjadsharafi10@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Amjad Alsharafi 2024-10-28 11:57:28 +08:00 committed by David Gibson
parent d1e2384185
commit 838f11e830

View file

@ -46,6 +46,7 @@ static void *apply_one(char *base, const char *overlay, size_t *buf_len,
char *tmp = NULL; char *tmp = NULL;
char *tmpo; char *tmpo;
int ret; int ret;
bool has_symbols;
/* /*
* We take copies first, because a failed apply can trash * We take copies first, because a failed apply can trash
@ -62,6 +63,8 @@ static void *apply_one(char *base, const char *overlay, size_t *buf_len,
fdt_strerror(ret)); fdt_strerror(ret));
goto fail; goto fail;
} }
ret = fdt_path_offset(tmp, "/__symbols__");
has_symbols = ret >= 0;
memcpy(tmpo, overlay, fdt_totalsize(overlay)); memcpy(tmpo, overlay, fdt_totalsize(overlay));
@ -74,6 +77,11 @@ static void *apply_one(char *base, const char *overlay, size_t *buf_len,
if (ret) { if (ret) {
fprintf(stderr, "\nFailed to apply '%s': %s\n", fprintf(stderr, "\nFailed to apply '%s': %s\n",
name, fdt_strerror(ret)); name, fdt_strerror(ret));
if (!has_symbols) {
fprintf(stderr,
"base blob does not have a '/__symbols__' node, "
"make sure you have compiled the base blob with '-@' option\n");
}
goto fail; goto fail;
} }