TF-A-STM32MP: add file type for deploying image

When a compilation a made for TF-a with 'all' target, several binaries are generated
and have the same name on several kind of build but generated with different
compilation switch. In some case (like arm64 bits) the bl2 need to generate a
bl31 binary but without the specific option requested by the generation of official bl31,
which can generate an issue when you deploy the file because it's the binary of
last build which are used but it's not in all case the binary with compilation
option desired.
For solving this king of issue, a flag <file type> which can be : bl31 b32 bl2 fwconfig
are added on the TF_A_CONFIG to specify which kind of binary we need to export.

Change-Id: Ibd484ae2e285bf70e3e0790e020d2ea595506a3c
Signed-off-by: Christophe Priouzeau <christophe.priouzeau@foss.st.com>
This commit is contained in:
Romuald JEANNE 2021-06-29 12:14:52 +02:00 committed by Lionel VITTE
parent f724e2f9e7
commit af9ec1ddf8
2 changed files with 85 additions and 51 deletions

View File

@ -110,6 +110,8 @@ python () {
raise bb.parse.SkipRecipe("You cannot use TF_A_BINARIES as it is internal to TF_A_CONFIG var expansion.")
if (d.getVar('TF_A_MAKE_TARGET') or "").split():
raise bb.parse.SkipRecipe("You cannot use TF_A_MAKE_TARGET as it is internal to TF_A_CONFIG var expansion.")
if (d.getVar('TF_A_FILES') or "").split():
raise bb.parse.SkipRecipe("You cannot use TF_A_FILES as it is internal to TF_A_CONFIG var expansion.")
if len(tfaconfig) > 0:
for config in tfaconfig:
@ -120,8 +122,8 @@ python () {
if not v.strip():
bb.fatal('[TF_A_CONFIG] Missing configuration for %s config' % config)
items = v.split(',')
if items[0] and len(items) > 4:
raise bb.parse.SkipRecipe('Only <DEVICETREE>,<EXTRA_OPTFLAGS>,<BINARY_BASENAME>,<MAKE_TARGET> can be specified!')
if items[0] and len(items) > 5:
raise bb.parse.SkipRecipe('Only <DEVICETREE>,<EXTRA_OPTFLAGS>,<BINARY_BASENAME>,<MAKE_TARGET>,<FILES TYPE> can be specified!')
# Set internal vars
bb.debug(1, "Appending '%s' to TF_A_DEVICETREE" % items[0])
d.appendVar('TF_A_DEVICETREE', items[0] + ',')
@ -141,6 +143,11 @@ python () {
d.appendVar('TF_A_MAKE_TARGET', items[3] + ',')
else:
d.appendVar('TF_A_MAKE_TARGET', 'all' + ',')
if len(items) > 4 and items[4]:
bb.debug(1, "Appending '%s' to TF_A_FILES." % items[4])
d.appendVar('TF_A_FILES', items[4] + ',')
else:
d.appendVar('TF_A_FILES', 'bl2' + ',')
break
}
@ -237,6 +244,7 @@ do_deploy() {
# Initialize devicetree list and tf-a basename
dt_config=$(echo ${TF_A_DEVICETREE} | cut -d',' -f${i})
tfa_basename=$(echo ${TF_A_BINARIES} | cut -d',' -f${i})
tfa_file_type=$(echo ${TF_A_FILES} | cut -d',' -f${i})
for dt in ${dt_config}; do
# Init soc suffix
soc_suffix=""
@ -245,6 +253,9 @@ do_deploy() {
[ "$(echo ${dt} | grep -c ${soc})" -eq 1 ] && soc_suffix="-${soc}"
done
fi
for file_type in ${tfa_file_type}; do
case ${file_type} in
bl2)
# Install TF-A binary
if [ -f ${B}/${config}${soc_suffix}/${tfa_basename}-${dt}-${config}.${TF_A_SUFFIX} ]; then
install -m 644 ${B}/${config}${soc_suffix}/${tfa_basename}-${dt}-${config}.${TF_A_SUFFIX} ${DEPLOYDIR}/arm-trusted-firmware/
@ -253,6 +264,14 @@ do_deploy() {
install -m 644 ${B}/${config}${soc_suffix}/debug-${tfa_basename}-${dt}-${config}.${TF_A_SUFFIX} ${DEPLOYDIR}/arm-trusted-firmware/debug/
fi
fi
if [ -n "${ELF_DEBUG_ENABLE}" ]; then
install -d ${DEPLOYDIR}/arm-trusted-firmware/debug
if [ -f ${B}/${config}${soc_suffix}/${BL2_ELF} ]; then
install -m 644 ${B}/${config}${soc_suffix}/${BL2_ELF} ${DEPLOYDIR}/arm-trusted-firmware/debug/${tfa_basename}-${BL2_BASENAME_DEPLOY}-${config}.${TF_A_ELF_SUFFIX}
fi
fi
;;
bl31)
# Install BL31 files
if [ -f ${B}/${config}${soc_suffix}/${BL31_BASENAME}.${BL31_SUFFIX} ]; then
install -d ${DEPLOYDIR}/arm-trusted-firmware/bl31
@ -265,6 +284,14 @@ do_deploy() {
fi
fi
fi
if [ -n "${ELF_DEBUG_ENABLE}" ]; then
install -d ${DEPLOYDIR}/arm-trusted-firmware/debug
if [ -f ${B}/${config}${soc_suffix}/${BL31_ELF} ]; then
install -m 644 ${B}/${config}${soc_suffix}/${BL31_ELF} ${DEPLOYDIR}/arm-trusted-firmware/debug/${tfa_basename}-${BL31_BASENAME_DEPLOY}-${config}.${TF_A_ELF_SUFFIX}
fi
fi
;;
bl32)
# Install BL32 files
if [ -f ${B}/${config}${soc_suffix}/${BL32_BASENAME}.${BL32_SUFFIX} ]; then
install -d ${DEPLOYDIR}/arm-trusted-firmware/bl32
@ -281,24 +308,29 @@ do_deploy() {
fi
fi
fi
if [ -n "${ELF_DEBUG_ENABLE}" ]; then
install -d ${DEPLOYDIR}/arm-trusted-firmware/debug
if [ -f ${B}/${config}${soc_suffix}/${BL32_ELF} ]; then
install -m 644 ${B}/${config}${soc_suffix}/${BL32_ELF} ${DEPLOYDIR}/arm-trusted-firmware/debug/${tfa_basename}-${BL32_BASENAME_DEPLOY}-${config}.${TF_A_ELF_SUFFIX}
fi
fi
;;
fwconfig)
# Install fwconfig
if [ -f ${B}/${config}${soc_suffix}/fdts/${dt}-${FWCONFIG_NAME}.${DT_SUFFIX} ]; then
install -d ${DEPLOYDIR}/arm-trusted-firmware/fwconfig
install -m 644 ${B}/${config}${soc_suffix}/fdts/${dt}-${FWCONFIG_NAME}.${DT_SUFFIX} ${DEPLOYDIR}/arm-trusted-firmware/fwconfig/${dt}-${FWCONFIG_NAME}-${config}.${DT_SUFFIX}
fi
done
;;
esac
done # for file_type in ${tfa_file_type}
done # for dt in ${dt_config}
if [ -n "${ELF_DEBUG_ENABLE}" ]; then
install -d ${DEPLOYDIR}/arm-trusted-firmware/debug
if [ -f ${B}/${config}${soc_suffix}/${BL1_ELF} ]; then
install -m 644 ${B}/${config}${soc_suffix}/${BL1_ELF} ${DEPLOYDIR}/arm-trusted-firmware/debug/${tfa_basename}-${BL1_BASENAME_DEPLOY}-${config}.${TF_A_ELF_SUFFIX}
fi
if [ -f ${B}/${config}${soc_suffix}/${BL2_ELF} ]; then
install -m 644 ${B}/${config}${soc_suffix}/${BL2_ELF} ${DEPLOYDIR}/arm-trusted-firmware/debug/${tfa_basename}-${BL2_BASENAME_DEPLOY}-${config}.${TF_A_ELF_SUFFIX}
fi
if [ -f ${B}/${config}${soc_suffix}/${BL32_ELF} ]; then
install -m 644 ${B}/${config}${soc_suffix}/${BL32_ELF} ${DEPLOYDIR}/arm-trusted-firmware/debug/${tfa_basename}-${BL32_BASENAME_DEPLOY}-${config}.${TF_A_ELF_SUFFIX}
fi
fi
done
done # for config in ${TF_A_CONFIG}
}
addtask deploy before do_build after do_compile

View File

@ -7,8 +7,10 @@ TF_A_EXTRACONF_LEGACY += "STM32MP_SPI_NAND=1"
TF_A_EXTRACONF_LEGACY += "STM32MP_USE_STM32IMAGE=1"
# Define config for each TF_A_CONFIG
TF_A_CONFIG[optee] ?= "${STM32MP_DEVICETREE},AARCH32_SP=optee ${@bb.utils.contains('MACHINE_FEATURES', 'fip', '', '${TF_A_EXTRACONF_LEGACY}', d)},,${@bb.utils.contains('MACHINE_FEATURES', 'fip', bb.utils.contains('FIP_BL31_ENABLE', '1', 'bl31 dtbs', 'dtbs', d), '', d)}"
TF_A_CONFIG[trusted] ?= "${STM32MP_DEVICETREE},AARCH32_SP=sp_min ${@bb.utils.contains('MACHINE_FEATURES', 'fip', '', '${TF_A_EXTRACONF_LEGACY}', d)},,${@bb.utils.contains('MACHINE_FEATURES', 'fip', 'bl32 dtbs', '', d)}"
# TF_A_CONFIG[config] ?= "<list of devicetree>,<extra opt flags>,<binary basename (default: 'tf-a')>,<make target (default: 'all')>,<type of binary to deploy: [bl2 bl31 bl32 fwconfig] (default 'bl2')>"
TF_A_CONFIG[optee] ?= "${STM32MP_DEVICETREE},AARCH32_SP=optee ${@bb.utils.contains('MACHINE_FEATURES', 'fip', '', '${TF_A_EXTRACONF_LEGACY}', d)},,${@bb.utils.contains('MACHINE_FEATURES', 'fip', bb.utils.contains('FIP_BL31_ENABLE', '1', 'bl31 dtbs', 'dtbs', d), '', d)},${@bb.utils.contains('MACHINE_FEATURES', 'fip', bb.utils.contains('FIP_BL31_ENABLE', '1', 'bl31 fwconfig', 'fwconfig', d), '', d)}"
TF_A_CONFIG[trusted] ?= "${STM32MP_DEVICETREE},AARCH32_SP=sp_min ${@bb.utils.contains('MACHINE_FEATURES', 'fip', '', '${TF_A_EXTRACONF_LEGACY}', d)},,${@bb.utils.contains('MACHINE_FEATURES', 'fip', 'bl32 dtbs', '', d)},${@bb.utils.contains('MACHINE_FEATURES', 'fip', 'bl32 fwconfig', '', d)}"
TF_A_CONFIG[serialboot] ?= "${STM32MP_DEVICETREE},AARCH32_SP=sp_min STM32MP_UART_PROGRAMMER=1 STM32MP_USB_PROGRAMMER=1 STM32MP_USE_STM32IMAGE=1"