Neha Malcom Francis | 507be12 | 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 | |
Nishanth Menon | eaa39c6 | 2023-11-01 15:56:03 -0500 | [diff] [blame] | 25 | More info can be found in TRM: https://www.ti.com/lit/pdf/spruid7 |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 26 | |
Nishanth Menon | 4981d9a | 2023-07-27 13:59:00 -0500 | [diff] [blame] | 27 | Platform information: |
| 28 | |
| 29 | * https://www.ti.com/tool/TMDX654GPEVM |
| 30 | |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 31 | Boot Flow: |
| 32 | ---------- |
| 33 | On AM65x family devices, ROM supports boot only via MCU(R5). This means that |
| 34 | bootloader has to run on R5 core. In order to meet this constraint, and for |
| 35 | the following reasons the boot flow is designed as mentioned: |
| 36 | |
| 37 | 1. Need to move away from R5 asap, so that we want to start *any* |
| 38 | firmware on the R5 cores for example autosar can be loaded to receive CAN |
| 39 | response and other safety operations to be started. This operation is |
| 40 | very time critical and is applicable for all automotive use cases. |
| 41 | |
| 42 | 2. U-Boot on A53 should start other remotecores for various |
| 43 | applications. This should happen before running Linux. |
| 44 | |
| 45 | 3. In production boot flow, we might not like to use full U-Boot, |
| 46 | instead use Falcon boot flow to reduce boot time. |
| 47 | |
Nishanth Menon | d683f50 | 2023-07-27 13:58:46 -0500 | [diff] [blame] | 48 | .. image:: img/boot_diagram_am65.svg |
Heinrich Schuchardt | 529aed0 | 2023-08-22 11:40:59 -0500 | [diff] [blame] | 49 | :alt: Boot flow diagram |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 50 | |
| 51 | - Here DMSC acts as master and provides all the critical services. R5/A53 |
| 52 | requests DMSC to get these services done as shown in the above diagram. |
| 53 | |
| 54 | Sources: |
| 55 | -------- |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 56 | |
Nishanth Menon | ee91e48 | 2023-07-27 13:58:44 -0500 | [diff] [blame] | 57 | .. include:: k3.rst |
| 58 | :start-after: .. k3_rst_include_start_boot_sources |
| 59 | :end-before: .. k3_rst_include_end_boot_sources |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 60 | |
| 61 | Build procedure: |
| 62 | ---------------- |
Nishanth Menon | b7ee22f | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 63 | 0. Setup the environment variables: |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 64 | |
Nishanth Menon | b7ee22f | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 65 | .. include:: k3.rst |
| 66 | :start-after: .. k3_rst_include_start_common_env_vars_desc |
| 67 | :end-before: .. k3_rst_include_end_common_env_vars_desc |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 68 | |
Nishanth Menon | b7ee22f | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 69 | .. include:: k3.rst |
| 70 | :start-after: .. k3_rst_include_start_board_env_vars_desc |
| 71 | :end-before: .. k3_rst_include_end_board_env_vars_desc |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 72 | |
Nishanth Menon | b7ee22f | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 73 | Set the variables corresponding to this platform: |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 74 | |
Nishanth Menon | b7ee22f | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 75 | .. include:: k3.rst |
| 76 | :start-after: .. k3_rst_include_start_common_env_vars_defn |
| 77 | :end-before: .. k3_rst_include_end_common_env_vars_defn |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 78 | .. prompt:: bash $ |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 79 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 80 | export UBOOT_CFG_CORTEXR=am65x_evm_r5_defconfig |
| 81 | export UBOOT_CFG_CORTEXA=am65x_evm_a53_defconfig |
| 82 | export TFA_BOARD=generic |
| 83 | # we dont use any extra TFA parameters |
| 84 | unset TFA_EXTRA_ARGS |
| 85 | export OPTEE_PLATFORM=k3-am65x |
| 86 | # we dont use any extra OP-TEE parameters |
| 87 | unset OPTEE_EXTRA_ARGS |
Nishanth Menon | b7ee22f | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 88 | |
| 89 | .. am65x_evm_rst_include_start_build_steps |
| 90 | |
| 91 | 1. Trusted Firmware-A: |
| 92 | |
| 93 | .. include:: k3.rst |
| 94 | :start-after: .. k3_rst_include_start_build_steps_tfa |
| 95 | :end-before: .. k3_rst_include_end_build_steps_tfa |
| 96 | |
| 97 | |
| 98 | 2. OP-TEE: |
| 99 | |
| 100 | .. include:: k3.rst |
| 101 | :start-after: .. k3_rst_include_start_build_steps_optee |
| 102 | :end-before: .. k3_rst_include_end_build_steps_optee |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 103 | |
| 104 | 3. U-Boot: |
| 105 | |
Nishanth Menon | d14cec5 | 2023-08-22 11:41:04 -0500 | [diff] [blame] | 106 | * 3.1 R5: |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 107 | |
Nishanth Menon | b7ee22f | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 108 | .. include:: k3.rst |
| 109 | :start-after: .. k3_rst_include_start_build_steps_spl_r5 |
| 110 | :end-before: .. k3_rst_include_end_build_steps_spl_r5 |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 111 | |
Nishanth Menon | d14cec5 | 2023-08-22 11:41:04 -0500 | [diff] [blame] | 112 | * 3.2 A53: |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 113 | |
Nishanth Menon | b7ee22f | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 114 | .. include:: k3.rst |
| 115 | :start-after: .. k3_rst_include_start_build_steps_uboot |
| 116 | :end-before: .. k3_rst_include_end_build_steps_uboot |
| 117 | .. am65x_evm_rst_include_end_build_steps |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 118 | |
| 119 | Target Images |
Heinrich Schuchardt | b72160b | 2023-10-28 11:59:32 +0200 | [diff] [blame] | 120 | ------------- |
| 121 | |
Tom Rini | fdf4503 | 2023-07-25 12:44:16 -0400 | [diff] [blame] | 122 | In order to boot we need tiboot3.bin, sysfw.itb, tispl.bin and u-boot.img. |
| 123 | Each SoC variant (GP and HS) requires a different source for these files. |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 124 | |
| 125 | - GP |
| 126 | |
Nishanth Menon | d14cec5 | 2023-08-22 11:41:04 -0500 | [diff] [blame] | 127 | * tiboot3-am65x_sr2-gp-evm.bin, sysfw-am65x_sr2-gp-evm.itb from step 3.1 |
| 128 | * tispl.bin_unsigned, u-boot.img_unsigned from step 3.2 |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 129 | |
| 130 | - HS |
| 131 | |
Nishanth Menon | d14cec5 | 2023-08-22 11:41:04 -0500 | [diff] [blame] | 132 | * tiboot3-am65x_sr2-hs-evm.bin, sysfw-am65x_sr2-hs-evm.itb from step 3.1 |
| 133 | * tispl.bin, u-boot.img from step 3.2 |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 134 | |
| 135 | Image formats: |
| 136 | -------------- |
| 137 | |
Nishanth Menon | 9183494 | 2023-07-27 13:58:51 -0500 | [diff] [blame] | 138 | - tiboot3.bin |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 139 | |
Nishanth Menon | 9183494 | 2023-07-27 13:58:51 -0500 | [diff] [blame] | 140 | .. image:: img/no_multi_cert_tiboot3.bin.svg |
Heinrich Schuchardt | 529aed0 | 2023-08-22 11:40:59 -0500 | [diff] [blame] | 141 | :alt: tiboot3.bin image format |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 142 | |
| 143 | - tispl.bin |
| 144 | |
Nishanth Menon | 9183494 | 2023-07-27 13:58:51 -0500 | [diff] [blame] | 145 | .. image:: img/nodm_tispl.bin.svg |
Heinrich Schuchardt | 529aed0 | 2023-08-22 11:40:59 -0500 | [diff] [blame] | 146 | :alt: tispl.bin image format |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 147 | |
| 148 | - sysfw.itb |
| 149 | |
Nishanth Menon | 9183494 | 2023-07-27 13:58:51 -0500 | [diff] [blame] | 150 | .. image:: img/sysfw.itb.svg |
Heinrich Schuchardt | 529aed0 | 2023-08-22 11:40:59 -0500 | [diff] [blame] | 151 | :alt: sysfw.itb image format |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 152 | |
| 153 | eMMC: |
| 154 | ----- |
| 155 | ROM supports booting from eMMC from boot0 partition offset 0x0 |
| 156 | |
| 157 | Flashing images to eMMC: |
| 158 | |
| 159 | The following commands can be used to download tiboot3.bin, tispl.bin, |
| 160 | u-boot.img, and sysfw.itb from an SD card and write them to the eMMC boot0 |
| 161 | partition at respective addresses. |
| 162 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 163 | .. prompt:: bash => |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 164 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 165 | mmc dev 0 1 |
| 166 | fatload mmc 1 ${loadaddr} tiboot3.bin |
| 167 | mmc write ${loadaddr} 0x0 0x400 |
| 168 | fatload mmc 1 ${loadaddr} tispl.bin |
| 169 | mmc write ${loadaddr} 0x400 0x1000 |
| 170 | fatload mmc 1 ${loadaddr} u-boot.img |
| 171 | mmc write ${loadaddr} 0x1400 0x2000 |
| 172 | fatload mmc 1 ${loadaddr} sysfw.itb |
| 173 | mmc write ${loadaddr} 0x3600 0x800 |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 174 | |
| 175 | To give the ROM access to the boot partition, the following commands must be |
| 176 | used for the first time: |
| 177 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 178 | .. prompt:: bash => |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 179 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 180 | mmc partconf 0 1 1 1 |
| 181 | mmc bootbus 0 1 0 0 |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 182 | |
| 183 | To create a software partition for the rootfs, the following command can be |
| 184 | used: |
| 185 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 186 | .. prompt:: bash => |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 187 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 188 | gpt write mmc 0 ${partitions} |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 189 | |
| 190 | eMMC layout: |
| 191 | |
Nishanth Menon | ef930a7 | 2023-07-27 13:58:58 -0500 | [diff] [blame] | 192 | .. image:: img/emmc_am65x_evm_boot0.svg |
Heinrich Schuchardt | 529aed0 | 2023-08-22 11:40:59 -0500 | [diff] [blame] | 193 | :alt: emmc boot partition layout |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 194 | |
| 195 | Kernel image and DT are expected to be present in the /boot folder of rootfs. |
| 196 | To boot kernel from eMMC, use the following commands: |
| 197 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 198 | .. prompt:: bash => |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 199 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 200 | setenv mmcdev 0 |
| 201 | setenv bootpart 0 |
| 202 | boot |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 203 | |
| 204 | OSPI: |
| 205 | ----- |
| 206 | ROM supports booting from OSPI from offset 0x0. |
| 207 | |
| 208 | Flashing images to OSPI: |
| 209 | |
| 210 | Below commands can be used to download tiboot3.bin, tispl.bin, u-boot.img, |
| 211 | and sysfw.itb over tftp and then flash those to OSPI at their respective |
| 212 | addresses. |
| 213 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 214 | .. prompt:: bash => |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 215 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 216 | sf probe |
| 217 | tftp ${loadaddr} tiboot3.bin |
| 218 | sf update $loadaddr 0x0 $filesize |
| 219 | tftp ${loadaddr} tispl.bin |
| 220 | sf update $loadaddr 0x80000 $filesize |
| 221 | tftp ${loadaddr} u-boot.img |
| 222 | sf update $loadaddr 0x280000 $filesize |
| 223 | tftp ${loadaddr} sysfw.itb |
| 224 | sf update $loadaddr 0x6C0000 $filesize |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 225 | |
| 226 | Flash layout for OSPI: |
| 227 | |
Nishanth Menon | 2bb20e4 | 2023-07-27 13:58:57 -0500 | [diff] [blame] | 228 | .. image:: img/ospi_sysfw.svg |
Heinrich Schuchardt | 529aed0 | 2023-08-22 11:40:59 -0500 | [diff] [blame] | 229 | :alt: OSPI flash partition layout |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 230 | |
| 231 | Kernel Image and DT are expected to be present in the /boot folder of UBIFS |
| 232 | ospi.rootfs just like in SD card case. U-Boot looks for UBI volume named |
| 233 | "rootfs" for rootfs. |
| 234 | |
| 235 | To boot kernel from OSPI, at the U-Boot prompt: |
| 236 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 237 | .. prompt:: bash => |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 238 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 239 | setenv boot ubi |
| 240 | boot |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 241 | |
| 242 | UART: |
| 243 | ----- |
| 244 | ROM supports booting from MCU_UART0 via X-Modem protocol. The entire UART-based |
| 245 | boot process up to U-Boot (proper) prompt goes through different stages and uses |
| 246 | different UART peripherals as follows: |
| 247 | |
Nishanth Menon | f020680 | 2023-07-27 13:58:56 -0500 | [diff] [blame] | 248 | .. list-table:: ROM UART Boot Responsibilities |
| 249 | :widths: 16 16 16 16 |
| 250 | :header-rows: 1 |
| 251 | |
| 252 | * - Who |
| 253 | - Loading What |
| 254 | - Hardware Module |
| 255 | - Protocol |
| 256 | |
| 257 | * - Boot ROM |
| 258 | - tiboot3.bin |
| 259 | - MCU_UART0 |
| 260 | - X-Modem(*) |
| 261 | |
| 262 | * - R5 SPL |
| 263 | - sysfw.itb |
| 264 | - MCU_UART0 |
| 265 | - Y-Modem(*) |
| 266 | |
| 267 | * - R5 SPL |
| 268 | - tispl.bin |
| 269 | - MAIN_UART0 |
| 270 | - Y-Modem |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 271 | |
Nishanth Menon | f020680 | 2023-07-27 13:58:56 -0500 | [diff] [blame] | 272 | * - A53 SPL |
| 273 | - u-boot.img |
| 274 | - MAIN_UART0 |
| 275 | - Y-Modem |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 276 | |
| 277 | Note that in addition to X/Y-Modem related protocol timeouts the DMSC |
| 278 | watchdog timeout of 3min (typ.) needs to be observed until System Firmware |
| 279 | is fully loaded (from sysfw.itb) and started. |
| 280 | |
| 281 | Example bash script sequence for running on a Linux host PC feeding all boot |
| 282 | artifacts needed to the device: |
| 283 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 284 | .. prompt:: bash $ |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 285 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 286 | MCU_DEV=/dev/ttyUSB1 |
| 287 | MAIN_DEV=/dev/ttyUSB0 |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 288 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 289 | stty -F $MCU_DEV 115200 cs8 -cstopb -parenb |
| 290 | stty -F $MAIN_DEV 115200 cs8 -cstopb -parenb |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 291 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 292 | sb --xmodem tiboot3.bin > $MCU_DEV < $MCU_DEV |
| 293 | sb --ymodem sysfw.itb > $MCU_DEV < $MCU_DEV |
| 294 | sb --ymodem tispl.bin > $MAIN_DEV < $MAIN_DEV |
| 295 | sleep 1 |
| 296 | sb --xmodem u-boot.img > $MAIN_DEV < $MAIN_DEV |
Jason Kacines | b0fdee9 | 2023-08-03 01:29:22 -0500 | [diff] [blame] | 297 | |
| 298 | Debugging U-Boot |
| 299 | ---------------- |
| 300 | |
| 301 | See :ref:`Common Debugging environment - OpenOCD<k3_rst_refer_openocd>`: for |
| 302 | detailed setup information. |
| 303 | |
| 304 | .. warning:: |
| 305 | |
| 306 | **OpenOCD support since**: v0.12.0 |
| 307 | |
| 308 | If the default package version of OpenOCD in your development |
| 309 | environment's distribution needs to be updated, it might be necessary to |
| 310 | build OpenOCD from the source. |
| 311 | |
| 312 | .. include:: k3.rst |
| 313 | :start-after: .. k3_rst_include_start_openocd_connect_XDS110 |
| 314 | :end-before: .. k3_rst_include_end_openocd_connect_XDS110 |
| 315 | |
| 316 | To start OpenOCD and connect to the board |
| 317 | |
Nishanth Menon | fdd7cb7 | 2023-11-02 23:40:26 -0500 | [diff] [blame] | 318 | .. prompt:: bash $ |
Jason Kacines | b0fdee9 | 2023-08-03 01:29:22 -0500 | [diff] [blame] | 319 | |
| 320 | openocd -f board/ti_am654evm.cfg |