Changes between Version 2 and Version 3 of venice/tee


Ignore:
Timestamp:
10/19/2021 10:30:23 PM (10 months ago)
Author:
Tim Harvey
Comment:

add reserved-memory nodes

Legend:

Unmodified
Added
Removed
Modified
  • venice/tee

    v2 v3  
    4646- build OP-TEE (tee.bin) and copy it to your U-Boot build dir. Take care to define CFG_DDR_SIZE which is used to determine TEE's load address
    4747- add tee.bin to U-Boot FIT image and take care to specify the load address of the ATF (BL31) (0x920000 for MX8MM and 0x960000 for MX8MN) and the load address of TEE (BL32) as specified above
    48  * for U-Boot v2021.07 which uses arch/arm/mach-imx/mkimage_fit_atf.sh to create the FIT image the tee.bin will be added as long as it is in your U-Boot's build directory but you also need to set TEE_LOAD_ADDR env to specify the load addr of the TEE as well as ATF_LOAD_ADDRESS per your SoC
     48 * for U-Boot v2021.07 which uses arch/arm/mach-imx/mkimage_fit_atf.sh to create the FIT image the tee.bin will be added as long as it is in your U-Boot's build director but you also need to set TEE_LOAD_ADDR env to specify the load addr of the TEE as well as ATF_LOAD_ADDRESS per your SoC
    4949 * for U-Boot v2022.01 the generation of the FIT image has moved to using the 'binman' tool thus adding tee.bin requires you to modify your board's u-boot.dtsi itb node to add tee.bin to itb/fit/images/ and add a reference to it in the loadables property of your boot configuration following atf
    5050- To enable OP-TEE support in U-Boot and Linux a /firmware/optee node needs to be added to your board u-boot.dtsi with 'compatible = "linaro,optee-tz"' and 'method = "smc"' nodes. This node is used by the U-Boot dek_blob command and if present and OP-TEE is loaded will be added to your Linux dtb via ft_system_setup in arch/arm/mach-imx/imx8m/fdt.c
    5151- To enable the 'dek_blob' command in U-Boot which uses OP-TEE enable CMD_DEKBLOB=y
    5252- To enable optee driver in Linux enable "CONFIG_TEE" and "CONFIG_OPTEE" and optionally CONFIG_HW_RANDOM_OPTEE as well as the /firmware/optee node in your U-Boot board u-boot.dtsi as that automates adding it to the Linux dtb during boot
     53- Add a memory carve-out for the memory reserved for OP-TEE core and shared-memory block via /reserved-memory/optee_core and /reserved_memory/optee_shm nodes in u-boot.dtsi (they will be copied to the Linux dtb when booting of OP-TEE is enabled)
    5354
    5455It is important to specify the 'load address' of the TEE appropriately for each component (ATF, OP-TEE, and U-Boot FIT image) and the value depends both on the IMX8M SoC flavor (ie IMX8MM vs IMX8MN) and size of DRAM.
     
    8586make -C atf $ATF_ARGS bl31
    8687}}}
     88 * add /firmware/optee and /reserved-memory nodes to U-Boot dtsi. The reserved memory ranges depend on the TEE_LOAD_ADDR: the optee_core starts at TEE_LOAD_ADDR and is 32MiB in size and the optee_shm starts at TEE_LOAD_ADDR + 0x1c000000 and is 4KiB in size. You will need to edit files in u-boot/arch/arm/dts and the diff will look like this for example for a 1GiB board:
     89{{{
     90$ git -C u-boot diff
     91diff --git a/arch/arm/dts/imx8mm-u-boot.dtsi b/arch/arm/dts/imx8mm-u-boot.dtsi
     92index f833d9df59bd..c443d45515c5 100644
     93--- a/arch/arm/dts/imx8mm-u-boot.dtsi
     94+++ b/arch/arm/dts/imx8mm-u-boot.dtsi
     95@@ -3,6 +3,31 @@
     96  * Copyright (C) 2020 Jagan Teki <jagan@amarulasolutions.com>
     97  */
     98 
     99+/ {
     100+       firmware {
     101+               optee {
     102+                       compatible = "linaro,optee-tz";
     103+                       method = "smc";
     104+               };
     105+       };
     106+
     107+       reserved-memory {
     108+               #address-cells = <2>;
     109+               #size-cells = <2>;
     110+               ranges;
     111+
     112+               /* 32MiB */
     113+               optee_core@7e000000 {
     114+                       reg = <0x00 0x7e000000 0x00 0x1c00000>;
     115+               };
     116+
     117+               /* 4K */
     118+               optee_shm@7fc00000 {
     119+                       reg = <0x00 0x7fc00000 0x00 0x400000>;
     120+               };
     121+       };
     122+};
     123+
     124 &{/soc@0} {
     125        u-boot,dm-pre-reloc;
     126        u-boot,dm-spl;
     127diff --git a/configs/imx8mm_venice_defconfig b/configs/imx8mm_venice_defconfig
     128index e24b0ed317f6..262b4e399d7e 100644
     129--- a/configs/imx8mm_venice_defconfig
     130+++ b/configs/imx8mm_venice_defconfig
     131@@ -21,6 +21,7 @@ CONFIG_SPL_SERIAL_SUPPORT=y
     132 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
     133 CONFIG_SPL=y
     134 CONFIG_ENV_OFFSET_REDUND=0xff8000
     135+CONFIG_CMD_DEKBLOB=y
     136 CONFIG_LTO=y
     137 CONFIG_DISTRO_DEFAULTS=y
     138 CONFIG_FIT=y
     139}}}
    87140 * rebuild U-Boot:
    88141{{{#!bash
     
    107160- https://elixir.bootlin.com/linux/latest/source/Documentation/staging/tee.rst
    108161- https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bindings/arm/firmware/linaro,optee-tz.yaml
    109