diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 5c0afec1544..f73d6eb0e2d 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -606,20 +606,6 @@ failure: return ret; } -/** - * bootefi_run_finish() - finish up after running an EFI test - * - * @loaded_image_info: Pointer to a struct which holds the loaded image info - * @image_obj: Pointer to a struct which holds the loaded image object - */ -static void bootefi_run_finish(struct efi_loaded_image_obj *image_obj, - struct efi_loaded_image *loaded_image_info) -{ - efi_restore_gd(); - free(loaded_image_info->load_options); - efi_delete_handle(&image_obj->header); -} - /** * do_efi_selftest() - execute EFI selftest * @@ -638,7 +624,12 @@ static int do_efi_selftest(void) /* Execute the test */ ret = EFI_CALL(efi_selftest(&image_obj->header, &systab)); - bootefi_run_finish(image_obj, loaded_image_info); + efi_restore_gd(); + free(loaded_image_info->load_options); + if (ret != EFI_SUCCESS) + efi_delete_handle(&image_obj->header); + else + ret = efi_delete_handle(&image_obj->header); return ret != EFI_SUCCESS; } diff --git a/doc/board/emulation/blkdev.rst b/doc/board/emulation/blkdev.rst new file mode 100644 index 00000000000..dc83a005268 --- /dev/null +++ b/doc/board/emulation/blkdev.rst @@ -0,0 +1,38 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Emulation of block devices +-------------------------- + +QEMU can emulate common block devices by adding the following parameters to +the qemu-system- command line: + +* MMC + + .. code-block:: bash + + -device sdhci-pci,sd-spec-version=3 \ + -device sd-card,drive=MMC1 \ + -drive if=none,file=disk.img,format=raw,id=MMC1 + +* NVMe + + .. code-block:: bash + + -drive if=none,file=disk.img,format=raw,id=NVME1 \ + -device nvme,drive=NVME1,serial=nvme-1 + +* SATA + + .. code-block:: bash + + -device ahci,id=ahci0 \ + -drive if=none,file=disk.img,format=raw,id=SATA1 \ + -device ide-hd,bus=ahci0.0,drive=SATA1 + +* USB + + .. code-block:: bash + + -device qemu-xhci \ + -drive if=none,file=disk.img,format=raw,id=USB1 \ + -device usb-storage,drive=USB1 diff --git a/doc/board/emulation/index.rst b/doc/board/emulation/index.rst index b5b6c3fa0de..932c65adebb 100644 --- a/doc/board/emulation/index.rst +++ b/doc/board/emulation/index.rst @@ -4,8 +4,10 @@ Emulation ========= .. toctree:: - :maxdepth: 2 + :maxdepth: 1 + blkdev + ../../usage/semihosting qemu-arm qemu-mips qemu-ppce500 diff --git a/doc/board/ti/am62x_sk.rst b/doc/board/ti/am62x_sk.rst index 3a122b07564..637985cb096 100644 --- a/doc/board/ti/am62x_sk.rst +++ b/doc/board/ti/am62x_sk.rst @@ -38,138 +38,87 @@ Some highlights of this SoC are: More details can be found in the Technical Reference Manual: https://www.ti.com/lit/pdf/spruiv7 +Platform information: + +* https://www.ti.com/tool/SK-AM62B + Boot Flow: ---------- Below is the pictorial representation of boot flow: -.. code-block:: text - - +------------------------------------------------------------------------+ - | TIFS | Main R5 | A53 | - +------------------------------------------------------------------------+ - | +--------+ | | | - | | Reset | | | | - | +--------+ | | | - | : | | | - | +--------+ | +-----------+ | | - | | *ROM* |----------|-->| Reset rls | | | - | +--------+ | +-----------+ | | - | | | | : | | - | | ROM | | : | | - | |services| | : | | - | | | | +-------------+ | | - | | | | | *R5 ROM* | | | - | | | | +-------------+ | | - | | |<---------|---|Load and auth| | | - | | | | | tiboot3.bin | | | - | +--------+ | +-------------+ | | - | | |<---------|---| Load sysfw | | | - | | | | | part to TIFS| | | - | | | | | core | | | - | | | | +-------------+ | | - | | | | : | | - | | | | : | | - | | | | : | | - | | | | +-------------+ | | - | | | | | *R5 SPL* | | | - | | | | +-------------+ | | - | | | | | DDR | | | - | | | | | config | | | - | | | | +-------------+ | | - | | | | | Load | | | - | | | | | tispl.bin | | | - | | | | +-------------+ | | - | | | | | Load R5 | | | - | | | | | firmware | | | - | | | | +-------------+ | | - | | |<---------|---| Start A53 | | | - | | | | | and jump to | | | - | | | | | DM fw image | | | - | | | | +-------------+ | | - | | | | | +-----------+ | - | | |----------|-----------------------|---->| Reset rls | | - | | | | | +-----------+ | - | | TIFS | | | : | - | |Services| | | +-------------+ | - | | |<---------|-----------------------|---->|*TF-A/OP-TEE*| | - | | | | | +-------------+ | - | | | | | : | - | | | | | +-----------+ | - | | |<---------|-----------------------|---->| *A53 SPL* | | - | | | | | +-----------+ | - | | | | | | Load | | - | | | | | | u-boot.img| | - | | | | | +-----------+ | - | | | | | : | - | | | | | +-----------+ | - | | |<---------|-----------------------|---->| *U-Boot* | | - | | | | | +-----------+ | - | | | | | | prompt | | - | | |----------|-----------------------|-----+-----------+-----| - | +--------+ | | | - | | | | - +------------------------------------------------------------------------+ +.. image:: img/boot_diagram_k3_current.svg - Here TIFS acts as master and provides all the critical services. R5/A53 requests TIFS to get these services done as shown in the above diagram. Sources: -------- -1. Trusted Firmware-A: - Tree: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ - Branch: master -2. OP-TEE: - Tree: https://github.com/OP-TEE/optee_os.git - Branch: master - -3. U-Boot: - Tree: https://source.denx.de/u-boot/u-boot - Branch: master - -4. TI Linux Firmware: - Tree: git://git.ti.com/processor-firmware/ti-linux-firmware.git - Branch: ti-linux-firmware +.. include:: k3.rst + :start-after: .. k3_rst_include_start_boot_sources + :end-before: .. k3_rst_include_end_boot_sources Build procedure: ---------------- -1. Trusted Firmware-A: +0. Setup the environment variables: +.. include:: k3.rst + :start-after: .. k3_rst_include_start_common_env_vars_desc + :end-before: .. k3_rst_include_end_common_env_vars_desc + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_board_env_vars_desc + :end-before: .. k3_rst_include_end_board_env_vars_desc + +Set the variables corresponding to this platform: + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_common_env_vars_defn + :end-before: .. k3_rst_include_end_common_env_vars_defn .. code-block:: bash - $ make CROSS_COMPILE=aarch64-none-linux-gnu- ARCH=aarch64 PLAT=k3 \ - TARGET_BOARD=lite SPD=opteed + $ export UBOOT_CFG_CORTEXR=am62x_evm_r5_defconfig + $ export UBOOT_CFG_CORTEXA=am62x_evm_a53_defconfig + $ export TFA_BOARD=lite + $ # we dont use any extra TFA parameters + $ unset TFA_EXTRA_ARGS + $ export OPTEE_PLATFORM=k3-am62x + $ export OPTEE_EXTRA_ARGS="CFG_WITH_SOFTWARE_PRNG=y" + +.. am62x_evm_rst_include_start_build_steps + +1. Trusted Firmware-A: + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_tfa + :end-before: .. k3_rst_include_end_build_steps_tfa + 2. OP-TEE: -.. code-block:: bash - - $ make PLATFORM=k3 CFG_ARM64_core=y CROSS_COMPILE=arm-none-linux-gnueabihf- \ - CROSS_COMPILE64=aarch64-none-linux-gnu- +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_optee + :end-before: .. k3_rst_include_end_build_steps_optee 3. U-Boot: -* 3.1 R5: +* 4.1 R5: -.. code-block:: bash +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_spl_r5 + :end-before: .. k3_rst_include_end_build_steps_spl_r5 - $ make ARCH=arm am62x_evm_r5_defconfig - $ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- \ - BINMAN_INDIRS= +* 4.2 A53: -* 3.2 A53: - -.. code-block:: bash - - $ make ARCH=arm am62x_evm_a53_defconfig - $ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- \ - BL31=/build/k3/lite/release/bl31.bin \ - TEE=/out/arm-plat-k3/core/tee-raw.bin \ - BINMAN_INDIRS= +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_uboot + :end-before: .. k3_rst_include_end_build_steps_uboot +.. am62x_evm_rst_include_end_build_steps Target Images -------------- -Copy the below images to an SD card and boot: +In order to boot we need tiboot3.bin, tispl.bin and u-boot.img. Each SoC +variant (GP, HS-FS, HS-SE) requires a different source for these files. - GP @@ -189,61 +138,19 @@ Copy the below images to an SD card and boot: Image formats: -------------- -- tiboot3.bin: +- tiboot3.bin -.. code-block:: text - - +-----------------------+ - | X.509 | - | Certificate | - | +-------------------+ | - | | | | - | | R5 | | - | | u-boot-spl.bin | | - | | | | - | +-------------------+ | - | | | | - | |TIFS with board cfg| | - | | | | - | +-------------------+ | - | | | | - | | | | - | | FIT header | | - | | +---------------+ | | - | | | | | | - | | | DTB 1...N | | | - | | +---------------+ | | - | +-------------------+ | - +-----------------------+ +.. image:: img/multi_cert_tiboot3.bin.svg - tispl.bin -.. code-block:: text - - +-----------------------+ - | | - | FIT HEADER | - | +-------------------+ | - | | | | - | | A53 TF-A | | - | +-------------------+ | - | | | | - | | A53 OP-TEE | | - | +-------------------+ | - | | | | - | | R5 DM FW | | - | +-------------------+ | - | | | | - | | A53 SPL | | - | +-------------------+ | - | | | | - | | SPL DTB 1...N | | - | +-------------------+ | - +-----------------------+ +.. image:: img/dm_tispl.bin.svg A53 SPL DDR Memory Layout ------------------------- +.. am62x_evm_rst_include_start_ddr_mem_layout + This provides an overview memory usage in A53 SPL stage. .. list-table:: @@ -297,6 +204,7 @@ This provides an overview memory usage in A53 SPL stage. * - EMPTY - 0x80d00400 - 0x81000000 +.. am62x_evm_rst_include_end_ddr_mem_layout Switch Setting for Boot Mode ---------------------------- @@ -309,16 +217,32 @@ The following table shows some common boot modes used on AM62 platform. More details can be found in the Technical Reference Manual: https://www.ti.com/lit/pdf/spruiv7 under the `Boot Mode Pins` section. -*Boot Modes* +.. list-table:: Boot Modes + :widths: 16 16 16 + :header-rows: 1 -============ ============= ============= -Switch Label SW2: 12345678 SW3: 12345678 -============ ============= ============= -SD 01000000 11000010 -OSPI 00000000 11001110 -EMMC 00000000 11010010 -UART 00000000 11011100 -USB DFU 00000000 11001010 -============ ============= ============= + * - Switch Label + - SW2: 12345678 + - SW3: 12345678 + + * - SD + - 01000000 + - 11000010 + + * - OSPI + - 00000000 + - 11001110 + + * - EMMC + - 00000000 + - 11010010 + + * - UART + - 00000000 + - 11011100 + + * - USB DFU + - 00000000 + - 11001010 For SW2 and SW1, the switch state in the "ON" position = 1. diff --git a/doc/board/ti/am65x_evm.rst b/doc/board/ti/am65x_evm.rst index 300cd3e9b96..0129235c2b2 100644 --- a/doc/board/ti/am65x_evm.rst +++ b/doc/board/ti/am65x_evm.rst @@ -24,6 +24,10 @@ cores, voltage domains and peripherals: More info can be found in TRM: http://www.ti.com/lit/pdf/spruid7 +Platform information: + +* https://www.ti.com/tool/TMDX654GPEVM + Boot Flow: ---------- On AM65x family devices, ROM supports boot only via MCU(R5). This means that @@ -41,136 +45,80 @@ applications. This should happen before running Linux. 3. In production boot flow, we might not like to use full U-Boot, instead use Falcon boot flow to reduce boot time. -.. code-block:: text - - +------------------------------------------------------------------------+ - | DMSC | R5 | A53 | - +------------------------------------------------------------------------+ - | +--------+ | | | - | | Reset | | | | - | +--------+ | | | - | : | | | - | +--------+ | +-----------+ | | - | | *ROM* |----------|-->| Reset rls | | | - | +--------+ | +-----------+ | | - | | | | : | | - | | ROM | | : | | - | |services| | : | | - | | | | +-------------+ | | - | | | | | *R5 ROM* | | | - | | | | +-------------+ | | - | | |<---------|---|Load and auth| | | - | | | | | tiboot3.bin | | | - | | | | +-------------+ | | - | | | | : | | - | | | | : | | - | | | | : | | - | | | | +-------------+ | | - | | | | | *R5 SPL* | | | - | | | | +-------------+ | | - | | | | | Load | | | - | | | | | sysfw.itb | | | - | | Start | | +-------------+ | | - | | System |<---------|---| Start | | | - | |Firmware| | | SYSFW | | | - | +--------+ | +-------------+ | | - | : | | | | | - | +---------+ | | Load | | | - | | *SYSFW* | | | system | | | - | +---------+ | | Config data | | | - | | |<--------|---| | | | - | | | | +-------------+ | | - | | | | | | | | - | | | | | DDR | | | - | | | | | config | | | - | | | | +-------------+ | | - | | | | | | | | - | | |<--------|---| Start A53 | | | - | | | | | and Reset | | | - | | | | +-------------+ | | - | | | | | +-----------+ | - | | |---------|-----------------------|---->| Reset rls | | - | | | | | +-----------+ | - | | DMSC | | | : | - | |Services | | | +------------+ | - | | |<--------|-----------------------|---->|*ATF/OP-TEE*| | - | | | | | +------------+ | - | | | | | : | - | | | | | +-----------+ | - | | |<--------|-----------------------|---->| *A53 SPL* | | - | | | | | +-----------+ | - | | | | | | Load | | - | | | | | | u-boot.img| | - | | | | | +-----------+ | - | | | | | : | - | | | | | +-----------+ | - | | |<--------|-----------------------|---->| *U-Boot* | | - | | | | | +-----------+ | - | | | | | | prompt | | - | | | | | +-----------+ | - | +---------+ | | | - | | | | - +------------------------------------------------------------------------+ +.. image:: img/boot_diagram_am65.svg - Here DMSC acts as master and provides all the critical services. R5/A53 requests DMSC to get these services done as shown in the above diagram. Sources: -------- -1. Trusted Firmware-A: - Tree: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ - Branch: master -2. OP-TEE: - Tree: https://github.com/OP-TEE/optee_os.git - Branch: master - -3. U-Boot: - Tree: https://source.denx.de/u-boot/u-boot - Branch: master - -4. TI Linux Firmware: - Tree: git://git.ti.com/processor-firmware/ti-linux-firmware.git - Branch: ti-linux-firmware +.. include:: k3.rst + :start-after: .. k3_rst_include_start_boot_sources + :end-before: .. k3_rst_include_end_boot_sources Build procedure: ---------------- -1. Trusted Firmware-A: +0. Setup the environment variables: +.. include:: k3.rst + :start-after: .. k3_rst_include_start_common_env_vars_desc + :end-before: .. k3_rst_include_end_common_env_vars_desc + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_board_env_vars_desc + :end-before: .. k3_rst_include_end_board_env_vars_desc + +Set the variables corresponding to this platform: + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_common_env_vars_defn + :end-before: .. k3_rst_include_end_common_env_vars_defn .. code-block:: bash - $ make CROSS_COMPILE=aarch64-linux-gnu- ARCH=aarch64 PLAT=k3 \ - TARGET_BOARD=generic SPD=opteed + $ export UBOOT_CFG_CORTEXR=am65x_evm_r5_defconfig + $ export UBOOT_CFG_CORTEXA=am65x_evm_a53_defconfig + $ export TFA_BOARD=generic + $ # we dont use any extra TFA parameters + $ unset TFA_EXTRA_ARGS + $ export OPTEE_PLATFORM=k3-am65x + $ # we dont use any extra OP-TEE parameters + $ unset OPTEE_EXTRA_ARGS + +.. am65x_evm_rst_include_start_build_steps + +1. Trusted Firmware-A: + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_tfa + :end-before: .. k3_rst_include_end_build_steps_tfa + 2. OP-TEE: -.. code-block:: bash - - $ make PLATFORM=k3-am65x CFG_ARM64_core=y +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_optee + :end-before: .. k3_rst_include_end_build_steps_optee 3. U-Boot: * 4.1 R5: -.. code-block:: bash - - $ make am65x_evm_r5_defconfig - $ make CROSS_COMPILE=arm-linux-gnueabihf- \ - BINMAN_INDIRS= +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_spl_r5 + :end-before: .. k3_rst_include_end_build_steps_spl_r5 * 4.2 A53: -.. code-block:: bash - - $ make am65x_evm_a53_defconfig - $ make CROSS_COMPILE=aarch64-linux-gnu- \ - BL31=/build/k3/generic/release/bl31.bin \ - TEE=/out/arm-plat-k3/core/tee-raw.bin \ - BINMAN_INDIRS= +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_uboot + :end-before: .. k3_rst_include_end_build_steps_uboot +.. am65x_evm_rst_include_end_build_steps Target Images -------------- -Copy the below images to an SD card and boot: +In order to boot we need tiboot3.bin, sysfw.itb, tispl.bin and u-boot.img. +Each SoC variant (GP and HS) requires a different source for these files. - GP @@ -185,74 +133,17 @@ Copy the below images to an SD card and boot: Image formats: -------------- -- tiboot3.bin: +- tiboot3.bin -.. code-block:: text - - +-----------------------+ - | X.509 | - | Certificate | - | +-------------------+ | - | | | | - | | R5 | | - | | u-boot-spl.bin | | - | | | | - | +-------------------+ | - | | | | - | | FIT header | | - | | +---------------+ | | - | | | | | | - | | | DTB 1...N | | | - | | +---------------+ | | - | +-------------------+ | - +-----------------------+ +.. image:: img/no_multi_cert_tiboot3.bin.svg - tispl.bin -.. code-block:: text - - +-----------------------+ - | | - | FIT HEADER | - | +-------------------+ | - | | | | - | | A53 ATF | | - | +-------------------+ | - | | | | - | | A53 OP-TEE | | - | +-------------------+ | - | | | | - | | A53 SPL | | - | +-------------------+ | - | | | | - | | SPL DTB 1...N | | - | +-------------------+ | - +-----------------------+ +.. image:: img/nodm_tispl.bin.svg - sysfw.itb -.. code-block:: text - - +-----------------------+ - | | - | FIT HEADER | - | +-------------------+ | - | | | | - | | sysfw.bin | | - | +-------------------+ | - | | | | - | | board config | | - | +-------------------+ | - | | | | - | | PM config | | - | +-------------------+ | - | | | | - | | RM config | | - | +-------------------+ | - | | | | - | | Secure config | | - | +-------------------+ | - +-----------------------+ +.. image:: img/sysfw.itb.svg eMMC: ----- @@ -293,22 +184,7 @@ used: eMMC layout: -.. code-block:: text - - boot0 partition (8 MB) user partition - 0x0+----------------------------------+ 0x0+-------------------------+ - | tiboot3.bin (512 KB) | | | - 0x400+----------------------------------+ | | - | tispl.bin (2 MB) | | | - 0x1400+----------------------------------+ | rootfs | - | u-boot.img (4 MB) | | | - 0x3400+----------------------------------+ | | - | environment (128 KB) | | | - 0x3500+----------------------------------+ | | - | backup environment (128 KB) | | | - 0x3600+----------------------------------+ | | - | sysfw (1 MB) | | | - 0x3E00+----------------------------------+ +-------------------------+ +.. image:: img/emmc_am65x_evm_boot0.svg Kernel image and DT are expected to be present in the /boot folder of rootfs. To boot kernel from eMMC, use the following commands: @@ -343,32 +219,7 @@ addresses. Flash layout for OSPI: -.. code-block:: text - - 0x0 +----------------------------+ - | ospi.tiboot3(512K) | - | | - 0x80000 +----------------------------+ - | ospi.tispl(2M) | - | | - 0x280000 +----------------------------+ - | ospi.u-boot(4M) | - | | - 0x680000 +----------------------------+ - | ospi.env(128K) | - | | - 0x6A0000 +----------------------------+ - | ospi.env.backup (128K) | - | | - 0x6C0000 +----------------------------+ - | ospi.sysfw(1M) | - | | - 0x7C0000 +----------------------------+ - | padding (256k) | - 0x800000 +----------------------------+ - | ospi.rootfs(UBIFS) | - | | - +----------------------------+ +.. image:: img/ospi_sysfw.svg Kernel Image and DT are expected to be present in the /boot folder of UBIFS ospi.rootfs just like in SD card case. U-Boot looks for UBI volume named @@ -387,16 +238,34 @@ ROM supports booting from MCU_UART0 via X-Modem protocol. The entire UART-based boot process up to U-Boot (proper) prompt goes through different stages and uses different UART peripherals as follows: -.. code-block:: text +.. list-table:: ROM UART Boot Responsibilities + :widths: 16 16 16 16 + :header-rows: 1 - +---------+---------------+-------------+------------+ - | WHO | Loading WHAT | HW Module | Protocol | - +---------+---------------+-------------+------------+ - |Boot ROM | tiboot3.bin | MCU_UART0 | X-Modem(*)| - |R5 SPL | sysfw.itb | MCU_UART0 | Y-Modem(*)| - |R5 SPL | tispl.bin | MAIN_UART0 | Y-Modem | - |A53 SPL | u-boot.img | MAIN_UART0 | Y-Modem | - +---------+---------------+-------------+------------+ + * - Who + - Loading What + - Hardware Module + - Protocol + + * - Boot ROM + - tiboot3.bin + - MCU_UART0 + - X-Modem(*) + + * - R5 SPL + - sysfw.itb + - MCU_UART0 + - Y-Modem(*) + + * - R5 SPL + - tispl.bin + - MAIN_UART0 + - Y-Modem + + * - A53 SPL + - u-boot.img + - MAIN_UART0 + - Y-Modem Note that in addition to X/Y-Modem related protocol timeouts the DMSC watchdog timeout of 3min (typ.) needs to be observed until System Firmware diff --git a/doc/board/ti/img/boot_diagram_am65.svg b/doc/board/ti/img/boot_diagram_am65.svg new file mode 100644 index 00000000000..fe5533a5197 --- /dev/null +++ b/doc/board/ti/img/boot_diagram_am65.svg @@ -0,0 +1,1779 @@ + + + + + + + + + + + + + Cortex-R + + + + Cortex-R + + + + + + + + + + ROM + + + + ROM + + + + + + + + + Load and auth tiboot3.bin + + + + Load and auth t... + + + + + + + + + + Cortex-A + + + + Cortex-A + + + + + + + + + + Load system +config data + + + + Load system... + + + + + + + + + DDR Config + + + + DDR Config + + + + + + + + + Load tispl.bin + + + + Load tispl.bin + + + + + + + + + Start Cortex-A + + + + Start Cortex-A + + + + + + + + + + Start Cortex-A + + + + Start Cort... + + + + + + + + + + + + + + + + + + + + + Aux f/w + + + + Aux f/w + + + + + + + + + + + Start SYSFW + + + + Start SYSFW + + + + + + + + + SYSFW + + + + SYSFW + + + + + + + + + + Load system config data + + + + Load syste... + + + + + + + + + Start SYSFW + + + + Start SYSFW + + + + + + + + + + Release Reset + + + + Release Re... + + + + + + + + + TF-A + + + + TF-A + + + + + + + + + + OP-TEE + + + + OP-TEE + + + + + + + + + + Cortex-A SPL + + + + Cortex-A SPL + + + + + + + + + + U-Boot + + + + U-Boot + + + + + + + + + Load u-boot.img + + + + Load u-boot.img + + + + + + + + + Load Aux core f/w +(optional) + + + + Load Aux core f/w... + + + + + + + + + Start Aux core +(optional) + + + + Start Aux core... + + + + + + + + + + Release Reset + + + + Release Re... + + + + + + + + + + Cortex-R/M +C6x/C7x + + + + Cortex-R/M... + + + + + + + + + + TIFS/DMSC + + + + TIFS/DMSC + + + + + + + + + + ROM + + + + ROM + + + + + + + + + + Security Enclave Boot Processor + + + + Security Enclave Boot... + + + + + + + + + + Boot Loader +Processor + + + + Boot Loader... + + + + + + + + + + Main CPU + + + + Main CPU + + + + + + + + + + Auxiliary +Processor + + + + Auxiliary... + + + + + + + + + + H/w Seq: Reset rls + + + + H/w Seq: Reset rls + + + + + + + + + + Auth tiboot3.bin + + + + Auth tiboo... + + + + + + + + + + Release Reset + + + + Release Re... + + + + + + + + + Cortex-R SPL + + + + Cortex-R SPL + + + + + + + + + Load sysfw.itb + + + + Load sysfw.itb + + + + + + + + + + Auth SYSFW + + + + Auth SYSFW + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/boot_diagram_j721e.svg b/doc/board/ti/img/boot_diagram_j721e.svg new file mode 100644 index 00000000000..e61af5b7670 --- /dev/null +++ b/doc/board/ti/img/boot_diagram_j721e.svg @@ -0,0 +1,2012 @@ + + + + + + + + + + + + + Cortex-R + + + + Cortex-R + + + + + + + + + + ROM + + + + ROM + + + + + + + + + Load and auth tiboot3.bin + + + + Load and auth t... + + + + + + + + + + Cortex-A + + + + Cortex-A + + + + + + + + + + Load system +config data + + + + Load system... + + + + + + + + + DDR Config + + + + DDR Config + + + + + + + + + Load tispl.bin + + + + Load tispl.bin + + + + + + + + + Start Cortex-A + + + + Start Cortex-A + + + + + + + + + Start DM + + + + Start DM + + + + + + + + + + Device Mgr + + + + Device Mgr + + + + + + + + + + Start Cortex-A + + + + Start Cort... + + + + + + + + + + + + + + + + + + + + + + + + + + + Aux f/w + + + + Aux f/w + + + + + + + + + + + Start TIFS + + + + Start TIFS + + + + + + + + + TIFS + + + + TIFS + + + + + + + + + + Load system config data + + + + Load syste... + + + + + + + + + Start TIFS + + + + Start TIFS + + + + + + + + + Load DM f/w + + + + Load DM f/w + + + + + + + + + + branch + + + + branch + + + + + + + + + + Release Reset + + + + Release Re... + + + + + + + + + TF-A + + + + TF-A + + + + + + + + + + OP-TEE + + + + OP-TEE + + + + + + + + + + Cortex A SPL + + + + Cortex A SPL + + + + + + + + + + U-Boot + + + + U-Boot + + + + + + + + + Load u-boot.img + + + + Load u-boot.img + + + + + + + + + Load Aux core f/w +(optional) + + + + Load Aux core f/w... + + + + + + + + + Start Aux core +(optional) + + + + Start Aux core... + + + + + + + + + + Release Reset + + + + Release Re... + + + + + + + + + + + + Cortex-R/M +C6x/C7x + + + + Cortex-R/M... + + + + + + + + + + TIFS/DMSC + + + + TIFS/DMSC + + + + + + + + + + ROM + + + + ROM + + + + + + + + + + Security Enclave Boot Processor + + + + Security Enclave Boot... + + + + + + + + + + Boot Loader +Processor + + + + Boot Loader... + + + + + + + + + + Main CPU + + + + Main CPU + + + + + + + + + + Auxiliary +Processor + + + + Auxiliary... + + + + + + + + + + H/w Seq: Reset rls + + + + H/w Seq: Reset rls + + + + + + + + + + Auth tiboot3.bin + + + + Auth tiboo... + + + + + + + + + + Release Reset + + + + Release Re... + + + + + + + + + Cortex-R SPL + + + + Cortex-R SPL + + + + + + + + + Load sysfw.itb + + + + Load sysfw.itb + + + + + + + + + + Auth TIFS + + + + Auth TIFS + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/boot_diagram_k3_current.svg b/doc/board/ti/img/boot_diagram_k3_current.svg new file mode 100644 index 00000000000..995afd890e1 --- /dev/null +++ b/doc/board/ti/img/boot_diagram_k3_current.svg @@ -0,0 +1,1925 @@ + + + + + + + + + + + + + Cortex-R + + + + Cortex-R + + + + + + + + + + ROM + + + + ROM + + + + + + + + + + Cortex-R SPL + + + + Cortex-R SPL + + + + + + + + + Load and auth tiboot3.bin + + + + Load and auth t... + + + + + + + + + Load system +config data + + + + Load system... + + + + + + + + + DDR Config + + + + DDR Config + + + + + + + + + Load tispl.bin + + + + Load tispl.bin + + + + + + + + + Start Cortex-A + + + + Start Cortex-A + + + + + + + + + Start DM + + + + Start DM + + + + + + + + + + Device Mgr + + + + Device Mgr + + + + + + + + + + Start Cortex-A + + + + Start Cort... + + + + + + + + + + + + + + + + + + + + + + + + Cortex-A + + + + Cortex-A + + + + + + + + + + + + + Cortex-R/M +C6x/C7x + + + + Cortex-R/M... + + + + + + + + + + Aux f/w + + + + Aux f/w + + + + + + + + + + TIFS/DMSC + + + + TIFS/DMSC + + + + + + + + + + ROM + + + + ROM + + + + + + + + + + + Start TIFS + + + + Start TIFS + + + + + + + + + TIFS + + + + TIFS + + + + + + + + + + Security Enclave Boot Processor + + + + Security Enclave Boot... + + + + + + + + + + Boot Loader +Processor + + + + Boot Loader... + + + + + + + + + + Main CPU + + + + Main CPU + + + + + + + + + + Auxiliary +Processor + + + + Auxiliary... + + + + + + + + + + H/w Seq: Reset rls + + + + H/w Seq: Reset rls + + + + + + + + + + Auth tiboot3.bin + + + + Auth tiboo... + + + + + + + + + + Release Reset + + + + Release Re... + + + + + + + + + + Load system config data + + + + Load syste... + + + + + + + + + Start TIFS + + + + Start TIFS + + + + + + + + + Load DM f/w + + + + Load DM f/w + + + + + + + + + + branch + + + + branch + + + + + + + + + + Release Reset + + + + Release Re... + + + + + + + + + TF-A + + + + TF-A + + + + + + + + + + OP-TEE + + + + OP-TEE + + + + + + + + + + Cortex-A SPL + + + + Cortex-A SPL + + + + + + + + + + U-Boot + + + + U-Boot + + + + + + + + + Load u-boot.img + + + + Load u-boot.img + + + + + + + + + Load Aux core f/w +(optional) + + + + Load Aux core f/w... + + + + + + + + + Start Aux core +(optional) + + + + Start Aux core... + + + + + + + + + + Release Reset + + + + Release Re... + + + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/boot_flow_01.svg b/doc/board/ti/img/boot_flow_01.svg new file mode 100644 index 00000000000..b5bd0ac2774 --- /dev/null +++ b/doc/board/ti/img/boot_flow_01.svg @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + WKUP Domain + + + + WKUP Domain + + + + + + + + + + ROM + + + + ROM + + + + + + + + + + WKUP SPL + + + + WKUP SPL + + + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/boot_flow_02.svg b/doc/board/ti/img/boot_flow_02.svg new file mode 100644 index 00000000000..4e282d8baf0 --- /dev/null +++ b/doc/board/ti/img/boot_flow_02.svg @@ -0,0 +1,459 @@ + + + + + + + + + + + + + + WKUP Domain + + + + WKUP Domain + + + + + + + + + + ROM + + + + ROM + + + + + + + + + + WKUP SPL + + + + WKUP SPL + + + + + + + + + + + + + Main Domain + + + + Main Domain + + + + + + + + + + TF-A + + + + TF-A + + + + + + + + + + OP-TEE + + + + OP-TEE + + + + + + + + + + + + Main SPL + + + + Main SPL + + + + + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/boot_flow_03.svg b/doc/board/ti/img/boot_flow_03.svg new file mode 100644 index 00000000000..b77d679926d --- /dev/null +++ b/doc/board/ti/img/boot_flow_03.svg @@ -0,0 +1,583 @@ + + + + + + + + + + + + + + WKUP Domain + + + + WKUP Domain + + + + + + + + + + ROM + + + + ROM + + + + + + + + + + WKUP SPL + + + + WKUP SPL + + + + + + + + + + + + + Main Domain + + + + Main Domain + + + + + + + + + + TF-A + + + + TF-A + + + + + + + + + + OP-TEE + + + + OP-TEE + + + + + + + + + + + + Main SPL + + + + Main SPL + + + + + + + + + + + + U-Boot + + + + U-Boot + + + + + + + + + + Linux + + + + Linux + + + + + + + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/dm_tispl.bin.svg b/doc/board/ti/img/dm_tispl.bin.svg new file mode 100644 index 00000000000..ffca67d0269 --- /dev/null +++ b/doc/board/ti/img/dm_tispl.bin.svg @@ -0,0 +1,317 @@ + + + + + + + + + + + + + FIT Header + + + + FIT Header + + + + + + + + + + TF-A + + + + TF-A + + + + + + + + + OP-TEE + + + + OP-TEE + + + + + + + + + R5 DM FW + + + + R5 DM FW + + + + + + + + + Cortex-A SPL + + + + Cortex-A SPL + + + + + + + + + SPL DTB 1..N + + + + SPL DTB 1..N + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/emmc_am65x_evm_boot0.svg b/doc/board/ti/img/emmc_am65x_evm_boot0.svg new file mode 100644 index 00000000000..ff5c7bf74b2 --- /dev/null +++ b/doc/board/ti/img/emmc_am65x_evm_boot0.svg @@ -0,0 +1,748 @@ + + + + + + + + + + + + tiboot3.bin (512KB) + + + + tiboot3.bin (512KB) + + + + + + + + + + + 0x0 + + + + + + 0x0 + + + + + + + + + tispl.bin (2MB) + + + + tispl.bin (2MB) + + + + + + + + + + + 0x400 + + + + + + 0x400 + + + + + + + + + U-boot.img (4MB) + + + + U-boot.img (4MB) + + + + + + + + + + + 0x1400 + + + + + + 0x1400 + + + + + + + + + environment (128KB) + + + + environment (128KB) + + + + + + + + + + + 0x3400 + + + + + + 0x3400 + + + + + + + + + backup environment (128KB) + + + + backup environment (128KB) + + + + + + + + + + + 0x3500 + + + + + + 0x3500 + + + + + + + + + Sysfw (1MB) + + + + Sysfw (1MB) + + + + + + + + + + + 0x3600 + + + + + + 0x3600 + + + + + + + + + + + 0x3E00 + + + + + + 0x3E00 + + + + + + + + + + UDA Partition + + + + UDA Partition + + + + + + + + + Boot0 partition (8MB) + + + + Boot0 partition (8MB) + + + + + + + + + rootfs + + + + rootfs + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/emmc_j7200_evm_boot01.svg b/doc/board/ti/img/emmc_j7200_evm_boot01.svg new file mode 100644 index 00000000000..43e8b254a82 --- /dev/null +++ b/doc/board/ti/img/emmc_j7200_evm_boot01.svg @@ -0,0 +1,662 @@ + + + + + + + + + + + + tiboot3.bin (1MB) + + + + tiboot3.bin (1MB) + + + + + + + + + + + 0x0 + + + + + + 0x0 + + + + + + + + + tispl.bin (2MB) + + + + tispl.bin (2MB) + + + + + + + + + + + 0x800 + + + + + + 0x800 + + + + + + + + + U-boot.img (4MB) + + + + U-boot.img (4MB) + + + + + + + + + + + 0x1800 + + + + + + 0x1800 + + + + + + + + + environment (128KB) + + + + environment (128KB) + + + + + + + + + + + 0x3800 + + + + + + 0x3800 + + + + + + + + + backup environment (128KB) + + + + backup environment (128KB) + + + + + + + + + + + 0x3900 + + + + + + 0x3900 + + + + + + + + + + + 0x3A00 + + + + + + 0x3A00 + + + + + + + + + + UDA Partition + + + + UDA Partition + + + + + + + + + Boot0/1 partition (8MB) + + + + Boot0/1 partition (8MB) + + + + + + + + + rootfs + + + + rootfs + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/emmc_j7200_evm_udafs.svg b/doc/board/ti/img/emmc_j7200_evm_udafs.svg new file mode 100644 index 00000000000..4287bb65b54 --- /dev/null +++ b/doc/board/ti/img/emmc_j7200_evm_udafs.svg @@ -0,0 +1,505 @@ + + + + + + + + + + + + + + 0x0 + + + + + + 0x0 + + + + + + + + + + + 0x3A00 + + + + + + 0x3A00 + + + + + + + + + + UDA Partition + + + + UDA Partition + + + + + + + + + Boot0/1 partition (8MB) + + + + Boot0/1 partition (8MB) + + + + + + + + + + + rootfs + + + + rootfs + + + + + + + + + boot + + + + boot + + + + + + + + + + tiboot3.bin* + + + + tiboot3.bi... + + + + + + + + + tispl.bin + + + + tispl.bin + + + + + + + + + u-boot.img + + + + u-boot.img + + + + + + + + + environment + + + + environment + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/j7200_tiboot3.bin.svg b/doc/board/ti/img/j7200_tiboot3.bin.svg new file mode 100644 index 00000000000..f535310f76d --- /dev/null +++ b/doc/board/ti/img/j7200_tiboot3.bin.svg @@ -0,0 +1,447 @@ + + + + + + + + + + + + + X.509 Certificate + + + + X.509 Cert... + + + + + + + + + R5 +u-boot-spl.bin + + + + R5... + + + + + + + + + + FIT Header + + + + FIT Header + + + + + + + + + DTB 1..N + + + + DTB 1..N + + + + + + + + + + sysfw.bin + + + + sysfw.bin + + + + + + + + + board config + + + + board config + + + + + + + + + PM config + + + + PM config + + + + + + + + + RM config + + + + RM config + + + + + + + + + Secure config + + + + Secure config + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/multi_cert_tiboot3.bin.svg b/doc/board/ti/img/multi_cert_tiboot3.bin.svg new file mode 100644 index 00000000000..a210d66ca6d --- /dev/null +++ b/doc/board/ti/img/multi_cert_tiboot3.bin.svg @@ -0,0 +1,287 @@ + + + + + + + + + + + + + X.509 Certificate + + + + X.509 Cert... + + + + + + + + + R5 +u-boot-spl.bin + + + + R5... + + + + + + + + + + DTB 1..N + + + + DTB 1..N + + + + + + + + + + FIT Header + + + + FIT Header + + + + + + + + + TIFS with board cfg + + + + TIFS with board cfg + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/no_multi_cert_tiboot3.bin.svg b/doc/board/ti/img/no_multi_cert_tiboot3.bin.svg new file mode 100644 index 00000000000..557dbf0c040 --- /dev/null +++ b/doc/board/ti/img/no_multi_cert_tiboot3.bin.svg @@ -0,0 +1,238 @@ + + + + + + + + + + + + + X.509 Certificate + + + + X.509 Cert... + + + + + + + + + R5 +u-boot-spl.bin + + + + R5... + + + + + + + + + + DTB 1..N + + + + DTB 1..N + + + + + + + + + FIT Header + + + + FIT Header + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/nodm_tispl.bin.svg b/doc/board/ti/img/nodm_tispl.bin.svg new file mode 100644 index 00000000000..040676400aa --- /dev/null +++ b/doc/board/ti/img/nodm_tispl.bin.svg @@ -0,0 +1,277 @@ + + + + + + + + + + + + + FIT Header + + + + FIT Header + + + + + + + + + + TF-A + + + + TF-A + + + + + + + + + OP-TEE + + + + OP-TEE + + + + + + + + + Cortex-A SPL + + + + Cortex-A SPL + + + + + + + + + SPL DTB 1..N + + + + SPL DTB 1..N + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/ospi_sysfw.svg b/doc/board/ti/img/ospi_sysfw.svg new file mode 100644 index 00000000000..e7a0fd24824 --- /dev/null +++ b/doc/board/ti/img/ospi_sysfw.svg @@ -0,0 +1,721 @@ + + + + + + + + + + + + ospi.tiboot3(512k) + + + + ospi.tiboot3(512k) + + + + + + + + + + 0x0 + + + + + 0x0 + + + + + + + + + ospi.tispl(2M) + + + + ospi.tispl(2M) + + + + + + + + + + 0x80000 + + + + + 0x80000 + + + + + + + + + ospi.u-boot(4M) + + + + ospi.u-boot(4M) + + + + + + + + + + 0x280000 + + + + + 0x280000 + + + + + + + + + ospi.env(128K) + + + + ospi.env(128K) + + + + + + + + + + 0x680000 + + + + + 0x680000 + + + + + + + + + ospi.env.backup(128K) + + + + ospi.env.backup(128K) + + + + + + + + + + 0x6A0000 + + + + + 0x6A0000 + + + + + + + + + ospi.sysfw(1M) + + + + ospi.sysfw(1M) + + + + + + + + + + 0x6C0000 + + + + + 0x6C0000 + + + + + + + + + padding(256K) + + + + padding(256K) + + + + + + + + + + 0x7C0000 + + + + + 0x7C0000 + + + + + + + + + ospi.rootfs(UBIFS) + + + + ospi.rootfs(UBIFS) + + + + + + + + + + 0x800000 + + + + + 0x800000 + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/img/sysfw.itb.svg b/doc/board/ti/img/sysfw.itb.svg new file mode 100644 index 00000000000..2d6640a6e2d --- /dev/null +++ b/doc/board/ti/img/sysfw.itb.svg @@ -0,0 +1,317 @@ + + + + + + + + + + + + + + FIT Header + + + + FIT Header + + + + + + + + + sysfw.bin + + + + sysfw.bin + + + + + + + + + board config + + + + board config + + + + + + + + + PM config + + + + PM config + + + + + + + + + RM config + + + + RM config + + + + + + + + + Secure config + + + + Secure config + + + + + + + Text is not SVG - cannot display + + + diff --git a/doc/board/ti/j7200_evm.rst b/doc/board/ti/j7200_evm.rst index 5e3d75059ca..69abc55a93c 100644 --- a/doc/board/ti/j7200_evm.rst +++ b/doc/board/ti/j7200_evm.rst @@ -26,153 +26,88 @@ specific processing cores and peripherals: More info can be found in TRM: https://www.ti.com/lit/pdf/spruiu1 +Platform information: + +* https://www.ti.com/tool/J7200XSOMXEVM + Boot Flow: ---------- Below is the pictorial representation of boot flow: -.. code-block:: text - - +------------------------------------------------------------------------+-----------------------+ - | DMSC | MCU R5 | A72 | MAIN R5/C7x | - +------------------------------------------------------------------------+-----------------------+ - | +--------+ | | | | - | | Reset | | | | | - | +--------+ | | | | - | : | | | | - | +--------+ | +-----------+ | | | - | | *ROM* |----------|-->| Reset rls | | | | - | +--------+ | +-----------+ | | | - | | | | : | | | - | | ROM | | : | | | - | |services| | : | | | - | | | | +-------------+ | | | - | | | | | *R5 ROM* | | | | - | | | | +-------------+ | | | - | | |<---------|---|Load and auth| | | | - | | | | | tiboot3.bin | | | | - | | Start | | +-------------+ | | | - | | TIFS |<---------|---| Start | | | | - | | | | | TIFS | | | | - | +--------+ | +-------------+ | | | - | : | | | | | | - | +---------+ | | Load | | | | - | | *TIFS* | | | system | | | | - | +---------+ | | Config data | | | | - | | |<--------|---| | | | | - | | | | +-------------+ | | | - | | | | : | | | - | | | | : | | | - | | | | : | | | - | | | | +-------------+ | | | - | | | | | *R5 SPL* | | | | - | | | | +-------------+ | | | - | | | | | DDR | | | | - | | | | | config | | | | - | | | | +-------------+ | | | - | | | | | Load | | | | - | | | | | tispl.bin | | | | - | | | | +-------------+ | | | - | | | | | Load R5 | | | | - | | | | | firmware | | | | - | | | | +-------------+ | | | - | | |<--------|---| Start A72 | | | | - | | | | | and jump to | | | | - | | | | | DM fw image | | | | - | | | | +-------------+ | | | - | | | | | +-----------+ | | - | | |---------|-----------------------|---->| Reset rls | | | - | | | | | +-----------+ | | - | | TIFS | | | : | | - | |Services | | | +-------------+ | | - | | |<--------|-----------------------|---->|*TF-A/OP-TEE*| | | - | | | | | +-------------+ | | - | | | | | : | | - | | | | | +-----------+ | | - | | |<--------|-----------------------|---->| *A72 SPL* | | | - | | | | | +-----------+ | | - | | | | | | Load | | | - | | | | | | u-boot.img| | | - | | | | | +-----------+ | | - | | | | | : | | - | | | | | +-----------+ | | - | | |<--------|-----------------------|---->| *U-Boot* | | | - | | | | | +-----------+ | | - | | | | | | prompt | | | - | | | | | +-----------+ | | - | | | | | | Load R5 | | | - | | | | | | Firmware | | | - | | | | | +-----------+ | | - | | |<--------|-----------------------|-----| Start R5 | | +-----------+ | - | | |---------|-----------------------|-----+-----------+-----|----->| R5 starts | | - | | | | | | Load C7 | | +-----------+ | - | | | | | | Firmware | | | - | | | | | +-----------+ | | - | | |<--------|-----------------------|-----| Start C7 | | +-----------+ | - | | |---------|-----------------------|-----+-----------+-----|----->| C7 starts | | - | | | | | | +-----------+ | - | | | | | | | - | +---------+ | | | | - | | | | | - +------------------------------------------------------------------------+-----------------------+ +.. image:: img/boot_diagram_k3_current.svg - Here DMSC acts as master and provides all the critical services. R5/A72 requests DMSC to get these services done as shown in the above diagram. Sources: -------- -1. Trusted Firmware-A: - Tree: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ - Branch: master -2. OP-TEE: - Tree: https://github.com/OP-TEE/optee_os.git - Branch: master - -3. U-Boot: - Tree: https://source.denx.de/u-boot/u-boot - Branch: master - -4. TI Linux Firmware: - Tree: git://git.ti.com/processor-firmware/ti-linux-firmware.git - Branch: ti-linux-firmware +.. include:: k3.rst + :start-after: .. k3_rst_include_start_boot_sources + :end-before: .. k3_rst_include_end_boot_sources Build procedure: ---------------- -1. Trusted Firmware-A: +0. Setup the environment variables: +.. include:: k3.rst + :start-after: .. k3_rst_include_start_common_env_vars_desc + :end-before: .. k3_rst_include_end_common_env_vars_desc + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_board_env_vars_desc + :end-before: .. k3_rst_include_end_board_env_vars_desc + +Set the variables corresponding to this platform: + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_common_env_vars_defn + :end-before: .. k3_rst_include_end_common_env_vars_defn .. code-block:: bash - $ make CROSS_COMPILE=aarch64-linux-gnu- ARCH=aarch64 PLAT=k3 TARGET_BOARD=generic SPD=opteed + $ export UBOOT_CFG_CORTEXR=j7200_evm_r5_defconfig + $ export UBOOT_CFG_CORTEXA=j7200_evm_a72_defconfig + $ export TFA_BOARD=generic + $ # we dont use any extra TFA parameters + $ unset TFA_EXTRA_ARGS + $ export OPTEE_PLATFORM=k3-j7200 + $ # we dont use any extra OP-TEE parameters + $ unset OPTEE_EXTRA_ARGS + +.. j7200_evm_rst_include_start_build_steps + +1. Trusted Firmware-A: + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_tfa + :end-before: .. k3_rst_include_end_build_steps_tfa + 2. OP-TEE: -.. code-block:: bash - - $ make PLATFORM=k3-j7200 CFG_ARM64_core=y +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_optee + :end-before: .. k3_rst_include_end_build_steps_optee 3. U-Boot: * 4.1 R5: -.. code-block:: bash - - $ make CROSS_COMPILE=arm-linux-gnueabihf- j7200_evm_r5_defconfig O=build/r5 - $ make CROSS_COMPILE=arm-linux-gnueabihf- \ - BINMAN_INDIRS= +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_spl_r5 + :end-before: .. k3_rst_include_end_build_steps_spl_r5 * 4.2 A72: -.. code-block:: bash - - $ make CROSS_COMPILE=aarch64-linux-gnu- j7200_evm_a72_defconfig O=build/a72 - $ make CROSS_COMPILE=aarch64-linux-gnu- \ - BL31=/build/k3/generic/release/bl31.bin \ - TEE=/out/arm-plat-k3/core/tee-raw.bin \ - BINMAN_INDIRS= +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_uboot + :end-before: .. k3_rst_include_end_build_steps_uboot +.. j7200_evm_rst_include_end_build_steps Target Images -------------- -Copy the below images to an SD card and boot: +In order to boot we need tiboot3.bin, tispl.bin and u-boot.img. Each SoC +variant (GP, HS-FS, HS-SE) requires a different source for these files. - GP @@ -192,71 +127,14 @@ Copy the below images to an SD card and boot: Image formats: -------------- -- tiboot3.bin: +- tiboot3.bin -.. code-block:: console - - +-----------------------+ - | X.509 | - | Certificate | - | +-------------------+ | - | | | | - | | R5 | | - | | u-boot-spl.bin | | - | | | | - | +-------------------+ | - | | | | - | | FIT header | | - | | +---------------+ | | - | | | | | | - | | | DTB 1...N | | | - | | +---------------+ | | - | +-------------------+ | - | | | | - | | FIT HEADER | | - | | +---------------+ | | - | | | | | | - | | | sysfw.bin | | | - | | +---------------+ | | - | | | | | | - | | | board config | | | - | | +---------------+ | | - | | | | | | - | | | PM config | | | - | | +---------------+ | | - | | | | | | - | | | RM config | | | - | | +---------------+ | | - | | | | | | - | | | Secure config | | | - | | +---------------+ | | - | +-------------------+ | - +-----------------------+ +.. image:: img/j7200_tiboot3.bin.svg - tispl.bin -.. code-block:: console +.. image:: img/dm_tispl.bin.svg - +-----------------------+ - | | - | FIT HEADER | - | +-------------------+ | - | | | | - | | A72 TF-A | | - | +-------------------+ | - | | | | - | | A72 OP-TEE | | - | +-------------------+ | - | | | | - | | R5 DM FW | | - | +-------------------+ | - | | | | - | | A72 SPL | | - | +-------------------+ | - | | | | - | | SPL DTB 1...N | | - | +-------------------+ | - +-----------------------+ Switch Setting for Boot Mode @@ -270,18 +148,33 @@ The following table shows some common boot modes used on J7200 platform. More details can be found in the Technical Reference Manual: https://www.ti.com/lit/pdf/spruiu1 under the `Boot Mode Pins` section. +.. list-table:: Boot Modes + :widths: 16 16 16 + :header-rows: 1 -*Boot Modes* + * - Switch Label + - SW9: 12345678 + - SW8: 12345678 -============ ============= ============= -Switch Label SW9: 12345678 SW8: 12345678 -============ ============= ============= -SD 00000000 10000010 -EMMC 01000000 10000000 -OSPI 01000000 00000110 -UART 01110000 00000000 -USB DFU 00100000 10000000 -============ ============= ============= + * - SD + - 00000000 + - 10000010 + + * - EMMC + - 01000000 + - 10000000 + + * - OSPI + - 01000000 + - 00000110 + + * - UART + - 01110000 + - 00000000 + + * - USB DFU + - 00100000 + - 10000000 For SW8 and SW9, the switch state in the "ON" position = 1. @@ -297,42 +190,14 @@ Current allocated size for tiboot3 size is 1MB, tispl is 2MB. Size of u-boot.img is taken 4MB for refernece, But this is subject to change depending upon atf, optee size -.. code-block:: console - - boot0/1 partition (8 MB) user partition - 0x0+----------------------------------+ 0x0+------------------------+ - | tiboot3.bin (1 MB) | | | - 0x800+----------------------------------+ | | - | tispl.bin (2 MB) | | | - 0x1800+----------------------------------+ | | - | u-boot.img (4MB) | | | - 0x3800+----------------------------------+ | | - | | | | - 0x3900+ environment | | | - | | | | - 0x3A00+----------------------------------+ +-------------------------+ +.. image:: img/emmc_j7200_evm_boot01.svg In case of UDA FS mode booting, following is layout. All boot images tiboot3.bin, tispl and u-boot should be written to fat formatted UDA FS as file. -.. code-block:: console - - boot0/1 partition (8 MB) user partition - 0x0+---------------------------------+ 0x0+-------------------------+ - | | | tiboot3.bin* | - 0x800+----------------------------------+ | | - | | | tispl.bin | - 0x1800+----------------------------------+ | | - | | | u-boot.img | - 0x3800+----------------------------------+ | | - | | | | - 0x3900+ | | environment | - | | | | - 0x3A00+----------------------------------+ +-------------------------+ - - +.. image:: img/emmc_j7200_evm_udafs.svg In case of booting from eMMC, write above images into raw or UDA FS. and set mmc partconf accordingly. diff --git a/doc/board/ti/j721e_evm.rst b/doc/board/ti/j721e_evm.rst index 46244197f34..f4b4c192d9d 100644 --- a/doc/board/ti/j721e_evm.rst +++ b/doc/board/ti/j721e_evm.rst @@ -29,161 +29,91 @@ specific processing cores and peripherals: More info can be found in TRM: http://www.ti.com/lit/pdf/spruil1 +Platform information: + +* https://www.ti.com/tool/J721EXSOMXEVM +* https://www.ti.com/tool/SK-TDA4VM + Boot Flow: ---------- Boot flow is similar to that of AM65x SoC and extending it with remoteproc support. Below is the pictorial representation of boot flow: -.. code-block:: text - - +------------------------------------------------------------------------+-----------------------+ - | DMSC | MCU R5 | A72 | MAIN R5/C66x/C7x | - +------------------------------------------------------------------------+-----------------------+ - | +--------+ | | | | - | | Reset | | | | | - | +--------+ | | | | - | : | | | | - | +--------+ | +-----------+ | | | - | | *ROM* |----------|-->| Reset rls | | | | - | +--------+ | +-----------+ | | | - | | | | : | | | - | | ROM | | : | | | - | |services| | : | | | - | | | | +-------------+ | | | - | | | | | *R5 ROM* | | | | - | | | | +-------------+ | | | - | | |<---------|---|Load and auth| | | | - | | | | | tiboot3.bin | | | | - | | | | +-------------+ | | | - | | | | : | | | - | | | | : | | | - | | | | : | | | - | | | | +-------------+ | | | - | | | | | *R5 SPL* | | | | - | | | | +-------------+ | | | - | | | | | Load | | | | - | | | | | sysfw.itb | | | | - | | Start | | +-------------+ | | | - | | System |<---------|---| Start | | | | - | |Firmware| | | SYSFW | | | | - | +--------+ | +-------------+ | | | - | : | | | | | | - | +---------+ | | Load | | | | - | | *SYSFW* | | | system | | | | - | +---------+ | | Config data | | | | - | | |<--------|---| | | | | - | | | | +-------------+ | | | - | | | | | DDR | | | | - | | | | | config | | | | - | | | | +-------------+ | | | - | | | | | Load | | | | - | | | | | tispl.bin | | | | - | | | | +-------------+ | | | - | | | | | Load R5 | | | | - | | | | | firmware | | | | - | | | | +-------------+ | | | - | | |<--------|---| Start A72 | | | | - | | | | | and jump to | | | | - | | | | | DM fw image | | | | - | | | | +-------------+ | | | - | | | | | +-----------+ | | - | | |---------|-----------------------|---->| Reset rls | | | - | | | | | +-----------+ | | - | | TIFS | | | : | | - | |Services | | | +-------------+ | | - | | |<--------|-----------------------|---->|*TF-A/OP-TEE*| | | - | | | | | +-------------+ | | - | | | | | : | | - | | | | | +-----------+ | | - | | |<--------|-----------------------|---->| *A72 SPL* | | | - | | | | | +-----------+ | | - | | | | | | Load | | | - | | | | | | u-boot.img| | | - | | | | | +-----------+ | | - | | | | | : | | - | | | | | +-----------+ | | - | | |<--------|-----------------------|---->| *U-Boot* | | | - | | | | | +-----------+ | | - | | | | | | prompt | | | - | | | | | +-----------+ | | - | | | | | | Load R5 | | | - | | | | | | Firmware | | | - | | | | | +-----------+ | | - | | |<--------|-----------------------|-----| Start R5 | | +-----------+ | - | | |---------|-----------------------|-----+-----------+-----|----->| R5 starts | | - | | | | | | Load C6 | | +-----------+ | - | | | | | | Firmware | | | - | | | | | +-----------+ | | - | | |<--------|-----------------------|-----| Start C6 | | +-----------+ | - | | |---------|-----------------------|-----+-----------+-----|----->| C6 starts | | - | | | | | | Load C7 | | +-----------+ | - | | | | | | Firmware | | | - | | | | | +-----------+ | | - | | |<--------|-----------------------|-----| Start C7 | | +-----------+ | - | | |---------|-----------------------|-----+-----------+-----|----->| C7 starts | | - | +---------+ | | | +-----------+ | - | | | | | - +------------------------------------------------------------------------+-----------------------+ +.. image:: img/boot_diagram_j721e.svg - Here DMSC acts as master and provides all the critical services. R5/A72 requests DMSC to get these services done as shown in the above diagram. Sources: -------- -1. Trusted Firmware-A: - Tree: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ - Branch: master -2. OP-TEE: - Tree: https://github.com/OP-TEE/optee_os.git - Branch: master - -3. U-Boot: - Tree: https://source.denx.de/u-boot/u-boot - Branch: master - -4. TI Linux Firmware: - Tree: git://git.ti.com/processor-firmware/ti-linux-firmware.git - Branch: ti-linux-firmware +.. include:: k3.rst + :start-after: .. k3_rst_include_start_boot_sources + :end-before: .. k3_rst_include_end_boot_sources Build procedure: ---------------- -1. Trusted Firmware-A: +0. Setup the environment variables: +.. include:: k3.rst + :start-after: .. k3_rst_include_start_common_env_vars_desc + :end-before: .. k3_rst_include_end_common_env_vars_desc + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_board_env_vars_desc + :end-before: .. k3_rst_include_end_board_env_vars_desc + +Set the variables corresponding to this platform: + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_common_env_vars_defn + :end-before: .. k3_rst_include_end_common_env_vars_defn .. code-block:: bash - $ make CROSS_COMPILE=aarch64-linux-gnu- ARCH=aarch64 PLAT=k3 \ - TARGET_BOARD=generic SPD=opteed + $ export UBOOT_CFG_CORTEXR=j721e_evm_r5_defconfig + $ export UBOOT_CFG_CORTEXA=j721e_evm_a72_defconfig + $ export TFA_BOARD=generic + $ # we dont use any extra TFA parameters + $ unset TFA_EXTRA_ARGS + $ export OPTEE_PLATFORM=k3-j721e + $ # we dont use any extra OP-TEE parameters + $ unset OPTEE_EXTRA_ARGS + +.. j721e_evm_rst_include_start_build_steps + +1. Trusted Firmware-A: + +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_tfa + :end-before: .. k3_rst_include_end_build_steps_tfa + 2. OP-TEE: -.. code-block:: bash - - $ make PLATFORM=k3-j721e CFG_ARM64_core=y +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_optee + :end-before: .. k3_rst_include_end_build_steps_optee 3. U-Boot: * 4.1 R5: -.. code-block:: bash - - $ make j721e_evm_r5_defconfig - $ make CROSS_COMPILE=arm-linux-gnueabihf- \ - BINMAN_INDIRS= +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_spl_r5 + :end-before: .. k3_rst_include_end_build_steps_spl_r5 * 4.2 A72: -.. code-block:: bash - - $ make j721e_evm_a72_defconfig - $ make CROSS_COMPILE=aarch64-linux-gnu- \ - BL31=/build/k3/generic/release/bl31.bin \ - TEE=/out/arm-plat-k3/core/tee-raw.bin \ - BINMAN_INDIRS= +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_uboot + :end-before: .. k3_rst_include_end_build_steps_uboot +.. j721e_evm_rst_include_end_build_steps Target Images -------------- -Copy the below images to an SD card and boot: +In order to boot we need tiboot3.bin, sysfw.itb, tispl.bin and u-boot.img. +Each SoC variant (GP, HS-FS and HS-SE) requires a different source for these +files. - GP @@ -203,77 +133,17 @@ Copy the below images to an SD card and boot: Image formats: -------------- -- tiboot3.bin: +- tiboot3.bin -.. code-block:: text - - +-----------------------+ - | X.509 | - | Certificate | - | +-------------------+ | - | | | | - | | R5 | | - | | u-boot-spl.bin | | - | | | | - | +-------------------+ | - | | | | - | | FIT header | | - | | +---------------+ | | - | | | | | | - | | | DTB 1...N | | | - | | +---------------+ | | - | +-------------------+ | - +-----------------------+ +.. image:: img/no_multi_cert_tiboot3.bin.svg - tispl.bin -.. code-block:: text - - +-----------------------+ - | | - | FIT HEADER | - | +-------------------+ | - | | | | - | | A72 TF-A | | - | +-------------------+ | - | | | | - | | A72 OP-TEE | | - | +-------------------+ | - | | | | - | | R5 DM FW | | - | +-------------------+ | - | | | | - | | A72 SPL | | - | +-------------------+ | - | | | | - | | SPL DTB 1...N | | - | +-------------------+ | - +-----------------------+ +.. image:: img/dm_tispl.bin.svg - sysfw.itb -.. code-block:: text - - +-----------------------+ - | | - | FIT HEADER | - | +-------------------+ | - | | | | - | | sysfw.bin | | - | +-------------------+ | - | | | | - | | board config | | - | +-------------------+ | - | | | | - | | PM config | | - | +-------------------+ | - | | | | - | | RM config | | - | +-------------------+ | - | | | | - | | Secure config | | - | +-------------------+ | - +-----------------------+ +.. image:: img/sysfw.itb.svg R5 Memory Map: -------------- @@ -342,32 +212,7 @@ addresses. Flash layout for OSPI: -.. code-block:: text - - 0x0 +----------------------------+ - | ospi.tiboot3(512K) | - | | - 0x80000 +----------------------------+ - | ospi.tispl(2M) | - | | - 0x280000 +----------------------------+ - | ospi.u-boot(4M) | - | | - 0x680000 +----------------------------+ - | ospi.env(128K) | - | | - 0x6A0000 +----------------------------+ - | ospi.env.backup (128K) | - | | - 0x6C0000 +----------------------------+ - | ospi.sysfw(1M) | - | | - 0x7C0000 +----------------------------+ - | padding (256k) | - 0x800000 +----------------------------+ - | ospi.rootfs(UBIFS) | - | | - +----------------------------+ +.. image:: img/ospi_sysfw.svg Firmwares: ---------- diff --git a/doc/board/ti/k3.rst b/doc/board/ti/k3.rst index 2db7bbdb42e..9d40675b600 100644 --- a/doc/board/ti/k3.rst +++ b/doc/board/ti/k3.rst @@ -30,10 +30,10 @@ K3 Based SoCs .. toctree:: :maxdepth: 1 - j721e_evm - j7200_evm am62x_sk am65x_evm + j7200_evm + j721e_evm Boot Flow Overview ------------------ @@ -45,10 +45,7 @@ boot media needed to load the binaries packaged inside `tiboot3.bin`, including a 32bit U-Boot SPL, (called the wakup SPL) that ROM will jump to after it has finished loading everything into internal SRAM. -.. code-block:: text - - | WKUP Domain - ROM -> WKUP SPL -> +.. image:: img/boot_flow_01.svg The wakeup SPL, running on a wakeup domain core, will initialize DDR and any peripherals needed load the larger binaries inside the `tispl.bin` @@ -57,10 +54,7 @@ application cores inside the main domain to initialize the main domain, starting with Trusted Firmware-A (TF-A), before moving on to start OP-TEE and the main domain's U-Boot SPL. -.. code-block:: text - - | WKUP Domain | Main Domain -> - ROM -> WKUP SPL -> TF-A -> OP-TEE -> Main SPL +.. image:: img/boot_flow_02.svg The main domain's SPL, running on a 64bit application core, has virtually unlimited space (billions of bytes now that DDR is working) to @@ -68,10 +62,7 @@ initialize even more peripherals needed to load in the `u-boot.img` which loads more firmware into the micro-controller & wakeup domains and finally prepare the main domain to run Linux. -.. code-block:: text - - | WKUP Domain | Main Domain -> - ROM -> WKUP SPL -> TF-A -> OP-TEE -> Main SPL -> UBoot -> Linux +.. image:: img/boot_flow_03.svg This is the typical boot flow for all K3 based SoCs, however this flow offers quite a lot in the terms of flexibility, especially on High @@ -111,6 +102,8 @@ All scripts and code needed to build the `tiboot3.bin`, `tispl.bin` and `u-boot.img` for all K3 SoCs can be located at the following places online +.. k3_rst_include_start_boot_sources + * **Das U-Boot** | **source:** https://source.denx.de/u-boot/u-boot.git @@ -131,6 +124,8 @@ online | **source:** https://git.ti.com/git/processor-firmware/ti-linux-firmware.git | **branch:** ti-linux-firmware +.. k3_rst_include_end_boot_sources + Build Procedure --------------- @@ -150,10 +145,71 @@ compiled for 64bit main domain CPU cores. All of that to say you will need both a 32bit and 64bit cross compiler (assuming you're using an x86 desktop) +.. k3_rst_include_start_common_env_vars_desc +.. list-table:: Generic environment variables + :widths: 25 25 50 + :header-rows: 1 + + * - S/w Component + - Env Variable + - Description + * - All Software + - CC32 + - Cross compiler for ARMv7 (ARM 32bit), typically arm-linux-gnueabihf- + * - All Software + - CC64 + - Cross compiler for ARMv8 (ARM 64bit), typically aarch64-linux-gnu- + * - All Software + - LNX_FW_PATH + - Path to TI Linux firmware repository + * - All Software + - TFA_PATH + - Path to source of Trusted Firmware-A + * - All Software + - OPTEE_PATH + - Path to source of OP-TEE +.. k3_rst_include_end_common_env_vars_desc + +.. k3_rst_include_start_common_env_vars_defn .. code-block:: bash $ export CC32=arm-linux-gnueabihf- $ export CC64=aarch64-linux-gnu- + $ export LNX_FW_PATH=path/to/ti-linux-firmware + $ export TFA_PATH=path/to/trusted-firmware-a + $ export OPTEE_PATH=path/to/optee_os +.. k3_rst_include_end_common_env_vars_defn + +We will also need some common environment variables set up for the various +other build sources. we shall use the following, in the build descriptions below: + +.. k3_rst_include_start_board_env_vars_desc +.. list-table:: Board specific environment variables + :widths: 25 25 50 + :header-rows: 1 + + * - S/w Component + - Env Variable + - Description + * - U-Boot + - UBOOT_CFG_CORTEXR + - Defconfig for Cortex-R (Boot processor). + * - U-Boot + - UBOOT_CFG_CORTEXA + - Defconfig for Cortex-A (MPU processor). + * - Trusted Firmware-A + - TFA_BOARD + - Platform name used for building TF-A for Cortex-A Processor. + * - Trusted Firmware-A + - TFA_EXTRA_ARGS + - Any extra arguments used for building TF-A. + * - OP-TEE + - OPTEE_PLATFORM + - Platform name used for building OP-TEE for Cortex-A Processor. + * - OP-TEE + - OPTEE_EXTRA_ARGS + - Any extra arguments used for building OP-TEE. +.. k3_rst_include_end_board_env_vars_desc Building tiboot3.bin ^^^^^^^^^^^^^^^^^^^^^ @@ -164,13 +220,13 @@ Building tiboot3.bin the final `tiboot3.bin` binary. (or the `sysfw.itb` if your device uses the split binary flow) - +.. k3_rst_include_start_build_steps_spl_r5 .. code-block:: bash $ # inside u-boot source - $ make ARCH=arm {SOC}_evm_r5_defconfig - $ make ARCH=arm CROSS_COMPILE=$CC32 \ - BINMAN_INDIRS= + $ make $UBOOT_CFG_CORTEXR + $ make CROSS_COMPILE=$CC32 BINMAN_INDIRS=$LNX_FW_PATH +.. k3_rst_include_end_build_steps_spl_r5 At this point you should have all the needed binaries to boot the wakeup domain of your K3 SoC. @@ -200,39 +256,43 @@ firmware if your device using a split firmware. 2. We will first need TF-A, as it's the first thing to run on the 'big' application cores on the main domain. +.. k3_rst_include_start_build_steps_tfa .. code-block:: bash $ # inside trusted-firmware-a source - $ make CROSS_COMPILE=$CC64 ARCH=aarch64 PLAT=k3 \ - TARGET_BOARD={lite|generic|j784s4} \ - SPD=opteed + $ make CROSS_COMPILE=$CC64 ARCH=aarch64 PLAT=k3 SPD=opteed $TFA_EXTRA_ARGS \ + TARGET_BOARD=$TFA_BOARD +.. k3_rst_include_end_build_steps_tfa Typically all `j7*` devices will use `TARGET_BOARD=generic` or `TARGET_BOARD -=j784s4` (if it is a J784S4 device), while all Sitara (`am6*`) devices +=j784s4` (if it is a J784S4 device), while typical Sitara (`am6*`) devices use the `lite` option. 3. The Open Portable Trusted Execution Environment (OP-TEE) is designed to run as a companion to a non-secure Linux kernel for Cortex-A cores using the TrustZone technology built into the core. +.. k3_rst_include_start_build_steps_optee .. code-block:: bash $ # inside optee_os source - $ make CROSS_COMPILE=$CC32 CROSS_COMPILE64=$CC64 \ - PLATFORM=k3 CFG_ARM64_core=y + $ make CROSS_COMPILE=$CC32 CROSS_COMPILE64=$CC64 CFG_ARM64_core=y $OPTEE_EXTRA_ARGS \ + PLATFORM=$OPTEE_PLATFORM +.. k3_rst_include_end_build_steps_optee 4. Finally, after TF-A has initialized the main domain and OP-TEE has finished, we can jump back into U-Boot again, this time running on a 64bit core in the main domain. +.. k3_rst_include_start_build_steps_uboot .. code-block:: bash $ # inside u-boot source - $ make ARCH=arm {SOC}_evm_a{53,72}_defconfig - $ make ARCH=arm CROSS_COMPILE=$CC64 \ - BINMAN_INDIRS= \ - BL31=/build/k3/generic/release/bl31.bin \ - TEE=/out/arm-plat-k3/core/tee-raw.bin + $ make $UBOOT_CFG_CORTEXA + $ make CROSS_COMPILE=$CC64 BINMAN_INDIRS=$LNX_FW_PATH \ + BL31=$TFA_PATH/build/k3/$TFA_BOARD/release/bl31.bin \ + TEE=$OPTEE_PATH/out/arm-plat-k3/core/tee-raw.bin +.. k3_rst_include_end_build_steps_uboot At this point you should have every binary needed initialize both the wakeup and main domain and to boot to the U-Boot prompt @@ -310,13 +370,11 @@ and the same can be extended to other platforms 2. Compile U-boot for the respective board - .. code-block:: bash +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_uboot + :end-before: .. k3_rst_include_end_build_steps_uboot - make O=build/a72 CROSS_COMPILE=aarch64-none-linux-gnu- ARCH=arm - BL31=/path/to/bl31.bin TEE=/path/to/bl32.bin - BINMAN_INDIRS="/path/to/ti-linux-firmware" -j15 - - .. note:: +.. note:: The changes only affect a72 binaries so the example just builds that @@ -362,11 +420,9 @@ and the same can be extended to other platforms This is required so that the modified dtb gets updated in u-boot.img - .. code-block:: bash - - make O=build/a72 CROSS_COMPILE=aarch64-none-linux-gnu- ARCH=arm - BL31=/path/to/bl31.bin TEE=/path/to/bl32.bin - BINMAN_INDIRS="/path/to/ti-linux-firmware" -j15 +.. include:: k3.rst + :start-after: .. k3_rst_include_start_build_steps_uboot + :end-before: .. k3_rst_include_end_build_steps_uboot 6. (Optional) Enabled FIT_SIGNATURE_ENFORCED diff --git a/doc/develop/codingstyle.rst b/doc/develop/codingstyle.rst index 3d05a6b9887..b25bfbd271f 100644 --- a/doc/develop/codingstyle.rst +++ b/doc/develop/codingstyle.rst @@ -120,7 +120,7 @@ then headers with directories, then local files: #include #include #include - #include + #include #include #include "local.h" diff --git a/doc/sphinx/requirements.txt b/doc/sphinx/requirements.txt index aed44921171..b74661ad3f1 100644 --- a/doc/sphinx/requirements.txt +++ b/doc/sphinx/requirements.txt @@ -1,6 +1,6 @@ alabaster==0.7.12 Babel==2.9.1 -certifi==2022.12.7 +certifi==2023.5.7 charset-normalizer==2.0.12 docutils==0.16 idna==3.3 @@ -8,9 +8,9 @@ imagesize==1.3.0 Jinja2==3.0.3 MarkupSafe==2.1.1 packaging==21.3 -Pygments==2.11.2 +Pygments==2.15.1 pyparsing==3.0.7 -pytz==2022.1 +pytz==2023.3 requests==2.31.0 six==1.16.0 snowballstemmer==2.2.0 diff --git a/include/efi_loader.h b/include/efi_loader.h index b5fa0fe01de..3a64eb9c667 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -629,7 +629,7 @@ void efi_add_handle(efi_handle_t obj); /* Create handle */ efi_status_t efi_create_handle(efi_handle_t *handle); /* Delete handle */ -void efi_delete_handle(efi_handle_t obj); +efi_status_t efi_delete_handle(efi_handle_t obj); /* Call this to validate a handle and find the EFI object for it */ struct efi_object *efi_search_obj(const efi_handle_t handle); /* Locate device_path handle */ diff --git a/lib/efi_driver/efi_uclass.c b/lib/efi_driver/efi_uclass.c index 45f93519887..66a45e156d6 100644 --- a/lib/efi_driver/efi_uclass.c +++ b/lib/efi_driver/efi_uclass.c @@ -285,10 +285,8 @@ static efi_status_t efi_add_driver(struct driver *drv) bp->ops = ops; ret = efi_create_handle(&bp->bp.driver_binding_handle); - if (ret != EFI_SUCCESS) { - free(bp); - goto out; - } + if (ret != EFI_SUCCESS) + goto err; bp->bp.image_handle = bp->bp.driver_binding_handle; ret = efi_add_protocol(bp->bp.driver_binding_handle, &efi_guid_driver_binding_protocol, bp); @@ -299,11 +297,11 @@ static efi_status_t efi_add_driver(struct driver *drv) if (ret != EFI_SUCCESS) goto err; } -out: - return ret; + return ret; err: - efi_delete_handle(bp->bp.driver_binding_handle); + if (bp->bp.driver_binding_handle) + efi_delete_handle(bp->bp.driver_binding_handle); free(bp); return ret; } diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 052fe481e47..0e89c8505b1 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -59,6 +59,10 @@ static efi_handle_t current_image; static volatile gd_t *efi_gd, *app_gd; #endif +static efi_status_t efi_uninstall_protocol + (efi_handle_t handle, const efi_guid_t *protocol, + void *protocol_interface); + /* 1 if inside U-Boot code, 0 if inside EFI payload code */ static int entry_count = 1; static int nesting_level; @@ -610,8 +614,8 @@ static efi_status_t efi_remove_all_protocols(const efi_handle_t handle) list_for_each_entry_safe(protocol, pos, &efiobj->protocols, link) { efi_status_t ret; - ret = efi_remove_protocol(handle, &protocol->guid, - protocol->protocol_interface); + ret = efi_uninstall_protocol(handle, &protocol->guid, + protocol->protocol_interface); if (ret != EFI_SUCCESS) return ret; } @@ -622,19 +626,23 @@ static efi_status_t efi_remove_all_protocols(const efi_handle_t handle) * efi_delete_handle() - delete handle * * @handle: handle to delete + * + * Return: status code */ -void efi_delete_handle(efi_handle_t handle) +efi_status_t efi_delete_handle(efi_handle_t handle) { efi_status_t ret; ret = efi_remove_all_protocols(handle); - if (ret == EFI_INVALID_PARAMETER) { - log_err("Can't remove invalid handle %p\n", handle); - return; + if (ret != EFI_SUCCESS) { + log_err("Handle %p has protocols installed. Unable to delete\n", handle); + return ret; } list_del(&handle->link); free(handle); + + return ret; } /** diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index 19e8861ef49..ed7214f3a34 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -22,16 +22,6 @@ #include #include /* U16_MAX */ -#ifdef CONFIG_BLKMAP -const efi_guid_t efi_guid_blkmap_dev = U_BOOT_BLKMAP_DEV_GUID; -#endif -#ifdef CONFIG_SANDBOX -const efi_guid_t efi_guid_host_dev = U_BOOT_HOST_DEV_GUID; -#endif -#ifdef CONFIG_VIRTIO_BLK -const efi_guid_t efi_guid_virtio_dev = U_BOOT_VIRTIO_DEV_GUID; -#endif - /* template END node: */ const struct efi_device_path END = { .type = DEVICE_PATH_TYPE_END, @@ -524,43 +514,15 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev) return dp_size(dev->parent) + sizeof(struct efi_device_path_nvme); #endif -#ifdef CONFIG_SANDBOX - case UCLASS_HOST: - /* - * Sandbox's host device will be represented - * as vendor device with extra one byte for - * device number - */ - return dp_size(dev->parent) - + sizeof(struct efi_device_path_vendor) + 1; -#endif #ifdef CONFIG_USB case UCLASS_MASS_STORAGE: return dp_size(dev->parent) + sizeof(struct efi_device_path_controller); -#endif -#ifdef CONFIG_VIRTIO_BLK - case UCLASS_VIRTIO: - /* - * Virtio devices will be represented as a vendor - * device node with an extra byte for the device - * number. - */ - return dp_size(dev->parent) - + sizeof(struct efi_device_path_vendor) + 1; -#endif -#ifdef CONFIG_BLKMAP - case UCLASS_BLKMAP: - /* - * blkmap devices will be represented as a vendor - * device node with an extra byte for the device - * number. - */ - return dp_size(dev->parent) - + sizeof(struct efi_device_path_vendor) + 1; #endif default: - return dp_size(dev->parent); + /* UCLASS_BLKMAP, UCLASS_HOST, UCLASS_VIRTIO */ + return dp_size(dev->parent) + + sizeof(struct efi_device_path_udevice); } #if defined(CONFIG_MMC) case UCLASS_MMC: @@ -586,14 +548,19 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev) */ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) { + enum uclass_id uclass_id; + if (!dev || !dev->driver) return buf; - switch (device_get_uclass_id(dev)) { + uclass_id = device_get_uclass_id(dev); + if (uclass_id != UCLASS_ROOT) + buf = dp_fill(buf, dev->parent); + + switch (uclass_id) { #ifdef CONFIG_NETDEVICES case UCLASS_ETH: { - struct efi_device_path_mac_addr *dp = - dp_fill(buf, dev->parent); + struct efi_device_path_mac_addr *dp = buf; struct eth_pdata *pdata = dev_get_plat(dev); dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; @@ -608,57 +575,10 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) } #endif case UCLASS_BLK: - switch (dev->parent->uclass->uc_drv->id) { -#ifdef CONFIG_BLKMAP - case UCLASS_BLKMAP: { - struct efi_device_path_vendor *dp; - struct blk_desc *desc = dev_get_uclass_plat(dev); - - dp = dp_fill(buf, dev->parent); - dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; - dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR; - dp->dp.length = sizeof(*dp) + 1; - memcpy(&dp->guid, &efi_guid_blkmap_dev, - sizeof(efi_guid_t)); - dp->vendor_data[0] = desc->devnum; - return &dp->vendor_data[1]; - } -#endif -#ifdef CONFIG_SANDBOX - case UCLASS_HOST: { - /* stop traversing parents at this point: */ - struct efi_device_path_vendor *dp; - struct blk_desc *desc = dev_get_uclass_plat(dev); - - dp = dp_fill(buf, dev->parent); - dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; - dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR; - dp->dp.length = sizeof(*dp) + 1; - memcpy(&dp->guid, &efi_guid_host_dev, - sizeof(efi_guid_t)); - dp->vendor_data[0] = desc->devnum; - return &dp->vendor_data[1]; - } -#endif -#ifdef CONFIG_VIRTIO_BLK - case UCLASS_VIRTIO: { - struct efi_device_path_vendor *dp; - struct blk_desc *desc = dev_get_uclass_plat(dev); - - dp = dp_fill(buf, dev->parent); - dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; - dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR; - dp->dp.length = sizeof(*dp) + 1; - memcpy(&dp->guid, &efi_guid_virtio_dev, - sizeof(efi_guid_t)); - dp->vendor_data[0] = desc->devnum; - return &dp->vendor_data[1]; - } -#endif + switch (device_get_uclass_id(dev->parent)) { #ifdef CONFIG_IDE case UCLASS_IDE: { - struct efi_device_path_atapi *dp = - dp_fill(buf, dev->parent); + struct efi_device_path_atapi *dp = buf; struct blk_desc *desc = dev_get_uclass_plat(dev); dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; @@ -674,8 +594,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) #endif #if defined(CONFIG_SCSI) case UCLASS_SCSI: { - struct efi_device_path_scsi *dp = - dp_fill(buf, dev->parent); + struct efi_device_path_scsi *dp = buf; struct blk_desc *desc = dev_get_uclass_plat(dev); dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; @@ -688,8 +607,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) #endif #if defined(CONFIG_MMC) case UCLASS_MMC: { - struct efi_device_path_sd_mmc_path *sddp = - dp_fill(buf, dev->parent); + struct efi_device_path_sd_mmc_path *sddp = buf; struct blk_desc *desc = dev_get_uclass_plat(dev); sddp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; @@ -703,8 +621,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) #endif #if defined(CONFIG_AHCI) || defined(CONFIG_SATA) case UCLASS_AHCI: { - struct efi_device_path_sata *dp = - dp_fill(buf, dev->parent); + struct efi_device_path_sata *dp = buf; struct blk_desc *desc = dev_get_uclass_plat(dev); dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; @@ -719,8 +636,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) #endif #if defined(CONFIG_NVME) case UCLASS_NVME: { - struct efi_device_path_nvme *dp = - dp_fill(buf, dev->parent); + struct efi_device_path_nvme *dp = buf; u32 ns_id; dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; @@ -734,8 +650,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) #if defined(CONFIG_USB) case UCLASS_MASS_STORAGE: { struct blk_desc *desc = dev_get_uclass_plat(dev); - struct efi_device_path_controller *dp = - dp_fill(buf, dev->parent); + struct efi_device_path_controller *dp = buf; dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_CONTROLLER; @@ -744,16 +659,26 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) return &dp[1]; } #endif - default: - debug("%s(%u) %s: unhandled parent class: %s (%u)\n", - __FILE__, __LINE__, __func__, - dev->name, dev->parent->uclass->uc_drv->id); - return dp_fill(buf, dev->parent); + default: { + /* UCLASS_BLKMAP, UCLASS_HOST, UCLASS_VIRTIO */ + struct efi_device_path_udevice *dp = buf; + struct blk_desc *desc = dev_get_uclass_plat(dev); + + dp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; + dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR; + dp->dp.length = sizeof(*dp); + memcpy(&dp->guid, &efi_u_boot_guid, + sizeof(efi_guid_t)); + dp->uclass_id = (UCLASS_BLK & 0xffff) | + (desc->uclass_id << 16); + dp->dev_number = desc->devnum; + + return &dp[1]; } + } #if defined(CONFIG_MMC) case UCLASS_MMC: { - struct efi_device_path_sd_mmc_path *sddp = - dp_fill(buf, dev->parent); + struct efi_device_path_sd_mmc_path *sddp = buf; struct mmc *mmc = mmc_get_mmc_dev(dev); struct blk_desc *desc = mmc_get_blk_desc(mmc); @@ -769,7 +694,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) #endif case UCLASS_MASS_STORAGE: case UCLASS_USB_HUB: { - struct efi_device_path_usb *udp = dp_fill(buf, dev->parent); + struct efi_device_path_usb *udp = buf; switch (device_get_uclass_id(dev->parent)) { case UCLASS_USB_HUB: { @@ -789,13 +714,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev) return &udp[1]; } default: { - struct efi_device_path_udevice *vdp; - enum uclass_id uclass_id = device_get_uclass_id(dev); - - if (uclass_id == UCLASS_ROOT) - vdp = buf; - else - vdp = dp_fill(buf, dev->parent); + struct efi_device_path_udevice *vdp = buf; vdp->dp.type = DEVICE_PATH_TYPE_HARDWARE_DEVICE; vdp->dp.sub_type = DEVICE_PATH_SUB_TYPE_VENDOR; diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 28c8cdf7100..46cb5704a72 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -708,6 +708,7 @@ int efi_disk_remove(void *ctx, struct event *event) efi_handle_t handle; struct blk_desc *desc; struct efi_disk_obj *diskobj = NULL; + efi_status_t ret; if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle)) return 0; @@ -727,10 +728,14 @@ int efi_disk_remove(void *ctx, struct event *event) return 0; } + ret = efi_delete_handle(handle); + /* Do not delete DM device if there are still EFI drivers attached. */ + if (ret != EFI_SUCCESS) + return -1; + if (diskobj) efi_free_pool(diskobj->dp); - efi_delete_handle(handle); dev_tag_del(dev, DM_TAG_EFI); return 0; diff --git a/lib/efi_loader/efi_load_options.c b/lib/efi_loader/efi_load_options.c index 3cfddee014e..5f62184da1c 100644 --- a/lib/efi_loader/efi_load_options.c +++ b/lib/efi_loader/efi_load_options.c @@ -31,10 +31,10 @@ efi_status_t efi_set_load_options(efi_handle_t handle, efi_status_t ret; ret = efi_search_protocol(handle, &efi_guid_loaded_image, &handler); - loaded_image_info = handler->protocol_interface; if (ret != EFI_SUCCESS) return EFI_INVALID_PARAMETER; + loaded_image_info = handler->protocol_interface; loaded_image_info->load_options = load_options; loaded_image_info->load_options_size = load_options_size;