Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause |
| 2 | .. sectionauthor:: Neha Francis <n-francis@ti.com> |
| 3 | |
| 4 | AM65x Platforms |
| 5 | =============== |
| 6 | |
| 7 | Introduction: |
| 8 | ------------- |
| 9 | The AM65x family of SoCs is the first device family from K3 Multicore |
| 10 | SoC architecture, targeted for broad market and industrial control with |
| 11 | aim to meet the complex processing needs of modern embedded products. |
| 12 | |
| 13 | The device is built over three domains, each containing specific processing |
| 14 | cores, voltage domains and peripherals: |
| 15 | |
| 16 | 1. Wake-up (WKUP) domain: |
| 17 | * Device Management and Security Controller (DMSC) |
| 18 | |
| 19 | 2. Microcontroller (MCU) domain: |
| 20 | * Dual Core ARM Cortex-R5F processor |
| 21 | |
| 22 | 3. MAIN domain: |
| 23 | * Quad core 64-bit ARM Cortex-A53 |
| 24 | |
| 25 | More info can be found in TRM: http://www.ti.com/lit/pdf/spruid7 |
| 26 | |
| 27 | Boot Flow: |
| 28 | ---------- |
| 29 | On AM65x family devices, ROM supports boot only via MCU(R5). This means that |
| 30 | bootloader has to run on R5 core. In order to meet this constraint, and for |
| 31 | the following reasons the boot flow is designed as mentioned: |
| 32 | |
| 33 | 1. Need to move away from R5 asap, so that we want to start *any* |
| 34 | firmware on the R5 cores for example autosar can be loaded to receive CAN |
| 35 | response and other safety operations to be started. This operation is |
| 36 | very time critical and is applicable for all automotive use cases. |
| 37 | |
| 38 | 2. U-Boot on A53 should start other remotecores for various |
| 39 | applications. This should happen before running Linux. |
| 40 | |
| 41 | 3. In production boot flow, we might not like to use full U-Boot, |
| 42 | instead use Falcon boot flow to reduce boot time. |
| 43 | |
Nishanth Menon | fd35812 | 2023-07-27 13:58:46 -0500 | [diff] [blame] | 44 | .. image:: img/boot_diagram_am65.svg |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 45 | |
| 46 | - Here DMSC acts as master and provides all the critical services. R5/A53 |
| 47 | requests DMSC to get these services done as shown in the above diagram. |
| 48 | |
| 49 | Sources: |
| 50 | -------- |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 51 | |
Nishanth Menon | cce3e7a | 2023-07-27 13:58:44 -0500 | [diff] [blame] | 52 | .. include:: k3.rst |
| 53 | :start-after: .. k3_rst_include_start_boot_sources |
| 54 | :end-before: .. k3_rst_include_end_boot_sources |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 55 | |
| 56 | Build procedure: |
| 57 | ---------------- |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 58 | 0. Setup the environment variables: |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 59 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 60 | .. include:: k3.rst |
| 61 | :start-after: .. k3_rst_include_start_common_env_vars_desc |
| 62 | :end-before: .. k3_rst_include_end_common_env_vars_desc |
| 63 | |
| 64 | .. include:: k3.rst |
| 65 | :start-after: .. k3_rst_include_start_board_env_vars_desc |
| 66 | :end-before: .. k3_rst_include_end_board_env_vars_desc |
| 67 | |
| 68 | Set the variables corresponding to this platform: |
| 69 | |
| 70 | .. include:: k3.rst |
| 71 | :start-after: .. k3_rst_include_start_common_env_vars_defn |
| 72 | :end-before: .. k3_rst_include_end_common_env_vars_defn |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 73 | .. code-block:: bash |
| 74 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 75 | $ export UBOOT_CFG_CORTEXR=am65x_evm_r5_defconfig |
| 76 | $ export UBOOT_CFG_CORTEXA=am65x_evm_a53_defconfig |
| 77 | $ export TFA_BOARD=generic |
| 78 | $ # we dont use any extra TFA parameters |
| 79 | $ unset TFA_EXTRA_ARGS |
| 80 | $ export OPTEE_PLATFORM=k3-am65x |
| 81 | $ # we dont use any extra OP-TEE parameters |
| 82 | $ unset OPTEE_EXTRA_ARGS |
| 83 | |
| 84 | .. am65x_evm_rst_include_start_build_steps |
| 85 | |
| 86 | 1. Trusted Firmware-A: |
| 87 | |
| 88 | .. include:: k3.rst |
| 89 | :start-after: .. k3_rst_include_start_build_steps_tfa |
| 90 | :end-before: .. k3_rst_include_end_build_steps_tfa |
| 91 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 92 | |
| 93 | 2. OP-TEE: |
| 94 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 95 | .. include:: k3.rst |
| 96 | :start-after: .. k3_rst_include_start_build_steps_optee |
| 97 | :end-before: .. k3_rst_include_end_build_steps_optee |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 98 | |
| 99 | 3. U-Boot: |
| 100 | |
| 101 | * 4.1 R5: |
| 102 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 103 | .. include:: k3.rst |
| 104 | :start-after: .. k3_rst_include_start_build_steps_spl_r5 |
| 105 | :end-before: .. k3_rst_include_end_build_steps_spl_r5 |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 106 | |
| 107 | * 4.2 A53: |
| 108 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 109 | .. include:: k3.rst |
| 110 | :start-after: .. k3_rst_include_start_build_steps_uboot |
| 111 | :end-before: .. k3_rst_include_end_build_steps_uboot |
| 112 | .. am65x_evm_rst_include_end_build_steps |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 113 | |
| 114 | Target Images |
| 115 | -------------- |
Tom Rini | f687c8f | 2023-07-25 12:44:16 -0400 | [diff] [blame] | 116 | In order to boot we need tiboot3.bin, sysfw.itb, tispl.bin and u-boot.img. |
| 117 | Each SoC variant (GP and HS) requires a different source for these files. |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 118 | |
| 119 | - GP |
| 120 | |
| 121 | * tiboot3-am65x_sr2-gp-evm.bin, sysfw-am65x_sr2-gp-evm.itb from step 4.1 |
| 122 | * tispl.bin_unsigned, u-boot.img_unsigned from step 4.2 |
| 123 | |
| 124 | - HS |
| 125 | |
| 126 | * tiboot3-am65x_sr2-hs-evm.bin, sysfw-am65x_sr2-hs-evm.itb from step 4.1 |
| 127 | * tispl.bin, u-boot.img from step 4.2 |
| 128 | |
| 129 | Image formats: |
| 130 | -------------- |
| 131 | |
Nishanth Menon | 654dced | 2023-07-27 13:58:51 -0500 | [diff] [blame] | 132 | - tiboot3.bin |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 133 | |
Nishanth Menon | 654dced | 2023-07-27 13:58:51 -0500 | [diff] [blame] | 134 | .. image:: img/no_multi_cert_tiboot3.bin.svg |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 135 | |
| 136 | - tispl.bin |
| 137 | |
Nishanth Menon | 654dced | 2023-07-27 13:58:51 -0500 | [diff] [blame] | 138 | .. image:: img/nodm_tispl.bin.svg |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 139 | |
| 140 | - sysfw.itb |
| 141 | |
Nishanth Menon | 654dced | 2023-07-27 13:58:51 -0500 | [diff] [blame] | 142 | .. image:: img/sysfw.itb.svg |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 143 | |
| 144 | eMMC: |
| 145 | ----- |
| 146 | ROM supports booting from eMMC from boot0 partition offset 0x0 |
| 147 | |
| 148 | Flashing images to eMMC: |
| 149 | |
| 150 | The following commands can be used to download tiboot3.bin, tispl.bin, |
| 151 | u-boot.img, and sysfw.itb from an SD card and write them to the eMMC boot0 |
| 152 | partition at respective addresses. |
| 153 | |
| 154 | .. code-block:: text |
| 155 | |
| 156 | => mmc dev 0 1 |
| 157 | => fatload mmc 1 ${loadaddr} tiboot3.bin |
| 158 | => mmc write ${loadaddr} 0x0 0x400 |
| 159 | => fatload mmc 1 ${loadaddr} tispl.bin |
| 160 | => mmc write ${loadaddr} 0x400 0x1000 |
| 161 | => fatload mmc 1 ${loadaddr} u-boot.img |
| 162 | => mmc write ${loadaddr} 0x1400 0x2000 |
| 163 | => fatload mmc 1 ${loadaddr} sysfw.itb |
| 164 | => mmc write ${loadaddr} 0x3600 0x800 |
| 165 | |
| 166 | To give the ROM access to the boot partition, the following commands must be |
| 167 | used for the first time: |
| 168 | |
| 169 | .. code-block:: text |
| 170 | |
| 171 | => mmc partconf 0 1 1 1 |
| 172 | => mmc bootbus 0 1 0 0 |
| 173 | |
| 174 | To create a software partition for the rootfs, the following command can be |
| 175 | used: |
| 176 | |
| 177 | .. code-block:: text |
| 178 | |
| 179 | => gpt write mmc 0 ${partitions} |
| 180 | |
| 181 | eMMC layout: |
| 182 | |
Nishanth Menon | e19efb1 | 2023-07-27 13:58:58 -0500 | [diff] [blame] | 183 | .. image:: img/emmc_am65x_evm_boot0.svg |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 184 | |
| 185 | Kernel image and DT are expected to be present in the /boot folder of rootfs. |
| 186 | To boot kernel from eMMC, use the following commands: |
| 187 | |
| 188 | .. code-block:: text |
| 189 | |
| 190 | => setenv mmcdev 0 |
| 191 | => setenv bootpart 0 |
| 192 | => boot |
| 193 | |
| 194 | OSPI: |
| 195 | ----- |
| 196 | ROM supports booting from OSPI from offset 0x0. |
| 197 | |
| 198 | Flashing images to OSPI: |
| 199 | |
| 200 | Below commands can be used to download tiboot3.bin, tispl.bin, u-boot.img, |
| 201 | and sysfw.itb over tftp and then flash those to OSPI at their respective |
| 202 | addresses. |
| 203 | |
| 204 | .. code-block:: text |
| 205 | |
| 206 | => sf probe |
| 207 | => tftp ${loadaddr} tiboot3.bin |
| 208 | => sf update $loadaddr 0x0 $filesize |
| 209 | => tftp ${loadaddr} tispl.bin |
| 210 | => sf update $loadaddr 0x80000 $filesize |
| 211 | => tftp ${loadaddr} u-boot.img |
| 212 | => sf update $loadaddr 0x280000 $filesize |
| 213 | => tftp ${loadaddr} sysfw.itb |
| 214 | => sf update $loadaddr 0x6C0000 $filesize |
| 215 | |
| 216 | Flash layout for OSPI: |
| 217 | |
Nishanth Menon | 757836d | 2023-07-27 13:58:57 -0500 | [diff] [blame] | 218 | .. image:: img/ospi_sysfw.svg |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 219 | |
| 220 | Kernel Image and DT are expected to be present in the /boot folder of UBIFS |
| 221 | ospi.rootfs just like in SD card case. U-Boot looks for UBI volume named |
| 222 | "rootfs" for rootfs. |
| 223 | |
| 224 | To boot kernel from OSPI, at the U-Boot prompt: |
| 225 | |
| 226 | .. code-block:: text |
| 227 | |
| 228 | => setenv boot ubi |
| 229 | => boot |
| 230 | |
| 231 | UART: |
| 232 | ----- |
| 233 | ROM supports booting from MCU_UART0 via X-Modem protocol. The entire UART-based |
| 234 | boot process up to U-Boot (proper) prompt goes through different stages and uses |
| 235 | different UART peripherals as follows: |
| 236 | |
Nishanth Menon | fc5b2b8 | 2023-07-27 13:58:56 -0500 | [diff] [blame] | 237 | .. list-table:: ROM UART Boot Responsibilities |
| 238 | :widths: 16 16 16 16 |
| 239 | :header-rows: 1 |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 240 | |
Nishanth Menon | fc5b2b8 | 2023-07-27 13:58:56 -0500 | [diff] [blame] | 241 | * - Who |
| 242 | - Loading What |
| 243 | - Hardware Module |
| 244 | - Protocol |
| 245 | |
| 246 | * - Boot ROM |
| 247 | - tiboot3.bin |
| 248 | - MCU_UART0 |
| 249 | - X-Modem(*) |
| 250 | |
| 251 | * - R5 SPL |
| 252 | - sysfw.itb |
| 253 | - MCU_UART0 |
| 254 | - Y-Modem(*) |
| 255 | |
| 256 | * - R5 SPL |
| 257 | - tispl.bin |
| 258 | - MAIN_UART0 |
| 259 | - Y-Modem |
| 260 | |
| 261 | * - A53 SPL |
| 262 | - u-boot.img |
| 263 | - MAIN_UART0 |
| 264 | - Y-Modem |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 265 | |
| 266 | Note that in addition to X/Y-Modem related protocol timeouts the DMSC |
| 267 | watchdog timeout of 3min (typ.) needs to be observed until System Firmware |
| 268 | is fully loaded (from sysfw.itb) and started. |
| 269 | |
| 270 | Example bash script sequence for running on a Linux host PC feeding all boot |
| 271 | artifacts needed to the device: |
| 272 | |
| 273 | .. code-block:: text |
| 274 | |
| 275 | MCU_DEV=/dev/ttyUSB1 |
| 276 | MAIN_DEV=/dev/ttyUSB0 |
| 277 | |
| 278 | stty -F $MCU_DEV 115200 cs8 -cstopb -parenb |
| 279 | stty -F $MAIN_DEV 115200 cs8 -cstopb -parenb |
| 280 | |
| 281 | sb --xmodem tiboot3.bin > $MCU_DEV < $MCU_DEV |
| 282 | sb --ymodem sysfw.itb > $MCU_DEV < $MCU_DEV |
| 283 | sb --ymodem tispl.bin > $MAIN_DEV < $MAIN_DEV |
| 284 | sleep 1 |
| 285 | sb --xmodem u-boot.img > $MAIN_DEV < $MAIN_DEV |