On Thu, 2012-06-21 at 09:45 +0200, Loïc Minier wrote: > On Wed, Jun 20, 2012, Ian Campbell wrote: > > Are you suggesting that I should move the non-flash-kernel related > > content of /dev/sdb1 (e.g. vmlinuz, initramfs etc) to /dev/sdb2:/boot > > and remove sdb1 from the fstab, leaving it unmounted the majority of the > > time? > > Exactly; also it should also keep working if you leave your system > untouched (if you keep /dev/sdb1 in fstab and if f-k tries to mount it > in /tmp to update boot files, it should just get bind-mounted > automatically).
Thanks, I just left my partitions as they were in the end and switched to Boot-Device and everything was fine. I've also added support for appending a DTB to the kernel and a test case for detection via /proc/device-tree/model. > > I'm happy to do that, just want to make sure I understand before I start > > moving stuff about. > > Yup; it's also best if you have some recovery mechanism -- like being > able to pull the SD card and changing it from another device -- and some > debug mechanism -- like serial console over mini-USB. I've got things setup so I can boot from the network (via u-boot) so I'm pretty good to mess around. > > It is possible that other DP users will want /dev/sda* (the internal > > sdcard) instead of /dev/sdb* (the external sdcard). Can I express sda vs > > sdb in the flash-kernel db somehow? > > Ah, yes; that's indeed a problem. That means we need some config file > to override the boot device (ideally an installer would create this file > for you). This is currently missing in flash-kernel, but here I think > it should allow overriding parts of the machine db entry. That sounds very sensible, I didn't look at that here though. Seems like it shouldn't be too hard to add to get_machine_field(). 3 patches attached. Also pushed to gitorious Ian.
>From 2f9d5d7e2eee338cc8b65d31ff38b0579f7da3a7 Mon Sep 17 00:00:00 2001 From: Ian Campbell <i...@hellion.org.uk> Date: Sat, 31 Mar 2012 07:00:54 +0000 Subject: [PATCH 1/3] Use /proc/device-tree/model in preference to /proc/cpuinfo:Hardware If a system uses Device Tree then this node will be present and will identify the actual hardware platform whereas /proc/cpuinfo:Hardware will only identify the general class of platform. Add support for "Globalscale Technologies Dreamplug" using this scheme. --- db/all.db | 10 ++++++++++ debian/changelog | 9 +++++++++ functions | 13 ++++++++++++- test_functions | 39 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/db/all.db b/db/all.db index b7f7caa..31246ad 100644 --- a/db/all.db +++ b/db/all.db @@ -199,6 +199,16 @@ Boot-Initrd-Path: /boot/uInitrd Required-Packages: u-boot-tools Bootloader-sets-root: no +Machine: Globalscale Technologies Dreamplug +Kernel-Flavors: kirkwood +U-Boot-Kernel-Address: 0x00008000 +U-Boot-Initrd-Address: 0x0 +Boot-Device: /dev/sdb1 +Boot-Kernel-Path: uImage +Boot-Initrd-Path: uInitrd +Required-Packages: u-boot-tools +Bootloader-sets-root: no + Machine: Marvell GuruPlug Reference Board Kernel-Flavors: kirkwood U-Boot-Kernel-Address: 0x00008000 diff --git a/debian/changelog b/debian/changelog index 01bed30..3b9c842 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +flash-kernel (3.1) unstable; urgency=low + + [ Ian Campbell ] + * Add support for FDT based devices using /proc/device-tree/model for + detection. + * Add support for DreamPlug. + + -- Ian Campbell <i...@hellion.org.uk> Sat, 23 Jun 2012 16:59:12 +0000 + flash-kernel (3.0) unstable; urgency=low [ Aurelien Jarno ] diff --git a/functions b/functions index bbfa772..82bb09e 100644 --- a/functions +++ b/functions @@ -21,6 +21,7 @@ BOOTSCRIPTS_DIR="${FK_CHECKOUT:-$FK_DIR}/bootscript" MACHINE_DB="$(cat "${FK_CHECKOUT:-$FK_DIR}/db/"*.db)" PROC_CPUINFO="${FK_PROC_CPUINFO:-/proc/cpuinfo}" +PROC_DTMODEL="${FK_PROC_DRMODEL:-/proc/device-tree/model}" PROC_MTD="/proc/mtd" @@ -94,6 +95,16 @@ check_supported() { get_cpuinfo_hardware() { grep "^Hardware" "$PROC_CPUINFO" | sed 's/Hardware\s*:\s*//' } +get_dt_model() { + cat "$PROC_DTMODEL" +} +get_machine() { + if [ -f "$PROC_DTMODEL" ] ; then + get_dt_model + else + get_cpuinfo_hardware + fi +} get_kfile_suffix() { local kfile="$1" @@ -302,7 +313,7 @@ elif [ -n "$FK_MACHINE" ]; then machine="$FK_MACHINE" [ "x$machine" = "xnone" ] && exit else - machine="$(get_cpuinfo_hardware)" + machine="$(get_machine)" fi if [ "x$1" = "x--supported" ]; then diff --git a/test_functions b/test_functions index 604a296..6f3fbe8 100755 --- a/test_functions +++ b/test_functions @@ -155,7 +155,8 @@ EOF ( . "$functions" PROC_CPUINFO="$mock_proc_cpuinfo" - machine=$(get_cpuinfo_hardware) + PROC_DTMODEL="/this/must/not/exist" + machine=$(get_machine) if [ "$machine" != "Marvell SheevaPlug Reference Board" ]; then echo "Expected machine to be Marvell SheevaPlug Reference Board but got $machine" >&2 exit 1 @@ -164,6 +165,42 @@ EOF } add_test test_get_cpuinfo_hardware +test_get_dt_hardware() { + get_tempfile + mock_proc_cpuinfo="$last_tempfile" + cat >"$mock_proc_cpuinfo" <<EOF +Processor : Feroceon 88FR131 rev 1 (v5l) +BogoMIPS : 1191.11 +Features : swp half thumb fastmult edsp +CPU implementer : 0x56 +CPU architecture: 5TE +CPU variant : 0x2 +CPU part : 0x131 +CPU revision : 1 + +Hardware : Marvell Kirkwood (Flattened Device Tree) +Revision : 0000 +Serial : 0000000000000000 +EOF + + get_tempfile + mock_dt_model="$last_tempfile" + echo -n "Globalscale Technologies Dreamplug" >"$mock_dt_model" + + ( + . "$functions" + PROC_CPUINFO="$mock_proc_cpuinfo" + PROC_DTMODEL="$mock_dt_model" + machine=$(get_machine) + if [ "$machine" != "Globalscale Technologies Dreamplug" ]; then + echo "Expected machine to be Globalscale Technologies Dreamplug but got $machine" >&2 + exit 1 + fi + ) + +} +add_test test_get_dt_hardware + test_get_kfile_suffix() { ( . "$functions" -- 1.7.9.1
>From 7e68068116e15770119503e9a8a16326dceff4f3 Mon Sep 17 00:00:00 2001 From: Ian Campbell <i...@hellion.org.uk> Date: Sat, 21 Apr 2012 20:06:10 +0100 Subject: [PATCH 2/3] Add support for installing a DTB binary into /boot Use this new functionality for the dreamplug --- README | 6 ++++++ db/all.db | 2 ++ debian/changelog | 1 + functions | 12 ++++++++++++ 4 files changed, 21 insertions(+), 0 deletions(-) diff --git a/README b/README index 1d2c600..f8c2c1e 100644 --- a/README +++ b/README @@ -89,6 +89,8 @@ The supported fields are: * 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 +* DTB-Id: (optional) specifies the name of the DTB file for this device + * U-Boot-Kernel-Address, U-Boot-Initrd-Address: (optional) address where to load in (physical) RAM the kernel and initrd, respectively; this also indicates that U-Boot images should be generated with mkimage @@ -108,6 +110,10 @@ The supported fields are: Boot-Initrd-Path but for an U-Boot boot script; see also U-Boot-Script-Name and Boot-Device +* Boot-DTB-Path: (optional) like Boot-Kernel-Path and Boot-Initrd-Path + but for a DTB file. The DTB file named by DTB-Id will be copied + here; see also DTB-Id + * Required-packages: (optional) list of packages which must be added during installer phase for flash-kernel to work properly; failure to add these packages aborts the installation diff --git a/db/all.db b/db/all.db index 31246ad..dbf3bf6 100644 --- a/db/all.db +++ b/db/all.db @@ -201,11 +201,13 @@ Bootloader-sets-root: no Machine: Globalscale Technologies Dreamplug Kernel-Flavors: kirkwood +DTB-Id: kirkwood-dreamplug.dtb U-Boot-Kernel-Address: 0x00008000 U-Boot-Initrd-Address: 0x0 Boot-Device: /dev/sdb1 Boot-Kernel-Path: uImage Boot-Initrd-Path: uInitrd +Boot-DTB-Path: dtb Required-Packages: u-boot-tools Bootloader-sets-root: no diff --git a/debian/changelog b/debian/changelog index 3b9c842..4448c13 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ flash-kernel (3.1) unstable; urgency=low [ Ian Campbell ] * Add support for FDT based devices using /proc/device-tree/model for detection. + * Add support for installing a DTB file into the boot partition. * Add support for DreamPlug. -- Ian Campbell <i...@hellion.org.uk> Sat, 23 Jun 2012 16:59:12 +0000 diff --git a/functions b/functions index 82bb09e..586140f 100644 --- a/functions +++ b/functions @@ -382,6 +382,7 @@ machine_id="$(get_machine_field "$machine" "Machine-Id")" || : method="$(get_machine_field "$machine" "Method")" || method="generic" mtd_kernel="$(get_machine_field "$machine" "Mtd-Kernel")" || : mtd_initrd="$(get_machine_field "$machine" "Mtd-Initrd")" || : +dtb_name="$(get_machine_field "$machine" "DTB-Id")" || : ukaddr="$(get_machine_field "$machine" "U-Boot-Kernel-Address")" || : uiaddr="$(get_machine_field "$machine" "U-Boot-Initrd-Address")" || : umaddr="$(get_machine_field "$machine" "U-Boot-Multi-Address")" || : @@ -391,6 +392,7 @@ boot_device="$(get_machine_field "$machine" "Boot-Device")" || : boot_kernel_path="$(get_machine_field "$machine" "Boot-Kernel-Path")" || : boot_initrd_path="$(get_machine_field "$machine" "Boot-Initrd-Path")" || : boot_script_path="$(get_machine_field "$machine" "Boot-Script-Path")" || : +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")" || : @@ -537,6 +539,16 @@ case "$method" in boot_script="$tmpdir/boot.scr" backup_and_install "$boot_script" "$boot_script_path" fi + if [ -n "$boot_dtb_path" ] ; then + boot_dtb_path="$boot_mnt_dir/$boot_dtb_path" + boot_dtb="/usr/lib/linux-image-$kvers/$dtb_name" + if [ ! -f "$boot_dtb" ] ; then + error "Couldn't find $boot_dtb" + fi + dtb="$tmpdir/dtb" + cp "$boot_dtb" "$dtb" + backup_and_install "$dtb" "$boot_dtb_path" + fi ;; "symlink") rm -f /boot/initrd /boot/zImage -- 1.7.9.1
>From e7fc8e9ef6de21428acba96b8cec97744a46da6b Mon Sep 17 00:00:00 2001 From: Ian Campbell <i...@hellion.org.uk> Date: Sat, 23 Jun 2012 12:07:03 +0000 Subject: [PATCH 3/3] Support for appended DTB Use it on DreamPlug --- README | 3 +++ db/all.db | 1 + debian/changelog | 1 + functions | 20 ++++++++++++++++++++ 4 files changed, 25 insertions(+), 0 deletions(-) diff --git a/README b/README index f8c2c1e..81b65d2 100644 --- a/README +++ b/README @@ -91,6 +91,9 @@ The supported fields are: * 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. + * U-Boot-Kernel-Address, U-Boot-Initrd-Address: (optional) address where to load in (physical) RAM the kernel and initrd, respectively; this also indicates that U-Boot images should be generated with mkimage diff --git a/db/all.db b/db/all.db index dbf3bf6..f1917fe 100644 --- a/db/all.db +++ b/db/all.db @@ -202,6 +202,7 @@ Bootloader-sets-root: no Machine: Globalscale Technologies Dreamplug Kernel-Flavors: kirkwood DTB-Id: kirkwood-dreamplug.dtb +DTB-Append: yes U-Boot-Kernel-Address: 0x00008000 U-Boot-Initrd-Address: 0x0 Boot-Device: /dev/sdb1 diff --git a/debian/changelog b/debian/changelog index 4448c13..f4621c1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ flash-kernel (3.1) unstable; urgency=low * Add support for FDT based devices using /proc/device-tree/model for detection. * Add support for installing a DTB file into the boot partition. + * Add support for appending a DTB to the kernel. * Add support for DreamPlug. -- Ian Campbell <i...@hellion.org.uk> Sat, 23 Jun 2012 16:59:12 +0000 diff --git a/functions b/functions index 586140f..df00a86 100644 --- a/functions +++ b/functions @@ -186,6 +186,17 @@ gen_kernel() { } >"$output" } +append_dtb() { + local kernel="$1" + local dtb="$2" + local output="$3" + + { + cat "$kernel" + cat "$dtb" + } >"$output" +} + flash_kernel() { local input_file="$1" local output_mtd="$2" @@ -383,6 +394,7 @@ method="$(get_machine_field "$machine" "Method")" || method="generic" 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")" || : ukaddr="$(get_machine_field "$machine" "U-Boot-Kernel-Address")" || : uiaddr="$(get_machine_field "$machine" "U-Boot-Initrd-Address")" || : umaddr="$(get_machine_field "$machine" "U-Boot-Multi-Address")" || : @@ -472,6 +484,14 @@ case "$method" in gen_kernel "$kernel" "$tmpdir/kernel" "$machine_id" kernel="$tmpdir/kernel" fi + if [ x"$dtb_append" = "xyes" ] ; then + dtb="/usr/lib/linux-image-$kvers/$dtb_name" + if [ ! -f "$dtb" ] ; then + error "Couldn't find $dtb" + fi + append_dtb "$kernel" "$dtb" "$tmpdir/kernel" + kernel="$tmpdir/kernel" + fi if [ -n "$ukaddr" ]; then mkimage_kernel "$ukaddr" "$desc" "$kernel" \ "$tmpdir/uImage" -- 1.7.9.1