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 | |
| 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 | d683f50 | 2023-07-27 13:58:46 -0500 | [diff] [blame] | 44 | .. image:: img/boot_diagram_am65.svg |
Neha Malcom Francis | 507be12 | 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 | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 51 | |
Nishanth Menon | ee91e48 | 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 | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 55 | |
| 56 | Build procedure: |
| 57 | ---------------- |
Nishanth Menon | b7ee22f | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 58 | 0. Setup the environment variables: |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 59 | |
Nishanth Menon | b7ee22f | 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 |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 63 | |
Nishanth Menon | b7ee22f | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 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 |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 67 | |
Nishanth Menon | b7ee22f | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 68 | Set the variables corresponding to this platform: |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 69 | |
Nishanth Menon | b7ee22f | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 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 | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 73 | .. code-block:: bash |
| 74 | |
Nishanth Menon | b7ee22f | 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 | |
| 92 | |
| 93 | 2. OP-TEE: |
| 94 | |
| 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 | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 98 | |
| 99 | 3. U-Boot: |
| 100 | |
| 101 | * 4.1 R5: |
| 102 | |
Nishanth Menon | b7ee22f | 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 | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 106 | |
| 107 | * 4.2 A53: |
| 108 | |
Nishanth Menon | b7ee22f | 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 | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 113 | |
| 114 | Target Images |
| 115 | -------------- |
Tom Rini | fdf4503 | 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 | 507be12 | 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 | 9183494 | 2023-07-27 13:58:51 -0500 | [diff] [blame] | 132 | - tiboot3.bin |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 133 | |
Nishanth Menon | 9183494 | 2023-07-27 13:58:51 -0500 | [diff] [blame] | 134 | .. image:: img/no_multi_cert_tiboot3.bin.svg |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 135 | |
| 136 | - tispl.bin |
| 137 | |
Nishanth Menon | 9183494 | 2023-07-27 13:58:51 -0500 | [diff] [blame] | 138 | .. image:: img/nodm_tispl.bin.svg |
Neha Malcom Francis | 507be12 | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 139 | |
| 140 | - sysfw.itb |
| 141 | |
Nishanth Menon | 9183494 | 2023-07-27 13:58:51 -0500 | [diff] [blame] | 142 | .. image:: img/sysfw.itb.svg |
Neha Malcom Francis | 507be12 | 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 | |
| 183 | .. code-block:: text |
| 184 | |
| 185 | boot0 partition (8 MB) user partition |
| 186 | 0x0+----------------------------------+ 0x0+-------------------------+ |
| 187 | | tiboot3.bin (512 KB) | | | |
| 188 | 0x400+----------------------------------+ | | |
| 189 | | tispl.bin (2 MB) | | | |
| 190 | 0x1400+----------------------------------+ | rootfs | |
| 191 | | u-boot.img (4 MB) | | | |
| 192 | 0x3400+----------------------------------+ | | |
| 193 | | environment (128 KB) | | | |
| 194 | 0x3500+----------------------------------+ | | |
| 195 | | backup environment (128 KB) | | | |
| 196 | 0x3600+----------------------------------+ | | |
| 197 | | sysfw (1 MB) | | | |
| 198 | 0x3E00+----------------------------------+ +-------------------------+ |
| 199 | |
| 200 | Kernel image and DT are expected to be present in the /boot folder of rootfs. |
| 201 | To boot kernel from eMMC, use the following commands: |
| 202 | |
| 203 | .. code-block:: text |
| 204 | |
| 205 | => setenv mmcdev 0 |
| 206 | => setenv bootpart 0 |
| 207 | => boot |
| 208 | |
| 209 | OSPI: |
| 210 | ----- |
| 211 | ROM supports booting from OSPI from offset 0x0. |
| 212 | |
| 213 | Flashing images to OSPI: |
| 214 | |
| 215 | Below commands can be used to download tiboot3.bin, tispl.bin, u-boot.img, |
| 216 | and sysfw.itb over tftp and then flash those to OSPI at their respective |
| 217 | addresses. |
| 218 | |
| 219 | .. code-block:: text |
| 220 | |
| 221 | => sf probe |
| 222 | => tftp ${loadaddr} tiboot3.bin |
| 223 | => sf update $loadaddr 0x0 $filesize |
| 224 | => tftp ${loadaddr} tispl.bin |
| 225 | => sf update $loadaddr 0x80000 $filesize |
| 226 | => tftp ${loadaddr} u-boot.img |
| 227 | => sf update $loadaddr 0x280000 $filesize |
| 228 | => tftp ${loadaddr} sysfw.itb |
| 229 | => sf update $loadaddr 0x6C0000 $filesize |
| 230 | |
| 231 | Flash layout for OSPI: |
| 232 | |
| 233 | .. code-block:: text |
| 234 | |
| 235 | 0x0 +----------------------------+ |
| 236 | | ospi.tiboot3(512K) | |
| 237 | | | |
| 238 | 0x80000 +----------------------------+ |
| 239 | | ospi.tispl(2M) | |
| 240 | | | |
| 241 | 0x280000 +----------------------------+ |
| 242 | | ospi.u-boot(4M) | |
| 243 | | | |
| 244 | 0x680000 +----------------------------+ |
| 245 | | ospi.env(128K) | |
| 246 | | | |
| 247 | 0x6A0000 +----------------------------+ |
| 248 | | ospi.env.backup (128K) | |
| 249 | | | |
| 250 | 0x6C0000 +----------------------------+ |
| 251 | | ospi.sysfw(1M) | |
| 252 | | | |
| 253 | 0x7C0000 +----------------------------+ |
| 254 | | padding (256k) | |
| 255 | 0x800000 +----------------------------+ |
| 256 | | ospi.rootfs(UBIFS) | |
| 257 | | | |
| 258 | +----------------------------+ |
| 259 | |
| 260 | Kernel Image and DT are expected to be present in the /boot folder of UBIFS |
| 261 | ospi.rootfs just like in SD card case. U-Boot looks for UBI volume named |
| 262 | "rootfs" for rootfs. |
| 263 | |
| 264 | To boot kernel from OSPI, at the U-Boot prompt: |
| 265 | |
| 266 | .. code-block:: text |
| 267 | |
| 268 | => setenv boot ubi |
| 269 | => boot |
| 270 | |
| 271 | UART: |
| 272 | ----- |
| 273 | ROM supports booting from MCU_UART0 via X-Modem protocol. The entire UART-based |
| 274 | boot process up to U-Boot (proper) prompt goes through different stages and uses |
| 275 | different UART peripherals as follows: |
| 276 | |
| 277 | .. code-block:: text |
| 278 | |
| 279 | +---------+---------------+-------------+------------+ |
| 280 | | WHO | Loading WHAT | HW Module | Protocol | |
| 281 | +---------+---------------+-------------+------------+ |
| 282 | |Boot ROM | tiboot3.bin | MCU_UART0 | X-Modem(*)| |
| 283 | |R5 SPL | sysfw.itb | MCU_UART0 | Y-Modem(*)| |
| 284 | |R5 SPL | tispl.bin | MAIN_UART0 | Y-Modem | |
| 285 | |A53 SPL | u-boot.img | MAIN_UART0 | Y-Modem | |
| 286 | +---------+---------------+-------------+------------+ |
| 287 | |
| 288 | Note that in addition to X/Y-Modem related protocol timeouts the DMSC |
| 289 | watchdog timeout of 3min (typ.) needs to be observed until System Firmware |
| 290 | is fully loaded (from sysfw.itb) and started. |
| 291 | |
| 292 | Example bash script sequence for running on a Linux host PC feeding all boot |
| 293 | artifacts needed to the device: |
| 294 | |
| 295 | .. code-block:: text |
| 296 | |
| 297 | MCU_DEV=/dev/ttyUSB1 |
| 298 | MAIN_DEV=/dev/ttyUSB0 |
| 299 | |
| 300 | stty -F $MCU_DEV 115200 cs8 -cstopb -parenb |
| 301 | stty -F $MAIN_DEV 115200 cs8 -cstopb -parenb |
| 302 | |
| 303 | sb --xmodem tiboot3.bin > $MCU_DEV < $MCU_DEV |
| 304 | sb --ymodem sysfw.itb > $MCU_DEV < $MCU_DEV |
| 305 | sb --ymodem tispl.bin > $MAIN_DEV < $MAIN_DEV |
| 306 | sleep 1 |
| 307 | sb --xmodem u-boot.img > $MAIN_DEV < $MAIN_DEV |