aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorLech Perczak <lech.perczak@gmail.com>2022-04-28 23:32:06 +0200
committerPiotr Dymacz <pepe2k@gmail.com>2022-07-11 14:18:40 +0200
commit70a9c75ef3ff3866b0cf9b80323ba756a3850b59 (patch)
tree069a5fca1ed5ce2d966b245bef3c7155e5e34e8e /target
parentf987887e14702ef0fe63b1721f498946669e3b79 (diff)
downloadupstream-70a9c75ef3ff3866b0cf9b80323ba756a3850b59.tar.gz
upstream-70a9c75ef3ff3866b0cf9b80323ba756a3850b59.tar.bz2
upstream-70a9c75ef3ff3866b0cf9b80323ba756a3850b59.zip
imx: decouple sdcard sysupgrade from Apalis boards
Sysupgrade procedure for i.MX 6 Apalis boards is suitable for most other i.MX boards booting from eMMC or SD card. Extract the common parts and decouple the procedure from "apalis" board name in sysupgrade TAR contents, so the procedure is reusable for i.MX 7 boards. Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
Diffstat (limited to 'target')
-rw-r--r--target/linux/imx/base-files/lib/imx.sh63
-rw-r--r--target/linux/imx/cortexa9/base-files/lib/imx.sh30
-rw-r--r--target/linux/imx/cortexa9/base-files/lib/preinit/79_move_config6
-rwxr-xr-xtarget/linux/imx/cortexa9/base-files/lib/upgrade/platform.sh24
4 files changed, 67 insertions, 56 deletions
diff --git a/target/linux/imx/base-files/lib/imx.sh b/target/linux/imx/base-files/lib/imx.sh
new file mode 100644
index 0000000000..a451de3779
--- /dev/null
+++ b/target/linux/imx/base-files/lib/imx.sh
@@ -0,0 +1,63 @@
+#
+# Copyright (C) 2010-2013 OpenWrt.org
+#
+
+rootpartuuid() {
+ local cmdline=$(cat /proc/cmdline)
+ local bootpart=${cmdline##*root=}
+ bootpart=${bootpart%% *}
+ local uuid=${bootpart#PARTUUID=}
+ echo ${uuid%-02}
+}
+
+bootdev_from_uuid() {
+ blkid | grep "PTUUID=\"$(rootpartuuid)\"" | cut -d : -f1
+}
+
+bootpart_from_uuid() {
+ blkid | grep $(rootpartuuid)-01 | cut -d : -f1
+}
+
+rootpart_from_uuid() {
+ blkid | grep $(rootpartuuid)-02 | cut -d : -f1
+}
+
+imx_sdcard_mount_boot() {
+ mkdir -p /boot
+ [ -f /boot/uImage ] || {
+ mount -o rw,noatime $(bootpart_from_uuid) /boot > /dev/null
+ }
+}
+
+imx_sdcard_copy_config() {
+ imx_sdcard_mount_boot
+ cp -af "$UPGRADE_BACKUP" "/boot/$BACKUP_FILE"
+ sync
+ umount /boot
+}
+
+imx_sdcard_do_upgrade() {
+ local board_dir="$(tar tf "${1}" | grep -m 1 '^sysupgrade-.*/$')"
+ board_dir="${board_dir%/}"
+
+ imx_sdcard_mount_boot
+ get_image "$1" | tar Oxf - ${board_dir}/kernel > /boot/uImage
+ get_image "$1" | tar Oxf - ${board_dir}/root > $(rootpart_from_uuid)
+ sync
+ umount /boot
+}
+
+imx_sdcard_pre_upgrade() {
+ [ -z "$UPGRADE_BACKUP" ] && {
+ jffs2reset -y
+ umount /overlay
+ }
+}
+
+imx_sdcard_move_config() {
+ if [ -b $(bootpart_from_uuid) ]; then
+ imx_sdcard_mount_boot
+ [ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
+ umount /boot
+ fi
+}
diff --git a/target/linux/imx/cortexa9/base-files/lib/imx.sh b/target/linux/imx/cortexa9/base-files/lib/imx.sh
deleted file mode 100644
index 46d2eeb006..0000000000
--- a/target/linux/imx/cortexa9/base-files/lib/imx.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright (C) 2010-2013 OpenWrt.org
-#
-
-rootpartuuid() {
- local cmdline=$(cat /proc/cmdline)
- local bootpart=${cmdline##*root=}
- bootpart=${bootpart%% *}
- local uuid=${bootpart#PARTUUID=}
- echo ${uuid%-02}
-}
-
-bootdev_from_uuid() {
- blkid | grep "PTUUID=\"$(rootpartuuid)\"" | cut -d : -f1
-}
-
-bootpart_from_uuid() {
- blkid | grep $(rootpartuuid)-01 | cut -d : -f1
-}
-
-rootpart_from_uuid() {
- blkid | grep $(rootpartuuid)-02 | cut -d : -f1
-}
-
-apalis_mount_boot() {
- mkdir -p /boot
- [ -f /boot/uImage ] || {
- mount -o rw,noatime $(bootpart_from_uuid) /boot > /dev/null
- }
-}
diff --git a/target/linux/imx/cortexa9/base-files/lib/preinit/79_move_config b/target/linux/imx/cortexa9/base-files/lib/preinit/79_move_config
index 7188c2d8f4..a2e3aa3b86 100644
--- a/target/linux/imx/cortexa9/base-files/lib/preinit/79_move_config
+++ b/target/linux/imx/cortexa9/base-files/lib/preinit/79_move_config
@@ -9,11 +9,7 @@ move_config() {
toradex,apalis_imx6q-eval|\
toradex,apalis_imx6q-ixora|\
toradex,apalis_imx6q-ixora-v1.1)
- if [ -b $(bootpart_from_uuid) ]; then
- apalis_mount_boot
- [ -f "/boot/$BACKUP_FILE" ] && mv -f "/boot/$BACKUP_FILE" /
- umount /boot
- fi
+ imx_sdcard_move_config
;;
esac
}
diff --git a/target/linux/imx/cortexa9/base-files/lib/upgrade/platform.sh b/target/linux/imx/cortexa9/base-files/lib/upgrade/platform.sh
index d6f8fb82a6..dc2bf9cf49 100755
--- a/target/linux/imx/cortexa9/base-files/lib/upgrade/platform.sh
+++ b/target/linux/imx/cortexa9/base-files/lib/upgrade/platform.sh
@@ -17,21 +17,6 @@ enable_image_metadata_check() {
}
enable_image_metadata_check
-apalis_copy_config() {
- apalis_mount_boot
- cp -af "$UPGRADE_BACKUP" "/boot/$BACKUP_FILE"
- sync
- umount /boot
-}
-
-apalis_do_upgrade() {
- apalis_mount_boot
- get_image "$1" | tar Oxf - sysupgrade-apalis/kernel > /boot/uImage
- get_image "$1" | tar Oxf - sysupgrade-apalis/root > $(rootpart_from_uuid)
- sync
- umount /boot
-}
-
platform_check_image() {
local board=$(board_name)
@@ -109,7 +94,7 @@ platform_do_upgrade() {
toradex,apalis_imx6q-eval|\
toradex,apalis_imx6q-ixora|\
toradex,apalis_imx6q-ixora-v1.1)
- apalis_do_upgrade "$1"
+ imx_sdcard_do_upgrade "$1"
;;
esac
}
@@ -121,7 +106,7 @@ platform_copy_config() {
toradex,apalis_imx6q-eval|\
toradex,apalis_imx6q-ixora|\
toradex,apalis_imx6q-ixora-v1.1)
- apalis_copy_config
+ imx_sdcard_copy_config
;;
esac
}
@@ -133,10 +118,7 @@ platform_pre_upgrade() {
toradex,apalis_imx6q-eval|\
toradex,apalis_imx6q-ixora|\
toradex,apalis_imx6q-ixora-v1.1)
- [ -z "$UPGRADE_BACKUP" ] && {
- jffs2reset -y
- umount /overlay
- }
+ imx_sdcard_pre_upgrade
;;
esac
}