Skip to contentSkip to conversation

boot/uboot: add support for bundling TEE in BIN format into U-Boot

PATCH In review Michael Trimarchi 3 participants 7 messages Feb 1, 2022 – Feb 12, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 boot/uboot: add support for bundling TEE in BIN format into U-Boot

Some U-Boot platforms (e.g. nxp) can bundle OPTEE's tee.bin
into the U-Boot image using binman. This patch brings the necessary changes to enable this feature.

---
 boot/uboot/Config.in | 12 ++++++++++++
 boot/uboot/uboot.mk  | 12 ++++++++++++
 2 files changed, 24 insertions(+)
boot/uboot/Config.in +12 -0
index c630fc6552..117bbd3faf 100644
@@ -237,6 +237,18 @@ config BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE
 	  U-Boot. This option makes sure optee-os gets built prior to
 	  U-Boot, and that the TEE variable pointing to OPTEE's
 	  tee.elf, is passed during the Buildroot build.
+choice
+	prompt "U-Boot OPTEE BL32 format"
+	default BR2_TARGET_UBOOT_NEEDS_OPTEE_BIN
+	depends on BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE
+
+config BR2_TARGET_UBOOT_NEEDS_OPTEE_BIN
+	bool "tee.bin"
+
+config BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF
+	bool "tee.elf"
+
+endchoice
 
 config BR2_TARGET_UBOOT_NEEDS_OPENSBI
 	bool "U-Boot needs OpenSBI"
boot/uboot/uboot.mk +12 -0
index 574fc7089a..210fa219ed 100644
@@ -177,7 +177,19 @@ endif
 
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE),y)
 UBOOT_DEPENDENCIES += optee-os
+ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF),y)
 UBOOT_MAKE_OPTS += TEE=$(BINARIES_DIR)/tee.elf
+define UBOOT_COPY_TEE_FIRMWARE
+	cp $(BINARIES_DIR)/tee.elf $(@D)/
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_TEE_FIRMWARE
+else
+UBOOT_MAKE_OPTS += BL32=$(BINARIES_DIR)/tee.bin
+define UBOOT_COPY_TEE_FIRMWARE
+	cp $(BINARIES_DIR)/tee-raw.bin $(@D)/tee.bin
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_TEE_FIRMWARE
+endif
 endif
 
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPENSBI),y)
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Michael, All,

On 2022-02-01 10:13 +0100, Michael Trimarchi spake thusly:

Quoted 15 lines

Some U-Boot platforms (e.g. nxp) can bundle OPTEE's tee.bin
into the U-Boot image using binman. This patch brings the necessary changes to enable this feature.

---
 boot/uboot/Config.in | 12 ++++++++++++
 boot/uboot/uboot.mk  | 12 ++++++++++++
 2 files changed, 24 insertions(+)
boot/uboot/Config.in +0 -0
index c630fc6552..117bbd3faf 100644

boot/uboot/Config.in config BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE · line 239

Quoted 3 lines
boot/uboot/Config.in +0 -0
@@ -237,6 +237,18 @@ config BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE
 	  U-Boot. This option makes sure optee-os gets built prior to
 	  U-Boot, and that the TEE variable pointing to OPTEE's
 	  tee.elf, is passed during the Buildroot build.

Missing empty line here.

Quoted 20 lines
boot/uboot/Config.in +12 -0
+choice
+	prompt "U-Boot OPTEE BL32 format"
+	default BR2_TARGET_UBOOT_NEEDS_OPTEE_BIN
+	depends on BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE
+
+config BR2_TARGET_UBOOT_NEEDS_OPTEE_BIN
+	bool "tee.bin"
+
+config BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF
+	bool "tee.elf"
+
+endchoice
 
 config BR2_TARGET_UBOOT_NEEDS_OPENSBI
 	bool "U-Boot needs OpenSBI"
boot/uboot/uboot.mk +0 -0
index 574fc7089a..210fa219ed 100644

boot/uboot/uboot.mk endif · line 183

Quoted 7 lines
boot/uboot/uboot.mk +3 -0
@@ -177,7 +177,19 @@ endif
 
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE),y)
 UBOOT_DEPENDENCIES += optee-os
+ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF),y)
 UBOOT_MAKE_OPTS += TEE=$(BINARIES_DIR)/tee.elf
+define UBOOT_COPY_TEE_FIRMWARE
+	cp $(BINARIES_DIR)/tee.elf $(@D)/

Why do you need to copy it, when TEE is pointing to the original in $(BINARIESD_DIR), just above, and that has worked well so far?

boot/uboot/uboot.mk endif · line 189

Quoted 6 lines
boot/uboot/uboot.mk +6 -0
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_TEE_FIRMWARE
+else
+UBOOT_MAKE_OPTS += BL32=$(BINARIES_DIR)/tee.bin
+define UBOOT_COPY_TEE_FIRMWARE
+	cp $(BINARIES_DIR)/tee-raw.bin $(@D)/tee.bin

Ditto: why do you need to copy it, when TEE, just above, also points to the original in $(BINARIES_DIR) ?

Regards,
Yann E. MORIN.

Quoted 9 lines
boot/uboot/uboot.mk +3 -0
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_TEE_FIRMWARE
+endif
 endif
 
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPENSBI),y)
Signature · 1 line
2.25.1
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Hi

Quoted 14 lines · Yann E. MORIN

Michael, All,

On 2022-02-01 10:13 +0100, Michael Trimarchi spake thusly:

Quoted 10 lines

Some U-Boot platforms (e.g. nxp) can bundle OPTEE's tee.bin
into the U-Boot image using binman. This patch brings the necessary changes to enable this feature.

---
 boot/uboot/Config.in | 12 ++++++++++++
 boot/uboot/uboot.mk  | 12 ++++++++++++
 2 files changed, 24 insertions(+)
Quoted 11 lines

boot/uboot/Config.in config BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE · line 239

Quoted 8 lines
boot/uboot/Config.in +0 -0
index c630fc6552..117bbd3faf 100644
@@ -237,6 +237,18 @@ config BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE
        U-Boot. This option makes sure optee-os gets built prior to
        U-Boot, and that the TEE variable pointing to OPTEE's
        tee.elf, is passed during the Buildroot build.

Missing empty line here.

ok

Quoted 21 lines
Quoted 21 lines
boot/uboot/Config.in +12 -0
+choice
+     prompt "U-Boot OPTEE BL32 format"
+     default BR2_TARGET_UBOOT_NEEDS_OPTEE_BIN
+     depends on BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE
+
+config BR2_TARGET_UBOOT_NEEDS_OPTEE_BIN
+     bool "tee.bin"
+
+config BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF
+     bool "tee.elf"
+
+endchoice
 
 config BR2_TARGET_UBOOT_NEEDS_OPENSBI
      bool "U-Boot needs OpenSBI"
boot/uboot/uboot.mk +0 -0
index 574fc7089a..210fa219ed 100644
@@ -177,7 +177,19 @@ endif
 
Quoted 10 lines

boot/uboot/uboot.mk endif · line 183

Quoted 6 lines
boot/uboot/uboot.mk +3 -0
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE),y)
 UBOOT_DEPENDENCIES += optee-os
+ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF),y)
 UBOOT_MAKE_OPTS += TEE=$(BINARIES_DIR)/tee.elf
+define UBOOT_COPY_TEE_FIRMWARE
+     cp $(BINARIES_DIR)/tee.elf $(@D)/

Why do you need to copy it, when TEE is pointing to the original in $(BINARIESD_DIR), just above, and that has worked well so far?

The copy are needed to binman to include it

Quoted 9 lines

boot/uboot/uboot.mk endif · line 189

Quoted 6 lines
boot/uboot/uboot.mk +6 -0
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_TEE_FIRMWARE
+else
+UBOOT_MAKE_OPTS += BL32=$(BINARIES_DIR)/tee.bin
+define UBOOT_COPY_TEE_FIRMWARE
+     cp $(BINARIES_DIR)/tee-raw.bin $(@D)/tee.bin

Ditto: why do you need to copy it, when TEE, just above, also points to the original in $(BINARIES_DIR) ?

Same as above

Michael

Quoted 21 lines

Regards,
Yann E. MORIN.

Quoted 9 lines
boot/uboot/uboot.mk +3 -1
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_TEE_FIRMWARE
+endif
 endif
 
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPENSBI),y)
--

2.25.1

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |

'------------------------------^-------^------------------^--------------------'

Signature · 15 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Michael, All,

On 2022-02-01 18:57 +0100, Michael Nazzareno Trimarchi spake thusly:

Quoted 5 lines · Yann E. MORIN
Quoted 4 lines

On 2022-02-01 10:13 +0100, Michael Trimarchi spake thusly:

Quoted 3 lines

Some U-Boot platforms (e.g. nxp) can bundle OPTEE's tee.bin
into the U-Boot image using binman. This patch brings the necessary changes to enable this feature.

Also, comit log not nicely formatted: it should be wrapped at ~72 chars on every lines.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

---

[--SNIP--]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE),y)
UBOOT_DEPENDENCIES += optee-os
+ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF),y)
UBOOT_MAKE_OPTS += TEE=$(BINARIES_DIR)/tee.elf

                         ,^^^^^^^^^^^^^^^^^^^^^^^^^^^

Note this for later ----/

Quoted 5 lines
Quoted 4 lines

boot/uboot/uboot.mk endif · line 183

Quoted 2 lines
boot/uboot/uboot.mk +2 -0
+define UBOOT_COPY_TEE_FIRMWARE
+     cp $(BINARIES_DIR)/tee.elf $(@D)/

Why do you need to copy it, when TEE is pointing to the original in $(BINARIESD_DIR), just above, and that has worked well so far?

The copy are needed to binman to include it

As far as I understand it, BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF is supposed to behave like the code we had so far, and so far we did not have the copy, and that seems that it worked OK without the copy.

Now you are adding the copy: why was it not needed before, and why is it needed now?

And if binman needs it in the source tree, then why do we point the TEE variable to the original location in BINARIES_DIR, as I highlighted above?

Quoted 9 lines
Quoted 8 lines

boot/uboot/uboot.mk endif · line 189

Quoted 6 lines
boot/uboot/uboot.mk +6 -0
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_TEE_FIRMWARE
+else
+UBOOT_MAKE_OPTS += BL32=$(BINARIES_DIR)/tee.bin
+define UBOOT_COPY_TEE_FIRMWARE
+     cp $(BINARIES_DIR)/tee-raw.bin $(@D)/tee.bin

Ditto: why do you need to copy it, when TEE, just above, also points to the original in $(BINARIES_DIR) ?

Same as above

Ditto.

Regards,
Yann E. MORIN.

Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

Hi Yann

Quoted 33 lines · Yann E. MORIN

Michael, All,

On 2022-02-01 18:57 +0100, Michael Nazzareno Trimarchi spake thusly:

Quoted 5 lines · Yann E. MORIN
Quoted 4 lines

On 2022-02-01 10:13 +0100, Michael Trimarchi spake thusly:

Quoted 3 lines

Some U-Boot platforms (e.g. nxp) can bundle OPTEE's tee.bin
into the U-Boot image using binman. This patch brings the necessary changes to enable this feature.

Also, comit log not nicely formatted: it should be wrapped at ~72 chars on every lines.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

---

[--SNIP--]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE),y)
UBOOT_DEPENDENCIES += optee-os
+ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF),y)
UBOOT_MAKE_OPTS += TEE=$(BINARIES_DIR)/tee.elf

                         ,^^^^^^^^^^^^^^^^^^^^^^^^^^^

Note this for later ----/

Quoted 5 lines
Quoted 4 lines

boot/uboot/uboot.mk endif · line 183

Quoted 2 lines
boot/uboot/uboot.mk +2 -0
+define UBOOT_COPY_TEE_FIRMWARE
+     cp $(BINARIES_DIR)/tee.elf $(@D)/

Why do you need to copy it, when TEE is pointing to the original in $(BINARIESD_DIR), just above, and that has worked well so far?

The copy are needed to binman to include it

As far as I understand it, BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF is supposed to behave like the code we had so far, and so far we did not have the copy, and that seems that it worked OK without the copy.

Quoted 6 lines

Now you are adding the copy: why was it not needed before, and why is it needed now?

And if binman needs it in the source tree, then why do we point the TEE variable to the original location in BINARIES_DIR, as I highlighted above?

binman takes this and put an image on each part. We already copy atf. Now nxp I need to copy tee-raw.bin in tee.bin

fit {
                        description = "Configuration to load ATF before U-Boot";
                        fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>;
                        fit,fdt-list = "of-list";
                        #address-cells = <1>;

                        images {
                                uboot {
                                        arch = "arm64";
                                        compression = "none";
                                        description = "U-Boot (64-bit)";
                                        load = <CONFIG_SYS_TEXT_BASE>;
                                        type = "standalone";

                                        uboot_blob {
                                                filename = "u-boot-nodtb.bin";
                                                type = "blob-ext";
                                        };
                                };

                                atf {
                                        arch = "arm64";
                                        compression = "none";
                                        description = "ARM Trusted Firmware";
                                        entry = <0x960000>;
                                        load = <0x960000>;
                                        type = "firmware";

                                        atf_blob {
                                                filename = "bl31.bin";
                                                type = "blob-ext";
                                        };
                                };

                                tee {
                                        arch = "arm64";
                                        compression = "none";
                                        description = "OP-TEE Trusted
OS (bl32)";
                                        load = <0x5f800000>;
                                        entry = <0x5f800000>;
                                        type = "firmware";

                                        tee_blob {
                                                filename = "tee.bin";
                                                type = "blob-ext";
                                        };
                                };

                                binman_fip: fip {
                                        arch = "arm64";
                                        compression = "none";
                                        description = "Trusted Firmware FIP";
                                        load = <0x40310000>;
                                        type = "firmware";
                                };

                                @fdt-SEQ {
                                        compression = "none";
                                        description = "NAME";
                                        type = "flat_dt";

                                        uboot_fdt_blob {
                                                filename = "u-boot.dtb";
                                                type = "blob-ext";
                                        };
                                };
                        };

The above work working for rockchip so as we copy atf, I need to copy tee

Michael

Quoted 23 lines
Quoted 10 lines
Quoted 9 lines

boot/uboot/uboot.mk endif · line 189

Quoted 7 lines
boot/uboot/uboot.mk +6 -0
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_TEE_FIRMWARE
+else
+UBOOT_MAKE_OPTS += BL32=$(BINARIES_DIR)/tee.bin
+define UBOOT_COPY_TEE_FIRMWARE
+     cp $(BINARIES_DIR)/tee-raw.bin $(@D)/tee.bin

Ditto: why do you need to copy it, when TEE, just above, also points to the original in $(BINARIES_DIR) ?

Same as above

Ditto.

Regards,
Yann E. MORIN.

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |

'------------------------------^-------^------------------^--------------------'

Signature · 15 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

Hi Yann

Quoted 117 lines · Michael Nazzareno Trimarchi

Hi Yann

Quoted 33 lines · Yann E. MORIN

Michael, All,

On 2022-02-01 18:57 +0100, Michael Nazzareno Trimarchi spake thusly:

Quoted 5 lines · Yann E. MORIN
Quoted 4 lines

On 2022-02-01 10:13 +0100, Michael Trimarchi spake thusly:

Quoted 3 lines

Some U-Boot platforms (e.g. nxp) can bundle OPTEE's tee.bin
into the U-Boot image using binman. This patch brings the necessary changes to enable this feature.

Also, comit log not nicely formatted: it should be wrapped at ~72 chars on every lines.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

---

[--SNIP--]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE),y)
UBOOT_DEPENDENCIES += optee-os
+ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF),y)
UBOOT_MAKE_OPTS += TEE=$(BINARIES_DIR)/tee.elf

                         ,^^^^^^^^^^^^^^^^^^^^^^^^^^^

Note this for later ----/

Quoted 5 lines
Quoted 4 lines

boot/uboot/uboot.mk endif · line 183

Quoted 2 lines
boot/uboot/uboot.mk +2 -0
+define UBOOT_COPY_TEE_FIRMWARE
+     cp $(BINARIES_DIR)/tee.elf $(@D)/

Why do you need to copy it, when TEE is pointing to the original in $(BINARIESD_DIR), just above, and that has worked well so far?

The copy are needed to binman to include it

As far as I understand it, BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF is supposed to behave like the code we had so far, and so far we did not have the copy, and that seems that it worked OK without the copy.

Quoted 6 lines

Now you are adding the copy: why was it not needed before, and why is it needed now?

And if binman needs it in the source tree, then why do we point the TEE variable to the original location in BINARIES_DIR, as I highlighted above?

binman takes this and put an image on each part. We already copy atf. Now nxp I need to copy tee-raw.bin in tee.bin

fit {
                        description = "Configuration to load ATF before U-Boot";
                        fit,external-offset = <CONFIG_FIT_EXTERNAL_OFFSET>;
                        fit,fdt-list = "of-list";
                        #address-cells = <1>;

                        images {
                                uboot {
                                        arch = "arm64";
                                        compression = "none";
                                        description = "U-Boot (64-bit)";
                                        load = <CONFIG_SYS_TEXT_BASE>;
                                        type = "standalone";

                                        uboot_blob {
                                                filename = "u-boot-nodtb.bin";
                                                type = "blob-ext";
                                        };
                                };

                                atf {
                                        arch = "arm64";
                                        compression = "none";
                                        description = "ARM Trusted Firmware";
                                        entry = <0x960000>;
                                        load = <0x960000>;
                                        type = "firmware";

                                        atf_blob {
                                                filename = "bl31.bin";
                                                type = "blob-ext";
                                        };
                                };

                                tee {
                                        arch = "arm64";
                                        compression = "none";
                                        description = "OP-TEE Trusted
OS (bl32)";
                                        load = <0x5f800000>;
                                        entry = <0x5f800000>;
                                        type = "firmware";

                                        tee_blob {
                                                filename = "tee.bin";
                                                type = "blob-ext";
                                        };
                                };

                                binman_fip: fip {
                                        arch = "arm64";
                                        compression = "none";
                                        description = "Trusted Firmware FIP";
                                        load = <0x40310000>;
                                        type = "firmware";
                                };

                                @fdt-SEQ {
                                        compression = "none";
                                        description = "NAME";
                                        type = "flat_dt";

                                        uboot_fdt_blob {
                                                filename = "u-boot.dtb";
                                                type = "blob-ext";
                                        };
                                };
                        };
Quoted 2 lines

The above work working for rockchip so as we copy atf, I need to copy tee

For your better understand this is my config change for the board I sent yesterday

BR2_TARGET_ARM_TRUSTED_FIRMWARE=y
BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION=y BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION_VALUE="v2.5" BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM="imx8mn"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL32_OPTEE=y +BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_TARGETS="BL32_BASE=0x5f800000 BL32_SIZE=0x800000"
BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES="IMX_BOOT_UART_BASE=0x30a60000"
+BR2_TARGET_ARM_TRUSTED_FIRMWARE_DEBUG=y
+BR2_TARGET_OPTEE_OS=y
+BR2_TARGET_OPTEE_OS_PLATFORM="imx-mx8mnevk" +BR2_TARGET_OPTEE_OS_ADDITIONAL_VARIABLES="CFG_UART_BASE=UART4_BASE CFG_DDR_SIZE=0x20000000 CFG_TZDRAM_SIZE=0x600000 CFG_SHMEM_SIZE=0x200000 CFG_TEE_CORE_NB_CORE=1" +BR2_TARGET_OPTEE_OS_CORE_IMAGES="tee.bin tee-*_v2.bin tee-raw.bin"
BR2_TARGET_UBOOT=y
BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
BR2_TARGET_UBOOT_CUSTOM_GIT=y
@@ -36,6 +47,7 @@ BR2_TARGET_UBOOT_NEEDS_PYTHON3=y
BR2_TARGET_UBOOT_NEEDS_PYLIBFDT=y
BR2_TARGET_UBOOT_NEEDS_OPENSSL=y
BR2_TARGET_UBOOT_NEEDS_ATF_BL31=y
+BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE=y
BR2_TARGET_UBOOT_NEEDS_IMX_FIRMWARE=y
BR2_TARGET_UBOOT_FORMAT_CUSTOM=y BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="flash.bin"

I have sent a patch upstream for atf in order to calculate better reserved area.

Michael

Quoted 40 lines

Michael

Quoted 16 lines
Quoted 10 lines
Quoted 9 lines

boot/uboot/uboot.mk endif · line 189

Quoted 7 lines
boot/uboot/uboot.mk +6 -0
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_TEE_FIRMWARE
+else
+UBOOT_MAKE_OPTS += BL32=$(BINARIES_DIR)/tee.bin
+define UBOOT_COPY_TEE_FIRMWARE
+     cp $(BINARIES_DIR)/tee-raw.bin $(@D)/tee.bin

Ditto: why do you need to copy it, when TEE, just above, also points to the original in $(BINARIES_DIR) ?

Same as above

Ditto.

Regards,
Yann E. MORIN.

Quoted 7 lines

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |

'------------------------------^-------^------------------^--------------------'

--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com

Signature · 15 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#6 lore raw
In reply to Michael Trimarchi
Quoted 15 lines · Michael Trimarchi

Some U-Boot platforms (e.g. nxp) can bundle OPTEE's tee.bin
into the U-Boot image using binman. This patch brings the necessary changes to enable this feature.

---
  boot/uboot/Config.in | 12 ++++++++++++
  boot/uboot/uboot.mk  | 12 ++++++++++++
  2 files changed, 24 insertions(+)
boot/uboot/Config.in +0 -0
index c630fc6552..117bbd3faf 100644

boot/uboot/Config.in config BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE · line 239

Quoted 3 lines
boot/uboot/Config.in +0 -0
@@ -237,6 +237,18 @@ config BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE
  	  U-Boot. This option makes sure optee-os gets built prior to
  	  U-Boot, and that the TEE variable pointing to OPTEE's
  	  tee.elf, is passed during the Buildroot build.

^^^^^^^ This is inconsistent with the choice below. Perhaps
reformulate like this:

U-Boot, and that the TEE variable pointing to OPTEE's binary is passed during the Buildroot build.

boot/uboot/Config.in config BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE · line 243

Quoted 4 lines
boot/uboot/Config.in +4 -0
+choice
+	prompt "U-Boot OPTEE BL32 format"
+	default BR2_TARGET_UBOOT_NEEDS_OPTEE_BIN
+	depends on BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE

(nitpick) IMHO it's nicer to write this with if...endif around the choice.

More importantly: there should be a help text.

Quoted 16 lines
boot/uboot/Config.in +8 -0
+
+config BR2_TARGET_UBOOT_NEEDS_OPTEE_BIN
+	bool "tee.bin"
+
+config BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF
+	bool "tee.elf"
+
+endchoice
 
  config BR2_TARGET_UBOOT_NEEDS_OPENSBI
  	bool "U-Boot needs OpenSBI"
boot/uboot/uboot.mk +0 -0
index 574fc7089a..210fa219ed 100644

boot/uboot/uboot.mk endif · line 183

Quoted 7 lines
boot/uboot/uboot.mk +3 -0
@@ -177,7 +177,19 @@ endif
 
  ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_TEE),y)
  UBOOT_DEPENDENCIES += optee-os
+ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPTEE_ELF),y)
  UBOOT_MAKE_OPTS += TEE=$(BINARIES_DIR)/tee.elf
+define UBOOT_COPY_TEE_FIRMWARE
+	cp $(BINARIES_DIR)/tee.elf $(@D)/

As Yann explained but it didn't appear to get through: before, it supposedly
wasn't necessary to make this copy, so why is it necessary now?

Perhaps it is necessary to copy it in more recent versions of U-Boot (i.e.
when using binman). In that case, I think it would be good to also update the make option to TEE=tee.elf, to make it more consistent.

boot/uboot/uboot.mk endif · line 189

Quoted 6 lines
boot/uboot/uboot.mk +6 -0
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_TEE_FIRMWARE
+else
+UBOOT_MAKE_OPTS += BL32=$(BINARIES_DIR)/tee.bin
+define UBOOT_COPY_TEE_FIRMWARE
+	cp $(BINARIES_DIR)/tee-raw.bin $(@D)/tee.bin

Again, it's very weird that you pass in a BL32= that refers to a different
file (really different this time, because it's not the tee-raw.bin but the full tee.bin).

There may be good reasons to do it this way, but that should be explained in
detail in the commit message, and also briefly in a comment because it's simply too weird to understand like this.

I've marked the patch as Changes Requested.

Regards,
Arnout

boot/uboot/uboot.mk endif · line 195

Quoted 6 lines
boot/uboot/uboot.mk +3 -0
+endef
+UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_TEE_FIRMWARE
+endif
  endif
 
  ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPENSBI),y)

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot