diff options
author | Mykyta Dorokhin <mykyta.dorokhin@globallogic.com> | 2016-09-27 22:29:21 +0300 |
---|---|---|
committer | Brandon Bayer <bbayer@multitech.com> | 2016-10-26 15:36:30 -0500 |
commit | 8d54b0ff470aaa53cae0640f9093eff0b781202c (patch) | |
tree | 2ad34d6c4b592be0d7a1f4cad00d4d4120b6267e /recipes-core/mlinux-scripts | |
parent | 6a9a67e34aca63caff77fd2f430cdbeaa1be3551 (diff) | |
download | meta-mlinux-8d54b0ff470aaa53cae0640f9093eff0b781202c.tar.gz meta-mlinux-8d54b0ff470aaa53cae0640f9093eff0b781202c.tar.bz2 meta-mlinux-8d54b0ff470aaa53cae0640f9093eff0b781202c.zip |
mtp: add firmware upgrade support for mlinux builds
Diffstat (limited to 'recipes-core/mlinux-scripts')
3 files changed, 62 insertions, 2 deletions
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.0.inc b/recipes-core/mlinux-scripts/mlinux-scripts-1.0.inc index fd75904..979fc4c 100644 --- a/recipes-core/mlinux-scripts/mlinux-scripts-1.0.inc +++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.0.inc @@ -6,7 +6,9 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda SRC_URI = "file://mlinux-wifi-ap \ file://mlinux-dhcpd \ file://mlinux-set-apn \ - file://mlinux-cell-router" + file://mlinux-cell-router \ + file://mlinux-firmware-upgrade \ +" do_install() { @@ -15,4 +17,5 @@ do_install() { install -m 755 ${WORKDIR}/mlinux-dhcpd ${D}${sbindir} install -m 755 ${WORKDIR}/mlinux-set-apn ${D}${sbindir} install -m 755 ${WORKDIR}/mlinux-cell-router ${D}${sbindir} + install -m 755 ${WORKDIR}/mlinux-firmware-upgrade ${D}${sbindir} } diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.0/mlinux-firmware-upgrade b/recipes-core/mlinux-scripts/mlinux-scripts-1.0/mlinux-firmware-upgrade new file mode 100755 index 0000000..94027d5 --- /dev/null +++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.0/mlinux-firmware-upgrade @@ -0,0 +1,57 @@ +#!/bin/bash + +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) + +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 /var/volatile/do_flash_upgrade + logger -s -t firmware_upgrade "Rebooting" + sleep 1 + reboot + exit 0 +else + logger -s -t firmware_upgrade "Nothing to be flashed!" + exit 1 +fi diff --git a/recipes-core/mlinux-scripts/mlinux-scripts_1.0.bb b/recipes-core/mlinux-scripts/mlinux-scripts_1.0.bb index 6b0d37f..9fb8fbd 100644 --- a/recipes-core/mlinux-scripts/mlinux-scripts_1.0.bb +++ b/recipes-core/mlinux-scripts/mlinux-scripts_1.0.bb @@ -2,6 +2,6 @@ DESCRIPTION = "Scripts to easily get started with common mLinux use cases" require mlinux-scripts-1.0.inc -PR = "r4" +PR = "r5" S = "${WORKDIR}/mlinux-scripts-${PV}" |