From d798a3fdb24f9abb5bbbc98892a9bc400107f181 Mon Sep 17 00:00:00 2001 From: Amjad Alsharafi Date: Mon, 28 Oct 2024 11:57:28 +0800 Subject: [PATCH] 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 --- fdtoverlay.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fdtoverlay.c b/fdtoverlay.c index 699b4f61..ee1eb8f3 100644 --- a/fdtoverlay.c +++ b/fdtoverlay.c @@ -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 @@ -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)); @@ -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; }