--- /dev/null
+SUMMARY = "HV MPD SWUpdate development image"
+
+# Image(s) to build before building swupdate image
+IMAGE_DEPENDS = "image-hvmpd-dev"
+
+require update-common.inc
+
+SWUPDATE_IMAGES_FSTYPES[image-hvmpd-dev] = ".tar.gz"
--- /dev/null
+SUMMARY = "HV MPD SWUpdate production image"
+
+# Image(s) to build before building swupdate image
+IMAGE_DEPENDS = "image-hvmpd-prod"
+
+require update-common.inc
+
+SWUPDATE_IMAGES_FSTYPES[image-hvmpd-prod] = ".tar.gz"
--- /dev/null
+LICENSE = "CLOSED"
+
+FILESEXTRAPATHS:prepend := "${THISDIR}/update:"
+
+SRC_URI = " \
+ file://sw-description \
+ file://update.sh \
+"
+
+# Image(s) and files that will be included in the .swu image
+SWUPDATE_IMAGES = "${IMAGE_DEPENDS}"
+
+UBOOT_PART_VAR ?= "mmcpart"
+
+inherit swupdate
--- /dev/null
+software = {
+ version = "@@DISTRO_VERSION@@";
+ description = "Firmware update description for @@MACHINE@@";
+
+ @@MACHINE@@ = {
+ hardware-compatibility: [ "revA" ];
+ stable: {
+ bootenv-common: (
+ {
+ name = "bootcount";
+ value = "0";
+ },
+ {
+ name = "upgrade_available";
+ value = "1";
+ },
+ );
+
+ rootfsA: {
+ images: (
+ {
+ filename = "@@IMAGE_DEPENDS@@-@@MACHINE@@@@SWUPDATE_IMAGES_FSTYPES[@@IMAGE_DEPENDS@@]@@";
+ type = "archive";
+ compressed = "zlib";
+ preserve-attributes = true;
+ sha256 = "$swupdate_get_sha256(@@IMAGE_DEPENDS@@-@@MACHINE@@@@SWUPDATE_IMAGES_FSTYPES[@@IMAGE_DEPENDS@@]@@)";
+ path = "/"; /* Destination path when decompressing. */
+ filesystem = "ext4";
+ device = "@@ROOT_PARENT_DEV@@@@ROOT_PART_PREFIX@@@@ROOT_PART_A_ID@@";
+ }
+ );
+ scripts: (
+ {
+ filename = "update.sh";
+ type = "shellscript";
+ data = "@@ROOT_PART_PREFIX@@@@ROOT_PART_A_ID@@"; /* Destination partition ID */
+ sha256 = "$swupdate_get_sha256(update.sh)";
+ }
+ );
+ bootenv: (
+ {
+ ref = "#./../bootenv-common";
+ },
+ {
+ name = "@@UBOOT_PART_VAR@@";
+ value = "@@ROOT_PART_A_ID@@";
+ }
+ );
+ };
+ rootfsB: {
+ images: (
+ {
+ filename = "@@IMAGE_DEPENDS@@-@@MACHINE@@@@SWUPDATE_IMAGES_FSTYPES[@@IMAGE_DEPENDS@@]@@";
+ type = "archive";
+ compressed = "zlib";
+ preserve-attributes = true;
+ sha256 = "$swupdate_get_sha256(@@IMAGE_DEPENDS@@-@@MACHINE@@@@SWUPDATE_IMAGES_FSTYPES[@@IMAGE_DEPENDS@@]@@)";
+ path = "/"; /* Destination path when decompressing. */
+ filesystem = "ext4";
+ device = "@@ROOT_PARENT_DEV@@@@ROOT_PART_PREFIX@@@@ROOT_PART_B_ID@@";
+ }
+ );
+ scripts: (
+ {
+ filename = "update.sh";
+ type = "shellscript";
+ data = "@@ROOT_PART_PREFIX@@@@ROOT_PART_B_ID@@"; /* Destination partition ID */
+ sha256 = "$swupdate_get_sha256(update.sh)";
+ }
+ );
+ bootenv: (
+ {
+ ref = "#./../bootenv-common";
+ },
+ {
+ name = "@@UBOOT_PART_VAR@@";
+ value = "@@ROOT_PART_B_ID@@";
+ }
+ );
+ };
+ };
+ };
+}
--- /dev/null
+#!/bin/sh
+set -e
+
+# Shell scripts are called via system command. SWUpdate scans for all scripts
+# and calls them before and after installing the images. SWUpdate passes
+# ‘preinst’ or ‘postinst’ as first argument to the script. If the data attribute
+# is defined, its value is passed as the last argument(s) to the script.
+
+FSTYPE="ext4"
+
+echo "${0}: arguments = \"${*}\""
+
+if [ $# -lt 2 ]; then
+ exit 1;
+fi
+
+# L'environnement U-Boot doit être valide pour utiliser ce script.
+# Après la programmation initiale avec uuu, il faut effectuer la sauvegarde
+# de l'environnement en mémoire non-volatile (ex: eMMC) dans U-boot avec
+# 'saveenv'. Sinon, fw_saveenv va utiliser l'environnement par défaut contenu
+# dans /etc/u-boot-initial-env
+if fw_printenv 2>&1 | grep -q 'Cannot read environment'; then
+ echo "Warning: U-Boot environment cannot be read. Make sure you save the"
+ echo " default environment to flash using these U-Boot commands:"
+ echo " $> env default -a"
+ echo " $> saveenv"
+fi
+
+do_preinst()
+{
+ # Find internal parent kernel device name of rootfs.
+ # For example:
+ # - /dev/sda1 --> /dev/sda
+ # - /dev/mmcblk2p2 --> /dev/mmcblk2
+ disk="/dev/$(lsblk -ndo pkname $(findmnt -n -o SOURCE /))"
+
+ if [ ! -b "${disk}" ]; then
+ echo "Error: disk \"${disk}\" not found"
+ exit 1
+ fi
+
+ update_dev="${disk}${next_part}"
+
+ if [ ! -b "${update_dev}" ]; then
+ echo "Error: destination partition \"${update_dev}\" not found"
+ exit 1
+ fi
+
+ echo "${0}: destination device = ${update_dev}"
+
+ # Create temporary mount point:
+ tmp_file=$(mktemp -q -d /tmp/swupdate-mount.XXXXXX)
+ if [ ${?} -ne 0 ]; then
+ echo "Error: cannot create temporary file"
+ exit 1
+ fi
+
+ # Mount update partition:
+ mount -t ${FSTYPE} ${update_dev} ${tmp_file}
+
+ # Remove old data:
+ echo "${0}: erasing old data..."
+ rm -rf ${tmp_file}/*
+
+ # Finish
+ umount ${tmp_file}
+ rmdir ${tmp_file}
+
+ exit 0
+}
+
+do_postinst()
+{
+ exit 0
+}
+
+next_part=${2}
+
+case "$1" in
+ preinst)
+ do_preinst
+ ;;
+ postinst)
+ do_postinst
+ ;;
+ *)
+ echo "unsupported install mode: \"${1}\""
+ exit 1
+ ;;
+esac