rzero: Update extlinux script to use a new way of setting options via the config.txt file

This commit is contained in:
Steev Klimaszewski
2023-01-22 17:04:25 -06:00
parent 3b88c1c2d5
commit e9b60e0d49
3 changed files with 83 additions and 39 deletions

View File

@@ -0,0 +1,32 @@
# Execute "update_extlinux.sh" after changing file /boot/config.txt.
#
# kernel command line: started with "cmdline:"
#
# For console
cmdline: console=ttyAML0,115200 console=tty1 console=both console=blank consoleblank=0 loglevel=0
# For rootfs
cmdline: panic=10 rootwait ro rootfstype=ext4
# Docker optimizations
cmdline: cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1
cmdline: switolb=1
cmdline: coherent_pool=2M
#
# dt overlay line: starts with "dtoverlay=". One dt overlay per line
# do not include the .dtbo extension
#
# To enable the 2GHz overclock, you need to echo 1 into
# /sys/devices/system/cpu/cpufreq/boost
dtoverlay=meson-g12a-opp-2ghz
# For 1.51+ Radxa Zero boards, the user LED is on GPIO 10.
dtoverlay=meson-g12a-gpio-10-led
# For earlier it is on GPIO 8.
#dtoverlay=meson-g12a-gpio-8-led

View File

@@ -6,22 +6,27 @@ APPEND=""
set -eo pipefail
. /etc/default/extlinux
if [[ ! -f "/boot/config.txt" ]]; then
. /etc/default/extlinux
fi
if [[ -f "/etc/kernel/cmdline" ]]; then
APPEND="$APPEND $(cat /etc/kernel/cmdline)"
elif grep -qi "rk3308" /sys/firmware/devicetree/base/compatible; then
APPEND="$APPEND root=PARTUUID=614E0000-0000-4B53-8000-1D28000054A9"
APPEND="$APPEND `cat /etc/kernel/cmdline`"
elif `grep -qi "rk3328" /sys/firmware/devicetree/base/compatible` || `grep -qi "rk3399" /sys/firmware/devicetree/base/compatible`; then
APPEND="$APPEND root=PARTUUID=B921B045-1DF0-41C3-AF44-4C6F280D3FAE"
else
APPEND="$APPEND root=PARTUUID=B921B045-1DF0-41C3-AF44-4C6F280D3FAE"
APPEND="$APPEND root=PARTUUID=614E0000-0000-4B53-8000-1D28000054A9"
fi
if [[ -f "/etc/default/console" ]]; then
APPEND="$APPEND $(cat /etc/default/console)"
APPEND="$APPEND `cat /etc/default/console`"
fi
if [[ -f "/boot/config.txt" ]]; then
for CMDLINE in `grep "^cmdline:" /boot/config.txt | sed 's/cmdline://g'`
do
APPEND="$APPEND $CMDLINE"
done
fi
echo "Kernel configuration : $APPEND" 1>&2
@@ -30,51 +35,57 @@ echo ""
echo "Creating new extlinux.conf..." 1>&2
mkdir -p /boot/extlinux/
exec 1>/boot/extlinux/extlinux.conf.new
exec 1> /boot/extlinux/extlinux.conf.new
echo "timeout ${TIMEOUT:-10}"
echo "menu title select kernel"
echo "#timeout ${TIMEOUT:-10}"
echo "#menu title select kernel"
[[ -n "$DEFAULT" ]] && echo "default $DEFAULT"
echo ""
emit_kernel() {
local VERSION="$1"
local APPEND="$2"
local NAME="$3"
local VERSION="$1"
local APPEND="$2"
local NAME="$3"
local DTOVERLAY=""
echo "label kernel-$VERSION$NAME"
echo " kernel /vmlinuz-$VERSION"
echo "label kernel-$VERSION$NAME"
echo " kernel /vmlinuz-$VERSION"
if [[ -f "/etc/kernel/cmdline" ]]; then
if [[ -f "/boot/initrd.img-$VERSION" ]]; then
echo " initrd /initrd.img-$VERSION"
fi
if [[ -f "/etc/kernel/cmdline" ]]; then
if [[ -f "/boot/initrd.img-$VERSION" ]]; then
echo " initrd /initrd.img-$VERSION"
fi
fi
if [[ -f "/boot/dtb-$VERSION" ]]; then
echo " fdt /dtb-$VERSION"
else
if [[ ! -d "/boot/dtbs/$VERSION" ]]; then
mkdir -p /boot/dtbs
cp -au "/usr/lib/linux-image-$VERSION" "/boot/dtbs/$VERSION"
fi
echo " devicetreedir /dtbs/$VERSION/amlogic"
if [[ -f "/boot/dtb-$VERSION" ]]; then
echo " fdt /dtb-$VERSION"
else
if [[ ! -d "/boot/dtbs/$VERSION" ]]; then
mkdir -p /boot/dtbs
cp -au "/usr/lib/linux-image-$VERSION" "/boot/dtbs/$VERSION"
fi
echo " devicetreedir /dtbs/$VERSION/amlogic"
fi
echo " append $APPEND"
echo ""
if [[ -f "/boot/config.txt" ]]; then
for DTBO in `grep "^dtoverlay=" /boot/config.txt | sed 's/dtoverlay=//g'`
do
if [[ -f "/boot/dtbs/$VERSION/amlogic/overlay/$DTBO.dtbo" ]]; then
DTOVERLAY="$DTOVERLAY /dtbs/$VERSION/amlogic/overlay/$DTBO.dtbo "
fi
done
if [[ -n "$DTOVERLAY" ]]; then
echo " fdtoverlays "$DTOVERLAY""
fi
fi
echo " append $APPEND"
echo ""
}
rm -rf /boot/dtbs
linux-version list | linux-version sort --reverse | while read VERSION; do
emit_kernel "$VERSION" "$APPEND"
emit_kernel "$VERSION" "$APPEND"
done
exec 1<&-

View File

@@ -35,6 +35,7 @@ cp /bsp/firmware/radxa-zero/* /lib/firmware/brcm/
status_stage3 'Add needed extlinux and uenv scripts'
cp /bsp/scripts/radxa/update_extlinux.sh /usr/local/sbin/
cp /bsp/scripts/radxa/update_uenv.sh /usr/local/sbin/
cp /bsp/scripts/radxa/config.txt /boot/
mkdir -p /etc/kernel/postinst.d
# Be sure to update the cmdline with the correct UUID after creating the img.
cp /bsp/scripts/radxa/cmdline /etc/kernel