aboutsummaryrefslogtreecommitdiff
path: root/boot/image-fdt.c
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias.schiffer@ew.tq-group.com>2023-12-11 12:03:17 +0100
committerTom Rini <trini@konsulko.com>2023-12-21 11:59:49 -0500
commite91d6607af47131eab917b31990b3542204e396f (patch)
tree7765da4b7befb2722a0b6a3b55594bcfd4fbe0cc /boot/image-fdt.c
parent0d72b0f2f83b788273c40ed4a64d1adf74877726 (diff)
boot: add support for fdt_fixup command in environment
The "fdt" command is convenient for making small changes to the OS FDT, especially during development. This is easy when the kernel and FDT are loaded separately, but can be cumbersome for FIT images, requiring to unpack the image, manually apply overlays, etc. Add an option to execute a command "fdt_fixup" from the environment at the beginning of image_setup_libfdt() (after overlays are applied, and before the other fixups). Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot/image-fdt.c')
-rw-r--r--boot/image-fdt.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/boot/image-fdt.c b/boot/image-fdt.c
index 2b166c0ff9..75bdd55f32 100644
--- a/boot/image-fdt.c
+++ b/boot/image-fdt.c
@@ -9,6 +9,7 @@
*/
#include <common.h>
+#include <command.h>
#include <fdt_support.h>
#include <fdtdec.h>
#include <env.h>
@@ -576,9 +577,22 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob,
{
ulong *initrd_start = &images->initrd_start;
ulong *initrd_end = &images->initrd_end;
- int ret = -EPERM;
- int fdt_ret;
- int of_size;
+ int ret, fdt_ret, of_size;
+
+ if (IS_ENABLED(CONFIG_OF_ENV_SETUP)) {
+ const char *fdt_fixup;
+
+ fdt_fixup = env_get("fdt_fixup");
+ if (fdt_fixup) {
+ set_working_fdt_addr(map_to_sysmem(blob));
+ ret = run_command_list(fdt_fixup, -1, 0);
+ if (ret)
+ printf("WARNING: fdt_fixup command returned %d\n",
+ ret);
+ }
+ }
+
+ ret = -EPERM;
if (fdt_root(blob) < 0) {
printf("ERROR: root node setup failed\n");