From fd72c74c99849b26db9a6876ada2e6a0e80bc783 Mon Sep 17 00:00:00 2001 From: John Klug Date: Mon, 12 Aug 2019 12:13:11 -0500 Subject: Update mlinux-set-apn for new chat_wrapper script --- .../mlinux-scripts-1.2/mlinux-firmware-upgrade | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-firmware-upgrade (limited to 'recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-firmware-upgrade') diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-firmware-upgrade b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-firmware-upgrade new file mode 100755 index 0000000..a377309 --- /dev/null +++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.2/mlinux-firmware-upgrade @@ -0,0 +1,69 @@ +#!/bin/bash +dofile=/var/volatile/do_flash_upgrade + +if [ $# != 1 ]; then + echo "Usage: $0 upgrade.bin" + exit 1 +fi + +set -e +upgrade=$1 + +mkdir -p /var/volatile +cd /var/volatile + +# make sure firmware is for this device +hw_version=$(cat /sys/devices/platform/mts-io/hw-version) +firmware_model=$(tar -xO -f $upgrade model) +shopt -s nocasematch +if [[ ! "$hw_version" =~ ^$firmware_model- ]]; then + logger -s -t firmware_upgrade "Wrong firmware for this hardware" + logger -s -t firmware_upgrade "hw version: $hw_version" + logger -s -t firmware_upgrade "firmware model: $firmware_model" + exit 1 +fi + +files=(bstrap.bin uboot.bin uImage.bin config.jffs2 oem.jffs2 rootfs.jffs2 install.sh) + +tobeflashed=0 +# verify all MD5 sums +for (( i = 0; i < ${#files[@]}; i++ )); do + file=${files[i]} + # if the file is in the tar, md5sum it + if tar -t -f $upgrade | grep -F -q "$file"; then + logger -s -t firmware_upgrade "Checking MD5 for $file..." + if ! tar -x -f $upgrade $file.md5; then + logger -s -t firmware_upgrade "MD5 is not found for the $file, upgrade aborted" + exit 1 + fi + if ! tar -xO -f $upgrade $file | md5sum -c $file.md5; then + logger -s -t firmware_upgrade "MD5 check failed, upgrade aborted" + exit 1 + fi + tobeflashed=1 + fi +done + +if (( $tobeflashed )); then + mkdir -p /var/volatile/flash-upgrade + mv -f $upgrade /var/volatile/flash-upgrade/upgrade.bin + touch "${dofile}" + chown "root:root" "${dofile}" || true + uid=$(stat -c %u "${dofile}") || true + result=$? + if ((result != 0)) ; then + logger -s -t firmware_upgrade "Cannot create ${dofile}" + exit 1 + fi + if ((uid != 0)) ; then + logger -s -t firmware_upgrade "Cannot set ownership of ${dofile} to root" + exit 1 + fi + logger -s -t firmware_upgrade "Rebooting" + sleep 1 + reboot + exit 0 +else + logger -s -t firmware_upgrade "Nothing to be flashed!" + exit 1 +fi -- cgit v1.2.3