more progress

This commit is contained in:
Pratham Patel 2023-10-05 05:49:25 +05:30
parent 96db78824f
commit f1321da0b5
No known key found for this signature in database
2 changed files with 48 additions and 45 deletions

View file

@ -1,8 +1,3 @@
# DO NOT EDIT THIS FILE
#
# Please edit /boot/uEnv.txt to set supported parameters
#
setenv load_addr "0x9000000"
setenv overlay_error "false"
# default values
@ -14,17 +9,19 @@ setenv docker_optimizations "on"
setenv earlycon "off"
setenvrootdev
setenvunamer
setenv envfile "${prefix}uEnv.txt-${unamer}"
setenv dtbdir "${prefix}dtb-${unamer}"
echo "Boot script loaded from ${devtype} ${devnum}"
echo "Testing for existence ${devtype} ${devnum} ${prefix}uEnv.txt ..."
if test -e ${devtype} ${devnum} ${prefix}uEnv.txt; then
echo "Found ${devtype} ${devnum} ${prefix}uEnv.txt - loading ${devtype} ${devnum} ${load_addr} ${prefix}uEnv.txt ..."
load ${devtype} ${devnum} ${load_addr} ${prefix}uEnv.txt
echo "Loaded environment from ${devtype} ${devnum} ${prefix}uEnv.txt into ${load_addr} filesize ${filesize}..."
echo "Importing into environment ..."
env import -t ${load_addr} ${filesize}
echo "uEnv.txt imported into environment"
echo "Testing for existence ${devtype} ${devnum} ${envfile} ..."
if test -e ${devtype} ${devnum} ${envfile}; then
echo "Loading ${devtype} ${devnum} ${load_addr} ${envfile} ..."
load ${devtype} ${devnum} ${load_addr} ${envfile}
echo "Loaded ${devtype} ${devnum} ${envfile} into ${load_addr} filesize ${filesize}..."
echo "Importing into environment ..."
env import -t ${load_addr} ${filesize}
echo "${envfile} imported into environment"
fi
if test "${logo}" = "disabled"; then setenv logo "logo.nologo"; fi
@ -33,9 +30,9 @@ if test "${console}" = "display" || test "${console}" = "both"; then setenv cons
if test "${console}" = "serial" || test "${console}" = "both"; then setenv consoleargs "console=ttyS2,1500000 ${consoleargs}"; fi
if test "${earlycon}" = "on"; then setenv consoleargs "earlycon ${consoleargs}"; fi
if test "${bootlogo}" = "true"; then
setenv consoleargs "splash plymouth.ignore-serial-consoles ${consoleargs}"
setenv consoleargs "splash plymouth.ignore-serial-consoles ${consoleargs}"
else
setenv consoleargs "splash=verbose ${consoleargs}"
setenv consoleargs "splash=verbose ${consoleargs}"
fi
# get PARTUUID of first partition on SD/eMMC the boot script was loaded from
@ -45,43 +42,40 @@ setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs
if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1"; fi
load ${devtype} ${devnum} ${ramdisk_addr_r} ${prefix}uInitrd
load ${devtype} ${devnum} ${kernel_addr_r} ${prefix}Image
load ${devtype} ${devnum} ${ramdisk_addr_r} ${prefix}uInitrd-${unamer}
load ${devtype} ${devnum} ${kernel_addr_r} ${prefix}vmlinuz-${unamer}
load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}dtb/${fdtfile}
load ${devtype} ${devnum} ${fdt_addr_r} ${dtbdir}/${fdtfile}
fdt addr ${fdt_addr_r}
fdt resize 65536
for overlay_file in ${overlays}; do
if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/rockchip/overlay/${overlay_prefix}-${overlay_file}.dtbo; then
echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
elif load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/rockchip/overlay/${overlay_file}.dtbo; then
echo "Applying kernel provided DT overlay ${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
fi
if load ${devtype} ${devnum} ${load_addr} ${dtbdir}/rockchip/overlay/${overlay_prefix}-${overlay_file}.dtbo; then
echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
elif load ${devtype} ${devnum} ${load_addr} ${dtbdir}/rockchip/overlay/${overlay_file}.dtbo; then
echo "Applying kernel provided DT overlay ${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
fi
done
for overlay_file in ${user_overlays}; do
if load ${devtype} ${devnum} ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then
echo "Applying user provided DT overlay ${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
fi
if load ${devtype} ${devnum} ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then
echo "Applying user provided DT overlay ${overlay_file}.dtbo"
fdt apply ${load_addr} || setenv overlay_error "true"
fi
done
if test "${overlay_error}" = "true"; then
echo "Error applying DT overlays, restoring original DT"
load ${devtype} ${devnum} ${fdt_addr_r} ${prefix}dtb/${fdtfile}
echo "Error applying DT overlays, restoring original DT"
load ${devtype} ${devnum} ${fdt_addr_r} ${dtbdir}/${fdtfile}
else
if load ${devtype} ${devnum} ${load_addr} ${prefix}dtb/rockchip/overlay/${overlay_prefix}-fixup.scr; then
echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)"
source ${load_addr}
fi
if test -e ${devtype} ${devnum} ${prefix}fixup.scr; then
load ${devtype} ${devnum} ${load_addr} ${prefix}fixup.scr
echo "Applying user provided fixup script (fixup.scr)"
source ${load_addr}
fi
if load ${devtype} ${devnum} ${load_addr} ${dtbdir}/rockchip/overlay/${overlay_prefix}-fixup.scr; then
echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)"
source ${load_addr}
fi
if test -e ${devtype} ${devnum} ${prefix}fixup.scr; then
load ${devtype} ${devnum} ${load_addr} ${prefix}fixup.scr
echo "Applying user provided fixup script (fixup.scr)"
source ${load_addr}
fi
fi
kaslrseed
booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
# Recompile with:
# mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr

View file

@ -23,14 +23,16 @@ echo "Nothing to prepare"
echo "Nothing to build"
%install
cp ${SOURCE0} $RPM_BUILD_ROOT/boot/efi/boot.cmd-%{full_ver}
cp ${SOURCE1} $RPM_BUILD_ROOT/boot/efi/uEnv.txt-%{full_ver}
cp ${SOURCE0} $RPM_BUILD_ROOT/boot/efi/boot.cmd
cp ${SOURCE1} $RPM_BUILD_ROOT/boot/efi/uEnv.txt
%clean
rm -rf $RPM_BUILD_ROOT
%post
set -xeuf -o pipefail
cp /boot/efi/boot.cmd /boot/efi/boot.cmd-%{full_ver}
cp /boot/efi/uEnv.txt /boot/efi/uEnv.txt-%{full_ver}
if [ -f /boot/.uname ]; then
UNAME_R=$(</boot/.uname)
BOOT_PART=$(grep '/ ' /etc/fstab | awk '{print $1}')
@ -41,5 +43,12 @@ if [ -f /boot/.uname ]; then
else
echo "ERROR: No /boot/.uname found to extract 'uname -r' from."
fi
mkimage -C none -A arm -T script -d /boot/efi/boot.cmd-%{full_ver} /boot/efi/boot.scr-%{full_ver}
cp /boot/boot.scr-%{full_ver} /boot/efi/boot.scr
mkimage -A arm -T ramdisk -C none -n uInitrd -d /boot/initramfs-${UNAME_R}.img /boot/uInitrd-${UNAME_R}
cp /boot/uInitrd-${UNAME_R} /boot/uInitrd
diff /boot/efi/boot.cmd /boot/efi/boot.cmd-%{full_ver} > /boot/diff_boot_cmd
diff /boot/efi/uEnv.txt /boot/efi/uEnv.txt-%{full_ver} > /boot/diff_uenv_txt