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 | |
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')
5 files changed, 88 insertions, 2 deletions
diff --git a/recipes-core/images/mlinux-firmware-upgrade.inc b/recipes-core/images/mlinux-firmware-upgrade.inc new file mode 100644 index 0000000..c3c7c8d --- /dev/null +++ b/recipes-core/images/mlinux-firmware-upgrade.inc @@ -0,0 +1,25 @@ +# generate mlinux firmware upgrade files + +FIRMWARE_UPGRADE_FILE_NAME ?= "${IMAGE_BASENAME}-${MACHINE}-upgrade.bin" + +do_firmware () { + cd ${DEPLOY_DIR_IMAGE} + rm -f bstrap.bin* uboot.bin* uImage.bin* rootfs.jffs2* model + + cp at91bootstrap_pmecc_padded.bin bstrap.bin + cp u-boot-${MACHINE}.bin uboot.bin + cp uImage-${MACHINE}.bin uImage.bin + cp ${IMAGE_BASENAME}-${MACHINE}.jffs2 rootfs.jffs2 + + cat bstrap.bin | md5sum > bstrap.bin.md5 + cat uboot.bin | md5sum > uboot.bin.md5 + cat uImage.bin | md5sum > uImage.bin.md5 + cat rootfs.jffs2 | md5sum > rootfs.jffs2.md5 + + echo "${MACHINE}" > model + + tar cvf ${FIRMWARE_UPGRADE_FILE_NAME} bstrap.bin* uboot.bin* uImage.bin* rootfs.jffs2* model + rm -f bstrap.bin* uboot.bin* uImage.bin* rootfs.jffs2* model +} + +addtask firmware after do_rootfs before do_build diff --git a/recipes-core/images/mlinux-picocell-image.bb b/recipes-core/images/mlinux-picocell-image.bb index 49670a9..f59793d 100644 --- a/recipes-core/images/mlinux-picocell-image.bb +++ b/recipes-core/images/mlinux-picocell-image.bb @@ -1,6 +1,7 @@ DESCRIPTION = "mLinux PicoCell image" require mlinux-minimal-image.bb +require mlinux-firmware-upgrade.inc FILESYSTEM_FEATURES = "dosfstools \ cifs-utils \ 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}" |