[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#783073: bootscripts: Support using fdtfile variable passed from u-boot



Package: flash-kernel
Version: 3.35
Severity: wishlist
Tags: patch

The following patch prefers the use of the dtb file identified by the
u-boot variable ${fdtfile}, which makes it easier to support installs
where a single u-boot image can support multiple boards, but need to
load different fdt files at boot.

It essentially makes a second copy of the .dtb file in
/boot/dtbs-${kver}/${fdtfile}. Ideally, it would copy all of the .dtb
files (to support the widest number of boards), but that should be
made conditional for resource-constrained systems, so I started off
with simply making a second copy.

The various boot scripts which may include ${fdtfile} are patched to
prefer ${fdtfile}, falling back to the old behavior of the hard-coded
fdt file path.

I don't expect to see this in jessie, but hopefully something like this
could be considered for jessie+1.

diff --git a/bootscript/bootscr.beaglebone b/bootscript/bootscr.beaglebone
index 1d079f8..3e16974 100644
--- a/bootscript/bootscr.beaglebone
+++ b/bootscript/bootscr.beaglebone
@@ -20,7 +20,8 @@ kvers='@@KERNEL_VERSION@@'
 for pathprefix in ${image_locations}
 do
   load ${device} ${partition} ${loadaddr} ${pathprefix}vmlinuz-${kvers} \
-  && load ${device} ${partition} ${fdtaddr} ${pathprefix}dtb-${kvers} \
+  && load ${device} ${partition} ${fdtaddr} ${pathprefix}dtbs-${kvers}/${fdtfile} \
+  || load ${device} ${partition} ${fdtaddr} ${pathprefix}dtb-${kvers} \
   && load ${device} ${partition} ${rdaddr} ${pathprefix}initrd.img-${kvers} \
   && echo "Booting Debian ${kvers} from ${device} ${partition}..." \
   && bootz ${loadaddr} ${rdaddr}:${filesize} ${fdtaddr}
diff --git a/bootscript/bootscr.cubox-i b/bootscript/bootscr.cubox-i
index adeb0d2..62e5c5d 100644
--- a/bootscript/bootscr.cubox-i
+++ b/bootscript/bootscr.cubox-i
@@ -19,7 +19,8 @@ kvers='@@KERNEL_VERSION@@'
 for pathprefix in ${image_locations}
 do
   load ${device} ${partition} ${loadaddr} ${pathprefix}vmlinuz-${kvers} \
-  && load ${device} ${partition} ${fdt_addr} ${pathprefix}dtb-${kvers} \
+  && load ${device} ${partition} ${fdt_addr} ${pathprefix}dtbs-${kvers}/${fdtfile} \
+  || load ${device} ${partition} ${fdt_addr} ${pathprefix}dtb-${kvers} \
   && load ${device} ${partition} ${ramdiskaddr} ${pathprefix}initrd.img-${kvers} \
   && echo "Booting Debian ${kvers} from ${device} ${partition}..." \
   && bootz ${loadaddr} ${ramdiskaddr}:${filesize} ${fdt_addr}
diff --git a/bootscript/bootscr.sunxi b/bootscript/bootscr.sunxi
index e64010f..004ff64 100644
--- a/bootscript/bootscr.sunxi
+++ b/bootscript/bootscr.sunxi
@@ -45,10 +45,10 @@ do
   if test -e ${device} ${partition} ${pathprefix}vmlinuz-${kvers}
   then
     load ${device} ${partition} ${kernel_addr_r} ${pathprefix}vmlinuz-${kvers} \
-    && load ${device} ${partition} ${fdt_addr_r} ${pathprefix}dtb-${kvers} \
+    && load ${device} ${partition} ${fdt_addr_r} ${pathprefix}dtbs-${kvers}/${fdtfile} \
+    || load ${device} ${partition} ${fdt_addr_r} ${pathprefix}dtb-${kvers} \
     && load ${device} ${partition} ${ramdisk_addr_r} ${pathprefix}initrd.img-${kvers} \
     && echo "Booting Debian ${kvers} from ${device} ${partition}..." \
     && bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
   fi
 done
-
diff --git a/bootscript/bootscr.uboot-generic b/bootscript/bootscr.uboot-generic
index 7451112..7342377 100644
--- a/bootscript/bootscr.uboot-generic
+++ b/bootscript/bootscr.uboot-generic
@@ -17,7 +17,8 @@ setenv bootargs ${bootargs} @@LINUX_KERNEL_CMDLINE@@
 @@UBOOT_ENV_EXTRA@@
 
 load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} ${prefix}vmlinuz \
-&& load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} ${prefix}dtb \
+&& load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} ${prefix}dtbs/${fdtfile} \
+|| load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} ${prefix}dtb \
 && load ${devtype} ${devnum}:${bootpart} ${ramdisk_addr_r} ${prefix}initrd.img \
 && echo "Booting Debian..." \
 && bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
diff --git a/bootscript/bootscr.wandboard b/bootscript/bootscr.wandboard
index cd04a90..39bd25e 100644
--- a/bootscript/bootscr.wandboard
+++ b/bootscript/bootscr.wandboard
@@ -22,7 +22,8 @@ kvers='@@KERNEL_VERSION@@'
 for pathprefix in ${image_locations}
 do
   load ${device} ${partition} ${loadaddr} ${pathprefix}vmlinuz-${kvers} \
-  && load ${device} ${partition} ${fdt_addr} ${pathprefix}dtb-${kvers} \
+  && load ${device} ${partition} ${fdt_addr} ${pathprefix}dtbs-${kvers}/${fdtfile} \
+  || load ${device} ${partition} ${fdt_addr} ${pathprefix}dtb-${kvers} \  
   && load ${device} ${partition} ${ramdiskaddr} ${pathprefix}initrd.img-${kvers} \
   && echo "Booting Debian ${kvers} from ${device} ${partition}..." \
   && bootz ${loadaddr} ${ramdiskaddr}:${filesize} ${fdt_addr}
diff --git a/functions b/functions
index a7ff6de..fc2c21b 100644
--- a/functions
+++ b/functions
@@ -420,13 +420,18 @@ handle_dtb() {
 
 	local dtb="/usr/lib/linux-image-$kvers/$dtb_id"
 	if [ "x$FK_KERNEL_HOOK_SCRIPT" = "xpostrm.d" ] ; then
-		rm -f "/boot/dtb-$kvers"
+		rm -f "/boot/dtb-$kvers" "/boot/dtbs-$kvers"
 	else
 		if [ -e $dtb ]; then
 			echo "Installing $dtb_id into /boot/dtb-$kvers" >&2
 			cp "$dtb" "/boot/dtb-$kvers.new"
 			backup_and_install "/boot/dtb-$kvers.new" "/boot/dtb-$kvers"
 			ln -nfs "dtb-$kvers" "/boot/dtb"
+			echo "Installing $dtb_id into /boot/dtbs-$kvers/$dtb_id" >&2
+			mkdir -p /boot/dtbs-$kvers/
+			cp "$dtb" "/boot/dtbs-$kvers/$dtb_id.new"
+			backup_and_install "/boot/dtbs-$kvers/$dtb_id.new" "/boot/dtbs-$kvers/"
+			ln -nfs "dtbs-$kvers" "/boot/dtbs"
 		else
 			echo "$dtb not found" >&2
 		fi


live well,
  vagrant

Attachment: signature.asc
Description: PGP signature


Reply to: