# Adding device tree overlay fail with libfdt fdt\_check\_header(): FDT\_ERR\_BADMAGIC error

**URL:** https://hub.mender.io/t/adding-device-tree-overlay-fail-with-libfdt-fdt-check-header-fdt-err-badmagic-error/6550
**Category:** General Discussions
**Tags:** raspberry-pi-4
**Created:** [February 13, 2024, 6:41pm UTC](https://hub.mender.io/t/adding-device-tree-overlay-fail-with-libfdt-fdt-check-header-fdt-err-badmagic-error/6550 "2024-02-13T18:41:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Amin](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@Amin](https://hub.mender.io/u/Amin)
#### Post date: [February 13, 2024, 6:41pm UTC](https://hub.mender.io/t/adding-device-tree-overlay-fail-with-libfdt-fdt-check-header-fdt-err-badmagic-error/6550/1 "2024-02-13T18:41:57Z")

</div>

Hello,

I am trying to apply manually a device tree overlay (dtoverlay=vc4-kms-v3d.dtbo) in u-boot for my rpi4-b but i have this error: `libfdt fdt_check_header(): FDT_ERR_BADMAGIC`  
. Usually i would use dtoverlay=dtoverlay=vc4-kms-v3d in my config.txt but somehow this does not work.

When I first type the u-boot command:  
`fdt addr`  
Nothing is printed, so i type all these commands:

```auto
 setenv fdtov_addr 2F0B2F00
 load mmc 0:1 ${fdt_addr} bcm2711-rpi-4-b.dtb
 load mmc 0:1 ${fdtov_addr} overlays/vc4-kms-v3d.dtbo
 fdt addr $fdt_addr
 fdt resize 8192
 fdt apply $fdtov_addr

```

But as I said previously i end up with the error: libfdt fdt\_check\_header(): FDT\_ERR\_BADMAGIC

I have checked that 0001-rpi-always-set-fdt\_addr-with-firmware-provided-FDT-address.patch is indeed applied.

Note that environment variable are from meta-mender/meta-mender-core/recipes-bsp/u-boot/patches/0002-Generic-boot-code-for-Mender.patch

Any help is appreciated.  
Thank you
