diff --git a/recipes-bsp/u-boot/u-boot-stm32mp-archiver.inc b/recipes-bsp/u-boot/u-boot-stm32mp-archiver.inc index e0f24d5..c1ad14b 100644 --- a/recipes-bsp/u-boot/u-boot-stm32mp-archiver.inc +++ b/recipes-bsp/u-boot/u-boot-stm32mp-archiver.inc @@ -9,7 +9,20 @@ ARCHIVER_MODE[src] = "original" inherit archiver_stm32mp_clean archiver_create_makefile_for_sdk() { - # Init internal var for uboot_configs: should be 'defconfig,type,binary' + mkdir -p ${ARCHIVER_OUTDIR} + cat << EOF > ${ARCHIVER_OUTDIR}/Makefile.sdk +# Set default path +SRC_PATH ?= \$(PWD) +BLD_PATH ?= \$(SRC_PATH)/../build +DEPLOYDIR ?= \$(SRC_PATH)/../deploy + +# Default U-Boot overall settings to null +UBOOT_CONFIG ?= +UBOOT_DEFCONFIG ?= +UBOOT_BINARY ?= +UBOOT_DEVICETREE ?= + +EOF if [ -n "${UBOOT_CONFIG}" ]; then unset i j k for config in ${UBOOT_MACHINE}; do @@ -20,7 +33,24 @@ archiver_create_makefile_for_sdk() { for binary in ${UBOOT_BINARIES}; do k=$(expr $k + 1); if [ $k -eq $i ]; then - uboot_configs="${uboot_configs} ${config},${type},${binary}" + type_suffix=$(echo ${type} | cut -d'_' -f1) + type_filter=$(echo ${type} | cut -d'_' -f2) + [ "${type_suffix}" = "${type_filter}" ] && type_filter="" + if [ -z "${type_filter}" ]; then + devicetree="${UBOOT_DEVICETREE}" + else + devicetree="" + for dt in ${UBOOT_DEVICETREE}; do + [ -z "$(echo ${dt} | grep ${type_filter})" ] || devicetree="${devicetree} ${dt}" + done + fi + cat << EOF >> ${ARCHIVER_OUTDIR}/Makefile.sdk +# Init default config settings +UBOOT_CONFIGS += ${type_suffix} +UBOOT_DEFCONFIG_$type_suffix += ${config} +UBOOT_BINARY_$config ?= ${binary} +UBOOT_DEVICETREE_$config ?= ${devicetree} +EOF fi done unset k @@ -29,17 +59,8 @@ archiver_create_makefile_for_sdk() { unset j done unset i - else - uboot_configs="${UBOOT_MACHINE},,${UBOOT_BINARY}" fi - - mkdir -p ${ARCHIVER_OUTDIR} - - cat << EOF > ${ARCHIVER_OUTDIR}/Makefile.sdk -# Set default path -SRC_PATH ?= \$(PWD) -BLD_PATH ?= \$(SRC_PATH)/../build -DEPLOYDIR ?= \$(SRC_PATH)/../deploy + cat << EOF >> ${ARCHIVER_OUTDIR}/Makefile.sdk # Remove default variables LDFLAGS = @@ -48,25 +69,81 @@ CPPFLAGS = UBOOT_LOCALVERSION = ${UBOOT_LOCALVERSION} -# Configure default U-Boot configs -UBOOT_CONFIGS ?= ${uboot_configs} -DEVICE_TREE ?= ${UBOOT_DEVICETREE} - # Configure default fip feature ENABLE_FIP ?= "${@bb.utils.contains('MACHINE_FEATURES','fip','1','',d)}" +# Display U-Boot config details +define uboot-configs + echo " \$(1)" ; \\ + \$(foreach defconfig, \$(if \$(UBOOT_DEFCONFIG),\$(UBOOT_DEFCONFIG),\$(UBOOT_DEFCONFIG_\$(1))), \\ + echo " defconfig : \$(defconfig)" ; \ + echo " for binary : \$(if \$(UBOOT_BINARY),\$(UBOOT_BINARY),\$(UBOOT_BINARY_\$(defconfig)))" ; \ + echo " with devicetree: \$(if \$(DEVICETREE),\$(DEVICETREE),\$(UBOOT_DEVICETREE_\$(defconfig)))" ; \ + ) +endef + +# Configure U-Boot configure rules (configure-DEFCONFIG-CONFIG) +define configure-rules +configure-\$(1)-\$(2): version +ifeq (\$(ENABLE_FIP),) + @if ! grep -q 'CONFIG_STM32MP15x_STM32IMAGE=y' \$(SRC_PATH)/configs/\$(1); then \\ + echo "CONFIG_STM32MP15x_STM32IMAGE=y" >> \$(SRC_PATH)/configs/\$(1) ; \\ + fi +endif + @mkdir -p \$(BLD_PATH)/\$(1) + @echo \$(UBOOT_LOCALVERSION) > \$(BLD_PATH)/\$(1)/.scmversion + \$(MAKE) -C \$(SRC_PATH) O=\$(BLD_PATH)/\$(1) \$(1) +endef + +# Configure U-Boot make rules (uboot-DEFCONFIG-CONFIG) +define uboot-rules +uboot-\$(1)-\$(2): configure-\$(1)-\$(2) + @\$(foreach dt, \$(if \$(DEVICETREE),\$(DEVICETREE),\$(UBOOT_DEVICETREE_\$(1))), \\ + \$(MAKE) -C \$(SRC_PATH) ${UBOOT_MAKE_TARGET} \\ + O=\$(BLD_PATH)/\$(1) \\ + DEVICE_TREE=\$(dt) \\ + DEVICE_TREE_EXT=\$(dt).dtb ; \\ + ) +endef + +# Configure U-Boot deploy rules (deploy-DEFCONFIG-CONFIG) +define deploy-rules +deploy-\$(1)-\$(2): uboot-\$(1)-\$(2) + @mkdir -p \$(DEPLOYDIR) + @mkdir -p \$(DEPLOYDIR)/debug + @\$(foreach dt, \$(if \$(DEVICETREE),\$(DEVICETREE),\$(UBOOT_DEVICETREE_\$(1))), \\ + cp -f \$(BLD_PATH)/\$(1)/\$(3) \$(DEPLOYDIR)/u-boot-\$(dt)-\$(2).\$(shell echo \$(3) | cut -d'.' -f2) ; \\ + if [ -f \$(BLD_PATH)/\$(1)/${SPL_BINARY_STM32} ]; then \\ + cp -f \$(BLD_PATH)/\$(1)/${SPL_BINARY_STM32} \$(DEPLOYDIR)/${SPL_BINARYNAME}-\$(dt)-\$(2) ; \\ + fi ; \\ + if [ "\$(shell echo \$(3) | cut -d'.' -f2)" = "dtb" ]; then \\ + cp -f \$(BLD_PATH)/\$(1)/u-boot-nodtb.bin \$(DEPLOYDIR)/u-boot-nodtb\$(foreach soc,${STM32MP_SOC_NAME},\$(if \$(shell echo \$(dt) | grep -c \$(soc)),-\$(soc),)).bin ; \\ + fi ; \\ + if [ -f \$(BLD_PATH)/\$(1)/${UBOOT_ELF} ]; then \\ + cp -f \$(BLD_PATH)/\$(1)/${UBOOT_ELF} \$(DEPLOYDIR)/debug/u-boot\$(foreach soc,${STM32MP_SOC_NAME},\$(if \$(shell echo \$(dt) | grep -c \$(soc)),-\$(soc),))-\$(2).${UBOOT_ELF_SUFFIX} ; \\ + fi ; \\ + if [ -f \$(BLD_PATH)/\$(1)/${SPL_ELF} ]; then \\ + cp -f \$(BLD_PATH)/\$(1)/${SPL_ELF} \$(DEPLOYDIR)/debug/${SPL_ELF_NAME}\$(foreach soc,${STM32MP_SOC_NAME},\$(if \$(shell echo \$(dt) | grep -c \$(soc)),-\$(soc),))-\$(2) ; \\ + fi ; \\ + ) +endef + +# Configure overall deploy rules list +deploy-targets := \$(foreach config, \$(if \$(UBOOT_CONFIG),\$(UBOOT_CONFIG),\$(UBOOT_CONFIGS)), \\ + \$(foreach defconfig, \$(if \$(UBOOT_DEFCONFIG),\$(UBOOT_DEFCONFIG),\$(UBOOT_DEFCONFIG_\$(config))), deploy-\$(defconfig)-\$(config)) \\ + ) + help: @echo - @echo "Configured U-Boot config(s):" - @for config in \$(UBOOT_CONFIGS); do \\ - defconfig=\$\$(echo \$\$config | cut -d',' -f1) ; \\ - type=\$\$(echo \$\$config | cut -d',' -f2) ; \\ - binary=\$\$(echo \$\$config | cut -d',' -f3) ; \\ - echo " \$\$defconfig config (\$\$type type) for \$\$binary binary" ; \\ - for devicetree in \$(DEVICE_TREE); do \\ - echo " with device tree: \$\$devicetree" ; \\ - done ; \\ - done + @echo "U-Boot configuration:" + @echo " UBOOT_CONFIG = \$(if \$(UBOOT_CONFIG),\$(UBOOT_CONFIG),\$(UBOOT_CONFIGS))" + @echo "Config details:" + @\$(foreach config, \$(if \$(UBOOT_CONFIG),\$(UBOOT_CONFIG),\$(UBOOT_CONFIGS)), \$(call uboot-configs,\$(config))) + @echo + @echo "Note that each U-Boot configuration settings can be updated through overall or specific config var:" + @echo " UBOOT_DEFCONFIG" + @echo " UBOOT_BINARY" + @echo " DEVICETREE" @echo @echo "U-Boot folder configuration:" @echo " SRC_PATH = \$(SRC_PATH)" @@ -81,97 +158,10 @@ endif @echo @echo "Available targets:" @echo " all : build U-Boot binaries for defined config(s)" + @echo " fip : build FIP binaries" @echo " clean : clean build directories from generated files" -version: - @if test ! -e .scmversion ; then echo \$(UBOOT_LOCALVERSION) > \$(SRC_PATH)/.scmversion; fi - -all: uboot \$(if \$(ENABLE_FIP),fip) - -uboot: version - @for config in \$(UBOOT_CONFIGS); do \\ - uboot_config=\$\$(echo \$\$config | cut -d',' -f1) ; \\ - uboot_type=\$\$(echo \$\$config | cut -d',' -f2) ; \\ - uboot_binary=\$\$(echo \$\$config | cut -d',' -f3) ; \\ - uboot_suffix=\$\$(echo \$\$uboot_binary | cut -d'.' -f2) ; \\ - # Configure destination folder \\ - if [ "\$\$uboot_suffix" = "img" ]; then \\ - subfolder=/\$\$uboot_type ; \\ - else \\ - subfolder= ; \\ - fi ; \\ - mkdir -p \$(DEPLOYDIR)\$\$subfolder ; \\ - mkdir -p \$(DEPLOYDIR)\$\$subfolder/debug ; \\ - # Make sure about configuration set \\ - if test -z "\$\$uboot_config" -o -z "\$\$uboot_type" -o -z "\$\$uboot_binary"; then \\ - echo ; \\ - echo "[ERROR] UBOOT_CONFIGS wrongly configured. It should be space separated list of element ,," ; \\ - echo ; \\ - exit 1 ; \\ - fi ; \\ - # Dynamic update for defconfig file \\ - if [ "\$\$uboot_suffix" = "stm32" ]; then \\ - if ! grep -q 'CONFIG_STM32MP15x_STM32IMAGE=y' "\$(SRC_PATH)/configs/\$\$uboot_config"; then \\ - echo "CONFIG_STM32MP15x_STM32IMAGE=y" >> "\$(SRC_PATH)/configs/\$\$uboot_config" ; \\ - fi ; \\ - fi ; \\ - # Init folder and defconfig selected \\ - if [ ! -d \$(BLD_PATH)/\$\$uboot_type ]; then \\ - mkdir -p \$(BLD_PATH)/\$\$uboot_type ; \\ - echo \$(UBOOT_LOCALVERSION) > \$(BLD_PATH)/\$\$uboot_type/.scmversion ; \\ - \$(MAKE) -C \$(SRC_PATH) O=\$(BLD_PATH)/\$\$uboot_type \$\$uboot_config ; \\ - fi ; \\ - # Build binaries \\ - if [ -z "\$(DEVICE_TREE)" ]; then \\ - \$(MAKE) -C \$(SRC_PATH) O=\$(BLD_PATH)/\$\$uboot_type ${UBOOT_MAKE_TARGET} ; \\ - # Copy binary files with explicit name \\ - cp -f \$(BLD_PATH)/\$\$uboot_type/\$\$uboot_binary \$(DEPLOYDIR)\$\$subfolder/u-boot-\$\$uboot_type.\$\$uboot_suffix ; \\ - if [ -f \$(BLD_PATH)/\$\$uboot_type/${SPL_BINARY_STM32} ]; then \\ - cp -f \$(BLD_PATH)/\$\$uboot_type/${SPL_BINARY_STM32} \$(DEPLOYDIR)\$\$subfolder/${SPL_BINARYNAME}-\$\$uboot_type ; \\ - fi ; \\ - if [ -f \$(BLD_PATH)/\$\$uboot_type/${UBOOT_ELF} ]; then \\ - cp -f \$(BLD_PATH)/\$\$uboot_type/${UBOOT_ELF} \$(DEPLOYDIR)\$\$subfolder/debug/u-boot-\$\$uboot_type.${UBOOT_ELF_SUFFIX} ; \\ - fi ; \\ - if [ -f \$(BLD_PATH)/\$\$uboot_type/${SPL_ELF} ]; then \\ - cp -f \$(BLD_PATH)/\$\$uboot_type/${SPL_ELF} \$(DEPLOYDIR)\$\$subfolder/debug/${SPL_ELF_NAME}-\$\$uboot_type ; \\ - fi ; \\ - # Install 'u-boot-nodtb.bin' binary in case '*.dtb' binary installation configured \\ - if [ "\$\$uboot_suffix" = "dtb" ]; then \\ - cp -f \$(BLD_PATH)/\$\$uboot_type/u-boot-nodtb.bin \$(DEPLOYDIR)\$\$subfolder/u-boot-nodtb.bin ; \\ - fi ; \\ - else \\ - for devicetree in \$(DEVICE_TREE); do \\ - \$(MAKE) -C \$(SRC_PATH) O=\$(BLD_PATH)/\$\$uboot_type ${UBOOT_MAKE_TARGET} DEVICE_TREE=\$\$devicetree DEVICE_TREE_EXT=\$\$devicetree.dtb; \\ - # Copy binary files with explicit name \\ - cp -f \$(BLD_PATH)/\$\$uboot_type/\$\$uboot_binary \$(DEPLOYDIR)\$\$subfolder/u-boot-\$\$devicetree-\$\$uboot_type.\$\$uboot_suffix ; \\ - if [ -f \$(BLD_PATH)/\$\$uboot_type/${SPL_BINARY_STM32} ]; then \\ - cp -f \$(BLD_PATH)/\$\$uboot_type/${SPL_BINARY_STM32} \$(DEPLOYDIR)\$\$subfolder/${SPL_BINARYNAME}-\$\$devicetree-\$\$uboot_type ; \\ - fi ; \\ - if [ -f \$(BLD_PATH)/\$\$uboot_type/${UBOOT_ELF} ]; then \\ - cp -f \$(BLD_PATH)/\$\$uboot_type/${UBOOT_ELF} \$(DEPLOYDIR)\$\$subfolder/debug/u-boot-\$\$devicetree-\$\$uboot_type.${UBOOT_ELF_SUFFIX} ; \\ - fi ; \\ - if [ -f \$(BLD_PATH)/\$\$uboot_type/${SPL_ELF} ]; then \\ - cp -f \$(BLD_PATH)/\$\$uboot_type/${SPL_ELF} \$(DEPLOYDIR)\$\$subfolder/debug/${SPL_ELF_NAME}-\$\$devicetree-\$\$uboot_type ; \\ - fi ; \\ - # Install ''u-boot-nodtb.bin' binary in case '*.dtb' binary installation configured \\ - if [ "\$\$uboot_suffix" = "dtb" ]; then \\ - # Init soc suffix \\ - soc_suffix="" ; \\ - if [ -n "${STM32MP_SOC_NAME}" ]; then \\ - for soc in ${STM32MP_SOC_NAME}; do \\ - if [ "\$\$(echo \$\$devicetree | grep -c \$\$soc)" -eq 1 ]; then \\ - soc_suffix="-\$\$soc" ; \\ - fi ; \\ - done ; \\ - fi ; \\ - cp -f \$(BLD_PATH)/\$\$uboot_type/u-boot-nodtb.bin \$(DEPLOYDIR)\$\$subfolder/u-boot-nodtb\$\$soc_suffix.bin ; \\ - fi ; \\ - done ; \\ - fi ; \\ - done - -fip: uboot - FIP_DEPLOYDIR_UBOOT=\$(DEPLOYDIR) FIP_DEVICETREE="\$(DEVICE_TREE)" fiptool-stm32mp +all: \$(deploy-targets) \$(if \$(ENABLE_FIP),fip) clean: @for config in \$(UBOOT_CONFIGS); do \\ @@ -182,6 +172,24 @@ clean: @echo "Removing \$(DEPLOYDIR) ..." @rm -rf \$(DEPLOYDIR) @echo + +fip: \$(deploy-targets) + FIP_DEPLOYDIR_UBOOT=\$(DEPLOYDIR) FIP_DEVICETREE="\$(DEVICE_TREE)" fiptool-stm32mp + +version: + @if test ! -e \$(SRC_PATH)/.scmversion ; then echo \$(UBOOT_LOCALVERSION) > \$(SRC_PATH)/.scmversion; fi + +# Set U-Boot configure rules +\$(foreach config, \$(if \$(UBOOT_CONFIG),\$(UBOOT_CONFIG),\$(UBOOT_CONFIGS)), \\ + \$(foreach defconfig, \$(if \$(UBOOT_DEFCONFIG),\$(UBOOT_DEFCONFIG),\$(UBOOT_DEFCONFIG_\$(config))), \$(eval \$(call configure-rules,\$(defconfig),\$(config))))) +# Set U-Boot make rules +\$(foreach config, \$(if \$(UBOOT_CONFIG),\$(UBOOT_CONFIG),\$(UBOOT_CONFIGS)), \\ + \$(foreach defconfig, \$(if \$(UBOOT_DEFCONFIG),\$(UBOOT_DEFCONFIG),\$(UBOOT_DEFCONFIG_\$(config))), \$(eval \$(call uboot-rules,\$(defconfig),\$(config))))) +# Set U-Boot deploy rules +\$(foreach config, \$(if \$(UBOOT_CONFIG),\$(UBOOT_CONFIG),\$(UBOOT_CONFIGS)), \\ + \$(foreach defconfig, \$(if \$(UBOOT_DEFCONFIG),\$(UBOOT_DEFCONFIG),\$(UBOOT_DEFCONFIG_\$(config))), \\ + \$(eval \$(call deploy-rules,\$(defconfig),\$(config),\$(if \$(UBOOT_BINARY),\$(UBOOT_BINARY),\$(UBOOT_BINARY_\$(defconfig))))))) + EOF } do_ar_original[prefuncs] += "archiver_create_makefile_for_sdk" diff --git a/recipes-bsp/u-boot/u-boot-stm32mp.inc b/recipes-bsp/u-boot/u-boot-stm32mp.inc index dec41fc..dc9cd85 100644 --- a/recipes-bsp/u-boot/u-boot-stm32mp.inc +++ b/recipes-bsp/u-boot/u-boot-stm32mp.inc @@ -69,9 +69,9 @@ do_configure_prepend() { if [ -f "${S}/configs/${config}" ]; then # Create copy of original defconfig cp -f "${S}/configs/${config}" "${WORKDIR}/" - i=$(expr $i + 1); + i=$(expr $i + 1) for binary in ${UBOOT_BINARIES}; do - j=$(expr $j + 1); + j=$(expr $j + 1) if [ $j -eq $i ]; then binarysuffix=$(echo ${binary} | cut -d'.' -f2) # Make sure to select STM32IMAGE if requested @@ -85,7 +85,6 @@ do_configure_prepend() { unset j fi done - unset i fi } @@ -142,48 +141,52 @@ do_configure_append() { # do_compile_append() { if [ -n "${UBOOT_DEVICETREE}" ]; then - for devicetree in ${UBOOT_DEVICETREE}; do - if [ -n "${UBOOT_CONFIG}" ]; then - unset i j k - for config in ${UBOOT_MACHINE}; do - i=$(expr $i + 1); - for type in ${UBOOT_CONFIG}; do - j=$(expr $j + 1); - if [ $j -eq $i ]; then - if [ -f ${B}/${config}/dts/dt.dtb ]; - then - rm ${B}/${config}/dts/dt.dtb + if [ -n "${UBOOT_CONFIG}" ]; then + unset i j k + for config in ${UBOOT_MACHINE}; do + i=$(expr $i + 1); + for type in ${UBOOT_CONFIG}; do + j=$(expr $j + 1); + if [ $j -eq $i ]; then + # Get short suffix for current type + type_suffix=$(echo ${type} | cut -d'_' -f1) + type_filter=$(echo ${type} | cut -d'_' -f2) + [ "${type_suffix}" = "${type_filter}" ] && type_filter="" + for devicetree in ${UBOOT_DEVICETREE}; do + if [ -n "${type_filter}" ]; then + if [ "$(echo ${devicetree} | grep -c ${type_filter})" -eq 1 ]; then + bbnote "The ${type_filter} filter for ${type_suffix} config matches ${devicetree} device tree. Go for build..." + else + bbnote "The ${type_filter} filter for ${type_suffix} config doesn't match ${devicetree} device tree. Skip build!" + continue + fi fi + # Cleanup previous build artifact + [ -f "${B}/${config}/dts/dt.dtb" ] && rm "${B}/${config}/dts/dt.dtb" + # Build target oe_runmake -C ${S} O=${B}/${config} DEVICE_TREE=${devicetree} DEVICE_TREE_EXT=${devicetree}.dtb + # Install specific binary for binary in ${UBOOT_BINARIES}; do - binarysuffix=$(echo ${binary} | cut -d'.' -f2) - binaryprefix=$(echo ${binary} | cut -d'.' -f1) k=$(expr $k + 1); if [ $k -eq $i ]; then - install -m 644 ${B}/${config}/${binary} ${B}/${config}/u-boot-${devicetree}-${type}.${binarysuffix} - if [ -n "${UBOOT_ELF}" ]; then - install -m 644 ${B}/${config}/${UBOOT_ELF} ${B}/${config}/u-boot-${devicetree}-${type}.${UBOOT_ELF_SUFFIX} - fi - # As soon as SPL binary exists, copy it with specific binary_type name - # This allow to mix u-boot configuration, with and without SPL - if [ -f ${B}/${config}/${SPL_BINARY_STM32} ]; then - install -m 644 ${B}/${config}/${SPL_BINARY_STM32} ${B}/${config}/${SPL_BINARYNAME}-${devicetree}-${type} - fi - if [ -n "${SPL_ELF}" ] && [ -f ${B}/${config}/${SPL_ELF} ]; then - install -m 644 ${B}/${config}/${SPL_ELF} ${B}/${config}/${SPL_ELF_NAME}-${devicetree}-${type} - fi + binarysuffix=$(echo ${binary} | cut -d'.' -f2) + install -m 644 ${B}/${config}/${binary} ${B}/${config}/u-boot-${devicetree}-${type_suffix}.${binarysuffix} fi done unset k - fi - done - unset j + # As soon as SPL binary exists, copy it with specific binary_type name + # This allow to mix u-boot configuration, with and without SPL + if [ -f "${B}/${config}/${SPL_BINARY_STM32}" ]; then + install -m 644 ${B}/${config}/${SPL_BINARY_STM32} ${B}/${config}/${SPL_BINARYNAME}-${devicetree}-${type_suffix} + fi + done + fi done - unset i - else - bbfatal "Wrong u-boot-stm32mp configuration: please make sure to use UBOOT_CONFIG through BOOTSCHEME_LABELS config" - fi - done + unset j + done + else + bbfatal "Wrong u-boot-stm32mp configuration: please make sure to use UBOOT_CONFIG through BOOTSCHEME_LABELS config" + fi fi } @@ -193,72 +196,79 @@ do_compile_append() { do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}/u-boot" do_deploy_append() { if [ -n "${UBOOT_DEVICETREE}" ]; then - # Clean deploydir from any available binary first - # This allows to only install the devicetree binary ones - rm -rf ${DEPLOYDIR} + if [ -n "${UBOOT_CONFIG}" ]; then + # Clean deploydir from any available binary first + # This allows to only install the devicetree binary ones + rm -rf ${DEPLOYDIR} + install -d ${DEPLOYDIR} - for devicetree in ${UBOOT_DEVICETREE}; do - if [ -n "${UBOOT_CONFIG}" ]; then - unset i j k - for config in ${UBOOT_MACHINE}; do - i=$(expr $i + 1); - for type in ${UBOOT_CONFIG}; do - j=$(expr $j + 1); - if [ $j -eq $i ]; then - for binary in ${UBOOT_BINARIES}; do + unset i j k + for config in ${UBOOT_MACHINE}; do + i=$(expr $i + 1) + for type in ${UBOOT_CONFIG}; do + j=$(expr $j + 1) + if [ $j -eq $i ]; then + for binary in ${UBOOT_BINARIES}; do + k=$(expr $k + 1) + if [ $k -eq $i ]; then binarysuffix=$(echo ${binary} | cut -d'.' -f2) - k=$(expr $k + 1); - if [ $k -eq $i ]; then - # Manage subfolder in case of u-boot.img - if [ "${binarysuffix}" = "img" ]; then - SUBFOLDER=/${type} - else - SUBFOLDER="" - fi - # Install destination folder - install -d ${DEPLOYDIR}${SUBFOLDER} - if [ -n "${ELF_DEBUG_ENABLE}" ]; then - install -d ${DEPLOYDIR}${SUBFOLDER}/debug + # Manage subfolder in case of u-boot.img + if [ "${binarysuffix}" = "img" ]; then + SUBFOLDER="/${type}" + else + SUBFOLDER="" + fi + # Install destination folder + install -d ${DEPLOYDIR}${SUBFOLDER} + [ -n "${ELF_DEBUG_ENABLE}" ] && install -d ${DEPLOYDIR}${SUBFOLDER}/debug + # Get short suffix for current type + type_suffix=$(echo ${type} | cut -d'_' -f1) + type_filter=$(echo ${type} | cut -d'_' -f2) + [ "${type_suffix}" = "${type_filter}" ] && type_filter="" + for devicetree in ${UBOOT_DEVICETREE}; do + if [ -n "${type_filter}" ]; then + if [ "$(echo ${devicetree} | grep -c ${type_filter})" -eq 1 ]; then + bbnote "The ${type_filter} filter for ${type_suffix} config matches ${devicetree} device tree. Go for binary deploy..." + else + bbnote "The ${type_filter} filter for ${type_suffix} config doesn't match ${devicetree} device tree. Skip binary deploy!" + continue + fi fi # Install u-boot binary - install -m 644 ${B}/${config}/u-boot-${devicetree}-${type}.${binarysuffix} ${DEPLOYDIR}${SUBFOLDER} - if [ -n "${UBOOT_ELF}" ]; then - install -d ${DEPLOYDIR}${SUBFOLDER}/debug - install -m 644 ${B}/${config}/u-boot-${devicetree}-${type}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}${SUBFOLDER}/debug/ + install -m 644 ${B}/${config}/u-boot-${devicetree}-${type_suffix}.${binarysuffix} ${DEPLOYDIR}${SUBFOLDER}/ + # As soon as SPL binary exists, install it + # This allow to mix u-boot configuration, with and without SPL + if [ -f "${B}/${config}/${SPL_BINARYNAME}-${devicetree}-${type_suffix}" ]; then + install -m 644 ${B}/${config}/${SPL_BINARYNAME}-${devicetree}-${type_suffix} ${DEPLOYDIR}${SUBFOLDER}/ + fi + # Init soc suffix + soc_suffix="" + if [ -n "${STM32MP_SOC_NAME}" ]; then + for soc in ${STM32MP_SOC_NAME}; do + [ "$(echo ${devicetree} | grep -c ${soc})" -eq 1 ] && soc_suffix="-${soc}" + done fi # Install 'u-boot-nodtb.bin' binary in case '*.dtb' binary installation configured if [ "${binarysuffix}" = "dtb" ]; then - # Init soc suffix - soc_suffix="" - if [ -n "${STM32MP_SOC_NAME}" ]; then - for soc in ${STM32MP_SOC_NAME}; do - if [ "$(echo ${devicetree} | grep -c ${soc})" -eq 1 ]; then - soc_suffix="-${soc}" - fi - done - fi install -m 644 ${B}/${config}/u-boot-nodtb.bin ${DEPLOYDIR}${SUBFOLDER}/u-boot-nodtb${soc_suffix}.bin fi - # As soon as SPL binary exists, install it - # This allow to mix u-boot configuration, with and without SPL - if [ -f ${B}/${config}/${SPL_BINARYNAME}-${devicetree}-${type} ]; then - install -m 644 ${B}/${config}/${SPL_BINARYNAME}-${devicetree}-${type} ${DEPLOYDIR}${SUBFOLDER}/ + if [ -n "${UBOOT_ELF}" ]; then + install -m 644 ${B}/${config}/${UBOOT_ELF} ${DEPLOYDIR}${SUBFOLDER}/debug/u-boot${soc_suffix}-${type_suffix}.${UBOOT_ELF_SUFFIX} fi - if [ -n "${SPL_ELF}" ] && [ -f ${B}/${config}/${SPL_ELF_NAME}-${devicetree}-${type} ]; then - install -m 644 ${B}/${config}/${SPL_ELF_NAME}-${devicetree}-${type} ${DEPLOYDIR}${SUBFOLDER}/debug + if [ -n "${SPL_ELF}" ] && [ -f "${B}/${config}/${SPL_ELF}" ]; then + install -m 644 ${B}/${config}/${SPL_ELF} ${DEPLOYDIR}${SUBFOLDER}/debug/${SPL_ELF_NAME}${soc_suffix}-${type_suffix} fi - fi - done - unset k - fi - done - unset j + done + fi + done + unset k + fi done - unset i - else - bbfatal "Wrong u-boot-stm32mp configuration: please make sure to use UBOOT_CONFIG through BOOTSCHEME_LABELS config" - fi - done + unset j + done + else + bbfatal "Wrong u-boot-stm32mp configuration: please make sure to use UBOOT_CONFIG through BOOTSCHEME_LABELS config" + fi fi } diff --git a/recipes-bsp/u-boot/u-boot-stm32mp/README.HOW_TO.txt b/recipes-bsp/u-boot/u-boot-stm32mp/README.HOW_TO.txt index fcd71ea..8749be4 100644 --- a/recipes-bsp/u-boot/u-boot-stm32mp/README.HOW_TO.txt +++ b/recipes-bsp/u-boot/u-boot-stm32mp/README.HOW_TO.txt @@ -126,25 +126,24 @@ As mentionned in help, OpenSTLinux has activated FIP by default, so the FIP_arti - Compile default U-Boot configuration: $> make -f $PWD/../Makefile.sdk all -Default U-Boot configuration is done in 'Makefile.sdk' file through two specific -variables 'DEVICE_TREE' and 'UBOOT_CONFIGS': - - 'DEVICE_TREE' is a list of device tree to build, using 'space' as separator. - ex: DEVICE_TREE=" " - - 'UBOOT_CONFIGS' is a list of ',,' configurations, - is the u-boot defconfig to use to build - is the name append to u-boot binaries (ex: 'trusted', 'basic', etc) - is the u-boot binary to export (ex: 'u-boot.bin', 'u-boot.stm32', etc) - ex: UBOOT_CONFIGS=",basic,u-boot.bin ,trusted,u-boot.stm32" +Default U-Boot configuration is done in 'Makefile.sdk' file through specific variables +'BOOT_CONFIG', 'UBOOT_DEFCONFIG', 'UBOOT_BINARY' and 'UBOOT_DEVICETREE': + - 'UBOOT_CONFIG' is the name to append to U-boot binaries (ex: 'trusted', etc). + ex: UBOOT_CONFIG=trusted + - 'UBOOT_DEFCONFIG' is the name of U-Boot defconfig to build + ex: UBOOT_DEFCONFIG=stm32mp15_trusted_defconfig + - 'UBOOT_BINARY' is the U-Boot binary to export (ex: 'u-boot.dtb', 'u-boot.img', etc) + ex: UBOOT_BINARY=u-boot.dtb + - 'UBOOT_DEVICETREE' is a list of device tree to build, using 'space' as separator. + ex: UBOOT_DEVICETREE=" " The generated FIP images are available in $FIP_DEPLOYDIR_ROOT/fip You can override the default U-Boot configuration if you specify these variables: - Compile default U-Boot configuration but applying specific devicetree(s): - $ make -f $PWD/../Makefile.sdk all DEVICE_TREE=" " + $ make -f $PWD/../Makefile.sdk all UBOOT_DEVICETREE=" " - Compile for a specific U-Boot configuration: - $ make -f $PWD/../Makefile.sdk all UBOOT_CONFIGS=,, - - Compile for a specific U-Boot configuration and applying specific devicetree(s): - $ make -f $PWD/../Makefile.sdk all UBOOT_CONFIGS=,, DEVICE_TREE=" " + $ make -f $PWD/../Makefile.sdk all UBOOT_CONFIG=trusted UBOOT_DEFCONFIG=stm32mp15_trusted_defconfig UBOOT_BINARY=u-boot.dtb DEVICETREE=stm32mp157f-dk2 6. Update software on board: ----------------------------