From 4e9d2d6a27c9a88aebda54ca9b2d3253bdc8145f Mon Sep 17 00:00:00 2001 From: John Klug Date: Thu, 10 Mar 2022 15:22:30 -0600 Subject: Kernel image install from ipk --- recipes-kernel/linux/linux-at91_5.4.81.bb | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/recipes-kernel/linux/linux-at91_5.4.81.bb b/recipes-kernel/linux/linux-at91_5.4.81.bb index de29088..985dedf 100644 --- a/recipes-kernel/linux/linux-at91_5.4.81.bb +++ b/recipes-kernel/linux/linux-at91_5.4.81.bb @@ -274,3 +274,43 @@ KERNEL_MODULE_AUTOLOAD_mtre += " \ ${NET_LOAD_ALL_MACHINES} \ ${DRIVER_LOAD_ALL_MACHINES} \ " + +# Never delete /boot, as it poisons the overlay +# and you cannot get it back. +pkg_preinst_kernel-image-uimage() { + set -x + if [ -d /boot ] ; then + cd /boot + rm -rf /boot/{*,.*} 2>/dev/null || true + else + mkdir -m 0755 /boot + fi + mkdir -m 0755 /var/volatile/boot 2>/dev/null || true + mount -o bind /var/volatile/boot /boot +} + +pkg_prerm_kernel-image-uimage() { + umount -lf /boot || true + rm -rf /var/volatile/boot || true + rm -rf /boot/{*,.*} 2>/dev/null || true +} + +PACKAGES =+ "kernel-image-uimage-inst" +# Not sure how to get the name below generated automatically +RDEPENDS_kernel-image-uimage-inst += "kernel-image-uimage-${PV}" +ALLOW_EMPTY_kernel-image-uimage-inst = "1" + +pkg_postinst_kernel-image-uimage-inst() { + # Only installs all the kernel on the device (D is defined in bitbake) + if [[ -z "$D" ]] ; then + logger -s -p user.info -t opkg "Upgrading kernel ${PV} -- poweroff will create an unbootable device" + set -x + kernel_mtd="/dev/$(cat /proc/mtd | grep '\"uImage\"' | cut -d : -f 1)" + flash_erase ${kernel_mtd} 0 0 + if nandwrite -p ${kernel_mtd} /boot/uImage-${PV} ; then + echo 'Kernel image update is successful' + fi + set +x + fi +} + -- cgit v1.2.3