163 lines
7.0 KiB
Plaintext
163 lines
7.0 KiB
Plaintext
# Copyright (C) 2023-2024 Digi International.
|
|
#
|
|
|
|
#######################################
|
|
########## General variables ##########
|
|
#######################################
|
|
|
|
def get_baseimg_pn(d):
|
|
file_name = d.getVar('PN')
|
|
return file_name[:file_name.find("-swu")] if "-swu" in file_name else file_name
|
|
|
|
IMAGE_DEPENDS = "${@get_baseimg_pn(d)}"
|
|
|
|
IMG_NAME = "${IMAGE_DEPENDS}"
|
|
|
|
# Update description.
|
|
SWUPDATE_DESCRIPTION = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS') == '1', 'Encrypted rootfs ${IMG_NAME} update', '${IMG_NAME} update')}"
|
|
|
|
# Storage type.
|
|
SWUPDATE_STORAGE_TYPE = "${@oe.utils.conditional('STORAGE_MEDIA', 'mmc', 'mmc', 'mtd', d)}"
|
|
|
|
# Root file system type.
|
|
SWUPDATE_ROOTFS_TYPE = "${@bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', 'squashfs', '', d)}"
|
|
|
|
# Dual boot partition names for eMMC or MTD
|
|
BOOT_DEV_NAME_A ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p1', 'linux_a', d)}"
|
|
BOOT_DEV_NAME_B ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p2', 'linux_b', d)}"
|
|
ROOTFS_DEV_NAME_A ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p3', 'rootfs_a', d)}"
|
|
ROOTFS_DEV_NAME_B ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p4', 'rootfs_b', d)}"
|
|
|
|
# Partition table is different in ccmp25
|
|
BOOT_DEV_NAME_A:ccmp25 ?= "/dev/mmcblk0p5"
|
|
BOOT_DEV_NAME_B:ccmp25 ?= "/dev/mmcblk0p6"
|
|
ROOTFS_DEV_NAME_A:ccmp25 ?= "/dev/mmcblk0p7"
|
|
ROOTFS_DEV_NAME_B:ccmp25 ?= "/dev/mmcblk0p8"
|
|
|
|
#######################################
|
|
###### SWU Update based on files ######
|
|
#######################################
|
|
|
|
# Variable used to generate the tar.gz file. Do not modify.
|
|
SWUPDATE_FILES_TARGZ_FILE_NAME = "swupdate-files.tar.gz"
|
|
|
|
# Initialize variable to provide a custom tar.gz file containing files/dirs to install.
|
|
SWUPDATE_FILES_TARGZ_FILE ?= ""
|
|
|
|
# Initialize variable to store the files/folders that will be part of the SWUpdate package.
|
|
SWUPDATE_FILES_LIST ?= ""
|
|
|
|
# Checks whether SWU update is based on files or not.
|
|
def update_based_on_files(d):
|
|
return str(d.getVar('SWUPDATE_FILES_TARGZ_FILE') != "" or d.getVar('SWUPDATE_FILES_LIST') != "").lower()
|
|
|
|
# Variable that determines if SWU update is based on files or not.
|
|
SWUPDATE_IS_FILES_UPDATE = "${@update_based_on_files(d)}"
|
|
|
|
#######################################
|
|
###### SWU Update based on RDIFF ######
|
|
#######################################
|
|
|
|
# Variable used to generate the 'rootfs' RDIFF file. Do not modify.
|
|
SWUPDATE_RDIFF_ROOTFS_DELTA_FILE_NAME = "swupdate-rootfs.rdiff"
|
|
|
|
# Initialize variable to provide the base file from which to generate the 'rootfs' RDIFF file.
|
|
SWUPDATE_RDIFF_ROOTFS_SOURCE_FILE ?= ""
|
|
|
|
# Rdiff image template based on storage type.
|
|
SWUPDATE_RDIFF_IMAGE_TEMPLATE_FILE = "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', 'image_template_rdiff_mmc', 'image_template_rdiff_nand', d)}"
|
|
|
|
# Checks whether SWU update is based on RDIFF or not.
|
|
def update_based_on_rdiff(d):
|
|
return str("read-only-rootfs" in d.getVar('IMAGE_FEATURES') and d.getVar('SWUPDATE_IS_FILES_UPDATE') != "true" and d.getVar('SWUPDATE_RDIFF_ROOTFS_SOURCE_FILE') != "").lower()
|
|
|
|
# Variable that determines if SWU update is based on RDIFF or not.
|
|
SWUPDATE_IS_RDIFF_UPDATE = "${@update_based_on_rdiff(d)}"
|
|
|
|
#######################################
|
|
##### SWU Update based on images ######
|
|
#######################################
|
|
|
|
# Image template based on storage type.
|
|
SWUPDATE_IMAGES_IMAGE_TEMPLATE_FILE = "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', 'image_template_mmc', 'image_template_nand', d)}"
|
|
|
|
# Checks whether SWU update is based on images or not.
|
|
def update_based_on_images(d):
|
|
return str(d.getVar('SWUPDATE_IS_FILES_UPDATE') != "true" and d.getVar('SWUPDATE_IS_RDIFF_UPDATE') != "true").lower()
|
|
|
|
# Variable that determines if SWU update is based on images or not.
|
|
SWUPDATE_IS_IMAGES_UPDATE = "${@update_based_on_images(d)}"
|
|
|
|
#######################################
|
|
########## SWU Update U-Boot ##########
|
|
#######################################
|
|
|
|
# Determine the correct UBoot update script file to use depending on storage type.
|
|
SWUPDATE_UBOOT_SCRIPT = "${@oe.utils.conditional('STORAGE_MEDIA', 'mmc', 'swupdate_uboot_mmc.sh', 'swupdate_uboot_nand.sh', d)}"
|
|
SWUPDATE_UBOOT_SCRIPT_NAME = "${@os.path.basename(d.getVar('SWUPDATE_UBOOT_SCRIPT'))}"
|
|
|
|
# Retrieve the correct U-Boot prefix.
|
|
def get_uboot_prefix(d):
|
|
prefix = d.getVar('UBOOT_PREFIX')
|
|
if d.getVar('DEY_SOC_VENDOR') == "NXP" and d.getVar('TRUSTFENCE_ENABLED') == "1":
|
|
if d.getVar('TRUSTFENCE_ENCRYPT') == "1":
|
|
prefix = f"{prefix}-encrypted"
|
|
else:
|
|
prefix = f"{prefix}-signed"
|
|
return prefix
|
|
|
|
SWUPDATE_UBOOT_PREFIX ?= "${@get_uboot_prefix(d)}"
|
|
SWUPDATE_UBOOT_PREFIX_TFA ?= "tf-a"
|
|
|
|
SWUPDATE_UBOOT_EXT ?= ".${UBOOT_SUFFIX}"
|
|
SWUPDATE_UBOOT_EXT_TFA ?= ".stm32"
|
|
SWUPDATE_UBOOT_MEM_VARIANT ?= "-512MB"
|
|
|
|
SWUPDATE_UBOOT_NAME ?= "${SWUPDATE_UBOOT_PREFIX}-${MACHINE}${SWUPDATE_UBOOT_EXT}"
|
|
SWUPDATE_UBOOT_NAME:ccimx6sbc ?= "${SWUPDATE_UBOOT_PREFIX}-ccimx6qsbc${SWUPDATE_UBOOT_EXT}"
|
|
SWUPDATE_UBOOT_NAME:ccmp1 ?= "${SWUPDATE_UBOOT_PREFIX}-${MACHINE}${SWUPDATE_UBOOT_MEM_VARIANT}-optee-nand${FIP_ENCRYPT_SUFFIX}${FIP_SIGN_SUFFIX}${SWUPDATE_UBOOT_EXT}"
|
|
SWUPDATE_UBOOT_NAME:ccmp25 ?= "${SWUPDATE_UBOOT_PREFIX}-${MACHINE}-optee-emmc${FIP_ENCRYPT_SUFFIX}${FIP_SIGN_SUFFIX}${SWUPDATE_UBOOT_EXT}"
|
|
SWUPDATE_UBOOT_NAME_TFA ?= ""
|
|
SWUPDATE_UBOOT_NAME_TFA:ccmp1 ?= "${SWUPDATE_UBOOT_PREFIX_TFA}-${MACHINE}${SWUPDATE_UBOOT_MEM_VARIANT}-optee-nand${TF_A_ENCRYPT_SUFFIX}${TF_A_SIGN_SUFFIX}${SWUPDATE_UBOOT_EXT_TFA}"
|
|
SWUPDATE_UBOOT_NAME_TFA:ccmp25 ?= "${SWUPDATE_UBOOT_PREFIX_TFA}-${MACHINE}-optee-emmc${TF_A_ENCRYPT_SUFFIX}${TF_A_SIGN_SUFFIX}${SWUPDATE_UBOOT_EXT_TFA}"
|
|
|
|
SWUPDATE_UBOOT_OFFSET ?= "${BOOTLOADER_SEEK_BOOTPART}"
|
|
|
|
# Retrieve the correct encryption type.
|
|
def get_swupdate_uboot_enc(d):
|
|
if d.getVar('TRUSTFENCE_ENCRYPT') == "1" :
|
|
return "enc"
|
|
return "normal"
|
|
|
|
SWUPDATE_UBOOT_ENC ?= "${@get_swupdate_uboot_enc(d)}"
|
|
|
|
# Retrieve the redundant U-Boot value.
|
|
def get_uboot_redundant(d):
|
|
if d.getVar("SWUPDATE_UBOOTIMG") == "true" and d.getVar("SWUPDATE_UBOOTIMG_REDUNDANT") == "true":
|
|
if any(d.getVar("MACHINE").startswith(platform) for platform in ("ccimx6", "ccimx8")):
|
|
bb.warn("Target does not support updating redundant U-Boot. Continuing with single SWU U-Boot update.")
|
|
return "single"
|
|
return "redundant"
|
|
|
|
return "single"
|
|
|
|
SWUPDATE_UBOOT_REDUNDANT = "${@get_uboot_redundant(d)}"
|
|
|
|
#######################################
|
|
########## SWU Update Script ##########
|
|
#######################################
|
|
|
|
# Retrieve the correct update script name based on the SWU update type.
|
|
def get_update_script_name(d):
|
|
if d.getVar('SWUPDATE_IS_FILES_UPDATE') == "true":
|
|
return "update_files.sh"
|
|
if d.getVar('SWUPDATE_IS_RDIFF_UPDATE') == "true":
|
|
return "update_rdiff.sh"
|
|
return "update_images.sh"
|
|
|
|
# Initialize variable that configures the update script to use.
|
|
SWUPDATE_SCRIPT ?= "${@get_update_script_name(d)}"
|
|
|
|
# Name of the update script to include in the SWU package.
|
|
SWUPDATE_SCRIPT_NAME = "${@os.path.basename(d.getVar('SWUPDATE_SCRIPT'))}"
|