swu-images: cc6: add pre-install script to open the virtual dev
For CC6, when using rootfs encryption, the encrypted device must be opened before trying to update. https://jira.digi.com/browse/DEL-3664 https://jira.digi.com/browse/DEL-3665 Signed-off-by: Tatiana Leon <tatiana.leon@digi.com>
This commit is contained in:
parent
96d7211a71
commit
0a64ff89e4
|
|
@ -5,6 +5,7 @@ LICENSE = "GPL-2.0"
|
|||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
|
||||
|
||||
SRC_URI = "file://sw-description"
|
||||
SRC_URI_append_ccimx6 = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), 'file://preinstall_swu.sh', '')}"
|
||||
|
||||
inherit swupdate
|
||||
|
||||
|
|
@ -26,6 +27,9 @@ ROOTFS_DEV_NAME_ccimx6ul ?= "rootfs"
|
|||
ROOTFS_ENC_DEV = "/dev/mapper/cryptroot"
|
||||
ROOTFS_ENC_DEV_ccimx6ul = "${ROOTFS_DEV_NAME}"
|
||||
ROOTFS_DEV_NAME_FINAL = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '${ROOTFS_ENC_DEV}', '${ROOTFS_DEV_NAME}')}"
|
||||
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}', '')}"
|
||||
|
||||
python () {
|
||||
img_fstypes = d.getVar('BOOTFS_EXT', True) + " " + d.getVar('ROOTFS_EXT', True)
|
||||
|
|
@ -40,4 +44,5 @@ fill_description() {
|
|||
sed -i -e "s,##ROOTIMG_NAME##,core-image-base-${MACHINE}${ROOTFS_EXT},g" "${WORKDIR}/sw-description"
|
||||
sed -i -e "s,##ROOTFS_DEV##,${ROOTFS_DEV_NAME_FINAL},g" "${WORKDIR}/sw-description"
|
||||
sed -i -e "s,##SW_VERSION##,${SOFTWARE_VERSION},g" "${WORKDIR}/sw-description"
|
||||
sed -i -e "s/##PREINSTALL_SCRIPT##/${PREINST_SCRIPT_DESC}/g" "${WORKDIR}/sw-description"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ LICENSE = "GPL-2.0"
|
|||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
|
||||
|
||||
SRC_URI = "file://sw-description"
|
||||
SRC_URI_append_ccimx6 = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), 'file://preinstall_swu.sh', '')}"
|
||||
|
||||
inherit swupdate
|
||||
|
||||
|
|
@ -26,6 +27,9 @@ ROOTFS_DEV_NAME_ccimx6ul ?= "rootfs"
|
|||
ROOTFS_ENC_DEV = "/dev/mapper/cryptroot"
|
||||
ROOTFS_ENC_DEV_ccimx6ul = "${ROOTFS_DEV_NAME}"
|
||||
ROOTFS_DEV_NAME_FINAL = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_INITRAMFS_IMAGE', True), '${ROOTFS_ENC_DEV}', '${ROOTFS_DEV_NAME}')}"
|
||||
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}', '')}"
|
||||
|
||||
python () {
|
||||
img_fstypes = d.getVar('BOOTFS_EXT', True) + " " + d.getVar('ROOTFS_EXT', True)
|
||||
|
|
@ -40,4 +44,5 @@ fill_description() {
|
|||
sed -i -e "s,##ROOTIMG_NAME##,dey-image-qt-${GRAPHICAL_BACKEND}-${MACHINE}${ROOTFS_EXT},g" "${WORKDIR}/sw-description"
|
||||
sed -i -e "s,##ROOTFS_DEV##,${ROOTFS_DEV_NAME_FINAL},g" "${WORKDIR}/sw-description"
|
||||
sed -i -e "s,##SW_VERSION##,${SOFTWARE_VERSION},g" "${WORKDIR}/sw-description"
|
||||
sed -i -e "s/##PREINSTALL_SCRIPT##/${PREINST_SCRIPT_DESC}/g" "${WORKDIR}/sw-description"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# preinstall_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 open the virtual mapped device
|
||||
#
|
||||
# SWUpdate calls this script before installing the image.
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
# 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"
|
||||
}
|
||||
|
||||
# Main
|
||||
#------------------------------------------------------------------------------
|
||||
# Check if encrypted device is already open.
|
||||
if [ -b /dev/mapper/cryptroot ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
rootfs_block="/dev/mmcblk0p$(parted -s /dev/mmcblk0 print | sed -ne "s,^[^0-9]*\([0-9]\+\).*\<rootfs\>.*,\1,g;T;p")"
|
||||
|
||||
# Open LUKS encrypted device
|
||||
trustfence-tool ${rootfs_block} cryptroot
|
||||
if [ "$?" != "0" ]; then
|
||||
log_error "Error executing the firmware update, cannot open virtual device"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -16,4 +16,5 @@ software =
|
|||
sha256 = "@##ROOTIMG_NAME##";
|
||||
}
|
||||
);
|
||||
##PREINSTALL_SCRIPT##
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue