aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mvebu/base-files/lib/preinit
diff options
context:
space:
mode:
authorVladimir Vid <vladimir.vid@sartura.hr>2019-07-22 13:08:18 +0200
committerLuka Perkov <luka.perkov@sartura.hr>2019-08-24 23:11:15 +0200
commit7dff6a8c89e30e660ef077d31ec0358a04161271 (patch)
treeab5b7fde846145b8ab0531ae41c78596a25b178c /target/linux/mvebu/base-files/lib/preinit
parent52cbe6b9c0865c8398c2fd23d1cf56a1afdb66f7 (diff)
downloadupstream-7dff6a8c89e30e660ef077d31ec0358a04161271.tar.gz
upstream-7dff6a8c89e30e660ef077d31ec0358a04161271.tar.bz2
upstream-7dff6a8c89e30e660ef077d31ec0358a04161271.zip
mvebu: uDPU: add sysupgrade support
This patch adds sysupgrade, uboot-env and networking support for Methode uDPU device. Device features 4 partitions: ----------------------------------------- | boot | recovery | rootfs | misc | | (ext4) | (ext4) | (fsf2) | (f2fs) | _________________________________________ Idea was to use f2fs only but the u-boot currently lacks support so first 2 partition are ext4 to be u-boot readable, and this was a reason why custom build and sysupgrade sections were required. On the sysupgrade, boot and rootfs partitions are updated, firmare image and user configuration is saved on the misc partition and if the upgrade was successfull, recovery partition will be updated on after the reboot from preinit script. If the sysupgrade fails for any reason, device will fallback to recovery initramfs image. Signed-off-by: Vladimir Vid <vladimir.vid@sartura.hr>
Diffstat (limited to 'target/linux/mvebu/base-files/lib/preinit')
-rw-r--r--target/linux/mvebu/base-files/lib/preinit/82_uDPU48
1 files changed, 48 insertions, 0 deletions
diff --git a/target/linux/mvebu/base-files/lib/preinit/82_uDPU b/target/linux/mvebu/base-files/lib/preinit/82_uDPU
new file mode 100644
index 0000000000..937a0a5f21
--- /dev/null
+++ b/target/linux/mvebu/base-files/lib/preinit/82_uDPU
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2014-2019 OpenWrt.org
+# Copyright (C) 2016 LEDE-Project.org
+#
+
+preinit_mount_udpu() {
+
+ . /lib/functions.sh
+
+ case $(board_name) in
+ methode,udpu)
+ # Check which device is detected
+ [ -b "/dev/mmcblk0" ] && mmcdev="/dev/mmcblk0" || mmcdev="/dev/mmcblk1"
+
+ if [ -b "${mmcdev}p4" ]; then
+ mkdir /misc
+ mount -t f2fs ${mmcdev}p4 /misc
+ [ -f "/misc/sysupgrade.tgz" ] && {
+ echo "- Restoring configuration files -"
+ tar xzf /misc/sysupgrade.tgz -C /
+ rm -f /misc/sysupgrade.tgz
+ sync
+ }
+ [ -f "/misc/firmware/recovery.itb" ] && {
+ echo "- Updating /recovery partition -"
+ mkfs.ext4 -q ${mmcdev}p2 | echo y &> /dev/null
+ mkdir -p /tmp/recovery
+ mount ${mmcdev}p2 /tmp/recovery
+ cp /misc/firmware/recovery.itb /tmp/recovery
+ [ -f "/misc/firmware/boot.scr" ] && \
+ cp /misc/firmware/boot.scr /tmp/recovery
+ sync
+ umount /tmp/recovery
+ rm -rf /tmp/recovery
+
+ # Replace previous backup with the new one
+ [ -d "/misc/firmware_old" ] && rm -rf /misc/firmware_old
+ [ -d "/misc/firmware" ] && mv /misc/firmware /misc/firmware_old
+ }
+ fi
+
+ # Legacy support - if rootfs was booted, instruct u-boot to keep the current root dev
+ [ "$(df | grep /dev/root)" ] && fw_setenv root_ok '2'
+ ;;
+ esac
+}
+
+boot_hook_add preinit_main preinit_mount_udpu