David Abdurachmanov
57ece75e86
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 <david.abdurachmanov@gmail.com>
210 lines
7.2 KiB
Diff
210 lines
7.2 KiB
Diff
From 3242d46a8e4badb1b7a804ce656db3a029808ef7 Mon Sep 17 00:00:00 2001
|
|
From: Your Name <you@example.com>
|
|
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
|
|
|