From 57ece75e86aab0fa97a0fd7970b150068d1afb9f Mon Sep 17 00:00:00 2001 From: David Abdurachmanov Date: Sat, 30 Mar 2019 21:10:12 +0100 Subject: [PATCH] Bring back U-Boot wrapped images support for RISC-V (riscv64) Currently it's the only way we can boot on RISC-V with U-Boot and allow people to update kernels without manually replacing firmware. Signed-off-by: David Abdurachmanov --- ...remove-the-old-crufty-u-boot-support.patch | 235 ------------------ 0001-riscv-uboot.patch | 209 ++++++++++++++++ grubby.spec | 19 +- 3 files changed, 225 insertions(+), 238 deletions(-) delete mode 100644 0001-remove-the-old-crufty-u-boot-support.patch create mode 100644 0001-riscv-uboot.patch diff --git a/0001-remove-the-old-crufty-u-boot-support.patch b/0001-remove-the-old-crufty-u-boot-support.patch deleted file mode 100644 index f6f5e97..0000000 --- a/0001-remove-the-old-crufty-u-boot-support.patch +++ /dev/null @@ -1,235 +0,0 @@ -From aa4472dbc10f3d669e24ac07293d7ac19e606866 Mon Sep 17 00:00:00 2001 -From: Dennis Gilmore -Date: Wed, 30 Aug 2017 14:03:45 -0500 -Subject: [PATCH 1/8] remove the old crufty u-boot support - -Fedora has only supported extlinux.conf for a few releases now -as a result it should be the only way we boot systems. Remove -the no longer needed uboot file - -Signed-off-by: Dennis Gilmore ---- - new-kernel-pkg | 116 ------------------------------------------------- - uboot | 43 ------------------ - 2 files changed, 159 deletions(-) - delete mode 100644 uboot - -diff --git a/new-kernel-pkg b/new-kernel-pkg -index b634388a83f..962008e3c9d 100755 ---- a/new-kernel-pkg -+++ b/new-kernel-pkg -@@ -37,7 +37,6 @@ else - fi - - [ -f /etc/sysconfig/kernel ] && . /etc/sysconfig/kernel --[ -f /etc/sysconfig/uboot ] && . /etc/sysconfig/uboot - - cfgGrub2="" - cfgGrub2Efi="" -@@ -50,7 +49,6 @@ grubConfig="" - grub2Config="" - grub2EfiConfig="" - extlinuxConfig="" --ubootScript="/boot/boot.scr" - - ARCH=$(uname -m) - -@@ -84,13 +82,6 @@ elif [[ ${ARCH} =~ armv[5|7].*l ]] ; then - liloConfig="" - bootPrefix=/boot - extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null) -- ubootDir=${UBOOT_DIR:-"/boot"} -- ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} -- ubootKList=${UBOOT_KLIST:-"klist.txt"} -- ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} -- ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} -- ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} -- ubootAddress=${UBOOT_IMGADDR:-"0x00008000"} - mounted="" - liloFlag="" - isx86="" -@@ -382,53 +373,6 @@ remove() { - [ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby" - fi - -- if [ -n "$cfguBoot" ]; then -- [ -n "$verbose" ] && echo "removing $version from $ubootDir..." -- -- if [ -f $ubootDir/$ubootKList ]; then -- tmpKList=`mktemp $ubootDir/$ubootKList.XXXX` -- curversion=`tail -n1 $ubootDir/$ubootKList` -- sed "/$version$/d" $ubootDir/$ubootKList > $tmpKList -- newversion=`tail -n1 $tmpKList` -- if [ -f $ubootDir/uImage-$newversion ] && [ -f $ubootDir/uInitrd-$newversion ]; then -- if [ "$curversion" != "$newversion" ]; then -- cp -fp $ubootDir/uImage-$newversion $ubootDir/${ubootDefaultImage} -- if [ $? -ne 0 ]; then -- [ -n "$verbose" ] && echo "copy uImage-$newversion error, default kernel not replaced!" && exit -- fi -- cp -fp $ubootDir/uInitrd-$newversion $ubootDir/${ubootDefaultInitrd} -- if [ $? -ne 0 ]; then -- [ -n "$verbose" ] && echo "copy uInitrd-$newversion error, default Initrd not replaced!" && exit -- fi -- fi -- -- [ -n "$verbose" ] && echo "removing uImage-$version" -- if [ -f $ubootDir/uImage-$version ]; then -- rm -f $ubootDir/uImage-$version -- else -- [ -n "$verbose" ] && echo "uImage-$version did not exist!" -- fi -- -- [ -n "$verbose" ] && echo "removing uInitrd-$version" -- if [ -f $ubootDir/uInitrd-$version ]; then -- rm -f $ubootDir/uInitrd-$version -- else -- [ -n "$verbose" ] && echo "uInitrd-$version did not exist!" -- fi -- -- mv $tmpKList $ubootDir/$ubootKList -- [ -x /sbin/a-b-c ] && /sbin/a-b-c -- else -- [ -n "$verbose" ] && echo "uImage $newversion does not exist!" -- [ -f $tmpKList ] && rm -f $tmpKList -- fi -- else -- [ -n "$verbose" ] && echo "No previous kernel version. U-Boot images not removed!" -- fi -- else -- [ -n "$verbose" ] && echo "$ubootScript does not exist, not modifying $ubootDir" -- fi -- - if [ -n "$cfgExtlinux" ]; then - [ -n "$verbose" ] && echo "removing $version from $extlinuxConfig" - $grubby --extlinux -c $extlinuxConfig \ -@@ -530,36 +474,6 @@ update() { - [ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby" - fi - -- if [ -n "$cfguBoot" ]; then -- [ -n "$verbose" ] && echo "adding $version to $ubootDir..." -- -- [ -n "$verbose" ] && echo "creating uImage-$version" -- mkimage -A arm -O linux -T kernel -C none -a $ubootAddress \ -- -e $ubootAddress -n $version \ -- -d $kernelImage $ubootDir/uImage-$version -- -- [ -n "$verbose" ] && echo "creating uInitrd-$version" -- mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ -- -n initramfs -d $initrdfile $ubootDir/uInitrd-$version -- -- if [ -f $ubootDir/uImage-$version ] && [ -f $ubootDir/uInitrd-$version ]; then -- cp -fp $ubootDir/uImage-$version $ubootDir/${ubootDefaultImage} -- if [ $? -ne 0 ]; then -- [ -n "$verbose" ] && echo "copy uImage-$version error, kernel not installed!" && exit -- fi -- cp -fp $ubootDir/uInitrd-$version $ubootDir/${ubootDefaultInitrd} -- if [ $? -ne 0 ]; then -- [ -n "$verbose" ] && echo "copy uInitrd-$version error, kernel not installed!" && exit -- fi -- echo $version >> $ubootDir/$ubootKList -- [ -x /sbin/a-b-c ] && /sbin/a-b-c -- else -- [ -n "$verbose" ] && echo "cannot make $version the default" -- fi -- else -- [ -n "$verbose" ] && echo "$ubootScript does not exist, not setting up $ubootDir" -- fi -- - if [ -n "$cfgExtlinux" ]; then - [ -n "$verbose" ] && echo "updating $version from $extlinuxConfig" - ARGS="--extlinux -c $extlinuxConfig --update-kernel=$kernelImage \ -@@ -877,33 +791,6 @@ fi - [ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1; - [ -n "$extlinuxConfig" ] && [ -f "$extlinuxConfig" ] && cfgExtlinux=1; - --# if we have a U-Boot directory, but no boot script, check if the directory --# is mounted. If not, mount it, and then check if a boot script exists. --if [ -n "$ubootDir" ]; then -- if [ -f "$ubootScript" ]; then -- cfguBoot=1 -- else -- mountEntry=`mount | grep $ubootDir` -- if [ -z "$mountEntry" ]; then -- mount $ubootDevice $ubootDir -- mounted=1 -- fi -- [ -f "$ubootScript" ] && cfguBoot=1; -- fi --fi -- --# if we're using U-Boot, check if the default load address should change --if [ -n "$cfguBoot" -a -z "$UBOOT_IMGADDR" ]; then -- [[ $version =~ .([^.]*)$ ]] -- platform=${BASH_REMATCH[1]} -- # A few platforms use an alternate kernel load address -- if [ "$platform" = "omap" ]; then -- ubootAddress=0x80008000 -- elif [ "$platform" = "imx" ]; then -- ubootAddress=0x90008000 -- fi --fi -- - # if we have a lilo config on an x86 box, see if the default boot loader - # is lilo to determine if it should be run - if [ -n "$cfgLilo" -a -n "$isx86" ]; then -@@ -920,7 +807,4 @@ elif [ "$mode" == "--rpmposttrans" ]; then - rpmposttrans - fi - --# if we mounted the U-Boot directory, unmount it. --[ -n "$mounted" ] && umount $ubootDir -- - exit 0 -diff --git a/uboot b/uboot -deleted file mode 100644 -index 07d8671822f..00000000000 ---- a/uboot -+++ /dev/null -@@ -1,43 +0,0 @@ --# Settings for uBoot setup in /sbin/new-kernel-pkg --# --# Default values are provided below (as comments) --# --# WARNING: These values affect where grubby installs and removes --# uBoot kernel images. Changing these _after_ kernels have --# been installed may cause removing a kernel image to fail. -- --# directory where uBoot images and scripts are found --#UBOOT_DIR=/boot -- --# Override the load address when running mkimage on the kernel. --# OMAP such as Beagleboard and Pandaboard: Use 0x80008000 --# Tegra such as Trimslice: Use 0x00008000 --# IMX such as Efika mx51 smarttop: Use 0x90008000 --# Kirkwood such as Dreamplug, Guruplug, Sheevaplug: Use 0x00008000 --# If left undefined grubby will use defults for Tegra or OMAP depending --# upon the contents of /proc/cpuinfo. --#UBOOT_IMGADDR=0x0x00008000 -- --# name of the text file containing the list of installed kernel versions --# NOTE: The versions are in order of installation. The last entry should --# always be the default boot kernel version. --#UBOOT_KLIST=klist.txt -- --# device partition where uBoot images reside; mounted on $UBOOT_DIR --#UBOOT_DEVICE=mmcblk0p1 -- -- --# NOTE: Both of the following files are automatically overwritte --# when a kernel package is installed or removed. -- --# default kernel uImage file name --#UBOOT_UIMAGE=uImage -- --# 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.17.1 - diff --git a/0001-riscv-uboot.patch b/0001-riscv-uboot.patch new file mode 100644 index 0000000..991288d --- /dev/null +++ b/0001-riscv-uboot.patch @@ -0,0 +1,209 @@ +From 3242d46a8e4badb1b7a804ce656db3a029808ef7 Mon Sep 17 00:00:00 2001 +From: Your Name +Date: Sat, 30 Mar 2019 06:11:45 -0400 +Subject: [PATCH] riscv uboot + +--- + new-kernel-pkg | 63 ++++++++++++++++++-------------------------------- + uboot | 39 ++++++++++++------------------- + 2 files changed, 37 insertions(+), 65 deletions(-) + +diff --git a/new-kernel-pkg b/new-kernel-pkg +index b634388..64a36ce 100755 +--- a/new-kernel-pkg ++++ b/new-kernel-pkg +@@ -50,7 +50,6 @@ grubConfig="" + grub2Config="" + grub2EfiConfig="" + extlinuxConfig="" +-ubootScript="/boot/boot.scr" + + ARCH=$(uname -m) + +@@ -84,14 +83,27 @@ elif [[ ${ARCH} =~ armv[5|7].*l ]] ; then + liloConfig="" + bootPrefix=/boot + extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null) ++ mounted="" ++ liloFlag="" ++ isx86="" ++elif [ $ARCH = 'riscv64' ]; then ++ # RISCV 64-bit (RV64GC, riscv64) ++ liloConfig="" ++ bootPrefix=/boot ++ # /etc/extlinux.conf installed by extlinux-bootloader RPM ++ extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null) + ubootDir=${UBOOT_DIR:-"/boot"} +- ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} + ubootKList=${UBOOT_KLIST:-"klist.txt"} +- ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} ++ # Default names are expected by appliance-tools appliance-creator ++ # tool to generate initial /boot/extlinux/extlinux.cfg + ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} + ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} +- ubootAddress=${UBOOT_IMGADDR:-"0x00008000"} +- mounted="" ++ ubootImageCompression=${UBOOT_UIMAGE_COMPRESSION:-"gzip"} ++ ubootInitrdCompression=${UBOOT_UINITRD_COMPRESSION:-"gzip"} ++ # Kernel load address used by QEMU virt machine and ++ # SiFive HiFive Unleashed (SOC: SiFive Freedom U540) ++ ubootAddress=${UBOOT_IMGADDR:-"0x80200000"} ++ ubootArch=riscv + liloFlag="" + isx86="" + else +@@ -417,7 +429,6 @@ remove() { + fi + + mv $tmpKList $ubootDir/$ubootKList +- [ -x /sbin/a-b-c ] && /sbin/a-b-c + else + [ -n "$verbose" ] && echo "uImage $newversion does not exist!" + [ -f $tmpKList ] && rm -f $tmpKList +@@ -426,7 +437,7 @@ remove() { + [ -n "$verbose" ] && echo "No previous kernel version. U-Boot images not removed!" + fi + else +- [ -n "$verbose" ] && echo "$ubootScript does not exist, not modifying $ubootDir" ++ [ -n "$verbose" ] && echo "U-Boot is not enabled, not modifying $ubootDir" + fi + + if [ -n "$cfgExtlinux" ]; then +@@ -534,12 +545,12 @@ update() { + [ -n "$verbose" ] && echo "adding $version to $ubootDir..." + + [ -n "$verbose" ] && echo "creating uImage-$version" +- mkimage -A arm -O linux -T kernel -C none -a $ubootAddress \ ++ mkimage -A $ubootArch -O linux -T kernel -C $ubootImageCompression -a $ubootAddress \ + -e $ubootAddress -n $version \ + -d $kernelImage $ubootDir/uImage-$version + + [ -n "$verbose" ] && echo "creating uInitrd-$version" +- mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ ++ mkimage -A $ubootArch -O linux -T ramdisk -C $ubootInitrdCompression -a 0 -e 0 \ + -n initramfs -d $initrdfile $ubootDir/uInitrd-$version + + if [ -f $ubootDir/uImage-$version ] && [ -f $ubootDir/uInitrd-$version ]; then +@@ -552,12 +563,11 @@ update() { + [ -n "$verbose" ] && echo "copy uInitrd-$version error, kernel not installed!" && exit + fi + echo $version >> $ubootDir/$ubootKList +- [ -x /sbin/a-b-c ] && /sbin/a-b-c + else + [ -n "$verbose" ] && echo "cannot make $version the default" + fi + else +- [ -n "$verbose" ] && echo "$ubootScript does not exist, not setting up $ubootDir" ++ [ -n "$verbose" ] && echo "U-Boot is not enabled, not setting up $ubootDir" + fi + + if [ -n "$cfgExtlinux" ]; then +@@ -876,33 +886,7 @@ fi + [ -n "$grub2EfiConfig" ] && [ -f "$grub2EfiConfig" ] && cfgGrub2Efi=1; + [ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1; + [ -n "$extlinuxConfig" ] && [ -f "$extlinuxConfig" ] && cfgExtlinux=1; +- +-# if we have a U-Boot directory, but no boot script, check if the directory +-# is mounted. If not, mount it, and then check if a boot script exists. +-if [ -n "$ubootDir" ]; then +- if [ -f "$ubootScript" ]; then +- cfguBoot=1 +- else +- mountEntry=`mount | grep $ubootDir` +- if [ -z "$mountEntry" ]; then +- mount $ubootDevice $ubootDir +- mounted=1 +- fi +- [ -f "$ubootScript" ] && cfguBoot=1; +- fi +-fi +- +-# if we're using U-Boot, check if the default load address should change +-if [ -n "$cfguBoot" -a -z "$UBOOT_IMGADDR" ]; then +- [[ $version =~ .([^.]*)$ ]] +- platform=${BASH_REMATCH[1]} +- # A few platforms use an alternate kernel load address +- if [ "$platform" = "omap" ]; then +- ubootAddress=0x80008000 +- elif [ "$platform" = "imx" ]; then +- ubootAddress=0x90008000 +- fi +-fi ++[ -n "$ubootDir" ] && cfguBoot=1 + + # if we have a lilo config on an x86 box, see if the default boot loader + # is lilo to determine if it should be run +@@ -920,7 +904,4 @@ elif [ "$mode" == "--rpmposttrans" ]; then + rpmposttrans + fi + +-# if we mounted the U-Boot directory, unmount it. +-[ -n "$mounted" ] && umount $ubootDir +- + exit 0 +diff --git a/uboot b/uboot +index 07d8671..3db046a 100644 +--- a/uboot ++++ b/uboot +@@ -1,43 +1,34 @@ +-# Settings for uBoot setup in /sbin/new-kernel-pkg ++# Settings for U-Boot setup in /sbin/new-kernel-pkg + # + # Default values are provided below (as comments) + # + # WARNING: These values affect where grubby installs and removes +-# uBoot kernel images. Changing these _after_ kernels have ++# U-Boot kernel images. Changing these _after_ kernels have + # been installed may cause removing a kernel image to fail. + +-# directory where uBoot images and scripts are found ++# Directory where U-Boot images are found. + #UBOOT_DIR=/boot + + # Override the load address when running mkimage on the kernel. +-# OMAP such as Beagleboard and Pandaboard: Use 0x80008000 +-# Tegra such as Trimslice: Use 0x00008000 +-# IMX such as Efika mx51 smarttop: Use 0x90008000 +-# Kirkwood such as Dreamplug, Guruplug, Sheevaplug: Use 0x00008000 +-# If left undefined grubby will use defults for Tegra or OMAP depending +-# upon the contents of /proc/cpuinfo. +-#UBOOT_IMGADDR=0x0x00008000 +- +-# name of the text file containing the list of installed kernel versions +-# NOTE: The versions are in order of installation. The last entry should ++#UBOOT_IMGADDR=0x80200000 ++ ++# Name of the text file containing the list of installed kernel versions ++# ++# NOTE: The versions are in order of installation. The last entry should + # always be the default boot kernel version. + #UBOOT_KLIST=klist.txt + +-# device partition where uBoot images reside; mounted on $UBOOT_DIR +-#UBOOT_DEVICE=mmcblk0p1 +- +- +-# NOTE: Both of the following files are automatically overwritte ++# NOTE: Both of the following files are automatically overwritten + # when a kernel package is installed or removed. + +-# default kernel uImage file name ++# Default kernel uImage file name + #UBOOT_UIMAGE=uImage + +-# default initrd uInitrd file name ++# Default initrd uInitrd file name + #UBOOT_UINITRD=uInitrd + +-# defualt for platform shipping an onboard dtb. +-#SHIPSDTB=no ++# Default uImage compression ++#UBOOT_UIMAGE_COMPRESSION=gzip + +-# option to tell new-kernel-pkg a specific dtb file to load in extlinux.conf +-#dtbfile=foo.dtb ++# Default uInitrd compression ++#UBOOT_UINITRD_COMPRESSION=gzip +-- +2.20.1 + diff --git a/grubby.spec b/grubby.spec index 711c7bc..2f11286 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 30%{?dist} +Release: 30.0.risc64%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -13,7 +13,6 @@ Source1: grubby-bls Source2: grubby.in Source3: installkernel.in Source4: installkernel-bls -Patch0001: 0001-remove-the-old-crufty-u-boot-support.patch Patch0002: 0002-Change-return-type-in-getRootSpecifier.patch Patch0003: 0003-Add-btrfs-subvolume-support-for-grub2.patch Patch0004: 0004-Add-tests-for-btrfs-support.patch @@ -23,6 +22,7 @@ Patch0007: 0007-Make-installkernel-to-use-kernel-install-scripts-on-.patch Patch0008: 0008-Add-usr-libexec-rpm-sort.patch Patch0009: 0009-Improve-man-page-for-info-option.patch Patch0010: 0010-Fix-GCC-warnings-about-possible-string-truncations-a.patch +Patch0020: 0001-riscv-uboot.patch BuildRequires: gcc BuildRequires: pkgconfig glib2-devel popt-devel @@ -39,6 +39,9 @@ Requires: grub2-tools Requires: s390utils-base %endif Requires: findutils +%ifarch riscv64 +Requires: uboot-tools +%endif Obsoletes: %{name}-bls @@ -70,6 +73,10 @@ make test %install make install DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} sbindir=%{_sbindir} libexecdir=%{_libexecdir} +%ifarch riscv64 +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ +install -p uboot $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/uboot +%endif mkdir -p %{buildroot}%{_libexecdir}/{grubby,installkernel}/ %{buildroot}%{_sbindir}/ mv -v %{buildroot}%{_sbindir}/grubby %{buildroot}%{_libexecdir}/grubby/grubby @@ -124,9 +131,15 @@ current boot environment. %attr(0755,root,root) %{_sbindir}/grubby %attr(0755,root,root) %{_sbindir}/installkernel %attr(0755,root,root) %{_sbindir}/new-kernel-pkg - %{_mandir}/man8/*.8* +%{_mandir}/man8/*.8* +%ifarch riscv64 +%config(noreplace) %{_sysconfdir}/sysconfig/uboot +%endif %changelog +* Sat Mar 30 2019 David Abdurachmanov - 8.40-30.0.riscv64 +- Bring back U-Boot wrapped images support for RISC-V (riscv64) + * Thu Mar 21 2019 Javier Martinez Canillas - 8.40-30 - grubby-bls: fix --add-kernel not working when using the --args option Resolves: rhbz#1691004