From 3cb44334c6cc2332b892423f49def533896dc638 Mon Sep 17 00:00:00 2001 From: Tatiana Leon Date: Wed, 1 Mar 2017 22:33:05 +0100 Subject: [PATCH] swu-images: cc6ul: add pre-install script to remove enc flag For CC6UL, when not using rootfs encryption, the "enc" flag must be removed from the "mtdparts" U-Boot variable. https://jira.digi.com/browse/DEL-3685 Signed-off-by: Tatiana Leon --- .../swu-images/core-image-base-swu.bb | 2 + .../swu-images/dey-image-qt-swu.bb | 2 + .../files/ccimx6ul/preinstall_swu.sh | 119 ++++++++++++++++++ .../swu-images/files/ccimx6ul/sw-description | 1 + 4 files changed, 124 insertions(+) create mode 100644 meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/preinstall_swu.sh diff --git a/meta-digi-dey/recipes-digi/swu-images/core-image-base-swu.bb b/meta-digi-dey/recipes-digi/swu-images/core-image-base-swu.bb index f996cf550..5dd78ecbb 100644 --- a/meta-digi-dey/recipes-digi/swu-images/core-image-base-swu.bb +++ b/meta-digi-dey/recipes-digi/swu-images/core-image-base-swu.bb @@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425 SRC_URI = "file://sw-description" SRC_URI_append_ccimx6 = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), 'file://preinstall_swu.sh', '')}" +SRC_URI_append_ccimx6ul = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '', 'file://preinstall_swu.sh')}" inherit swupdate @@ -30,6 +31,7 @@ ROOTFS_DEV_NAME_FINAL = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE PREINST_SCRIPT_TEMPLATE = "scripts: ( { filename = \\"preinstall_swu.sh\\"; type = \\"preinstall\\"; sha256 = \\"@preinstall_swu.sh\\"; \\x7D );" PREINST_SCRIPT_DESC = "" PREINST_SCRIPT_DESC_ccimx6sbc = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '${PREINST_SCRIPT_TEMPLATE}', '')}" +PREINST_SCRIPT_DESC_ccimx6ul = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '', '${PREINST_SCRIPT_TEMPLATE}')}" python () { img_fstypes = d.getVar('BOOTFS_EXT', True) + " " + d.getVar('ROOTFS_EXT', True) diff --git a/meta-digi-dey/recipes-digi/swu-images/dey-image-qt-swu.bb b/meta-digi-dey/recipes-digi/swu-images/dey-image-qt-swu.bb index 8a8a08695..727b84d38 100644 --- a/meta-digi-dey/recipes-digi/swu-images/dey-image-qt-swu.bb +++ b/meta-digi-dey/recipes-digi/swu-images/dey-image-qt-swu.bb @@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425 SRC_URI = "file://sw-description" SRC_URI_append_ccimx6 = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), 'file://preinstall_swu.sh', '')}" +SRC_URI_append_ccimx6ul = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '', 'file://preinstall_swu.sh')}" inherit swupdate @@ -30,6 +31,7 @@ ROOTFS_DEV_NAME_FINAL = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE PREINST_SCRIPT_TEMPLATE = "scripts: ( { filename = \\"preinstall_swu.sh\\"; type = \\"preinstall\\"; sha256 = \\"@preinstall_swu.sh\\"; \\x7D );" PREINST_SCRIPT_DESC = "" PREINST_SCRIPT_DESC_ccimx6sbc = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '${PREINST_SCRIPT_TEMPLATE}', '')}" +PREINST_SCRIPT_DESC_ccimx6ul = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '', '${PREINST_SCRIPT_TEMPLATE}')}" python () { img_fstypes = d.getVar('BOOTFS_EXT', True) + " " + d.getVar('ROOTFS_EXT', True) diff --git a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/preinstall_swu.sh b/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/preinstall_swu.sh new file mode 100644 index 000000000..292e6f518 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/preinstall_swu.sh @@ -0,0 +1,119 @@ +#!/bin/sh +#=============================================================================== +# +# pre-install_swu.sh +# +# Copyright (C) 2017 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: SWUpdate pre-install script to remove the encryption flag from +# rootfs +# +# SWUpdate calls this script before installing the image. +# +#=============================================================================== + +# Variables. +#------------------------------------------------------------------------------ +ENV_MTDPARTS="mtdparts" + +# Functions. +#------------------------------------------------------------------------------ +# Function - psplash_message +# +# Shows the given message in the psplash screen. +# +# @param ${1} - Message to show. +#------------------------------------------------------------------------------ +psplash_message() { + echo "MSG ${1}" > /tmp/psplash_fifo + sleep 0.2 +} + +#------------------------------------------------------------------------------ +# Function - psplash_progress +# +# Sets the psplash progress bar percentage to the given one. +# +# @param ${1} - Progress percentage. +#------------------------------------------------------------------------------ +psplash_progress() { + echo "PROGRESS ${1}" > /tmp/psplash_fifo + sleep 0.2 +} + +#------------------------------------------------------------------------------ +# Function - log +# +# Prints the given text in the console. +# +# @param ${1} - Text to print. +#------------------------------------------------------------------------------ +log() { + echo "[FW UPDATE] ${1}" +} + +#------------------------------------------------------------------------------ +# Function - log_error +# +# Prints the given text in the console as an error. +# +# @param ${1} - Error text to print. +#------------------------------------------------------------------------------ +log_error() { + log "[ERROR] ${1}" + psplash_message "ERROR: ${1}" + psplash_progress "0" +} + +#------------------------------------------------------------------------------ +# Function - read_uboot_var +# +# Reads the given U-Boot variable. +# +# @param ${1} - U-Boot variable to read. +# @param ${2} - Where to store the value of the read variable. +#------------------------------------------------------------------------------ +read_uboot_var() { + eval "${2}=\"$(fw_printenv -n ${1} 2>/dev/null)\"" +} + +#------------------------------------------------------------------------------ +# Function - set_uboot_var +# +# Sets the given U-Boot variable. +# +# @param ${1} - U-Boot variable to set. +# @param ${2} - Value to set. +#------------------------------------------------------------------------------ +set_uboot_var() { + fw_setenv ${1} ${2} 2>/dev/null +} + +# Main +#------------------------------------------------------------------------------ +# Read the mtdparts variable. +read_uboot_var "${ENV_MTDPARTS}" MTDPARTS + +# Check if there is any command. +if [ -z "${MTDPARTS}" ]; then + log_error "No mtdparts found" + exit 1 +fi + +# Parse the mtdparts value. +case "${MTDPARTS}" in + *\(rootfs\)enc*) + # Remove the flag from the rootfs partition. + NEW_MTDPARTS=$(echo "${MTDPARTS}" | sed -e "s/(rootfs)enc/(rootfs)/g") + set_uboot_var "${ENV_MTDPARTS}" "${NEW_MTDPARTS}" + sync && reboot -f + ;; + *) +esac + diff --git a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/sw-description b/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/sw-description index c0754e389..fb7072814 100644 --- a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/sw-description +++ b/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/sw-description @@ -16,4 +16,5 @@ software = sha256 = "@##ROOTIMG_NAME##"; } ); + ##PREINSTALL_SCRIPT## }