-From 9f4e4565afdb73641ad071e917056851fc4d8128 Mon Sep 17 00:00:00 2001
+From b2984225004e46e73d6d31b1580cacd6bd2180dc Mon Sep 17 00:00:00 2001
 From: Alexandru Costache <alexandru@balena.io>
-Date: Wed, 13 May 2020 10:39:39 +0200
+Date: Thu, 15 Apr 2021 11:14:56 +0200
 Subject: [PATCH] bootscript-n8mm-dwe: Integrate with BalenaOS
 
 Upstream-status: Inappropriate [configuration]
 Signed-off-by: Alexandru Costache <alexandru@balena.io>
 ---
- .../boundary/bootscripts/bootscript-yocto.txt | 34 +++++++++++++++----
- 1 file changed, 27 insertions(+), 7 deletions(-)
+ .../boundary/bootscripts/bootscript-yocto.txt | 40 +++++++++++++++----
+ 1 file changed, 32 insertions(+), 8 deletions(-)
 
 diff --git a/board/boundary/bootscripts/bootscript-yocto.txt b/board/boundary/bootscripts/bootscript-yocto.txt
-index 45e0f83498..51fa6ed07c 100644
+index 8ce490745f..54667f06fa 100644
 --- a/board/boundary/bootscripts/bootscript-yocto.txt
 +++ b/board/boundary/bootscripts/bootscript-yocto.txt
-@@ -68,6 +68,14 @@ if itest.s x${distro_bootpart} == x ; then
+@@ -68,14 +68,26 @@ if itest.s x${distro_bootpart} == x ; then
  	distro_bootpart=1
  fi
  

 
 if itest.s "x" != "x${disable_msi}" ; then
 	setenv bootargs ${bootargs} pci=nomsi
@@ -174,7 +181,20 @@ if itest.s "x" != "x${show_env}" ; then
 	printenv
 fi
 

 if load ${devtype} ${devnum}:${distro_bootpart} ${a_script} uEnv.txt ; then
     env import -t ${a_script} ${filesize}
 fi
 setenv bootargs ${bootargs} console=${console},115200 vmalloc=400M consoleblank=0 rootwait fixrtc cpu=${imx_cpu} board=${board}
 
-if load ${devtype} ${devnum}:${distro_bootpart} ${a_fdt} ${prefix}${fdt_file} ; then
+if load ${devtype} ${devnum}:${resin_root_part} ${a_fdt} boot/${fdt_file} ; then
 	fdt addr ${a_fdt}
 	setenv fdt_high 0xffffffff
+elif load ${devtype} ${devnum}:${resin_boot_part} ${a_fdt} ${fdt_file} ; then
+        echo "Did not find dtb in root filesystem, loaded it from boot partition"
+        fdt addr ${a_fdt}
+        setenv fdt_high 0xffffffff
 else
 	echo "!!!! Error loading ${prefix}${fdt_file}";
 	exit;
@@ -114,13 +126,12 @@ fi
 if itest.s "x" == "x${bpart}" ; then
 	bpart=2
 fi
