Update grubby to support device tree options for arm. Again.

Resolves: rhbz#1088933

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2014-10-15 17:03:50 -04:00
parent 396cebeb2a
commit daa3b4ea08
4 changed files with 430 additions and 1 deletions

View File

@ -0,0 +1,172 @@
From aa7af717b8855bcfb9a95b80931b8ff319112b88 Mon Sep 17 00:00:00 2001
From: Dennis Gilmore <dennis@ausil.us>
Date: Fri, 10 Oct 2014 02:06:52 -0500
Subject: [PATCH 1/3] Add --devtree support to extlinux (#1088933)
On 32 bit arm it needs the path to the dtb. This adds support for the
fdt command to the extlinux handling. If --devtree /path/to/dtb/file.dtb
is passed grubby will add or updated it.
---
grubby.c | 1 +
new-kernel-pkg | 23 ++++++++++++++++++++---
test.sh | 5 +++++
test/extlinux.5 | 21 +++++++++++++++++++++
test/results/add/extlinux5.1 | 21 +++++++++++++++++++++
5 files changed, 68 insertions(+), 3 deletions(-)
create mode 100644 test/extlinux.5
create mode 100644 test/results/add/extlinux5.1
diff --git a/grubby.c b/grubby.c
index 27b4547..bbe54b6 100644
--- a/grubby.c
+++ b/grubby.c
@@ -581,6 +581,7 @@ struct keywordTypes extlinuxKeywords[] = {
{ "initrd", LT_INITRD, ' ', ',' },
{ "append", LT_KERNELARGS, ' ' },
{ "prompt", LT_UNKNOWN, ' ' },
+ { "fdt", LT_DEVTREE, ' ' },
{ NULL, 0, 0 },
};
int useextlinuxmenu;
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 70f6118..9784f2b 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -7,7 +7,7 @@
# run of depmod/removal of depmod generated files
# addition/removal of kernel images from grub/lilo configuration (via grubby)
#
-# Copyright 2002-2008 Red Hat, Inc. All rights reserved.
+# Copyright 2002-2014 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -113,6 +113,7 @@ dracut=""
dracuthostonly=""
initrdfile=""
devtreefile=""
+devtreedir=""
moddep=""
verbose=""
makedefault=""
@@ -296,7 +297,7 @@ install() {
[ -n "$verbose" ] && echo "adding $version to $extlinuxConfig"
ARGS="--extlinux -c $extlinuxConfig --add-kernel=$kernelImage \
- $INITRD --copy-default --title \"$title\$debugtitle\" \
+ $DEVTREE $INITRD --copy-default --title \"$title\$debugtitle\" \
${mbkernel:+--add-multiboot=\"$mbkernel\"} \
${mbargs:+--mbargs=\"$mbargs\"} \
--args=\"root=$rootdevice $kernargs \$debugargs\" \
@@ -449,6 +450,12 @@ update() {
fi
fi
+ DEVTREE=""
+ if [ "x$devtreefile" != "x" -a -f "$devtreefile" ]; then
+ [ -n "$verbose" ] && echo "found $devtreefile and using it with grubby"
+ DEVTREE="--devtree $devtreefile"
+ fi
+
if [ -n "$cfgGrub" ]; then
[ -n "$verbose" ] && echo "updating $version from $grubConfig"
ARGS="--grub -c $grubConfig --update-kernel=$kernelImage $INITRD \
@@ -544,7 +551,7 @@ update() {
if [ -n "$cfgExtlinux" ]; then
[ -n "$verbose" ] && echo "updating $version from $extlinuxConfig"
ARGS="--extlinux -c $extlinuxConfig --update-kernel=$kernelImage \
- $INITRD ${kernargs:+--args=\"$kernargs\"} \
+ $DEVTREE $INITRD ${kernargs:+--args=\"$kernargs\"} \
${removeargs:+--remove-args=\"$removeargs\"} \
--title=\"$title\$debugtitle\""
@@ -772,6 +779,16 @@ if [ -z "$initrdfile" ]; then
fi
[ -n "$verbose" ] && echo "initrdfile is $initrdfile"
+if [[ ${ARCH} =~ armv[5|7].*l ]]; then
+ if [ -d "$bootPrefix/dtb-$version/" ]; then
+ devtreedir="$bootPrefix/dtb-$version/"
+ if [ -n "$dtbfile" -a -f "$devtreedir/$dtbfile" ]; then
+ devtreefile="$devtreedir/$dtbfile"
+ fi
+ fi
+fi
+[ -n "$verbose" ] && echo "devtreedir is $devtreedir"
+
# add dracut i18n, keyboard and plymouth kernel args if requested
if [ -n "$dracut" -o -n "$adddracutargs" ]; then
if [ -r /etc/vconsole.conf ]; then
diff --git a/test.sh b/test.sh
index 864a8ce..67b932d 100755
--- a/test.sh
+++ b/test.sh
@@ -647,6 +647,11 @@ extlinuxTest extlinux.2 add/extlinux2.1 --add-kernel=/boot/vmlinuz-3.12.0-2.fc21
--initrd=/boot/initrd-3.12.0-2.fc21.i686-new.img --boot-filesystem=/boot --copy-default \
--title="Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug)" \
--remove-kernel="TITLE=Fedora (3.12.0-2.fc21.i686) 20 (Heisenbug)"
+extlinuxTest extlinux.5 add/extlinux5.1 --add-kernel=/boot/vmlinuz-3.15.0-0.rc1.git4.1.fc21.armv7hl \
+ --devtree='/boot/dtb-3.15.0-0.rc1.git4.1.fc21.armv7hl/imx6q-cubox-i.dtb' \
+ --initrd=/boot/initramfs-3.15.0-0.rc1.git4.1.fc21.armv7hl.img --boot-filesystem=/boot --copy-default \
+ --title="Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)" \
+ --remove-kernel="TITLE=Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)"
testing="LILO long titles"
liloTest lilo.1 longtitle/l1.1 --add-kernel=/boot/new-kernel.img \
diff --git a/test/extlinux.5 b/test/extlinux.5
new file mode 100644
index 0000000..30e7572
--- /dev/null
+++ b/test/extlinux.5
@@ -0,0 +1,21 @@
+ui menu.c32
+
+menu hidden
+timeout 50
+totaltimeout 9000
+
+prompt 10
+default Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)
+
+label Fedora (3.15.0-0.rc1.git0.1.fc21.armv7hl) 21 (Rawhide)
+kernel /vmlinuz-3.15.0-0.rc1.git0.1.fc21.armv7hl
+fdt /dtb-3.15.0-0.rc1.git0.1.fc21.armv7hl/imx6q-cubox-i.dtb
+append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8
+initrd /initramfs-3.15.0-0.rc1.git0.1.fc21.armv7hl.img
+
+label Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)
+kernel /vmlinuz-3.12.0-0.fc21.armv7hl
+fdt /dtb-3.12.0-0.fc21.armv7hl/imx6q-cubox-i.dtb
+append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8
+initrd /initramfs-3.12.0-0.fc21.armv7hl.img
+
diff --git a/test/results/add/extlinux5.1 b/test/results/add/extlinux5.1
new file mode 100644
index 0000000..5e97883
--- /dev/null
+++ b/test/results/add/extlinux5.1
@@ -0,0 +1,21 @@
+ui menu.c32
+
+menu hidden
+timeout 50
+totaltimeout 9000
+
+prompt 10
+default Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)
+
+label Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)
+kernel /vmlinuz-3.15.0-0.rc1.git4.1.fc21.armv7hl
+fdt /dtb-3.15.0-0.rc1.git4.1.fc21.armv7hl/imx6q-cubox-i.dtb
+append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8
+initrd /initramfs-3.15.0-0.rc1.git4.1.fc21.armv7hl.img
+
+label Fedora (3.15.0-0.rc1.git0.1.fc21.armv7hl) 21 (Rawhide)
+kernel /vmlinuz-3.15.0-0.rc1.git0.1.fc21.armv7hl
+fdt /dtb-3.15.0-0.rc1.git0.1.fc21.armv7hl/imx6q-cubox-i.dtb
+append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8
+initrd /initramfs-3.15.0-0.rc1.git0.1.fc21.armv7hl.img
+
--
2.1.0

View File

@ -0,0 +1,194 @@
From 1ea4401882f2863ae5c5313c3b28645c60fc93b3 Mon Sep 17 00:00:00 2001
From: Dennis Gilmore <dennis@ausil.us>
Date: Fri, 10 Oct 2014 01:38:27 -0500
Subject: [PATCH 2/3] add support for devicetree directories for use on arm
---
grubby.c | 3 +++
new-kernel-pkg | 31 ++++++++++++++++++++++++++-----
test.sh | 5 +++++
test/extlinux.6 | 21 +++++++++++++++++++++
test/results/add/extlinux6.1 | 21 +++++++++++++++++++++
5 files changed, 76 insertions(+), 5 deletions(-)
create mode 100644 test/extlinux.6
create mode 100644 test/results/add/extlinux6.1
diff --git a/grubby.c b/grubby.c
index bbe54b6..8a8df98 100644
--- a/grubby.c
+++ b/grubby.c
@@ -582,6 +582,7 @@ struct keywordTypes extlinuxKeywords[] = {
{ "append", LT_KERNELARGS, ' ' },
{ "prompt", LT_UNKNOWN, ' ' },
{ "fdt", LT_DEVTREE, ' ' },
+ { "fdtdir", LT_DEVTREE, ' ' },
{ NULL, 0, 0 },
};
int useextlinuxmenu;
@@ -4269,6 +4270,8 @@ int main(int argc, const char ** argv) {
_("display the title of the default kernel") },
{ "devtree", 0, POPT_ARG_STRING, &newDevTreePath, 0,
_("device tree file for new stanza"), _("dtb-path") },
+ { "devtreedir", 0, POPT_ARG_STRING, &newDevTreePath, 0,
+ _("device tree directory for new stanza"), _("dtb-path") },
{ "elilo", 0, POPT_ARG_NONE, &configureELilo, 0,
_("configure elilo bootloader") },
{ "efi", 0, POPT_ARG_NONE, &isEfi, 0,
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 9784f2b..8d55abf 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -131,7 +131,7 @@ usage() {
echo " [--banner=<banner>] [--multiboot=multiboot]" >&2
echo " [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2
echo " [--add-plymouth-initrd]" >&2
- echo " [--host-only] [--devtree=<devicetree.dtb>]" >&2
+ echo " [--host-only] [--devtree=<devicetree.dtb>] [--devtreedir=</devicetree/path/>]" >&2
echo " <--install | --remove | --update | --rpmposttrans> <kernel-version>" >&2
echo " (ex: `basename $0` --mkinitrd --depmod --install 2.4.7-2)" >&2
exit 1
@@ -191,11 +191,17 @@ install() {
fi
DEVTREE=""
- if [ "x$devtreefile" != "x" -a -f "$devtreefile" ]; then
+ if [ -n $devtreefile -a -f "$devtreefile" ]; then
[ -n "$verbose" ] && echo "found $devtreefile and using it with grubby"
DEVTREE="--devtree $devtreefile"
fi
+ DEVTREEDIR=""
+ if [ -n $devtreedir -a -d "$devtreedir" ]; then
+ [ -n "$verbose" ] && echo "found $devtreedir and using it with grubby"
+ DEVTREEDIR="--devtreedir $devtreedir"
+ fi
+
# FIXME: is this a good heuristic to find out if we're on iSeries?
if [ -d /proc/iSeries ]; then
[ -n "$verbose" ] && echo "On an iSeries, just making img file"
@@ -297,7 +303,7 @@ install() {
[ -n "$verbose" ] && echo "adding $version to $extlinuxConfig"
ARGS="--extlinux -c $extlinuxConfig --add-kernel=$kernelImage \
- $DEVTREE $INITRD --copy-default --title \"$title\$debugtitle\" \
+ $DEVTREE $DEVTREEDIR $INITRD --copy-default --title \"$title\$debugtitle\" \
${mbkernel:+--add-multiboot=\"$mbkernel\"} \
${mbargs:+--mbargs=\"$mbargs\"} \
--args=\"root=$rootdevice $kernargs \$debugargs\" \
@@ -451,11 +457,17 @@ update() {
fi
DEVTREE=""
- if [ "x$devtreefile" != "x" -a -f "$devtreefile" ]; then
+ if [ -n $devtreefile -a -f "$devtreefile" ]; then
[ -n "$verbose" ] && echo "found $devtreefile and using it with grubby"
DEVTREE="--devtree $devtreefile"
fi
+ DEVTREEDIR=""
+ if [ -n $devtreedir -a -d "$devtreedir" ]; then
+ [ -n "$verbose" ] && echo "found $devtreedir and using it with grubby"
+ DEVTREEDIR="--devtreedir $devtreedir"
+ fi
+
if [ -n "$cfgGrub" ]; then
[ -n "$verbose" ] && echo "updating $version from $grubConfig"
ARGS="--grub -c $grubConfig --update-kernel=$kernelImage $INITRD \
@@ -551,7 +563,7 @@ update() {
if [ -n "$cfgExtlinux" ]; then
[ -n "$verbose" ] && echo "updating $version from $extlinuxConfig"
ARGS="--extlinux -c $extlinuxConfig --update-kernel=$kernelImage \
- $DEVTREE $INITRD ${kernargs:+--args=\"$kernargs\"} \
+ $DEVTREE $DEVTREEDIR $INITRD ${kernargs:+--args=\"$kernargs\"} \
${removeargs:+--remove-args=\"$removeargs\"} \
--title=\"$title\$debugtitle\""
@@ -615,6 +627,15 @@ while [ $# -gt 0 ]; do
fi
;;
+ --devtreedir*)
+ if [[ $1 == --devtreedir\=* ]]; then
+ devtreedir=${1#--devtreedir=}
+ else
+ devtreedir=$2
+ shift
+ fi
+ ;;
+
--dracut)
dracut=--dracut
;;
diff --git a/test.sh b/test.sh
index 67b932d..fe574c3 100755
--- a/test.sh
+++ b/test.sh
@@ -652,6 +652,11 @@ extlinuxTest extlinux.5 add/extlinux5.1 --add-kernel=/boot/vmlinuz-3.15.0-0.rc1.
--initrd=/boot/initramfs-3.15.0-0.rc1.git4.1.fc21.armv7hl.img --boot-filesystem=/boot --copy-default \
--title="Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)" \
--remove-kernel="TITLE=Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)"
+extlinuxTest extlinux.6 add/extlinux6.1 --add-kernel=/boot/vmlinuz-3.15.0-0.rc1.git4.1.fc21.armv7hl \
+ --devtreedir='/boot/dtb-3.15.0-0.rc1.git4.1.fc21.armv7hl/' \
+ --initrd=/boot/initramfs-3.15.0-0.rc1.git4.1.fc21.armv7hl.img --boot-filesystem=/boot --copy-default \
+ --title="Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)" \
+ --remove-kernel="TITLE=Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)"
testing="LILO long titles"
liloTest lilo.1 longtitle/l1.1 --add-kernel=/boot/new-kernel.img \
diff --git a/test/extlinux.6 b/test/extlinux.6
new file mode 100644
index 0000000..c28a4a8
--- /dev/null
+++ b/test/extlinux.6
@@ -0,0 +1,21 @@
+ui menu.c32
+
+menu hidden
+timeout 50
+totaltimeout 9000
+
+prompt 10
+default Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)
+
+label Fedora (3.15.0-0.rc1.git0.1.fc21.armv7hl) 21 (Rawhide)
+kernel /vmlinuz-3.15.0-0.rc1.git0.1.fc21.armv7hl
+fdtdir /dtb-3.15.0-0.rc1.git0.1.fc21.armv7hl/
+append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8
+initrd /initramfs-3.15.0-0.rc1.git0.1.fc21.armv7hl.img
+
+label Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)
+kernel /vmlinuz-3.12.0-0.fc21.armv7hl
+fdtdir /dtb-3.12.0-0.fc21.armv7hl/
+append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8
+initrd /initramfs-3.12.0-0.fc21.armv7hl.img
+
diff --git a/test/results/add/extlinux6.1 b/test/results/add/extlinux6.1
new file mode 100644
index 0000000..ec2a2ea
--- /dev/null
+++ b/test/results/add/extlinux6.1
@@ -0,0 +1,21 @@
+ui menu.c32
+
+menu hidden
+timeout 50
+totaltimeout 9000
+
+prompt 10
+default Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)
+
+label Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)
+kernel /vmlinuz-3.15.0-0.rc1.git4.1.fc21.armv7hl
+fdtdir /dtb-3.15.0-0.rc1.git4.1.fc21.armv7hl/
+append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8
+initrd /initramfs-3.15.0-0.rc1.git4.1.fc21.armv7hl.img
+
+label Fedora (3.15.0-0.rc1.git0.1.fc21.armv7hl) 21 (Rawhide)
+kernel /vmlinuz-3.15.0-0.rc1.git0.1.fc21.armv7hl
+fdtdir /dtb-3.15.0-0.rc1.git0.1.fc21.armv7hl/
+append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8
+initrd /initramfs-3.15.0-0.rc1.git0.1.fc21.armv7hl.img
+
--
2.1.0

View File

@ -0,0 +1,56 @@
From 595f8d2d3681d684dbb12eff32bf1a68636db977 Mon Sep 17 00:00:00 2001
From: Dennis Gilmore <dennis@ausil.us>
Date: Thu, 9 Oct 2014 01:42:03 -0500
Subject: [PATCH 3/3] cleanup dtb handling to work in the supported usecases
add SHIPSDTB variable in the uboot defaults file that needs to be set to yes for
platforms like the calxeda highbank that ship a dtb in u-boot that we want to use.
if the user defines a dtbfile in /etc/sysconfig/uboot update the extlinux.conf
with an fdt entry otherwise update a fdtdir entry unless SHIPSDTB is set to yes.
---
new-kernel-pkg | 12 +++++++-----
uboot | 5 +++++
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 8d55abf..e02f65c 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -801,14 +801,16 @@ fi
[ -n "$verbose" ] && echo "initrdfile is $initrdfile"
if [[ ${ARCH} =~ armv[5|7].*l ]]; then
- if [ -d "$bootPrefix/dtb-$version/" ]; then
- devtreedir="$bootPrefix/dtb-$version/"
- if [ -n "$dtbfile" -a -f "$devtreedir/$dtbfile" ]; then
- devtreefile="$devtreedir/$dtbfile"
+ if [ -z "$SHIPSDTB" -o "$SHIPSDTB" != "yes" ]; then
+ if [ -n "$dtbfile" -a -f "$bootPrefix/dtb-$version/$dtbfile" ]; then
+ devtreefile="$bootPrefix/dtb-$version/$dtbfile"
+ [ -n "$verbose" ] && echo "devtreefile is $devtreefile"
+ elif [ -d "$bootPrefix/dtb-$version/" ]; then
+ devtreedir="$bootPrefix/dtb-$version/"
+ [ -n "$verbose" ] && echo "devtreedir is $devtreedir"
fi
fi
fi
-[ -n "$verbose" ] && echo "devtreedir is $devtreedir"
# add dracut i18n, keyboard and plymouth kernel args if requested
if [ -n "$dracut" -o -n "$adddracutargs" ]; then
diff --git a/uboot b/uboot
index aa663ad..07d8671 100644
--- a/uboot
+++ b/uboot
@@ -36,3 +36,8 @@
# default initrd uInitrd file name
#UBOOT_UINITRD=uInitrd
+# defualt for platform shipping an onboard dtb.
+#SHIPSDTB=no
+
+# option to tell new-kernel-pkg a specific dtb file to load in extlinux.conf
+#dtbfile=foo.dtb
--
2.1.0

View File

@ -1,6 +1,6 @@
Name: grubby
Version: 8.35
Release: 5%{?dist}
Release: 6%{?dist}
Summary: Command line tool for updating bootloader configs
Group: System Environment/Base
License: GPLv2+
@ -18,6 +18,9 @@ Patch0006: 0006-Support-filtering-update-kernel-by-title-as-well.patch
Patch0007: 0007-Conditionally-create-debug-entries-when-installing-k.patch
Patch0008: 0008-Revert-Add-bls-test-harness-bits.patch
Patch0009: 0009-Always-error-check-getLineByType.patch
Patch0010: 0001-Add-devtree-support-to-extlinux-1088933.patch
Patch0011: 0002-add-support-for-devicetree-directories-for-use-on-ar.patch
Patch0012: 0003-cleanup-dtb-handling-to-work-in-the-supported-usecas.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: pkgconfig glib2-devel popt-devel
@ -87,6 +90,10 @@ rm -rf $RPM_BUILD_ROOT
%endif
%changelog
* Wed Oct 15 2014 Peter Jones <pjones@redhat.com> - 8.35-6
- Update grubby to support device tree options for arm. Again.
Resolves: rhbz#1088933
* Fri Sep 26 2014 Peter Jones <pjones@redhat.com> - 8.35-5
- See if what people are seeing in 1141414 is actually 957681
Related: rhbz#957681