Quirks for Ingenic SoC kernel validation (#565)

pull/568/head
Paul Philippov 2022-11-18 14:16:30 -05:00 committed by GitHub
parent 6b6bddd4ed
commit 00be133a26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 18 deletions

View File

@ -1,9 +1,9 @@
#!/bin/sh #!/bin/sh
# #
# OpenIPC.org | v.20221111 # OpenIPC.org | v.20221118
# #
scr_version=1.0.13 scr_version=1.0.14
args=" $@" args=" $@"
@ -35,25 +35,30 @@ compare_versions() {
} }
do_update_kernel() { do_update_kernel() {
x=$1 local x=$1
[ -z "$x" ] && x="/tmp/uImage.$soc" [ -z "$x" ] && x="/tmp/uImage.$soc"
echo_c 33 "\nKernel" echo_c 33 "\nKernel"
echo "Update kernel from $x" echo "Update kernel from $x"
[ ! -f "$x" ] && die "File $x not found" [ ! -f "$x" ] && die "File $x not found"
check_soc "$(od -j 32 -N 32 -S 1 -A n "$x" | cut -d- -f3)" local ksoc=$(od -j 32 -N 32 -S 1 -A n "$x" | cut -d- -f3)
# FIXME: Ingenic kernels do not include proper SoC identifiers.
case "$soc" in
t31) [ "t" != "$ksoc" ] && die "Wrong SoC!" ;;
t21) [ "" != "$ksoc" ] && die "Wrong SoC!" ;;
*) check_soc "$ksoc"
esac
compare_versions "$kernel_version" "$(get_kernel_version "$x")" && return 0 compare_versions "$kernel_version" "$(get_kernel_version "$x")" && return 0
flashcp -v "$x" "$kernel_device" flashcp -v "$x" "$kernel_device"
echo_c 32 "Kernel updated to $(get_kernel_version "$kernel_device")" echo_c 32 "Kernel updated to $(get_kernel_version "$kernel_device")"
unset x
} }
do_update_rootfs() { do_update_rootfs() {
x=$1 local x=$1
[ -z "$x" ] && x="/tmp/rootfs.squashfs.$soc" [ -z "$x" ] && x="/tmp/rootfs.squashfs.$soc"
echo_c 33 "\nRootFS" echo_c 33 "\nRootFS"
echo "Update rootfs from $x" echo "Update rootfs from $x"
[ ! -f "$x" ] && die "File ${x} not found" [ ! -f "$x" ] && die "File ${x} not found"
y=/tmp/rootfs local y=/tmp/rootfs
if mkdir -p "$y" && loop=$(losetup -f) && losetup "$loop" "$x" && mount "$loop" "$y"; then if mkdir -p "$y" && loop=$(losetup -f) && losetup "$loop" "$x" && mount "$loop" "$y"; then
check_soc "$(head -1 ${y}/etc/hostname | cut -d- -f2)" check_soc "$(head -1 ${y}/etc/hostname | cut -d- -f2)"
compare_versions "$system_version" "$(get_system_version "$y")" && return 0 compare_versions "$system_version" "$(get_system_version "$y")" && return 0
@ -61,11 +66,9 @@ do_update_rootfs() {
else else
die "Unable to mount $y!" die "Unable to mount $y!"
fi fi
unset y
flashcp -v "$x" "$(get_device "rootfs")" flashcp -v "$x" "$(get_device "rootfs")"
echo_c 32 "RootFS updated to $(get_system_version "")" echo_c 32 "RootFS updated to $(get_system_version "")"
unset x
} }
do_wipe_overlay() { do_wipe_overlay() {
@ -154,18 +157,19 @@ check_sdcard() {
echo_c 33 "\nUnmounting SD card" echo_c 33 "\nUnmounting SD card"
stoplist="autoupdate-kernel.img autoupdate-rootfs.img autoupdate-uboot.img" stoplist="autoupdate-kernel.img autoupdate-rootfs.img autoupdate-uboot.img"
while [ -n "$(mount | grep /mnt/mmc)" ]; do while [ -n "$(mount | grep /mnt/mmc)" ]; do
_d=$(mount | grep /mnt/mmc | tail -1 | awk '{print $3}') local d=$(mount | grep /mnt/mmc | tail -1 | awk '{print $3}')
echo_c 34 "$_d" echo_c 34 "$d"
for _f in $stoplist; do local f
echo "- checking for ${_d}/${_f}" for f in $stoplist; do
if [ -f "${_d}/${_f}" ]; then echo "- checking for ${d}/${f}"
echo_c 31 "\nCannot upgrade! Recovery file ${_d}/${_f} found on the mounted SD card!" if [ -f "${d}/${f}" ]; then
echo_c 31 "\nCannot upgrade! Recovery file ${d}/${f} found on the mounted SD card!"
echo_c 37 "Please remove the card from the slot and restart sysupgrade." echo_c 37 "Please remove the card from the slot and restart sysupgrade."
exit 1 exit 1
fi fi
done; unset _f done
umount $_d umount $d
done; unset _d done
} }
create_lock() { create_lock() {