CLASSES/MACHINES: update for v2.0.0

Several updates integrated:
- removal of no more supported basic boot scheme
- removal of no more supported boot device (nor-nand and nor-emmc)
- rework of providers and machine features
- introduction of new board versions (a, c, d, f)
- update of extlinuxconf-stm32mp class to manage multiple board versions
- configure 'extlinux.conf' file to manage PARTUUID to select rootfs
partition
- new partition images management (easy to add or remove partition through
new PARTITIONS_CONFIG var
- specific configuration on machine side for all storage device supported

Change-Id: I7e4d3d16535a5654c7fd80f9b56296a61050def3
This commit is contained in:
Romuald JEANNE committed 2020-06-23 17:23:52 +02:00
1 parent 2fbe4ce39c
commit af5ae28215
33 files changed
+1297 -1245

No files matched your search

+2 -1
View File
@@ -17,6 +17,7 @@ python archiver_clean_tarball() {
if os.path.exists(os.path.join(tmpdir,dirs_list[0],"git", ".git")):
src_origin = os.path.join(tmpdir,dirs_list[0], '.')
shutil.rmtree(os.path.join(tmpdir,dirs_list[0],"git", ".git"))
shutil.move(os.path.join(tmpdir,dirs_list[0],"git"),os.path.join(tmpdir,dirs_list[0],d.getVar('BPN')+'-'+d.getVar('PV')))
os.remove(os.path.join(ar_outdir,tarball_name[0]))
subdirs_list = [f for f in listdir(os.path.join(tmpdir,dirs_list[0])) if os.path.isdir(os.path.join(tmpdir,dirs_list[0], f))]
if len(subdirs_list) == 1:
@@ -34,7 +35,7 @@ archiver_git_uri() {
BRANCH=master
fi
sed -i -e "s|##GIT_BRANCH##|$BRANCH|g" -e "s|##GIT_SRCREV##|${SRCREV}|g" ${ARCHIVER_OUTDIR}/${ARCHIVER_README}
sed -i -e "s|##GIT_BRANCH##|$BRANCH|g" -e "s|##GIT_SRCREV##|${SRCREV}|g" -e "s|##BP##|${BP}|g" -e "s|##PV##|${PV}|g" -e "s|##PR##|${PR}|g" ${ARCHIVER_OUTDIR}/${ARCHIVER_README}
}
do_ar_original[postfuncs] =+ "archiver_git_uri"
+153 -118
View File
@@ -29,52 +29,44 @@
# --------------------------------------------------------------------
# STM32MP specific implementation
# --------------------------------------------------------------------
# Append new mechanism to allow multi 'extlinux.conf' file generation.
# Append new mechanism to allow multiple config file generation.
# - multiple targets case:
# each 'extlinux.conf' file generated is created under specific path:
# each config file generated is created under specific path:
# '${B}/<UBOOT_EXTLINUX_BOOTPREFIXES>extlinux/extlinux.conf'
# - simple target case:
# the 'extlinux.conf' file generated is created under default path:
# '${B}/extlinux/extlinux.conf'
#
# New external variables added:
# UBOOT_EXTLINUX_TARGETS - A list of targets for multi config file
# generation
# UBOOT_EXTLINUX_BOOTPREFIXES - Bootprefix used in uboot script to select
# extlinux.conf file to use
# UBOOT_EXTLINUX_TARGETS - List of targets for multi config file creation
# UBOOT_EXTLINUX_BOOTPREFIXES - Prefix used in uboot script to select config file
#
# Add an extra configuration to allow to duplicate current config file into a new
# one by appending some new labels to the current ones.
# This mechanism is enabled through UBOOT_EXTLINUX_TARGETS_EXTRA_CONFIG var.
# The format to specify it is:
# UBOOT_EXTLINUX_TARGETS_EXTRA_CONFIG ??= "foo"
# UBOOT_EXTLINUX_TARGETS_EXTRA_CONFIG[foo] = "label1 label2"
# Along with current config file created 'extlinux.conf', a new config file is
# created at same location with name 'foo_extlinux.conf'.
# This config file contains the labels defined for current config file with also
# the new configured lables (i.e. label1 and lable2).
#
# --------------------------------------------------------------------
# Output example:
# Implementation:
# --------------------------------------------------------------------
# Following 'extlinux.conf' files are generated under ${UBOOT_EXTLINUX_INSTALL_DIR}:
# ${UBOOT_EXTLINUX_BOOTPREFIXES_${UBOOT_EXTLINUX_TARGETS}[0]}extlinux/extlinux.conf
# ${UBOOT_EXTLINUX_BOOTPREFIXES_${UBOOT_EXTLINUX_TARGETS}[1]}extlinux/extlinux.conf
# We create all config file based on a loop for all targets set in
# UBOOT_EXTLINUX_TARGETS var, then we use the mechanism defined in
# 'uboot-extlinux-config.bbclass' class to generate the config file
# Plus for each target we may use the UBOOT_EXTLINUX_TARGETS_EXTRA_CONFIG var
# to create additional config file that will use the labels list from on going
# target plus the labels defined for this extra target.
#
# File content (${UBOOT_EXTLINUX_BOOTPREFIXES_${UBOOT_EXTLINUX_TARGETS}[0]}extlinux/exlinux.conf):
# menu title Select the boot mode
# TIMEOUT ${UBOOT_EXTLINUX_TIMEOUT}
# DEFAULT ${UBOOT_EXTLINUX_DEFAULT_LABEL_${UBOOT_EXTLINUX_TARGETS}[0]}
# LABEL ${UBOOT_EXTLINUX_LABELS_${UBOOT_EXTLINUX_TARGETS}[0]}[0]
# KERNEL ${UBOOT_EXTLINUX_KERNEL} < OR OVERRIDE WITH : ${UBOOT_EXTLINUX_KERNEL_${IMAGE_UBOOT_EXTLINUX_LABELS}[0]} >
# FDT ${UBOOT_EXTLINUX_FDT} < OR OVERRIDE WITH : ${UBOOT_EXTLINUX_FDT_${IMAGE_UBOOT_EXTLINUX_LABELS}[0]} >
# APPEND ${UBOOT_EXTLINUX_ROOT} < OR OVERRIDE WITH : ${UBOOT_EXTLINUX_ROOT_${IMAGE_UBOOT_EXTLINUX_LABELS}[0]} >
# LABEL ${UBOOT_EXTLINUX_LABELS_${UBOOT_EXTLINUX_TARGETS}[0]}[1]
# KERNEL ${UBOOT_EXTLINUX_KERNEL} < OR OVERRIDE WITH : ${UBOOT_EXTLINUX_KERNEL_${IMAGE_UBOOT_EXTLINUX_LABELS}[1]} >
# FDT ${UBOOT_EXTLINUX_FDT} < OR OVERRIDE WITH : ${UBOOT_EXTLINUX_FDT_${IMAGE_UBOOT_EXTLINUX_LABELS}[1]} >
# APPEND ${UBOOT_EXTLINUX_ROOT} < OR OVERRIDE WITH : ${UBOOT_EXTLINUX_ROOT_${IMAGE_UBOOT_EXTLINUX_LABELS}[1]} >
#
# File content (${UBOOT_EXTLINUX_BOOTPREFIXES_${UBOOT_EXTLINUX_TARGETS}[0]}extlinux/exlinux.conf):
# menu title Select the boot mode
# TIMEOUT ${UBOOT_EXTLINUX_TIMEOUT}
# DEFAULT ${UBOOT_EXTLINUX_DEFAULT_LABEL_${UBOOT_EXTLINUX_TARGETS}[1]}
# LABEL ${UBOOT_EXTLINUX_LABELS_${UBOOT_EXTLINUX_TARGETS}[1]}[0]
# KERNEL ${UBOOT_EXTLINUX_KERNEL} < OR OVERRIDE WITH : ${UBOOT_EXTLINUX_KERNEL_${IMAGE_UBOOT_EXTLINUX_LABELS}[0]} >
# FDT ${UBOOT_EXTLINUX_FDT} < OR OVERRIDE WITH : ${UBOOT_EXTLINUX_FDT_${IMAGE_UBOOT_EXTLINUX_LABELS}[0]} >
# APPEND ${UBOOT_EXTLINUX_ROOT} < OR OVERRIDE WITH : ${UBOOT_EXTLINUX_ROOT_${IMAGE_UBOOT_EXTLINUX_LABELS}[0]} >
# LABEL ${UBOOT_EXTLINUX_LABELS_${UBOOT_EXTLINUX_TARGETS}[1]}[1]
# KERNEL ${UBOOT_EXTLINUX_KERNEL} < OR OVERRIDE WITH : ${UBOOT_EXTLINUX_KERNEL_${IMAGE_UBOOT_EXTLINUX_LABELS}[1]} >
# FDT ${UBOOT_EXTLINUX_FDT} < OR OVERRIDE WITH : ${UBOOT_EXTLINUX_FDT_${IMAGE_UBOOT_EXTLINUX_LABELS}[1]} >
# APPEND ${UBOOT_EXTLINUX_ROOT} < OR OVERRIDE WITH : ${UBOOT_EXTLINUX_ROOT_${IMAGE_UBOOT_EXTLINUX_LABELS}[1]} >
# We manage to allow var override using the current target defined from the
# ongoing loop.
# In the same way var averride is managed through the ongoing label loop while
# writting the config file (refer to 'uboot-extlinux-config.bbclass' class for
# details).
# --------------------------------------------------------------------
UBOOT_EXTLINUX_TARGETS ?= ""
@@ -87,6 +79,85 @@ UBOOT_EXTLINUX_KERNEL_IMAGE ?= "/${KERNEL_IMAGETYPE}"
UBOOT_EXTLINUX_KERNEL_ARGS ?= "rootwait rw"
UBOOT_EXTLINUX_TIMEOUT ?= "20"
def create_extlinux_file(cfile, labels, data):
"""
Copy/Paste extract of 'do_create_extlinux_config()' function
from openembedded-core 'uboot-extlinux-config.bbclass' class
"""
# Use copy of provided data environment to allow label override without side
# effect when looping on 'create_extlinux_file' function.
localdata = bb.data.createCopy(data)
# Default function from OpenEmbedded class
try:
with open(cfile, 'w') as cfgfile:
cfgfile.write('# Generic Distro Configuration file generated by OpenEmbedded\n')
if len(labels.split()) > 1:
cfgfile.write('menu title Select the boot mode\n')
splashscreen_name = localdata.getVar('UBOOT_SPLASH_IMAGE')
if not splashscreen_name:
bb.warn('UBOOT_SPLASH_IMAGE not defined')
else:
cfgfile.write('MENU BACKGROUND /%s.bmp\n' % (splashscreen_name))
timeout = localdata.getVar('UBOOT_EXTLINUX_TIMEOUT')
if timeout:
cfgfile.write('TIMEOUT %s\n' % (timeout))
if len(labels.split()) > 1:
default = localdata.getVar('UBOOT_EXTLINUX_DEFAULT_LABEL')
if default:
cfgfile.write('DEFAULT %s\n' % (default))
# Need to deconflict the labels with existing overrides
label_overrides = labels.split()
default_overrides = localdata.getVar('OVERRIDES').split(':')
# We're keeping all the existing overrides that aren't used as a label
# an override for that label will be added back in while we're processing that label
keep_overrides = list(filter(lambda x: x not in label_overrides, default_overrides))
for label in labels.split():
localdata.setVar('OVERRIDES', ':'.join(keep_overrides + [label]))
extlinux_console = localdata.getVar('UBOOT_EXTLINUX_CONSOLE')
menu_description = localdata.getVar('UBOOT_EXTLINUX_MENU_DESCRIPTION')
if not menu_description:
menu_description = label
root = localdata.getVar('UBOOT_EXTLINUX_ROOT')
if not root:
bb.fatal('UBOOT_EXTLINUX_ROOT not defined')
kernel_image = localdata.getVar('UBOOT_EXTLINUX_KERNEL_IMAGE')
fdtdir = localdata.getVar('UBOOT_EXTLINUX_FDTDIR')
fdt = localdata.getVar('UBOOT_EXTLINUX_FDT')
if fdt:
cfgfile.write('LABEL %s\n\tKERNEL %s\n\tFDT %s\n' %
(menu_description, kernel_image, fdt))
elif fdtdir:
cfgfile.write('LABEL %s\n\tKERNEL %s\n\tFDTDIR %s\n' %
(menu_description, kernel_image, fdtdir))
else:
cfgfile.write('LABEL %s\n\tKERNEL %s\n' % (menu_description, kernel_image))
kernel_args = localdata.getVar('UBOOT_EXTLINUX_KERNEL_ARGS')
initrd = localdata.getVar('UBOOT_EXTLINUX_INITRD')
if initrd:
cfgfile.write('\tINITRD %s\n'% initrd)
kernel_args = root + " " + kernel_args
cfgfile.write('\tAPPEND %s %s\n' % (kernel_args, extlinux_console))
except OSError:
bb.fatal('Unable to open %s' % (cfile))
python do_create_multiextlinux_config() {
targets = d.getVar('UBOOT_EXTLINUX_TARGETS')
if not targets:
@@ -94,24 +165,32 @@ python do_create_multiextlinux_config() {
if not targets.strip():
bb.fatal("No targets, nothing to do")
# Need to deconflict the targets with existing overrides
target_overrides = targets.split()
default_overrides = d.getVar('OVERRIDES').split(':')
# We're keeping all the existing overrides that aren't used as a target
# an override for that target will be added back in while we're processing that target
keep_overrides = list(filter(lambda x: x not in target_overrides, default_overrides))
for target in targets.split():
bb.note("Loop for '%s' target" % target)
localdata = bb.data.createCopy(d)
overrides = localdata.getVar('OVERRIDES')
if not overrides:
bb.fatal('OVERRIDES not defined')
localdata.setVar('OVERRIDES', target + ':' + overrides)
# Append target as OVERRIDES
d.setVar('OVERRIDES', ':'.join(keep_overrides + [target]))
# Initialize labels from localdata to allow target override
labels = localdata.getVar('UBOOT_EXTLINUX_LABELS')
# Initialize labels
labels = d.getVar('UBOOT_EXTLINUX_LABELS')
if not labels:
bb.fatal("UBOOT_EXTLINUX_LABELS not defined, nothing to do")
if not labels.strip():
bb.fatal("No labels, nothing to do")
# Initialize subdir for extlinux.conf file location
if len(targets.split()) > 1:
bootprefix = localdata.getVar('UBOOT_EXTLINUX_BOOTPREFIXES') or ""
# Initialize extra target configs
extra_extlinuxtargetconfig = d.getVar('UBOOT_EXTLINUX_TARGETS_EXTRA_CONFIG') or ""
# Initialize subdir for config file location
if len(targets.split()) > 1 or len(extra_extlinuxtargetconfig.split()) > 0:
bootprefix = d.getVar('UBOOT_EXTLINUX_BOOTPREFIXES') or ""
subdir = bootprefix + 'extlinux'
else:
subdir = 'extlinux'
@@ -122,79 +201,35 @@ python do_create_multiextlinux_config() {
# Create extlinux folder
bb.utils.mkdirhier(os.path.dirname(cfile))
# ************************************************************
# Copy/Paste extract of 'do_create_extlinux_config()' function
# from openembedded-core 'uboot-extlinux-config.bbclass' class
# ************************************************************
try:
with open(cfile, 'w') as cfgfile:
cfgfile.write('# Generic Distro Configuration file generated by OpenEmbedded\n')
# Go for config file creation
bb.note("Create %s/extlinux.conf file for %s labels" % (subdir, labels))
create_extlinux_file(cfile, labels, d)
if len(labels.split()) > 1:
cfgfile.write('menu title Select the boot mode\n')
splashscreen_name = localdata.getVar('UBOOT_SPLASH_IMAGE')
if not splashscreen_name:
bb.warn('UBOOT_SPLASH_IMAGE not defined')
else:
cfgfile.write('MENU BACKGROUND /%s.bmp\n' % (splashscreen_name))
timeout = localdata.getVar('UBOOT_EXTLINUX_TIMEOUT')
if timeout:
cfgfile.write('TIMEOUT %s\n' % (timeout))
if len(labels.split()) > 1:
default = localdata.getVar('UBOOT_EXTLINUX_DEFAULT_LABEL')
if default:
cfgfile.write('DEFAULT %s\n' % (default))
for label in labels.split():
# **********************************************
# Add localdata reset to fix var expansion issue
# **********************************************
localdata = bb.data.createCopy(d)
overrides = localdata.getVar('OVERRIDES')
if not overrides:
bb.fatal('OVERRIDES not defined')
localdata.setVar('OVERRIDES', label + ':' + overrides)
extlinux_console = localdata.getVar('UBOOT_EXTLINUX_CONSOLE')
menu_description = localdata.getVar('UBOOT_EXTLINUX_MENU_DESCRIPTION')
if not menu_description:
menu_description = label
root = localdata.getVar('UBOOT_EXTLINUX_ROOT')
if not root:
bb.fatal('UBOOT_EXTLINUX_ROOT not defined')
kernel_image = localdata.getVar('UBOOT_EXTLINUX_KERNEL_IMAGE')
fdtdir = localdata.getVar('UBOOT_EXTLINUX_FDTDIR')
fdt = localdata.getVar('UBOOT_EXTLINUX_FDT')
if fdt:
cfgfile.write('LABEL %s\n\tKERNEL %s\n\tFDT %s\n' %
(menu_description, kernel_image, fdt))
elif fdtdir:
cfgfile.write('LABEL %s\n\tKERNEL %s\n\tFDTDIR %s\n' %
(menu_description, kernel_image, fdtdir))
else:
cfgfile.write('LABEL %s\n\tKERNEL %s\n' % (menu_description, kernel_image))
kernel_args = localdata.getVar('UBOOT_EXTLINUX_KERNEL_ARGS')
initrd = localdata.getVar('UBOOT_EXTLINUX_INITRD')
if initrd:
cfgfile.write('\tINITRD %s\n'% initrd)
kernel_args = root + " " + kernel_args
cfgfile.write('\tAPPEND %s %s\n' % (kernel_args, extlinux_console))
except OSError:
bb.fatal('Unable to open %s' % (cfile))
# Manage UBOOT_EXTLINUX_TARGETS_EXTRA_CONFIG
extra_extlinuxtargetconfigflag = d.getVarFlags('UBOOT_EXTLINUX_TARGETS_EXTRA_CONFIG')
# The "doc" varflag is special, we don't want to see it here
extra_extlinuxtargetconfigflag.pop('doc', None)
# Handle new targets and labels append
if len(extra_extlinuxtargetconfig.split()) > 0:
bb.note("Manage EXTRA target configuration:")
for config in extra_extlinuxtargetconfig.split():
# Init extra config vars:
extra_extlinuxlabels = ""
extra_cfile = ""
for f, v in extra_extlinuxtargetconfigflag.items():
if config == f:
bb.note(">>> Loop for '%s' extra target config." % config)
if len(v.split()) > 0:
bb.note(">>> Set '%s' to extra_extlinuxlabels." % v)
extra_extlinuxlabels = labels + ' ' + v
extra_cfile = os.path.join(d.getVar('B'), subdir , config + '_' + 'extlinux.conf')
else:
bb.note(">>> No extra labels defined, no new config file to create")
break
# Manage new config file creation
if extra_extlinuxlabels != "":
bb.note(">>> Create %s/%s_extlinux.conf file for %s labels" % (subdir, config, extra_extlinuxlabels))
create_extlinux_file(extra_cfile, extra_extlinuxlabels, d)
}
addtask create_multiextlinux_config before do_compile
@@ -203,7 +238,7 @@ do_create_multiextlinux_config[cleandirs] += "${B}"
# Manage specific var dependency:
# Because of local overrides within create_multiextlinux_config() function, we
# need to make sure to add each variables to the vardeps list.
UBOOT_EXTLINUX_TARGET_VARS = "LABELS BOOTPREFIXES TIMEOUT DEFAULT_LABEL"
UBOOT_EXTLINUX_TARGET_VARS = "LABELS BOOTPREFIXES TIMEOUT DEFAULT_LABEL TARGETS_EXTRA_CONFIG"
do_create_multiextlinux_config[vardeps] += "${@' '.join(['UBOOT_EXTLINUX_%s_%s' % (v, l) for v in d.getVar('UBOOT_EXTLINUX_TARGET_VARS').split() for l in d.getVar('UBOOT_EXTLINUX_TARGETS').split()])}"
UBOOT_EXTLINUX_LABELS_VARS = "CONSOLE MENU_DESCRIPTION ROOT KERNEL_IMAGE FDTDIR FDT KERNEL_ARGS INITRD"
UBOOT_EXTLINUX_LABELS_CONFIGURED = "${@" ".join(map(lambda t: "%s" % d.getVar("UBOOT_EXTLINUX_LABELS_%s" % t), d.getVar('UBOOT_EXTLINUX_TARGETS').split()))}"
+277 -59
View File
@@ -93,37 +93,52 @@
# FLASHLAYOUT_PARTITION_xxx
# -----------------------------------------------------------------------------
# Configure flashlayout file generation
ENABLE_FLASHLAYOUT_CONFIG ??= "1"
FLASHLAYOUT_SUBDIR = "flashlayout_${PN}"
FLASHLAYOUT_DESTDIR = "${IMGDEPLOYDIR}/${FLASHLAYOUT_SUBDIR}"
# Configure direct use of flashlayout file without automatic file generation
ENABLE_FLASHLAYOUT_DEFAULT ??= "0"
# Configure path for provided flashlayout file
FLASHLAYOUT_DEFAULT_SRC ??= ""
# Configure flashlayout file name default format
FLASHLAYOUT_BASENAME ??= "FlashLayout"
FLASHLAYOUT_SUFFIX ??= "tsv"
# Configure flashlayout file generation for stm32wrapper4dbg
ENABLE_FLASHLAYOUT_CONFIG_WRAPPER4DBG ??= "0"
# Configure folders for flashlayout file generation
FLASHLAYOUT_DEPLOYDIR ?= "${DEPLOY_DIR}/images/${MACHINE}"
FLASHLAYOUT_TOPDIR ?= "${WORKDIR}/flashlayout-destdir/"
FLASHLAYOUT_SUBDIR ?= "flashlayout_${PN}"
FLASHLAYOUT_DESTDIR = "${FLASHLAYOUT_TOPDIR}/${FLASHLAYOUT_SUBDIR}"
# Init bootscheme and config labels
FLASHLAYOUT_BOOTSCHEME_LABELS ??= ""
FLASHLAYOUT_CONFIG_LABELS ??= ""
# Init partition image list (used to configure partitions)
FLASHLAYOUT_PARTITION_IMAGES ??= ""
# Init partition and type labels
# Note: possible override with bootscheme and/or config
FLASHLAYOUT_PARTITION_LABELS ??= ""
FLASHLAYOUT_TYPE_LABELS ??= ""
# Init flashlayout partition vars
# Note: possible override with bootscheme and/or config and/or partition
FLASHLAYOUT_PARTITION_ENABLE ??= ""
FLASHLAYOUT_PARTITION_ID ??= ""
FLASHLAYOUT_PARTITION_TYPE ??= ""
FLASHLAYOUT_PARTITION_DEVICE ??= ""
FLASHLAYOUT_PARTITION_OFFSET ??= ""
FLASHLAYOUT_PARTITION_BIN2LOAD ??= ""
FLASHLAYOUT_PARTITION_SIZE ??= ""
FLASHLAYOUT_PARTITION_REPLACE_PATTERNS ??= ""
ENABLE_FLASHLAYOUT_DEFAULT ??= "0"
FLASHLAYOUT_DEFAULT_SRC ??= ""
# List all specific dependencies to image_complete task for successfull build
FLASHLAYOUT_DEPEND_TASKS ??= ""
# List configuration files to monitor to trigger new flashlayout generation
FLASHLAYOUT_CONFIGURE_FILES ??= ""
# -----------------------------------------------------------------------------
# Make sure to add the flashlayout file creation after ROOTFS build
# So we should identify image ROOTFS build and only the ROOTFS (for now)
# As we know that PARTITIONS may be built as part of ROOTFS build, let's
# avoid amending the partition images
# -----------------------------------------------------------------------------
python __anonymous () {
flashlayout_config = d.getVar('ENABLE_FLASHLAYOUT_CONFIG')
if flashlayout_config == "1":
# -----------------------------------------------------------------------------
# Make sure to add the flashlayout file creation after ROOTFS build
# So we should identify image ROOTFS build and only the ROOTFS (for now)
# As we know that PARTITIONS may be built as part of ROOTFS build, let's
# avoid amending the partition images
# -----------------------------------------------------------------------------
if d.getVar('ENABLE_FLASHLAYOUT_CONFIG') == "1":
# Gather all current tasks
tasks = filter(lambda k: d.getVarFlag(k, "task", True), d.keys())
for task in tasks:
@@ -135,18 +150,35 @@ python __anonymous () {
initramfs = d.getVar('INITRAMFS_IMAGE') or ""
# Init INITRD image if any
initrd = d.getVar('INITRD_IMAGE') or ""
# Init partition list from PARTITIONS_IMAGE
image_partitions = (d.getVar('PARTITIONS_IMAGE') or "").split()
# We need to clearly identify ROOTFS build, not InitRAMFS one (if any)
# Init partition list from PARTITIONS_CONFIG
image_partitions = []
# Append image_partitions list with all configured partition images:
partitionsconfigflags = d.getVarFlags('PARTITIONS_CONFIG')
# The "doc" varflag is special, we don't want to see it here
partitionsconfigflags.pop('doc', None)
partitionsconfig = (d.getVar('PARTITIONS_CONFIG') or "").split()
if len(partitionsconfig) > 0:
for config in partitionsconfig:
for f, v in partitionsconfigflags.items():
if config == f:
items = v.split(',')
# Make sure about PARTITIONS_CONFIG contents
if items[0] and len(items) > 5:
bb.fatal('[PARTITIONS_CONFIG] Only image,label,mountpoint,size,type can be specified!')
# Make sure that we're dealing with partition image and not rootfs image
if len(items) > 2 and items[2]:
# Mount point is available, so we're dealing with partition image
# Append image to image_partitions list
image_partitions.append(d.expand(items[0]))
break
# We need to clearly identify ROOTFS build, not InitRAMFS/initRD one (if any), not partition one either
if current_image_name not in image_partitions and current_image_name != initramfs and current_image_name != initrd:
# We need to make sure to add all extra dependencies as 'depends'
# for image_complete task
if d.getVar('FLASHLAYOUT_DEPEND_TASKS'):
d.appendVarFlag('do_image_complete', 'depends', ' %s' % (d.getVar('FLASHLAYOUT_DEPEND_TASKS',)))
# We can append the flashlayout file creation task to this ROOTFS build
d.appendVar('IMAGE_POSTPROCESS_COMMAND', 'do_create_flashlayout_config ; ')
# Append also the configuration files to properly take into account any updates
d.appendVarFlag('do_image_complete', 'file-checksums', ' ${FLASHLAYOUT_CONFIGURE_FILES} ')
# We add the flashlayout file creation task just after the do_image_complete for ROOTFS build
bb.build.addtask('do_create_flashlayout_config', 'do_build', 'do_image_complete', d)
# We add also the function that feeds the FLASHLAYOUT_PARTITION_* vars from PARTITIONS_CONFIG
d.appendVarFlag('do_create_flashlayout_config', 'prefuncs', ' flashlayout_partition_image_config')
}
def expand_var(var, bootscheme, config, partition, d):
@@ -179,30 +211,98 @@ def expand_var(var, bootscheme, config, partition, d):
# Return expanded and/or overriden var value
return expanded_var
def get_offset(new_offset, bootscheme, config, partition, d):
def get_device(bootscheme, config, partition, d):
"""
This function return a couple of strings: offset, next_offset
This function returns the device configured from FLASHLAYOUT_PARTITION_DEVICE for
the requested partition for label and bootscheme configured.
The var FLASHLAYOUT_PARTITION_DEVICE can be configured through different scheme
FLASHLAYOUT_PARTITION_DEVICE = '<device0>:<dev0part_0> <dev0part_1>,<device1>:<dev1part0>'
FLASHLAYOUT_PARTITION_DEVICE = '<device0>:default,<device1>:<dev1part0> <dev1part1>,<device2>:<dev2part0>'
FLASHLAYOUT_PARTITION_DEVICE = '<device0>'
Then, to set the device for the current partition, the logic followed is:
If the configuration provides a single device, then partition device is set
to this value.
Else,
If the current partition is specified in any of the configured partition
lists, the matching configured device is set as partition device.
And if the current partition is not found, the default device configured
is set as partition device.
"""
# Set device configuration
device_configs = expand_var('FLASHLAYOUT_PARTITION_DEVICE', bootscheme, config, partition, d)
bb.note('>>> Selected FLASHLAYOUT_PARTITION_DEVICE: %s' % device_configs)
if len(device_configs.split(',')) == 1:
bb.note('>>> Only one device configuration set for %s partition for %s label for %s bootscheme' % (partition, config, bootscheme))
device = device_configs.split(':')[0]
else:
bb.note('>>> Multiple device configurations set for %s partition for %s label for %s bootscheme' % (partition, config, bootscheme))
# Init default_device and device to empty string
default_device = ''
device = ''
for device_config in device_configs.split(','):
cfg_devc = device_config.split(':')[0].strip()
cfg_part = device_config.split(':')[1] or 'default'
# Make sure configuration is correct
if len(cfg_devc.split()) > 1:
bb.fatal('Only one device configuration can be specified: found %s for %s partition for %s label for %s bootscheme' % (cfg_devc, partition, config, bootscheme))
# Configure the default device configuration if any
if cfg_part == 'default':
if default_device != '':
bb.fatal('Found two "default" device configuration for %s partition for %s label for %s bootscheme in FLASHLAYOUT_PARTITION_DEVICE var' % (partition, config, bootscheme))
default_device = cfg_devc
bb.note('>>> Set default device configuration to %s' % default_device)
else:
# Find out if any device is configured for current partition
for p in cfg_part.split():
if p == partition:
device = cfg_devc
break
# If 'device' is still empty for current partition, check if we can apply default device configuration
if device == '':
if default_device == '':
bb.fatal('Not able to get device configuration for %s partition for %s label for %s bootscheme' % (partition, config, bootscheme))
else:
bb.note('>>> Configure device to default device setting')
device = default_device
bb.note('>>> New device configured: %s' % device)
# Return the value computed
return device
def get_offset(new_offset, current_device, bootscheme, config, partition, d):
"""
This function returns a couple of strings: offset, next_offset
The offset is the one to use in flashlayout file for the requested partition,
and next_offset is the one to use in flashlayout for next partition (if any).
The offset can be directly configured for the current partition through the
FLASHLAYOUT_PARTITION_OFFSET variable. If this one is set to 'none' for the
current partition, then we use the one provided through 'new_offset'.
current partition, then we use the one provided through 'new_offset' if set,
else we default to DEVICE_START_OFFSET_<device> one where <device> is feed from
'current_device' input.
The next_offset is computed by first getting the FLASHLAYOUT_PARTITION_SIZE for
the current partition, and we make sure to align properly the next_offset
according to the DEVICE_ALIGNMENT_SIZE_<device> where <device> is feed from
FLASHLAYOUT_PARTITION_DEVICE.
'current_device' input.
"""
import re
# Get current_device alias
device_alias = d.getVar('DEVICE_%s' % current_device) or ""
# Set offset
offset = expand_var('FLASHLAYOUT_PARTITION_OFFSET', bootscheme, config, partition, d)
bb.note('>>> Selected FLASHLAYOUT_PARTITION_OFFSET: %s' % offset)
if offset == 'none':
if new_offset == 'none':
bb.fatal('Missing %s partition offset configuration for %s label for %s bootscheme!' % (partition, config, bootscheme))
offset = new_offset
bb.note('>>> No %s partition offset configured (%s device) for %s label for %s bootscheme, so default to default origin device one.' % (partition, current_device, config, bootscheme))
start_offset = d.getVar('DEVICE_START_OFFSET_%s' % device_alias) or "none"
if start_offset == 'none':
bb.fatal('Missing DEVICE_START_OFFSET_%s value' % device_alias)
offset = start_offset
else:
offset = new_offset
bb.note('>>> New offset configured: %s' % offset)
# Set next offset
@@ -213,11 +313,10 @@ def get_offset(new_offset, bootscheme, config, partition, d):
next_offset = "none"
else:
if re.match('^0x.*$', offset):
current_device = expand_var('FLASHLAYOUT_PARTITION_DEVICE', bootscheme, config, partition, d)
bb.note('>>> Current device is %s' % current_device)
alignment_size = d.getVar('DEVICE_ALIGNMENT_SIZE_%s' % current_device) or "none"
bb.note('>>> Current device is %s (%s alias)' % (current_device, device_alias))
alignment_size = d.getVar('DEVICE_ALIGNMENT_SIZE_%s' % device_alias) or "none"
if alignment_size == 'none':
bb.fatal('Missing DEVICE_ALIGNMENT_SIZE_%s value' % current_device)
bb.fatal('Missing DEVICE_ALIGNMENT_SIZE_%s value' % device_alias)
if ( int(partition_size) * 1024 ) % int(alignment_size, 16) == 0:
bb.note('>>> The partition size properly follows %s erase size' % alignment_size)
else:
@@ -236,7 +335,6 @@ def get_offset(new_offset, bootscheme, config, partition, d):
# Return both offset and next offset
return str(offset), str(next_offset)
def get_binaryname(labeltype, bootscheme, config, partition, d):
"""
Return proper binary name to use in flashlayout file by applying any specific
@@ -260,7 +358,7 @@ def get_binaryname(labeltype, bootscheme, config, partition, d):
binary_type = labeltype + '-' + bootscheme
bb.note('>>> Binary type used: %s' % binary_type)
# Check for any replace pattern
replace_patterns = expand_var('BIN2BOOT_REPLACE_PATTERNS', bootscheme, config, partition, d)
replace_patterns = expand_var('FLASHLAYOUT_PARTITION_REPLACE_PATTERNS', bootscheme, config, partition, d)
bb.note('>>> Substitution patterns: %s' % replace_patterns)
# Apply replacement patterns on binary_type
if replace_patterns != 'none':
@@ -291,7 +389,7 @@ def flashlayout_search(d, files):
search_path = d.getVar("BBPATH").split(":")
for file in files.split():
for p in search_path:
file_path = p + "/" + file
file_path = os.path.join(p, file)
if os.path.isfile(file_path):
return (True, file_path)
return (False, "")
@@ -317,15 +415,16 @@ python do_create_flashlayout_config() {
bb.fatal("FLASHLAYOUT_DEFAULT_SRC not defined, please set a proper value")
if not flashlayout_src.strip():
bb.fatal("No static flashlayout file configured, nothing to do")
found, f = flashlayout_search(d, flashlayout_src)
if found:
flashlayout_staticname=os.path.basename(f)
flashlayout_file = d.expand("${FLASHLAYOUT_DESTDIR}/%s" % flashlayout_staticname)
shutil.copy2(f, flashlayout_file)
bb.note('Copy %s to output file %s' % (f, flashlayout_file))
return
else:
bb.fatal("Configure static file: %s not found" % flashlayout_src)
for fl_src in flashlayout_src.split():
found, f = flashlayout_search(d, fl_src)
if found:
flashlayout_staticname=os.path.basename(f)
flashlayout_file = os.path.join(d.getVar('FLASHLAYOUT_DESTDIR'), flashlayout_staticname)
shutil.copy2(f, flashlayout_file)
bb.note('Copy %s to output file %s' % (f, flashlayout_file))
else:
bb.fatal("Configure static file: %s not found" % fl_src)
return
# Set bootschemes for partition var override configuration
bootschemes = d.getVar('FLASHLAYOUT_BOOTSCHEME_LABELS')
@@ -341,7 +440,6 @@ python do_create_flashlayout_config() {
for bootscheme in bootschemes.split():
bb.note('*** Loop for bootscheme label: %s' % bootscheme)
# Get the different flashlayout config label
configs = expand_var('FLASHLAYOUT_CONFIG_LABELS', bootscheme, '', '', d)
# Make sure there is no '_' in FLASHLAYOUT_CONFIG_LABELS
@@ -350,16 +448,25 @@ python do_create_flashlayout_config() {
bb.fatal("Please remove all '_' for configs defined in FLASHLAYOUT_CONFIG_LABELS")
bb.note('FLASHLAYOUT_CONFIG_LABELS: %s' % configs)
if configs.strip() == 'none':
bb.note("FLASHLAYOUT_CONFIG_LABELS is none, so no flashlayout file to generate.")
continue
# Create bootscheme subfolder for flashlayout files
flashlayout_subfolder_path = os.path.join(d.getVar('FLASHLAYOUT_DESTDIR'), bootscheme)
bb.utils.mkdirhier(flashlayout_subfolder_path)
for config in configs.split():
bb.note('*** Loop for config label: %s' % config)
# Set labeltypes list
labeltypes = expand_var('FLASHLAYOUT_TYPE_LABELS', bootscheme, config, '', d)
bb.note('FLASHLAYOUT_TYPE_LABELS: %s' % labeltypes)
if labeltypes == 'none':
if labeltypes.strip() == 'none':
bb.note("FLASHLAYOUT_TYPE_LABELS is none, so no flashlayout file to generate.")
continue
for labeltype in labeltypes.split():
bb.note('*** Loop for label type: %s' % labeltype)
# Init current label
current_label = labeltype
# Init flashlayout file name
if config == 'none':
config_append = ''
@@ -369,7 +476,7 @@ python do_create_flashlayout_config() {
labeltype_append = ''
else:
labeltype_append = '_' + labeltype + '-' + bootscheme
flashlayout_file = d.expand("${FLASHLAYOUT_DESTDIR}/${FLASHLAYOUT_BASENAME}%s%s.${FLASHLAYOUT_SUFFIX}" % (config_append, labeltype_append))
flashlayout_file = os.path.join(flashlayout_subfolder_path, d.expand("${FLASHLAYOUT_BASENAME}%s%s.${FLASHLAYOUT_SUFFIX}" % (config_append, labeltype_append)))
# Get the partition list to write in flashlayout file
partitions = expand_var('FLASHLAYOUT_PARTITION_LABELS', bootscheme, config, '', d)
bb.note('FLASHLAYOUT_PARTITION_LABELS: %s' % partitions)
@@ -383,6 +490,8 @@ python do_create_flashlayout_config() {
fl_file.write('#Opt\tId\tName\tType\tIP\tOffset\tBinary\n')
# Init partition next offset to 'none'
partition_nextoffset = "none"
# Init partition previous device to 'none'
partition_prevdevice = "none"
for partition in partitions.split():
bb.note('*** Loop for partition: %s' % partition)
# Init partition settings
@@ -390,9 +499,14 @@ python do_create_flashlayout_config() {
partition_id = expand_var('FLASHLAYOUT_PARTITION_ID', bootscheme, config, partition, d)
partition_name = partition
partition_type = expand_var('FLASHLAYOUT_PARTITION_TYPE', bootscheme, config, partition, d)
partition_device = expand_var('FLASHLAYOUT_PARTITION_DEVICE', bootscheme, config, partition, d)
partition_device = get_device(bootscheme, config, partition, d)
# Reset partition_nextoffset to 'none' in case partition device has changed
if partition_device != partition_prevdevice:
partition_nextoffset = "none"
# Save partition current device to previous one for next loop
partition_prevdevice = partition_device
# Get partition offset
partition_offset, partition_nextoffset = get_offset(partition_nextoffset, bootscheme, config, partition, d)
partition_offset, partition_nextoffset = get_offset(partition_nextoffset, partition_device, bootscheme, config, partition, d)
# Get binary name
partition_bin2load = get_binaryname(labeltype, bootscheme, config, partition, d)
# Be verbose in log file
@@ -405,6 +519,14 @@ python do_create_flashlayout_config() {
bb.note('>>> FLASHLAYOUT_PARTITION_OFFSET: %s' % partition_offset)
bb.note('>>> FLASHLAYOUT_PARTITION_BIN2LOAD: %s' % partition_bin2load)
bb.note('>>> done')
# Get the supported labels for current storage device
partition_device_alias = d.getVar('DEVICE_%s' % partition_device) or ""
partition_type_supported_labels = d.getVar('DEVICE_BOARD_ENABLE_%s' % partition_device_alias) or "none"
# Check if partition type is supported for the current label
if partition_device != 'none' and current_label not in partition_type_supported_labels.split():
bb.note('>>> FLASHLAYOUT_PARTITION_DEVICE (%s, alias %s) is not supported for current label (%s): partition %s not appended in flashlayout file' % (partition_device, partition_device_alias, current_label, partition_name))
bb.note('>>> DEVICE_BOARD_ENABLE_%s: %s' % (partition_device_alias, partition_type_supported_labels))
continue
# Write to flashlayout file the partition configuration
fl_file.write('%s\t%s\t%s\t%s\t%s\t%s\t%s\n' %
(partition_enable, partition_id, partition_name, partition_type, partition_device, partition_offset, partition_bin2load))
@@ -444,3 +566,99 @@ python do_create_flashlayout_config() {
else:
os.remove(tmp_flashlayout_file)
}
do_create_flashlayout_config[dirs] = "${FLASHLAYOUT_DESTDIR}"
FLASHLAYOUT_DEPEND_TASKS ?= ""
do_create_flashlayout_config[depends] += "${FLASHLAYOUT_DEPEND_TASKS}"
SSTATETASKS += "do_create_flashlayout_config"
do_create_flashlayout_config[cleandirs] = "${FLASHLAYOUT_TOPDIR}"
do_create_flashlayout_config[sstate-inputdirs] = "${FLASHLAYOUT_TOPDIR}"
do_create_flashlayout_config[sstate-outputdirs] = "${FLASHLAYOUT_DEPLOYDIR}/"
python do_create_flashlayout_config_setscene () {
sstate_setscene(d)
}
addtask do_create_flashlayout_config_setscene
python flashlayout_partition_image_config() {
"""
Set the different flashlayout partition vars for the configure partition
images.
Based on PARTITIONS_CONFIG, feed:
FLASHLAYOUT_PARTITION_IMAGES
FLASHLAYOUT_PARTITION_ID_
FLASHLAYOUT_PARTITION_TYPE_
FLASHLAYOUT_PARTITION_SIZE_
FLASHLAYOUT_PARTITION_BIN2LOAD_
"""
partitionsconfigflags = d.getVarFlags('PARTITIONS_CONFIG')
# The "doc" varflag is special, we don't want to see it here
partitionsconfigflags.pop('doc', None)
partitionsconfig = (d.getVar('PARTITIONS_CONFIG') or "").split()
if len(partitionsconfig) > 0:
# Init default partition id for binary type and other
id_bin = 4
id_oth = 33
for config in partitionsconfig:
for f, v in partitionsconfigflags.items():
if config == f:
items = v.split(',')
# Make sure about PARTITIONS_CONFIG contents
if items[0] and len(items) > 5:
bb.fatal('[PARTITIONS_CONFIG] Only image,label,mountpoint,size,type can be specified!')
if items[1]:
bb.debug(1, "Appending %s to FLASHLAYOUT_PARTITION_IMAGES." % items[1])
d.appendVar('FLASHLAYOUT_PARTITION_IMAGES', ' ' + items[1])
else:
bb.fatal('[PARTITIONS_CONFIG] Missing image label setting')
# Init flashlayout label
fl_label = d.expand(items[1])
if items[2] == '':
# There is no mountpoint specified, so we apply rootfs image format
bb.debug(1, "Set FLASHLAYOUT_PARTITION_BIN2LOAD_%s to %s." % (fl_label, items[0] + "-${MACHINE}.ext4"))
d.setVar('FLASHLAYOUT_PARTITION_BIN2LOAD_%s' % fl_label, items[0] + "-${MACHINE}.ext4")
else:
bb.debug(1, "Set FLASHLAYOUT_PARTITION_BIN2LOAD_%s to %s." % (fl_label, items[0] + "-${DISTRO}-${MACHINE}.ext4"))
d.setVar('FLASHLAYOUT_PARTITION_BIN2LOAD_%s' % fl_label, items[0] + "-${DISTRO}-${MACHINE}.ext4")
if items[3]:
bb.debug(1, "Set FLASHLAYOUT_PARTITION_SIZE_%s to %s." % (fl_label, items[3]))
d.setVar('FLASHLAYOUT_PARTITION_SIZE_%s' % fl_label, items[3])
else:
bb.fatal('[PARTITIONS_CONFIG] Missing PARTITION_SIZE setting for % label' % fl_label)
if items[4]:
bb.debug(1, "Set FLASHLAYOUT_PARTITION_TYPE_%s to %s." % (fl_label, items[4]))
d.setVar('FLASHLAYOUT_PARTITION_TYPE_%s' % fl_label, items[4])
# Compute partition id according to type set
if items[4] == 'Binary':
part_id = '0x{0:0{1}X}'.format(id_bin, 2)
id_bin = id_bin + 1
else:
part_id = '0x{0:0{1}X}'.format(id_oth, 2)
id_oth = id_oth + 1
bb.debug(1, "Set FLASHLAYOUT_PARTITION_ID_%s to %s." % (fl_label, part_id))
d.setVar('FLASHLAYOUT_PARTITION_ID_%s' % fl_label, "%s" % part_id)
else:
bb.fatal('[PARTITIONS_CONFIG] Missing PARTITION_TYPE setting for % label' % fl_label)
break
}
# -----------------------------------------------------------------------------
# Manage specific var dependency:
# Because of local overrides within create_flashlayout_config() function, we
# need to make sure to add each variables to the vardeps list.
FLASHLAYOUT_LABELS_VARS = "CONFIG_LABELS PARTITION_LABELS TYPE_LABELS"
FLASHLAYOUT_LABELS_OVERRIDES = "${@' '.join('%s %s %s_%s' % (b, c, b, c) for b in d.getVar('FLASHLAYOUT_BOOTSCHEME_LABELS').split() for c in d.getVar('FLASHLAYOUT_CONFIG_LABELS').split())}"
do_create_flashlayout_config[vardeps] += "${@' '.join(['FLASHLAYOUT_%s_%s' % (v, o) for v in d.getVar('FLASHLAYOUT_LABELS_VARS').split() for o in d.getVar('FLASHLAYOUT_LABELS_OVERRIDES').split()])}"
FLASHLAYOUT_PARTITION_VARS = "ENABLE ID TYPE DEVICE OFFSET BIN2LOAD SIZE REPLACE_PATTERNS"
FLASHLAYOUT_PARTITION_CONFIGURED = "${@" ".join(map(lambda o: "%s" % d.getVar("FLASHLAYOUT_PARTITION_LABELS_%s" % o), d.getVar('FLASHLAYOUT_LABELS_OVERRIDES').split()))}"
FLASHLAYOUT_PARTITION_OVERRIDES = "${@' '.join('%s %s %s_%s' % (o, p, o, p) for o in d.getVar('FLASHLAYOUT_LABELS_OVERRIDES').split() for p in d.getVar('FLASHLAYOUT_PARTITION_CONFIGURED').split())}"
do_create_flashlayout_config[vardeps] += "${@' '.join(['FLASHLAYOUT_PARTITION_%s_%s' % (v, o) for v in d.getVar('FLASHLAYOUT_PARTITION_VARS').split() for o in d.getVar('FLASHLAYOUT_PARTITION_OVERRIDES').split()])}"
FLASHLAYOUT_DEVICE_VARS = "ALIGNMENT_SIZE BOARD_ENABLE START_OFFSET"
FLASHLAYOUT_PARTITION_DEVICE_CONFIGURED = "${@" ".join(map(lambda p: "%s" % d.getVar("DEVICE_%s" % p), d.getVar('DEVICE_STORAGE_NAMES').split()))}"
do_create_flashlayout_config[vardeps] += "${@' '.join(['DEVICE_%s_%s' % (v, o) for v in d.getVar('FLASHLAYOUT_DEVICE_VARS').split() for o in d.getVar('FLASHLAYOUT_PARTITION_DEVICE_CONFIGURED').split()])}"
+25 -30
View File
@@ -1,6 +1,9 @@
inherit image_types
do_image_stmultiubi[depends] += "mtd-utils-native:do_populate_sysroot"
do_image_stmultiubi[depends] += " \
mtd-utils-native:do_populate_sysroot \
bc-native:do_populate_sysroot \
"
python stmultiub_environment () {
if d.getVar('MULTIUBI_BUILD'):
@@ -39,36 +42,23 @@ IMAGE_CMD_stmultiubi () {
ENABLE_MULTIVOLUME_UBI ?= "1"
st_multivolume_ubifs() {
# This function depends on IMAGE_FSTYPES 'stmultiubi'
if [ "${@bb.utils.contains('IMAGE_FSTYPES', 'stmultiubi', '1', '0', d)}" != "1" ]; then
return
fi
# -----------------------------------------------------------------------------
# Define the list of volumes for the multi UBIFS with 'STM32MP_UBI_VOLUME' var.
# The format to follow is:
# STM32MP_UBI_VOLUME = "<VOL_NAME_1>:<VOL_SIZE_1>:<VOL_TYPE_1> <VOL_NAME_2>:<VOL_SIZE_2>"
# Note that:
# - 'VOL_NAME' is the image volume name
# - 'VOL_SIZE' is set in KiB
# - 'VOL_TYPE' is optional part and could be 'empty' to add empty UBI with
# volume name set to 'VOL_NAME'
# -----------------------------------------------------------------------------
STM32MP_UBI_VOLUME ?= ""
st_multivolume_ubifs() {
if [ "${ENABLE_MULTIVOLUME_UBI}" != "1" ]; then
return
fi
# -----------------------------------------------------------------------------
# Define the list of volumes for the multi UBIFS with 'STM32MP_UBI_VOLUME' var.
# The format to follow is:
# STM32MP_UBI_VOLUME = "<VOL_NAME_1>:<VOL_SIZE_1>:<VOL_TYPE_1> <VOL_NAME_2>:<VOL_SIZE_2>"
# Note that:
# - 'VOL_NAME' should follow 'IMAGE_LINK_NAME' format
# - 'VOL_SIZE' is set in KiB
# - 'VOL_TYPE' is optional part and could be 'empty' to add empty UBI with name 'VOL_NAME'
# -----------------------------------------------------------------------------
# We check that user as explicitly provided multi volume UBIFS var
# and that partition images are also provided
if [ -n "${STM32MP_UBI_VOLUME}" ] && [ -n "${PARTITIONS_IMAGE}" ]; then
# We should only generate multi volume UBIFS for rootfs image and not
# any of the partition image one
for partition in ${PARTITIONS_IMAGE}; do
[ "${partition}-${DISTRO}-${MACHINE}" = "${IMAGE_LINK_NAME}" ] && return
done
if [ -n "${STM32MP_UBI_VOLUME}" ]; then
. ${T}/stmultiubi_environment
# Get total volume number to handle
@@ -99,6 +89,13 @@ st_multivolume_ubifs() {
echo vol_name=${volume_name} >> ${cfg_filename}
echo vol_flags=autoresize >> ${cfg_filename}
else
# Update volume_name to fit image link name scheme
if [ "${volume_name}" = "${IMAGE_BASENAME}" ]; then
volume_name=${IMAGE_LINK_NAME}
else
# Partiton images use case, so make sure to append DISTRO and MACHINE
volume_name=${volume_name}-${DISTRO}-${MACHINE}
fi
if [ -z "${volume_type}" ]; then
bbnote "The UBI volume type is not set. Use default configuration for ${volume_name}"
bbnote "Append ${extra_size}KiB extra space to UBIFS volume size"
@@ -114,7 +111,7 @@ st_multivolume_ubifs() {
elif [ -e ${DEPLOY_DIR_IMAGE}/${volume_name}_${name}.ubinize.cfg.ubi ]; then
ubinize_cfg=${DEPLOY_DIR_IMAGE}/${volume_name}_${name}.ubinize.cfg.ubi
else
bbfatal "Can't find any '${name}' ubinize config file for ${volume_name} in ${IMGDEPLOYDIR} or ${DEPLOY_DIR_IMAGE} folders"
bbfatal "Can't find any '${volume_name}_${name}.ubinize.cfg.ubi' config file from ${IMGDEPLOYDIR} or ${DEPLOY_DIR_IMAGE} folders"
fi
# Create temporary copy of ubinize config file for update
cp ${ubinize_cfg} ${WORKDIR}/
@@ -159,5 +156,3 @@ st_multivolume_ubifs() {
done
fi
}
IMAGE_POSTPROCESS_COMMAND += " st_multivolume_ubifs ;"
+112 -23
View File
@@ -9,15 +9,92 @@
#
ENABLE_PARTITIONS_IMAGE ?= "1"
PARTITIONS_IMAGE ?= ""
PARTITIONS_CONFIG ??= ""
PARTITIONS_IMAGE ??= ""
PARTITIONS_MOUNTPOINT ??= ""
python __anonymous () {
# We check first if it is requested to generate any partition images
if d.getVar('ENABLE_PARTITIONS_IMAGE') != "1":
bb.note('ENABLE_PARTITIONS_IMAGE not enabled')
return
# -----------------------------------------------------------------------------
# Update the partition configuration set by user
# -----------------------------------------------------------------------------
partitionsconfigflags = d.getVarFlags('PARTITIONS_CONFIG')
# The "doc" varflag is special, we don't want to see it here
partitionsconfigflags.pop('doc', None)
partitionsconfig = (d.getVar('PARTITIONS_CONFIG') or "").split()
# Init image_summary_list
image_summary_list = ''
if len(partitionsconfig) > 0:
for config in partitionsconfig:
for f, v in partitionsconfigflags.items():
if config == f:
items = v.split(',')
if items[0]:
if len(items) > 5:
raise bb.parse.SkipRecipe('Only image,label,mountpoint,size,type can be specified!')
# Make sure that we're dealing with partition image and not rootfs image
if len(items) > 2 and items[2]:
# Mount point available, so we're dealing with partition image
# PARTITIONS_IMAGE appending
bb.debug(1, "Appending '%s' to PARTITIONS_IMAGE." % items[0])
d.appendVar('PARTITIONS_IMAGE', ' ' + items[0])
# PARTITIONS_MOUNTPOINT appending
bb.debug(1, "Appending '%s' to PARTITIONS_MOUNTPOINT." % items[2])
d.appendVar('PARTITIONS_MOUNTPOINT', ' ' + items[2])
# Update IMAGE vars for each partition image
if items[1]:
bb.debug(1, "Set UBI_VOLNAME to %s for %s partition image." % (items[1], items[0]))
d.setVar('UBI_VOLNAME_pn-%s' % d.expand(items[0]), items[1])
if d.expand(items[1])[-2:] != 'fs':
bb.debug(1, "Set IMAGE_NAME_SUFFIX to '.%sfs' for %s partition image." % (items[1], items[0]))
d.setVar('IMAGE_NAME_SUFFIX_pn-%s' % d.expand(items[0]), '.' + items[1] + 'fs')
else:
bb.debug(1, "Set IMAGE_NAME_SUFFIX to '.%s' for %s partition image." % (items[1], items[0]))
d.setVar('IMAGE_NAME_SUFFIX_pn-%s' % d.expand(items[0]), '.' + items[1])
else:
bb.fatal('[PARTITIONS_CONFIG] Missing label setting for %s image' % items[0])
if items[2]:
bb.debug(1, "Set IMAGE_PARTITION_MOUNTPOINT to %s for %s partition image." % (items[2], items[0]))
d.setVar('IMAGE_PARTITION_MOUNTPOINT_pn-%s' % d.expand(items[0]), items[2])
if items[3]:
bb.debug(1, "Set IMAGE_ROOTFS_SIZE to %s for %s partition image." % (items[3], items[0]))
d.setVar('IMAGE_ROOTFS_SIZE_pn-%s' % d.expand(items[0]), items[3])
else:
bb.fatal('[PARTITIONS_CONFIG] Missing size setting for %s image' % items[0])
# Manage IMAGE_SUMMARY_LIST configuration according to PARTITION_CONFIG set
if d.getVar('ENABLE_IMAGE_LICENSE_SUMMARY') == "1":
if not items[2]:
# Set '/' as default mountpoint for rootfs in IMAGE_SUMMARY_LIST
items[2] = '/'
image_summary_list += items[0] + ':' + items[2] + ';'
# Manage multiubi volume list STM32MP_UBI_VOLUME
if bb.utils.contains('IMAGE_FSTYPES', 'stmultiubi', True, False, d) and d.getVar('ENABLE_MULTIVOLUME_UBI') == "1":
bb.debug(1, "Appending '%s' image with %s size to STM32MP_UBI_VOLUME." % (items[0], items[3]))
d.appendVar('STM32MP_UBI_VOLUME', ' ' + items[0] + ':' + items[3])
else:
bb.fatal('[PARTITIONS_CONFIG] Missing image setting')
break
# Reset IMAGE_LIST_SUMMARY with computed partition configuration
if d.getVar('ENABLE_IMAGE_LICENSE_SUMMARY') == "1":
bb.debug(1, "Set IMAGE_SUMMARY_LIST with configuration: %s." % image_summary_list)
d.setVar('IMAGE_SUMMARY_LIST', image_summary_list)
# Init partition list from PARTITIONS_IMAGE
image_partitions = (d.getVar('PARTITIONS_IMAGE') or "").split()
# -----------------------------------------------------------------------------
# Make sure to append the partition build to current image target
# -----------------------------------------------------------------------------
if len(image_partitions) > 0:
# Gather all current tasks
tasks = filter(lambda k: d.getVarFlag(k, "task", True), d.keys())
@@ -28,33 +105,45 @@ python __anonymous () {
current_image_name = d.getVar('PN') or ""
# Init RAMFS image if any
initramfs = d.getVar('INITRAMFS_IMAGE') or ""
# Init INITRD image if any
initrd = d.getVar('INITRD_IMAGE') or ""
# We need to append partition images generation only to image
# that are not one of the defined partitions and not the InitRAMFS image.
# Without this check we would create circular dependency
if current_image_name not in image_partitions and current_image_name != initramfs:
if current_image_name not in image_partitions and current_image_name != initramfs and current_image_name != initrd:
for partition in image_partitions:
bb.debug(1, "Appending %s image build to 'do_image_complete' depends tasks." % partition)
d.appendVarFlag('do_image_complete', 'depends', ' %s:do_image_complete' % partition)
bb.debug(1, "Appending 'image_rootfs_image_clean_task' to IMAGE_PREPROCESS_COMMAND.")
d.appendVar('IMAGE_PREPROCESS_COMMAND', 'image_rootfs_image_clean_task;')
# Manage multiubi volume build enable for current image
if bb.utils.contains('IMAGE_FSTYPES', 'stmultiubi', True, False, d) and d.getVar('ENABLE_MULTIVOLUME_UBI') == "1":
bb.debug(1, "Appending 'st_multivolume_ubifs' to IMAGE_POSTPROCESS_COMMAND.")
d.appendVar('IMAGE_POSTPROCESS_COMMAND', 'st_multivolume_ubifs;')
}
image_rootfs_image_clean_task () {
if [ ${ENABLE_PARTITIONS_IMAGE} -ne "1" ]; then
return
fi
for name in ${PARTITIONS_IMAGE};
do
if `echo ${IMAGE_NAME} | grep -q $name` ;
then
return;
fi
done
bbnote "Clean mount point on ${IMAGE_NAME}:"
LIST=`ls -l ${IMAGE_ROOTFS}`
for dir in ${PARTITIONS_MOUNTPOINT_IMAGE};
do
bbnote "$dir on ${IMAGE_NAME} are cleanned because it's a mount point."
rm -rf ${IMAGE_ROOTFS}/$dir/*
image_rootfs_image_clean_task() {
bbnote "PARTITIONS_IMAGE"
bbnote ">>> ${PARTITIONS_IMAGE}"
bbnote "PARTITIONS_MOUNTPOINT"
bbnote ">>> ${PARTITIONS_MOUNTPOINT}"
unset i j
for img in ${PARTITIONS_IMAGE}; do
i=$(expr $i + 1);
for part in ${PARTITIONS_MOUNTPOINT}; do
j=$(expr $j + 1);
if [ $j -eq $i ]; then
bbnote "Expecting to clean folder:"
bbnote ">>> ${IMAGE_ROOTFS}/$part"
if [ -d ${IMAGE_ROOTFS}/$part ]; then
rm -rf ${IMAGE_ROOTFS}/$part/*
bbnote ">>> DONE"
else
bbnote ">>> NOT DONE : $part folder doesn't exist in image rootfs"
fi
fi
done
unset j
done
unset i
}
IMAGE_PREPROCESS_COMMAND_append = " image_rootfs_image_clean_task; "