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

Bug#731345: Kirkwood Kernel 3.12-1



On Wed, 2014-01-08 at 09:23 +0000, Ian Campbell wrote:
> Yes, thinking about it "DTB-After: version" probably makes more
> logical sense. 

Hi Marc,

Please can you try this flash-kernel patch on your SheevaPlug?

I've tried it on a ts-419 with Andrew Lunn's DTB patches for that
platform and in some basic tests it seems fine but the Sheevaplug
specific runes need validating.

I'm going to run a more complete set of combinations too, so where for
me 3.13 needs DTB appended and 3.12 I intend to test:

Installing 3.12 while running 3.12 (reran flash-kernel manually)
Installing 3.13 while running 3.13 (reran flash-kernel manually)
Installing 3.12 while running 3.13 (dpkg --purge linux-image-3.13...)
Installing 3.13 while running 3.12 (dpkg -i linux-image-3.13...)

If you could do something similar for the Sheeva case that would be
awesome.

Ian.


8<---------------------------------

>From c0543194c1fae562fa4c8042aa7ff4e37a49e970 Mon Sep 17 00:00:00 2001
From: Ian Campbell <ijc@hellion.org.uk>
Date: Thu, 2 Jan 2014 14:40:39 +0000
Subject: [PATCH] Support requirement to append a DTB on Sheevaplug from kernel
 v3.12 onwards

We want to support both flashing a new (DT based) kernel while running an old
(board file based) kernel as well as flashing an old kernel while running a new
(which normally corresponds to removing a new kernel package).

Therefore add two db entries, one which matches the old board file based
platform and one wich matches the new DT based platform.

We also need to know which kernels need the DTB. We cannot just append the DTB
and rely on the old kernels ignoring it because at least some older kernels
will malfunction if given an appended DTB while they would function fine with
their built in board support. Therefore introduce a new db field
"DTB-Append-From" which is compared against the kernel we are flashing to
determine if the DTB should be appended.

DTB-Append and DTB-Append-From now override/mask Machine-ID since DTB based
systems do not use Machine-ID.

Closes: #731345.
---
 README           |  8 +++++++-
 db/all.db        | 15 +++++++++++++++
 debian/changelog |  7 +++++++
 functions        | 23 ++++++++++++++++-------
 test_db          |  2 +-
 test_functions   | 17 +++++++++++++++++
 6 files changed, 63 insertions(+), 9 deletions(-)

diff --git a/README b/README
index 674a88a..6093d78 100644
--- a/README
+++ b/README
@@ -92,13 +92,19 @@ The supported fields are:
   suffix, installation is aborted
 
 * Machine-Id: (optional) linux mach-type to set before starting vmlinuz;
-  will be set by a small piece of ARM code prepended to the kernel image
+  will be set by a small piece of ARM code prepended to the kernel image.
+  This option is ignored if a DTB is to be appended, via either DTB-Append or
+  DTB-Append-From.
 
 * DTB-Id: (optional) specifies the name of the DTB file for this device
 
 * DTB-Append: (optional) when yes the DTB specified by DTB-Id will be appended
   to the kernel image.
 
+* DTB-Append-From: (optional): Can be used instead of DTB-Append. The argument
+  is a kernel version, if the kernel to be installed is at least this version
+  then the DTB specified named by DTB-Id will be appended to the kernel image.
+
 * U-Boot-Kernel-Address, U-Boot-Kernel-Entry-Point, U-Boot-Initrd-Address:
   (optional) address where to load in (physical) RAM the kernel, entry point
   and initrd, respectively; this also indicates that U-Boot images should be
diff --git a/db/all.db b/db/all.db
index 76e99fd..b62f821 100644
--- a/db/all.db
+++ b/db/all.db
@@ -250,10 +250,25 @@ Bootloader-Sets-Root: no
 
 Machine: Marvell SheevaPlug Reference Board
 Kernel-Flavors: kirkwood
+DTB-Id: kirkwood-sheevaplug.dtb
+DTB-Append-From: 3.12
 U-Boot-Kernel-Address: 0x00008000
 U-Boot-Initrd-Address: 0x0
 Boot-Kernel-Path: /boot/uImage
 Boot-Initrd-Path: /boot/uInitrd
+Boot-DTB-Path: dtb
+Required-Packages: u-boot-tools
+Bootloader-Sets-Root: no
+
+Machine: Globalscale Technologies SheevaPlug
+Kernel-Flavors: kirkwood
+DTB-Id: kirkwood-sheevaplug.dtb
+DTB-Append-From: 3.12
+U-Boot-Kernel-Address: 0x00008000
+U-Boot-Initrd-Address: 0x0
+Boot-Kernel-Path: /boot/uImage
+Boot-Initrd-Path: /boot/uInitrd
+Boot-DTB-Path: dtb
 Required-Packages: u-boot-tools
 Bootloader-Sets-Root: no
 
diff --git a/debian/changelog b/debian/changelog
index f9654c1..716606d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+flash-kernel (3.12) UNRELEASED; urgency=low
+
+  * Append a DTB on Sheevaplug from kernel version 3.12 onwards. Based on a
+    patch by Marc Kleine-Budde. (Closes: #731345).
+
+ -- Ian Campbell <ijc@hellion.org.uk>  Wed, 08 Jan 2014 19:55:43 +0000
+
 flash-kernel (3.11) unstable; urgency=low
 
   [ Updated translations ]
diff --git a/functions b/functions
index 66e9738..d75f139 100644
--- a/functions
+++ b/functions
@@ -319,6 +319,10 @@ abootimg_get_image_size() {
 	echo "$abootimg" | sed -rn 's/^\* image size = ([0-9]+) bytes.*/\1/p'
 }
 
+dtb_append_required() {
+	linux-version compare "$kvers" ge "$dtb_append_from"
+}
+
 # XXX needs testsuite coverage
 android_flash() {
 	local device="$1"
@@ -405,6 +409,7 @@ mtd_kernel="$(get_machine_field "$machine" "Mtd-Kernel")" || :
 mtd_initrd="$(get_machine_field "$machine" "Mtd-Initrd")" || :
 dtb_name="$(get_machine_field "$machine" "DTB-Id")" || :
 dtb_append="$(get_machine_field "$machine" "DTB-Append")" || :
+dtb_append_from="$(get_machine_field "$machine" "DTB-Append-From")" || :
 ukaddr="$(get_machine_field "$machine" "U-Boot-Kernel-Address")" || :
 ukepoint="$(get_machine_field "$machine" "U-Boot-Kernel-Entry-Point")" || :
 uiaddr="$(get_machine_field "$machine" "U-Boot-Initrd-Address")" || :
@@ -419,6 +424,14 @@ boot_dtb_path="$(get_machine_field "$machine" "Boot-DTB-Path")" || :
 boot_multi_path="$(get_machine_field "$machine" "Boot-Multi-Path")" || :
 android_boot_device="$(get_machine_field "$machine" "Android-Boot-Device")" || :
 
+if [ -n "$dtb_append_from" ]; then
+    if dtb_append_required; then
+	dtb_append="yes"
+    else
+	dtb_append="no"
+    fi
+fi
+
 if [ -n "$mtd_kernel" ] || [ -n "$mtd_initrd" ]; then
 	if [ ! -e "$PROC_MTD" ]; then
 		error "$PROC_MTD doesn't exist"
@@ -491,13 +504,6 @@ case "$method" in
 	"generic")
 		kernel="$kfile"
 		initrd="$ifile"
-		if [ -n "$machine_id" ]; then
-			if [ "$dtb_append" = "yes" ]; then
-				error "Can't set Machine-Id and DTB-Append"
-			fi
-			gen_kernel "$kernel" "$tmpdir/kernel" "$machine_id"
-			kernel="$tmpdir/kernel"
-		fi
 		if [ "$dtb_append" = "yes" ]; then
 			dtb="/usr/lib/linux-image-$kvers/$dtb_name"
 			if [ ! -f "$dtb" ]; then
@@ -505,6 +511,9 @@ case "$method" in
 			fi
 			append_dtb "$kernel" "$dtb" "$tmpdir/kernel"
 			kernel="$tmpdir/kernel"
+		elif [ -n "$machine_id" ]; then
+			gen_kernel "$kernel" "$tmpdir/kernel" "$machine_id"
+			kernel="$tmpdir/kernel"
 		fi
 		if [ -n "$ukaddr" ]; then
 			if [ -n "$ukepoint" ]; then
diff --git a/test_db b/test_db
index dd066d8..aec83f1 100755
--- a/test_db
+++ b/test_db
@@ -22,7 +22,7 @@
 MACHINE_DB="$(cat "${FK_CHECKOUT:-$FK_DIR}/db/"*.db)"
 
 test_no_unknown_fields() {
-    local expected='Android-Boot-Device Boot-Device Boot-DTB-Path Boot-Initrd-Path Boot-Kernel-Path Boot-Multi-Path Boot-Script-Path Bootloader-Sets-Root DTB-Append DTB-Id Kernel-Flavors Machine Machine-Id Method Mtd-Initrd Mtd-Kernel Optional-Packages Required-Packages U-Boot-Initrd-Address U-Boot-Kernel-Address U-Boot-Kernel-Entry-Point U-Boot-Multi-Address U-Boot-Script-Address U-Boot-Script-Name'
+    local expected='Android-Boot-Device Boot-Device Boot-DTB-Path Boot-Initrd-Path Boot-Kernel-Path Boot-Multi-Path Boot-Script-Path Bootloader-Sets-Root DTB-Append DTB-Append-From DTB-Id Kernel-Flavors Machine Machine-Id Method Mtd-Initrd Mtd-Kernel Optional-Packages Required-Packages U-Boot-Initrd-Address U-Boot-Kernel-Address U-Boot-Kernel-Entry-Point U-Boot-Multi-Address U-Boot-Script-Address U-Boot-Script-Name'
     expected="$(echo "$expected" | sed 's/ /\n/g' | sort -u | xargs)"
     local fields="$(echo "$MACHINE_DB" | sed -n '/^[^#]*:/s/:.*//p' | sort -u | xargs)"
     if [ "$fields" != "$expected" ]; then
diff --git a/test_functions b/test_functions
index 9874d1b..93fe269 100755
--- a/test_functions
+++ b/test_functions
@@ -497,6 +497,23 @@ test_flash_initrd() {
 }
 add_test test_flash_initrd
 
+test_dtb_append_from() {
+    (
+	. "$functions"
+	dtb_append_from="3.12"
+	kvers=3.11-1-kirkwood
+	if dtb_append_required ; then
+	    echo "Kernel $kvers does not need appended DTB, but got true" >&2
+	    exit 1
+	fi
+	kvers=3.12-1-kirkwood
+	if ! dtb_append_required ; then
+	    echo "Kernel $kvers does need appended DTB, but got false" >&2
+	    exit 1
+	fi
+    )
+}
+add_test test_dtb_append_from
 
 test_main
 
-- 
1.8.4.rc3


Reply to: