Skip to contentSkip to conversation

trusted-firmware-a: support multi-board platforms

PATCH In review Denys Dmytriyenko 3 participants 7 messages May 14, 2020 – May 15, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 trusted-firmware-a: support multi-board platforms

From: Denys Dmytriyenko <[email protected]>

Some platforms can have multiple board configurations, passed as TARGET_BOARD="" that also becomes an extra directory level in the build output hierarchy.

---
v2 - replace boolean index trick

 .../recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc    | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc +10 -2
index 4b5da7a..899b778 100644
@@ -12,6 +12,10 @@ COMPATIBLE_MACHINE ?= "invalid"
 # Platform must be set for each machine
 TFA_PLATFORM ?= "invalid"
 
+# Some platforms can have multiple board configurations
+# Leave empty for default behavior
+TFA_BOARD ?= ""
+
 # Build for debug (set TFA_DEBUG to 1 to activate)
 TFA_DEBUG ?= "0"
 
@@ -65,6 +69,10 @@ DEPENDS_append = " dtc-native openssl-native"
 # Add platform parameter
 EXTRA_OEMAKE += "BUILD_BASE=${B} PLAT=${TFA_PLATFORM}"
 
+# Handle TFA_BOARD parameter
+EXTRA_OEMAKE += "${@'TARGET_BOARD=${TFA_BOARD}' if d.getVar('TFA_BOARD') else ''}"
+BUILD_DIR = "${TFA_PLATFORM}${@'/${TFA_BOARD}' if d.getVar('TFA_BOARD') else ''}"
+
 # Handle TFA_DEBUG parameter
 EXTRA_OEMAKE += "${@bb.utils.contains('TFA_DEBUG', '1', ' DEBUG=${TFA_DEBUG}', '', d)}"
 
@@ -93,9 +101,9 @@ do_compile[cleandirs] = "${B}"
 
 do_install() {
     if ${@"true" if d.getVar('TFA_DEBUG') == '1' else "false"}; then
-        BUILD_PLAT=${B}/${TFA_PLATFORM}/debug/
+        BUILD_PLAT=${B}/${BUILD_DIR}/debug/
     else
-        BUILD_PLAT=${B}/${TFA_PLATFORM}/release/
+        BUILD_PLAT=${B}/${BUILD_DIR}/release/
     fi
 
     install -d -m 755 ${D}/firmware
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 2/4 trusted-firmware-a: add support for SPD (Secure Payload Dispatcher) services

From: Denys Dmytriyenko <[email protected]>

Some platforms use Secure Payload Dispatcher - allow selecting one with TFA_SPD.

Official SPD description:
/*******************************************************************************
* This is the Secure Payload Dispatcher (SPD). The dispatcher is meant to be a
* plug-in component to the Secure Monitor, registered as a runtime service. The
* SPD is expected to be a functional extension of the Secure Payload (SP) that
* executes in Secure EL1. The Secure Monitor will delegate all SMCs targeting
* the Trusted OS/Applications range to the dispatcher. The SPD will either
* handle the request locally or delegate it to the Secure Payload. It is also
* responsible for initialising and maintaining communication with the SP. ******************************************************************************/

Clean other EXTRA_OEMAKE to remove leading space not needed with +=

---
v2 - replace boolean index trick

 .../recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc  | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc +11 -3
index 899b778..25d5179 100644
@@ -16,6 +16,11 @@ TFA_PLATFORM ?= "invalid"
 # Leave empty for default behavior
 TFA_BOARD ?= ""
 
+# Some platforms use SPD (Secure Payload Dispatcher) services
+# Few options are "opteed", "tlkd", "trusty", "tspd"...
+# Leave empty to not use SPD
+TFA_SPD ?= ""
+
 # Build for debug (set TFA_DEBUG to 1 to activate)
 TFA_DEBUG ?= "0"
 
@@ -73,16 +78,19 @@ EXTRA_OEMAKE += "BUILD_BASE=${B} PLAT=${TFA_PLATFORM}"
 EXTRA_OEMAKE += "${@'TARGET_BOARD=${TFA_BOARD}' if d.getVar('TFA_BOARD') else ''}"
 BUILD_DIR = "${TFA_PLATFORM}${@'/${TFA_BOARD}' if d.getVar('TFA_BOARD') else ''}"
 
+# Handle TFA_SPD parameter
+EXTRA_OEMAKE += "${@'SPD=${TFA_SPD}' if d.getVar('TFA_SPD') else ''}"
+
 # Handle TFA_DEBUG parameter
-EXTRA_OEMAKE += "${@bb.utils.contains('TFA_DEBUG', '1', ' DEBUG=${TFA_DEBUG}', '', d)}"
+EXTRA_OEMAKE += "${@bb.utils.contains('TFA_DEBUG', '1', 'DEBUG=${TFA_DEBUG}', '', d)}"
 
 # Handle MBEDTLS
-EXTRA_OEMAKE += "${@bb.utils.contains('TFA_MBEDTLS', '1', ' MBEDTLS_DIR=${TFA_MBEDTLS_DIR}', '', d)}"
+EXTRA_OEMAKE += "${@bb.utils.contains('TFA_MBEDTLS', '1', 'MBEDTLS_DIR=${TFA_MBEDTLS_DIR}', '', d)}"
 
 # Uboot support
 DEPENDS += " ${@bb.utils.contains('TFA_UBOOT', '1', 'u-boot', '', d)}"
 do_compile[depends] += " ${@bb.utils.contains('TFA_UBOOT', '1', 'u-boot:do_deploy', '', d)}"
-EXTRA_OEMAKE += "${@bb.utils.contains('TFA_UBOOT', '1', ' BL33=${DEPLOY_DIR_IMAGE}/u-boot.bin', '',d)}"
+EXTRA_OEMAKE += "${@bb.utils.contains('TFA_UBOOT', '1', 'BL33=${DEPLOY_DIR_IMAGE}/u-boot.bin', '',d)}"
 
 # The following hack is needed to fit properly in yocto build environment
 # TFA is forcing the host compiler and its flags in the Makefile using :=
Signature · 1 line
2.7.4
Reviewed-by on v2 2/4
#2 lore raw

Re: [PATCH v2 2/4] trusted-firmware-a: add support for SPD (Secure Payload Dispatcher) services

Quoted 19 lines · Denys Dmytriyenko

From: Denys Dmytriyenko <[email protected]>

Some platforms use Secure Payload Dispatcher - allow selecting one with TFA_SPD.

Official SPD description:
/*******************************************************************************
* This is the Secure Payload Dispatcher (SPD). The dispatcher is meant to be
a
* plug-in component to the Secure Monitor, registered as a runtime service.
The
* SPD is expected to be a functional extension of the Secure Payload (SP)
that
* executes in Secure EL1. The Secure Monitor will delegate all SMCs targeting
* the Trusted OS/Applications range to the dispatcher. The SPD will either
* handle the request locally or delegate it to the Secure Payload. It is also
* responsible for initialising and maintaining communication with the SP.

Quoted 5 lines

******************************************************************************/

Clean other EXTRA_OEMAKE to remove leading space not needed with +=

Quoted 60 lines

---
v2 - replace boolean index trick

 .../recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc  | 14
+++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc +5 -0
index 899b778..25d5179 100644
@@ -16,6 +16,11 @@ TFA_PLATFORM ?= "invalid"
 # Leave empty for default behavior
 TFA_BOARD ?= ""
 
+# Some platforms use SPD (Secure Payload Dispatcher) services
+# Few options are "opteed", "tlkd", "trusty", "tspd"...
+# Leave empty to not use SPD
+TFA_SPD ?= ""
+
 # Build for debug (set TFA_DEBUG to 1 to activate)
 TFA_DEBUG ?= "0"
 
@@ -73,16 +78,19 @@ EXTRA_OEMAKE += "BUILD_BASE=${B} PLAT=${TFA_PLATFORM}"
 EXTRA_OEMAKE += "${@'TARGET_BOARD=${TFA_BOARD}' if d.getVar('TFA_BOARD') else

''}"
BUILD_DIR = "${TFA_PLATFORM}${@'/${TFA_BOARD}' if d.getVar('TFA_BOARD') else
''}"

meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc +3 -1
+# Handle TFA_SPD parameter
+EXTRA_OEMAKE += "${@'SPD=${TFA_SPD}' if d.getVar('TFA_SPD') else ''}"
+
 # Handle TFA_DEBUG parameter
-EXTRA_OEMAKE += "${@bb.utils.contains('TFA_DEBUG', '1', '

DEBUG=${TFA_DEBUG}', '', d)}"
+EXTRA_OEMAKE += "${@bb.utils.contains('TFA_DEBUG', '1', 'DEBUG=${TFA_DEBUG}', '', d)}"

# Handle MBEDTLS
-EXTRA_OEMAKE += "${@bb.utils.contains('TFA_MBEDTLS', '1', ' MBEDTLS_DIR=${TFA_MBEDTLS_DIR}', '', d)}" +EXTRA_OEMAKE += "${@bb.utils.contains('TFA_MBEDTLS', '1', 'MBEDTLS_DIR=${TFA_MBEDTLS_DIR}', '', d)}"

# Uboot support
DEPENDS += " ${@bb.utils.contains('TFA_UBOOT', '1', 'u-boot', '', d)}" do_compile[depends] += " ${@bb.utils.contains('TFA_UBOOT', '1',
'u-boot:do_deploy', '', d)}"
-EXTRA_OEMAKE += "${@bb.utils.contains('TFA_UBOOT', '1', ' BL33=${DEPLOY_DIR_IMAGE}/u-boot.bin', '',d)}"
+EXTRA_OEMAKE += "${@bb.utils.contains('TFA_UBOOT', '1', 'BL33=${DEPLOY_DIR_IMAGE}/u-boot.bin', '',d)}"

# The following hack is needed to fit properly in yocto build environment # TFA is forcing the host compiler and its flags in the Makefile using :=

Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/4 trusted-firmware-a: install/deploy multiple variants of the target

In reply to Denys Dmytriyenko

From: Denys Dmytriyenko <[email protected]>

Installing and deploying .bin and .elf shouldn't be mutually exclusive. There are scenarios where both can be useful - .bin for booting and .elf for debugging.

---
 .../trusted-firmware-a/trusted-firmware-a.inc        | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc +15 -5
index 25d5179..f5b5bc1 100644
@@ -116,29 +116,39 @@ do_install() {
 
     install -d -m 755 ${D}/firmware
     for atfbin in ${TFA_INSTALL_TARGET}; do
+        processes="0"
         if [ "$atfbin" = "all" ]; then
             # Target all is not handled by default
             bberror "all as TFA_INSTALL_TARGET is not handled by do_install"
             bberror "Please specify valid targets in TFA_INSTALL_TARGET or"
             bberror "rewrite or turn off do_install"
             exit 1
-        elif [ -f $BUILD_PLAT/$atfbin.bin ]; then
+        fi
+
+        if [ -f $BUILD_PLAT/$atfbin.bin ]; then
             echo "Install $atfbin.bin"
             install -m 0644 $BUILD_PLAT/$atfbin.bin \
                 ${D}/firmware/$atfbin-${TFA_PLATFORM}.bin
-        elif [ -f $BUILD_PLAT/$atfbin/$atfbin.elf ]; then
+            processes="1"
+        fi
+        if [ -f $BUILD_PLAT/$atfbin/$atfbin.elf ]; then
             echo "Install $atfbin.elf"
             install -m 0644 $BUILD_PLAT/$atfbin/$atfbin.elf \
                 ${D}/firmware/$atfbin-${TFA_PLATFORM}.elf
-        elif [ -f $BUILD_PLAT/$atfbin ]; then
+            processes="1"
+        fi
+        if [ -f $BUILD_PLAT/$atfbin ]; then
             echo "Install $atfbin"
             install -m 0644 $BUILD_PLAT/$atfbin \
                 ${D}/firmware/$atfbin-${TFA_PLATFORM}
-        elif [ "$atfbin" = "dtbs" ]; then
+            processes="1"
+        fi
+
+        if [ "$atfbin" = "dtbs" ]; then
             echo "dtbs install, skipped"
         elif [ -f ${B}/tools/$atfbin/$atfbin ]; then
             echo "Tools $atfbin install, skipped"
-        else
+        elif [ "$processed" = "0" ]; then
             bberror "Unsupported TFA_INSTALL_TARGET target $atfbin"
             exit 1
         fi
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/4 trusted-firmware-a: provide symlinks for canonical names

In reply to Denys Dmytriyenko

From: Denys Dmytriyenko <[email protected]>

Some platforms expect canonical names, like bl31.bin, instead of bl31-<plat>.bin Provide symlinks for those as well.

---
 meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc | 3 +++
 1 file changed, 3 insertions(+)
meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc +3 -0
index f5b5bc1..c9c5710 100644
@@ -129,18 +129,21 @@ do_install() {
             echo "Install $atfbin.bin"
             install -m 0644 $BUILD_PLAT/$atfbin.bin \
                 ${D}/firmware/$atfbin-${TFA_PLATFORM}.bin
+            ln -sf $atfbin-${TFA_PLATFORM}.bin ${D}/firmware/$atfbin.bin
             processes="1"
         fi
         if [ -f $BUILD_PLAT/$atfbin/$atfbin.elf ]; then
             echo "Install $atfbin.elf"
             install -m 0644 $BUILD_PLAT/$atfbin/$atfbin.elf \
                 ${D}/firmware/$atfbin-${TFA_PLATFORM}.elf
+            ln -sf $atfbin-${TFA_PLATFORM}.elf ${D}/firmware/$atfbin.elf
             processes="1"
         fi
         if [ -f $BUILD_PLAT/$atfbin ]; then
             echo "Install $atfbin"
             install -m 0644 $BUILD_PLAT/$atfbin \
                 ${D}/firmware/$atfbin-${TFA_PLATFORM}
+            ln -sf $atfbin-${TFA_PLATFORM} ${D}/firmware/$atfbin
             processes="1"
         fi
 
Signature · 1 line
2.7.4
Reviewed-by on v2 1/4
#5 lore raw
In reply to Denys Dmytriyenko
Quoted 8 lines · Denys Dmytriyenko

From: Denys Dmytriyenko <[email protected]>

Some platforms can have multiple board configurations, passed as TARGET_BOARD=""
that also becomes an extra directory level in the build output hierarchy.

Quoted 53 lines

---
v2 - replace boolean index trick

 .../recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc    | 12
++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc +6 -0
index 4b5da7a..899b778 100644
@@ -12,6 +12,10 @@ COMPATIBLE_MACHINE ?= "invalid"
 # Platform must be set for each machine
 TFA_PLATFORM ?= "invalid"
 
+# Some platforms can have multiple board configurations
+# Leave empty for default behavior
+TFA_BOARD ?= ""
+
 # Build for debug (set TFA_DEBUG to 1 to activate)
 TFA_DEBUG ?= "0"
 
@@ -65,6 +69,10 @@ DEPENDS_append = " dtc-native openssl-native"
 # Add platform parameter
 EXTRA_OEMAKE += "BUILD_BASE=${B} PLAT=${TFA_PLATFORM}"
 
+# Handle TFA_BOARD parameter
+EXTRA_OEMAKE += "${@'TARGET_BOARD=${TFA_BOARD}' if d.getVar('TFA_BOARD') else

''}"
+BUILD_DIR = "${TFA_PLATFORM}${@'/${TFA_BOARD}' if d.getVar('TFA_BOARD') else ''}"
+
# Handle TFA_DEBUG parameter
EXTRA_OEMAKE += "${@bb.utils.contains('TFA_DEBUG', '1', '
DEBUG=${TFA_DEBUG}', '', d)}"

meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc +2 -2
@@ -93,9 +101,9 @@ do_compile[cleandirs] = "${B}"
 
 do_install() {
     if ${@"true" if d.getVar('TFA_DEBUG') == '1' else "false"}; then
-        BUILD_PLAT=${B}/${TFA_PLATFORM}/debug/
+        BUILD_PLAT=${B}/${BUILD_DIR}/debug/
     else
-        BUILD_PLAT=${B}/${TFA_PLATFORM}/release/
+        BUILD_PLAT=${B}/${BUILD_DIR}/release/
     fi
 
     install -d -m 755 ${D}/firmware
Signature · 1 line
2.7.4
#6 lore raw
In reply to Denys Dmytriyenko
Quoted 8 lines · Denys Dmytriyenko

From: Denys Dmytriyenko <[email protected]>

Some platforms can have multiple board configurations, passed as TARGET_BOARD="" that also becomes an extra directory level in the build output hierarchy.

---
v2 - replace boolean index trick

Series pulled into the master branch.

Thanks,
Jon

Quoted 47 lines
 .../recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc    | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc +10 -2
index 4b5da7a..899b778 100644
@@ -12,6 +12,10 @@ COMPATIBLE_MACHINE ?= "invalid"
 # Platform must be set for each machine
 TFA_PLATFORM ?= "invalid"
 
+# Some platforms can have multiple board configurations
+# Leave empty for default behavior
+TFA_BOARD ?= ""
+
 # Build for debug (set TFA_DEBUG to 1 to activate)
 TFA_DEBUG ?= "0"
 
@@ -65,6 +69,10 @@ DEPENDS_append = " dtc-native openssl-native"
 # Add platform parameter
 EXTRA_OEMAKE += "BUILD_BASE=${B} PLAT=${TFA_PLATFORM}"
 
+# Handle TFA_BOARD parameter
+EXTRA_OEMAKE += "${@'TARGET_BOARD=${TFA_BOARD}' if d.getVar('TFA_BOARD') else ''}"
+BUILD_DIR = "${TFA_PLATFORM}${@'/${TFA_BOARD}' if d.getVar('TFA_BOARD') else ''}"
+
 # Handle TFA_DEBUG parameter
 EXTRA_OEMAKE += "${@bb.utils.contains('TFA_DEBUG', '1', ' DEBUG=${TFA_DEBUG}', '', d)}"
 
@@ -93,9 +101,9 @@ do_compile[cleandirs] = "${B}"
 
 do_install() {
     if ${@"true" if d.getVar('TFA_DEBUG') == '1' else "false"}; then
-        BUILD_PLAT=${B}/${TFA_PLATFORM}/debug/
+        BUILD_PLAT=${B}/${BUILD_DIR}/debug/
     else
-        BUILD_PLAT=${B}/${TFA_PLATFORM}/release/
+        BUILD_PLAT=${B}/${BUILD_DIR}/release/
     fi
 
     install -d -m 755 ${D}/firmware
Signature · 1 line
2.7.4