Skip to content

Commit

Permalink
fdtoverlay: provide better error message for missing /__symbols__
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David Gibson <[email protected]>
  • Loading branch information
Amjad50 authored and dgibson committed Oct 30, 2024
1 parent d1e2384 commit 838f11e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fdtoverlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static void *apply_one(char *base, const char *overlay, size_t *buf_len,
char *tmp = NULL;
char *tmpo;
int ret;
bool has_symbols;

/*
* We take copies first, because a failed apply can trash
Expand All @@ -62,6 +63,8 @@ static void *apply_one(char *base, const char *overlay, size_t *buf_len,
fdt_strerror(ret));
goto fail;
}
ret = fdt_path_offset(tmp, "/__symbols__");
has_symbols = ret >= 0;

memcpy(tmpo, overlay, fdt_totalsize(overlay));

Expand All @@ -74,6 +77,11 @@ static void *apply_one(char *base, const char *overlay, size_t *buf_len,
if (ret) {
fprintf(stderr, "\nFailed to apply '%s': %s\n",
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;
}

Expand Down

0 comments on commit 838f11e

Please sign in to comment.