dualboot: update-firmware: new option to swap active system ('--swap-active-system')
This allows to remove the script 'on-the-fly-swap-partition.sh'. https://onedigi.atlassian.net/browse/DEL-8399 Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
This commit is contained in:
parent
1b17e8f657
commit
ccc4680924
|
|
@ -11,7 +11,6 @@ SRC_URI = " \
|
||||||
file://dualboot-init \
|
file://dualboot-init \
|
||||||
file://update-firmware \
|
file://update-firmware \
|
||||||
file://firmware-update-check.service \
|
file://firmware-update-check.service \
|
||||||
file://on-the-fly-swap-partition.sh \
|
|
||||||
"
|
"
|
||||||
|
|
||||||
S = "${WORKDIR}"
|
S = "${WORKDIR}"
|
||||||
|
|
@ -28,7 +27,6 @@ do_install() {
|
||||||
|
|
||||||
install -d ${D}${bindir}
|
install -d ${D}${bindir}
|
||||||
install -m 0755 ${WORKDIR}/update-firmware ${D}${bindir}
|
install -m 0755 ${WORKDIR}/update-firmware ${D}${bindir}
|
||||||
install -m 0755 ${WORKDIR}/on-the-fly-swap-partition.sh ${D}${bindir}
|
|
||||||
|
|
||||||
install -d ${D}${systemd_unitdir}/system/
|
install -d ${D}${systemd_unitdir}/system/
|
||||||
install -m 0644 ${WORKDIR}/firmware-update-check.service ${D}${systemd_unitdir}/system/
|
install -m 0644 ${WORKDIR}/firmware-update-check.service ${D}${systemd_unitdir}/system/
|
||||||
|
|
@ -65,7 +63,6 @@ FILES:${PN} += " \
|
||||||
${sysconfdir}/dualboot-init \
|
${sysconfdir}/dualboot-init \
|
||||||
${sysconfdir}/init.d/dualboot-init \
|
${sysconfdir}/init.d/dualboot-init \
|
||||||
${bindir}/update-firmware \
|
${bindir}/update-firmware \
|
||||||
${bindir}/on-the-fly-swap-partition.sh \
|
|
||||||
${systemd_unitdir}/system/firmware-update-check.service \
|
${systemd_unitdir}/system/firmware-update-check.service \
|
||||||
${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', '${sysconfdir}/ssl/certs/key.pub', '', d)} \
|
${@oe.utils.conditional('TRUSTFENCE_SIGN', '1', '${sysconfdir}/ssl/certs/key.pub', '', d)} \
|
||||||
"
|
"
|
||||||
|
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#===============================================================================
|
|
||||||
#
|
|
||||||
# on-the-fly-swap-partition.sh
|
|
||||||
#
|
|
||||||
# Copyright (C) 2021-2022 by Digi International Inc.
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify it
|
|
||||||
# under the terms of the GNU General Public License version 2 as published by
|
|
||||||
# the Free Software Foundation.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# !Description: On the fly script to swap active partition
|
|
||||||
#
|
|
||||||
#===============================================================================
|
|
||||||
|
|
||||||
ACTIVE_SYSTEM="$(fw_printenv -n active_system 2>/dev/null)"
|
|
||||||
|
|
||||||
# Get current partition information so we can
|
|
||||||
# determine where to flash the images.
|
|
||||||
if [ "${ACTIVE_SYSTEM}" = "linux_a" ]; then
|
|
||||||
KERNELBOOT="linux_b"
|
|
||||||
ROOTFS="rootfs_b"
|
|
||||||
else
|
|
||||||
KERNELBOOT="linux_a"
|
|
||||||
ROOTFS="rootfs_a"
|
|
||||||
fi
|
|
||||||
if grep -qs environment /proc/mtd; then
|
|
||||||
fw_setenv mtdbootpart ${KERNELBOOT}
|
|
||||||
fw_setenv mtdrootfspart ${ROOTFS}
|
|
||||||
fw_setenv rootfsvol ${ROOTFS}
|
|
||||||
fw_setenv active_system ${KERNELBOOT}
|
|
||||||
else
|
|
||||||
# Get Boot partition device and index.
|
|
||||||
BOOT_DEV="$(fw_printenv -n mmcbootdev 2>/dev/null)"
|
|
||||||
|
|
||||||
# get boot partition index
|
|
||||||
MMC_PART="$(ls -l /dev/disk/by-partlabel/ | grep -i ${KERNELBOOT} | awk '{print $11}' | sed -e 's/[../mmcblkp]//g' -e 's/^.//')"
|
|
||||||
|
|
||||||
# search rootfs UUID
|
|
||||||
MMCROOT_PART="$(ls -l /dev/disk/by-partlabel/ | grep -i ${ROOTFS} | awk '{print $11}' | sed -e 's/[../mmcblkp]//g' -e 's/^.//')"
|
|
||||||
PART_UUID="$(ls -l /dev/disk/by-partuuid/ | grep -i mmcblk${BOOT_DEV}p${MMCROOT_PART} | awk '{print $9}')"
|
|
||||||
|
|
||||||
fw_setenv mmcroot PARTUUID=${PART_UUID}
|
|
||||||
fw_setenv mmcpart ${MMC_PART}
|
|
||||||
fw_setenv active_system ${KERNELBOOT}
|
|
||||||
fi
|
|
||||||
|
|
@ -26,6 +26,7 @@ PUBLIC_KEY="/etc/ssl/certs/key.pub"
|
||||||
ACTIVE_SYSTEM="$(fw_printenv -n active_system 2>/dev/null)"
|
ACTIVE_SYSTEM="$(fw_printenv -n active_system 2>/dev/null)"
|
||||||
SHOW_ACTIVE_SYSTEM=0
|
SHOW_ACTIVE_SYSTEM=0
|
||||||
SCRIPT_MODE=0
|
SCRIPT_MODE=0
|
||||||
|
SWAP_ACTIVE_SYSTEM=0
|
||||||
REBOOT=1
|
REBOOT=1
|
||||||
UPDATE_FILE=""
|
UPDATE_FILE=""
|
||||||
ALT_BOOT=""
|
ALT_BOOT=""
|
||||||
|
|
@ -42,6 +43,8 @@ Usage: ${SCRIPTNAME} [OPTIONS] </your-path/your-filename>.swu
|
||||||
|
|
||||||
-a --active Show currently active system
|
-a --active Show currently active system
|
||||||
--no-reboot Do not reboot after update
|
--no-reboot Do not reboot after update
|
||||||
|
--swap-active-system Swap active system block.
|
||||||
|
This option reboots the system, unless '--no-reboot' is specified.
|
||||||
-v --verbose Enable verbosity
|
-v --verbose Enable verbosity
|
||||||
-h --help Print help and exit
|
-h --help Print help and exit
|
||||||
|
|
||||||
|
|
@ -59,12 +62,13 @@ show_active_system() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# $1: message to show
|
||||||
reboot_system() {
|
reboot_system() {
|
||||||
if [ ${REBOOT} -eq 1 ]; then
|
if [ ${REBOOT} -eq 1 ]; then
|
||||||
echo "Firmware update finished. Rebooting the system."
|
echo "${1}. Rebooting the system."
|
||||||
reboot -f
|
reboot -f
|
||||||
else
|
else
|
||||||
echo "Firmware update finished. Reboot the system to use the new version."
|
echo "${1}. Reboot the system to use the new version."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,7 +157,7 @@ update_device() {
|
||||||
if ! swap_active_system; then
|
if ! swap_active_system; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
reboot_system
|
reboot_system "Firmware update finished"
|
||||||
else
|
else
|
||||||
echo "[ERROR] $? There was an error performing the update"
|
echo "[ERROR] $? There was an error performing the update"
|
||||||
fi
|
fi
|
||||||
|
|
@ -165,6 +169,8 @@ while :; do
|
||||||
;;
|
;;
|
||||||
--no-reboot) REBOOT=0
|
--no-reboot) REBOOT=0
|
||||||
;;
|
;;
|
||||||
|
--swap-active-system) SWAP_ACTIVE_SYSTEM=1
|
||||||
|
;;
|
||||||
-s) SCRIPT_MODE=1
|
-s) SCRIPT_MODE=1
|
||||||
;;
|
;;
|
||||||
-v|--verbose) VERBOSE="-v"
|
-v|--verbose) VERBOSE="-v"
|
||||||
|
|
@ -192,6 +198,15 @@ else
|
||||||
ALT_ROOTFS="rootfs_a"
|
ALT_ROOTFS="rootfs_a"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Swap active system.
|
||||||
|
if [ ${SWAP_ACTIVE_SYSTEM} -eq 1 ]; then
|
||||||
|
if ! swap_active_system; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
reboot_system "Swapped active system to $(echo ${ALT_BOOT} | cut -d'_' -f2 | tr [:lower:] [:upper:])"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
# Check update file parameter.
|
# Check update file parameter.
|
||||||
if [ -z "${UPDATE_FILE}" ]; then
|
if [ -z "${UPDATE_FILE}" ]; then
|
||||||
echo "[ERROR] Update file not specified"
|
echo "[ERROR] Update file not specified"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue