Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause |
| 2 | .. sectionauthor:: Bryan Brattlof <bb@ti.com> |
| 3 | |
| 4 | K3 Generation |
| 5 | ============= |
| 6 | |
| 7 | Summary |
| 8 | ------- |
| 9 | |
| 10 | Texas Instrument's K3 family of SoCs utilize a heterogeneous multicore |
| 11 | and highly integrated device architecture targeted to maximize |
| 12 | performance and power efficiency for a wide range of industrial, |
| 13 | automotive and other broad market segments. |
| 14 | |
| 15 | Typically the processing cores and the peripherals for these devices are |
| 16 | partitioned into three functional domains to provide ultra-low power |
| 17 | modes as well as accommodating application and industrial safety systems |
| 18 | on the same SoC. These functional domains are typically called the: |
| 19 | |
| 20 | * Wakeup (WKUP) domain |
| 21 | * Micro-controller (MCU) domain |
| 22 | * Main domain |
| 23 | |
| 24 | For a more detailed view of what peripherals are attached to each |
| 25 | domain, consult the device specific documentation. |
| 26 | |
| 27 | K3 Based SoCs |
| 28 | ------------- |
| 29 | |
| 30 | .. toctree:: |
| 31 | :maxdepth: 1 |
| 32 | |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 33 | am62x_sk |
Marcel Ziswiler | 7d1a106 | 2023-08-04 12:08:08 +0200 | [diff] [blame] | 34 | ../toradex/verdin-am62 |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 35 | am65x_evm |
Nishanth Menon | 5c86c57 | 2023-07-27 13:59:01 -0500 | [diff] [blame] | 36 | j7200_evm |
| 37 | j721e_evm |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 38 | |
| 39 | Boot Flow Overview |
| 40 | ------------------ |
| 41 | |
| 42 | For all K3 SoCs the first core started will be inside the Security |
| 43 | Management Subsystem (SMS) which will secure the device and start a core |
| 44 | in the wakeup domain to run the ROM code. ROM will then initialize the |
| 45 | boot media needed to load the binaries packaged inside `tiboot3.bin`, |
| 46 | including a 32bit U-Boot SPL, (called the wakup SPL) that ROM will jump |
| 47 | to after it has finished loading everything into internal SRAM. |
| 48 | |
Nishanth Menon | 6e8fa06 | 2023-07-27 13:59:02 -0500 | [diff] [blame] | 49 | .. image:: img/boot_flow_01.svg |
Heinrich Schuchardt | 7f62928 | 2023-08-22 11:40:55 -0500 | [diff] [blame] | 50 | :alt: Boot flow up to wakeup domain SPL |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 51 | |
| 52 | The wakeup SPL, running on a wakeup domain core, will initialize DDR and |
| 53 | any peripherals needed load the larger binaries inside the `tispl.bin` |
| 54 | into DDR. Once loaded the wakeup SPL will start one of the 'big' |
| 55 | application cores inside the main domain to initialize the main domain, |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 56 | starting with Trusted Firmware-A (TF-A), before moving on to start |
| 57 | OP-TEE and the main domain's U-Boot SPL. |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 58 | |
Nishanth Menon | 6e8fa06 | 2023-07-27 13:59:02 -0500 | [diff] [blame] | 59 | .. image:: img/boot_flow_02.svg |
Heinrich Schuchardt | 7f62928 | 2023-08-22 11:40:55 -0500 | [diff] [blame] | 60 | :alt: Boot flow up to main domain SPL |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 61 | |
| 62 | The main domain's SPL, running on a 64bit application core, has |
| 63 | virtually unlimited space (billions of bytes now that DDR is working) to |
| 64 | initialize even more peripherals needed to load in the `u-boot.img` |
| 65 | which loads more firmware into the micro-controller & wakeup domains and |
| 66 | finally prepare the main domain to run Linux. |
| 67 | |
Nishanth Menon | 6e8fa06 | 2023-07-27 13:59:02 -0500 | [diff] [blame] | 68 | .. image:: img/boot_flow_03.svg |
Heinrich Schuchardt | 7f62928 | 2023-08-22 11:40:55 -0500 | [diff] [blame] | 69 | :alt: Complete boot flow up to Linux |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 70 | |
| 71 | This is the typical boot flow for all K3 based SoCs, however this flow |
| 72 | offers quite a lot in the terms of flexibility, especially on High |
| 73 | Security (HS) SoCs. |
| 74 | |
| 75 | Boot Flow Variations |
| 76 | ^^^^^^^^^^^^^^^^^^^^ |
| 77 | |
| 78 | All K3 SoCs will generally use the above boot flow with two main |
| 79 | differences depending on the capabilities of the boot ROM and the number |
| 80 | of cores inside the device. These differences split the bootflow into |
| 81 | essentially 4 unique but very similar flows: |
| 82 | |
| 83 | * Split binary with a combined firmware: (eg: AM65) |
| 84 | * Combined binary with a combined firmware: (eg: AM64) |
| 85 | * Split binary with a split firmware: (eg: J721E) |
| 86 | * Combined binary with a split firmware: (eg: AM62) |
| 87 | |
| 88 | For devices that utilize the split binary approach, ROM is not capable |
| 89 | of loading the firmware into the SoC requiring the wakeup domain's |
| 90 | U-Boot SPL to load the firmware. |
| 91 | |
| 92 | Devices with a split firmware will have two firmwares loaded into the |
| 93 | device at different times during the bootup process. TI's Foundational |
| 94 | Security (TIFS), needed to operate the Security Management Subsystem, |
| 95 | will either be loaded by ROM or the WKUP U-Boot SPL, then once the |
| 96 | wakeup U-Boot SPL has completed, the second Device Management (DM) |
| 97 | firmware can be loaded on the now free core in the wakeup domain. |
| 98 | |
| 99 | For more information on the bootup process of your SoC, consult the |
| 100 | device specific boot flow documentation. |
| 101 | |
| 102 | Software Sources |
| 103 | ---------------- |
| 104 | |
| 105 | All scripts and code needed to build the `tiboot3.bin`, `tispl.bin` and |
| 106 | `u-boot.img` for all K3 SoCs can be located at the following places |
| 107 | online |
| 108 | |
Nishanth Menon | cce3e7a | 2023-07-27 13:58:44 -0500 | [diff] [blame] | 109 | .. k3_rst_include_start_boot_sources |
| 110 | |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 111 | * **Das U-Boot** |
| 112 | |
| 113 | | **source:** https://source.denx.de/u-boot/u-boot.git |
| 114 | | **branch:** master |
| 115 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 116 | * **Trusted Firmware-A (TF-A)** |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 117 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 118 | | **source:** https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/ |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 119 | | **branch:** master |
| 120 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 121 | * **Open Portable Trusted Execution Environment (OP-TEE)** |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 122 | |
| 123 | | **source:** https://github.com/OP-TEE/optee_os.git |
| 124 | | **branch:** master |
| 125 | |
| 126 | * **TI Firmware (TIFS, DM, DSMC)** |
| 127 | |
| 128 | | **source:** https://git.ti.com/git/processor-firmware/ti-linux-firmware.git |
| 129 | | **branch:** ti-linux-firmware |
| 130 | |
Nishanth Menon | cce3e7a | 2023-07-27 13:58:44 -0500 | [diff] [blame] | 131 | .. k3_rst_include_end_boot_sources |
| 132 | |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 133 | Build Procedure |
| 134 | --------------- |
| 135 | |
| 136 | Depending on the specifics of your device, you will need three or more |
| 137 | binaries to boot your SoC. |
| 138 | |
| 139 | * `tiboot3.bin` (bootloader for the wakeup domain) |
| 140 | * `tispl.bin` (bootloader for the main domain) |
| 141 | * `u-boot.img` |
| 142 | |
| 143 | During the bootup process, both the 32bit wakeup domain and the 64bit |
| 144 | main domains will be involved. This means everything inside the |
| 145 | `tiboot3.bin` running in the wakeup domain will need to be compiled for |
| 146 | 32bit cores and most binaries in the `tispl.bin` will need to be |
| 147 | compiled for 64bit main domain CPU cores. |
| 148 | |
| 149 | All of that to say you will need both a 32bit and 64bit cross compiler |
| 150 | (assuming you're using an x86 desktop) |
| 151 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 152 | .. k3_rst_include_start_common_env_vars_desc |
| 153 | .. list-table:: Generic environment variables |
| 154 | :widths: 25 25 50 |
| 155 | :header-rows: 1 |
| 156 | |
| 157 | * - S/w Component |
| 158 | - Env Variable |
| 159 | - Description |
| 160 | * - All Software |
| 161 | - CC32 |
| 162 | - Cross compiler for ARMv7 (ARM 32bit), typically arm-linux-gnueabihf- |
| 163 | * - All Software |
| 164 | - CC64 |
| 165 | - Cross compiler for ARMv8 (ARM 64bit), typically aarch64-linux-gnu- |
| 166 | * - All Software |
| 167 | - LNX_FW_PATH |
| 168 | - Path to TI Linux firmware repository |
| 169 | * - All Software |
| 170 | - TFA_PATH |
| 171 | - Path to source of Trusted Firmware-A |
| 172 | * - All Software |
| 173 | - OPTEE_PATH |
| 174 | - Path to source of OP-TEE |
| 175 | .. k3_rst_include_end_common_env_vars_desc |
| 176 | |
| 177 | .. k3_rst_include_start_common_env_vars_defn |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 178 | .. code-block:: bash |
| 179 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 180 | $ export CC32=arm-linux-gnueabihf- |
| 181 | $ export CC64=aarch64-linux-gnu- |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 182 | $ export LNX_FW_PATH=path/to/ti-linux-firmware |
| 183 | $ export TFA_PATH=path/to/trusted-firmware-a |
| 184 | $ export OPTEE_PATH=path/to/optee_os |
| 185 | .. k3_rst_include_end_common_env_vars_defn |
| 186 | |
| 187 | We will also need some common environment variables set up for the various |
| 188 | other build sources. we shall use the following, in the build descriptions below: |
| 189 | |
| 190 | .. k3_rst_include_start_board_env_vars_desc |
| 191 | .. list-table:: Board specific environment variables |
| 192 | :widths: 25 25 50 |
| 193 | :header-rows: 1 |
| 194 | |
| 195 | * - S/w Component |
| 196 | - Env Variable |
| 197 | - Description |
| 198 | * - U-Boot |
| 199 | - UBOOT_CFG_CORTEXR |
| 200 | - Defconfig for Cortex-R (Boot processor). |
| 201 | * - U-Boot |
| 202 | - UBOOT_CFG_CORTEXA |
| 203 | - Defconfig for Cortex-A (MPU processor). |
| 204 | * - Trusted Firmware-A |
| 205 | - TFA_BOARD |
| 206 | - Platform name used for building TF-A for Cortex-A Processor. |
| 207 | * - Trusted Firmware-A |
| 208 | - TFA_EXTRA_ARGS |
| 209 | - Any extra arguments used for building TF-A. |
| 210 | * - OP-TEE |
| 211 | - OPTEE_PLATFORM |
| 212 | - Platform name used for building OP-TEE for Cortex-A Processor. |
| 213 | * - OP-TEE |
| 214 | - OPTEE_EXTRA_ARGS |
| 215 | - Any extra arguments used for building OP-TEE. |
| 216 | .. k3_rst_include_end_board_env_vars_desc |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 217 | |
| 218 | Building tiboot3.bin |
| 219 | ^^^^^^^^^^^^^^^^^^^^^ |
| 220 | |
| 221 | 1. To generate the U-Boot SPL for the wakeup domain, use the following |
| 222 | commands, substituting :code:`{SOC}` for the name of your device (eg: |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 223 | am62x) to package the various firmware and the wakeup UBoot SPL into |
| 224 | the final `tiboot3.bin` binary. (or the `sysfw.itb` if your device |
| 225 | uses the split binary flow) |
| 226 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 227 | .. k3_rst_include_start_build_steps_spl_r5 |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 228 | .. code-block:: bash |
| 229 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 230 | $ # inside u-boot source |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 231 | $ make $UBOOT_CFG_CORTEXR |
| 232 | $ make CROSS_COMPILE=$CC32 BINMAN_INDIRS=$LNX_FW_PATH |
| 233 | .. k3_rst_include_end_build_steps_spl_r5 |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 234 | |
| 235 | At this point you should have all the needed binaries to boot the wakeup |
| 236 | domain of your K3 SoC. |
| 237 | |
| 238 | **Combined Binary Boot Flow** (eg: am62x, am64x, ... ) |
| 239 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 240 | `tiboot3-{SOC}-{gp/hs-fs/hs}.bin` |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 241 | |
| 242 | **Split Binary Boot Flow** (eg: j721e, am65x) |
| 243 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 244 | | `tiboot3-{SOC}-{gp/hs-fs/hs}.bin` |
| 245 | | `sysfw-{SOC}-{gp/hs-fs/hs}-evm.itb` |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 246 | |
| 247 | .. note :: |
| 248 | |
| 249 | It's important to rename the generated `tiboot3.bin` and `sysfw.itb` |
| 250 | to match exactly `tiboot3.bin` and `sysfw.itb` as ROM and the wakeup |
| 251 | UBoot SPL will only look for and load the files with these names. |
| 252 | |
| 253 | Building tispl.bin |
| 254 | ^^^^^^^^^^^^^^^^^^^ |
| 255 | |
| 256 | The `tispl.bin` is a standard fitImage combining the firmware need for |
| 257 | the main domain to function properly as well as Device Management (DM) |
| 258 | firmware if your device using a split firmware. |
| 259 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 260 | 2. We will first need TF-A, as it's the first thing to run on the 'big' |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 261 | application cores on the main domain. |
| 262 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 263 | .. k3_rst_include_start_build_steps_tfa |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 264 | .. code-block:: bash |
| 265 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 266 | $ # inside trusted-firmware-a source |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 267 | $ make CROSS_COMPILE=$CC64 ARCH=aarch64 PLAT=k3 SPD=opteed $TFA_EXTRA_ARGS \ |
| 268 | TARGET_BOARD=$TFA_BOARD |
| 269 | .. k3_rst_include_end_build_steps_tfa |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 270 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 271 | Typically all `j7*` devices will use `TARGET_BOARD=generic` or `TARGET_BOARD |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 272 | =j784s4` (if it is a J784S4 device), while typical Sitara (`am6*`) devices |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 273 | use the `lite` option. |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 274 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 275 | 3. The Open Portable Trusted Execution Environment (OP-TEE) is designed |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 276 | to run as a companion to a non-secure Linux kernel for Cortex-A cores |
| 277 | using the TrustZone technology built into the core. |
| 278 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 279 | .. k3_rst_include_start_build_steps_optee |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 280 | .. code-block:: bash |
| 281 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 282 | $ # inside optee_os source |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 283 | $ make CROSS_COMPILE=$CC32 CROSS_COMPILE64=$CC64 CFG_ARM64_core=y $OPTEE_EXTRA_ARGS \ |
| 284 | PLATFORM=$OPTEE_PLATFORM |
| 285 | .. k3_rst_include_end_build_steps_optee |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 286 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 287 | 4. Finally, after TF-A has initialized the main domain and OP-TEE has |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 288 | finished, we can jump back into U-Boot again, this time running on a |
| 289 | 64bit core in the main domain. |
| 290 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 291 | .. k3_rst_include_start_build_steps_uboot |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 292 | .. code-block:: bash |
| 293 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 294 | $ # inside u-boot source |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 295 | $ make $UBOOT_CFG_CORTEXA |
| 296 | $ make CROSS_COMPILE=$CC64 BINMAN_INDIRS=$LNX_FW_PATH \ |
| 297 | BL31=$TFA_PATH/build/k3/$TFA_BOARD/release/bl31.bin \ |
| 298 | TEE=$OPTEE_PATH/out/arm-plat-k3/core/tee-raw.bin |
| 299 | .. k3_rst_include_end_build_steps_uboot |
Bryan Brattlof | 16a30b3 | 2022-12-19 14:29:50 -0600 | [diff] [blame] | 300 | |
| 301 | At this point you should have every binary needed initialize both the |
| 302 | wakeup and main domain and to boot to the U-Boot prompt |
| 303 | |
| 304 | **Main Domain Bootloader** |
| 305 | |
Neha Malcom Francis | 1ee652a | 2023-07-22 00:14:43 +0530 | [diff] [blame] | 306 | | `tispl.bin` for HS devices or `tispl.bin_unsigned` for GP devices |
| 307 | | `u-boot.img` for HS devices or `u-boot.img_unsigned` for GP devices |
Manorit Chawdhry | a5e8678 | 2023-07-14 11:22:29 +0530 | [diff] [blame] | 308 | |
| 309 | Fit Signature Signing |
| 310 | --------------------- |
| 311 | |
| 312 | K3 Platforms have fit signature signing enabled by default on their primary |
| 313 | platforms. Here we'll take an example for creating fit image for J721e platform |
| 314 | and the same can be extended to other platforms |
| 315 | |
| 316 | 1. Describing FIT source |
| 317 | |
| 318 | .. code-block:: bash |
| 319 | |
| 320 | /dts-v1/; |
| 321 | |
| 322 | / { |
| 323 | description = "Kernel fitImage for j721e-hs-evm"; |
| 324 | #address-cells = <1>; |
| 325 | |
| 326 | images { |
| 327 | kernel-1 { |
| 328 | description = "Linux kernel"; |
| 329 | data = /incbin/("Image"); |
| 330 | type = "kernel"; |
| 331 | arch = "arm64"; |
| 332 | os = "linux"; |
| 333 | compression = "none"; |
| 334 | load = <0x80080000>; |
| 335 | entry = <0x80080000>; |
| 336 | hash-1 { |
| 337 | algo = "sha512"; |
| 338 | }; |
| 339 | |
| 340 | }; |
| 341 | fdt-ti_k3-j721e-common-proc-board.dtb { |
| 342 | description = "Flattened Device Tree blob"; |
| 343 | data = /incbin/("k3-j721e-common-proc-board.dtb"); |
| 344 | type = "flat_dt"; |
| 345 | arch = "arm64"; |
| 346 | compression = "none"; |
| 347 | load = <0x83000000>; |
| 348 | hash-1 { |
| 349 | algo = "sha512"; |
| 350 | }; |
| 351 | |
| 352 | }; |
| 353 | }; |
| 354 | |
| 355 | configurations { |
| 356 | default = "conf-ti_k3-j721e-common-proc-board.dtb"; |
| 357 | conf-ti_k3-j721e-common-proc-board.dtb { |
| 358 | description = "Linux kernel, FDT blob"; |
| 359 | fdt = "fdt-ti_k3-j721e-common-proc-board.dtb"; |
| 360 | kernel = "kernel-1"; |
| 361 | signature-1 { |
| 362 | algo = "sha512,rsa4096"; |
| 363 | key-name-hint = "custMpk"; |
| 364 | sign-images = "kernel", "fdt"; |
| 365 | }; |
| 366 | }; |
| 367 | }; |
| 368 | }; |
| 369 | |
| 370 | You would require to change the '/incbin/' lines to point to the respective |
| 371 | files in your local machine and the key-name-hint also needs to be changed |
| 372 | if you are using some other key other than the TI dummy key that we are |
| 373 | using for this example. |
| 374 | |
| 375 | 2. Compile U-boot for the respective board |
| 376 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 377 | .. include:: k3.rst |
| 378 | :start-after: .. k3_rst_include_start_build_steps_uboot |
| 379 | :end-before: .. k3_rst_include_end_build_steps_uboot |
Manorit Chawdhry | a5e8678 | 2023-07-14 11:22:29 +0530 | [diff] [blame] | 380 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 381 | .. note:: |
Manorit Chawdhry | a5e8678 | 2023-07-14 11:22:29 +0530 | [diff] [blame] | 382 | |
| 383 | The changes only affect a72 binaries so the example just builds that |
| 384 | |
| 385 | 3. Sign the fit image and embed the dtb in uboot |
| 386 | |
| 387 | Now once the build is done, you'll have a dtb for your board that you'll |
| 388 | be passing to mkimage for signing the fitImage and embedding the key in |
| 389 | the u-boot dtb. |
| 390 | |
| 391 | .. code-block:: bash |
| 392 | |
| 393 | mkimage -r -f fitImage.its -k $UBOOT_PATH/board/ti/keys -K |
| 394 | $UBOOT_PATH/build/a72/dts/dt.dtb |
| 395 | |
| 396 | For signing a secondary platform, pass the -K parameter to that DTB |
| 397 | |
| 398 | .. code-block:: bash |
| 399 | |
| 400 | mkimage -f fitImage.its -k $UBOOT_PATH/board/ti/keys -K |
| 401 | $UBOOT_PATH/build/a72/arch/arm/dts/k3-j721e-sk.dtb |
| 402 | |
| 403 | .. note:: |
| 404 | |
| 405 | If changing `CONFIG_DEFAULT_DEVICE_TREE` to the secondary platform, |
| 406 | binman changes would also be required so that correct dtb gets packaged. |
| 407 | |
| 408 | .. code-block:: bash |
| 409 | |
| 410 | diff --git a/arch/arm/dts/k3-j721e-binman.dtsi b/arch/arm/dts/k3-j721e-binman.dtsi |
| 411 | index 673be646b1e3..752fa805fe8d 100644 |
| 412 | --- a/arch/arm/dts/k3-j721e-binman.dtsi |
| 413 | +++ b/arch/arm/dts/k3-j721e-binman.dtsi |
| 414 | @@ -299,8 +299,8 @@ |
| 415 | #define SPL_J721E_SK_DTB "spl/dts/k3-j721e-sk.dtb" |
| 416 | |
| 417 | #define UBOOT_NODTB "u-boot-nodtb.bin" |
| 418 | -#define J721E_EVM_DTB "u-boot.dtb" |
| 419 | -#define J721E_SK_DTB "arch/arm/dts/k3-j721e-sk.dtb" |
| 420 | +#define J721E_EVM_DTB "arch/arm/dts/k3-j721e-common-proc-board.dtb" |
| 421 | +#define J721E_SK_DTB "u-boot.dtb" |
| 422 | |
| 423 | 5. Rebuilt u-boot |
| 424 | |
| 425 | This is required so that the modified dtb gets updated in u-boot.img |
| 426 | |
Nishanth Menon | c727b81 | 2023-07-27 13:58:48 -0500 | [diff] [blame] | 427 | .. include:: k3.rst |
| 428 | :start-after: .. k3_rst_include_start_build_steps_uboot |
| 429 | :end-before: .. k3_rst_include_end_build_steps_uboot |
Manorit Chawdhry | a5e8678 | 2023-07-14 11:22:29 +0530 | [diff] [blame] | 430 | |
| 431 | 6. (Optional) Enabled FIT_SIGNATURE_ENFORCED |
| 432 | |
| 433 | By default u-boot will boot up the fit image without any authentication as |
| 434 | such if the public key is not embedded properly, to check if the public key |
| 435 | nodes are proper you can enable FIT_SIGNATURE_ENFORCED that would not rely |
| 436 | on the dtb for anything else then the signature node for checking the fit |
| 437 | image, rest other things will be enforced such as the property of |
| 438 | required-keys. This is not an extensive check so do manual checks also |
| 439 | |
| 440 | This is by default enabled for devices with TI_SECURE_DEVICE enabled. |
| 441 | |
| 442 | .. note:: |
| 443 | |
| 444 | The devices now also have distroboot enabled so if the fit image doesn't |
| 445 | work then the fallback to normal distroboot will be there on hs devices, |
| 446 | this will need to be explicitly disabled by changing the boot_targets. |
| 447 | |
| 448 | Saving environment |
| 449 | ------------------ |
| 450 | |
| 451 | SAVEENV is disabled by default and for the new flow uses Uenv.txt as the default |
| 452 | way for saving the environments. This has been done as Uenv.txt is more granular |
| 453 | then the saveenv command and can be used across various bootmodes too. |
| 454 | |
| 455 | **Writing to MMC/EMMC** |
| 456 | |
| 457 | .. code-block:: |
| 458 | |
| 459 | => env export -t $loadaddr <list of variables> |
| 460 | => fatwrite mmc ${mmcdev} ${loadaddr} ${bootenvfile} ${filesize} |
| 461 | |
| 462 | **Reading from MMC/EMMC** |
| 463 | |
| 464 | By default run envboot will read it from the MMC/EMMC partition ( based on |
| 465 | mmcdev) and set the environments. |
| 466 | |
| 467 | If manually needs to be done then the environment can be read from the |
| 468 | filesystem and then imported |
| 469 | |
| 470 | .. code-block:: |
| 471 | |
| 472 | => fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile} |
| 473 | => env import -t ${loadaddr} ${filesize} |
Jason Kacines | effe508 | 2023-08-03 01:29:22 -0500 | [diff] [blame] | 474 | |
| 475 | .. _k3_rst_refer_openocd: |
| 476 | |
| 477 | Common Debugging environment - OpenOCD |
| 478 | -------------------------------------- |
| 479 | |
| 480 | This section will show you how to connect a board to `OpenOCD |
| 481 | <https://openocd.org/>`_ and load the SPL symbols for debugging with |
| 482 | a K3 generation device. To follow this guide, you must build custom |
| 483 | u-boot binaries, start your board from a boot media such as an SD |
| 484 | card, and use an OpenOCD environment. This section uses generic |
| 485 | examples, though you can apply these instructions to any supported K3 |
| 486 | generation device. |
| 487 | |
| 488 | The overall structure of this setup is in the following figure. |
| 489 | |
| 490 | .. image:: img/openocd-overview.svg |
Nishanth Menon | c6df528 | 2023-08-22 11:40:56 -0500 | [diff] [blame^] | 491 | :alt: Overview of OpenOCD setup. |
Jason Kacines | effe508 | 2023-08-03 01:29:22 -0500 | [diff] [blame] | 492 | |
| 493 | .. note:: |
| 494 | |
| 495 | If you find these instructions useful, please consider `donating |
| 496 | <https://openocd.org/pages/donations.html>`_ to OpenOCD. |
| 497 | |
| 498 | Step 1: Download and install OpenOCD |
| 499 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 500 | |
| 501 | To get started, it is more convenient if the distribution you |
| 502 | use supports OpenOCD by default. Follow the instructions in the |
| 503 | `getting OpenOCD <https://openocd.org/pages/getting-openocd.html>`_ |
| 504 | documentation to pick the installation steps appropriate to your |
| 505 | environment. Some references to OpenOCD documentation: |
| 506 | |
| 507 | * `OpenOCD User Guide <https://openocd.org/doc/html/index.html>`_ |
| 508 | * `OpenOCD Developer's Guide <https://openocd.org/doc/doxygen/html/index.html>`_ |
| 509 | |
| 510 | Refer to the release notes corresponding to the `OpenOCD version |
| 511 | <https://github.com/openocd-org/openocd/releases>`_ to ensure |
| 512 | |
| 513 | * Processor support: In general, processor support shouldn't present |
| 514 | any difficulties since OpenOCD provides solid support for both ARMv8 |
| 515 | and ARMv7. |
| 516 | * SoC support: When working with System-on-a-Chip (SoC), the support |
| 517 | usually comes as a TCL config file. It is vital to ensure the correct |
| 518 | version of OpenOCD or to use the TCL files from the latest release or |
| 519 | the one mentioned. |
| 520 | * Board or the JTAG adapter support: In most cases, board support is |
| 521 | a relatively easy problem if the board has a JTAG pin header. All |
| 522 | you need to do is ensure that the adapter you select is compatible |
| 523 | with OpenOCD. Some boards come with an onboard JTAG adapter that |
| 524 | requires a USB cable to be plugged into the board, in which case, it |
| 525 | is vital to ensure that the JTAG adapter is supported. Fortunately, |
| 526 | almost all TI K3 SK/EVMs come with TI's XDS110, which has out of the |
| 527 | box support by OpenOCD. The board-specific documentation will |
| 528 | cover the details and any adapter/dongle recommendations. |
| 529 | |
| 530 | .. code-block:: bash |
| 531 | |
| 532 | openocd -v |
| 533 | |
| 534 | .. note:: |
| 535 | |
| 536 | OpenOCD version 0.12.0 is usually required to connect to most K3 |
| 537 | devices. If your device is only supported by a newer version than the |
| 538 | one provided by your distribution, you may need to build it from the source. |
| 539 | |
| 540 | Building OpenOCD from source |
| 541 | """""""""""""""""""""""""""" |
| 542 | |
| 543 | The dependency package installation instructions below are for Debian |
| 544 | systems, but equivalent instructions should exist for systems with |
| 545 | other package managers. Please refer to the `OpenOCD Documentation |
| 546 | <https://openocd.org/>`_ for more recent installation steps. |
| 547 | |
| 548 | .. code-block:: bash |
| 549 | |
| 550 | $ # Check the packages to be installed: needs deb-src in sources.list |
| 551 | $ sudo apt build-dep openocd |
| 552 | $ # The following list is NOT complete - please check the latest |
| 553 | $ sudo apt-get install libtool pkg-config texinfo libusb-dev \ |
| 554 | libusb-1.0.0-dev libftdi-dev libhidapi-dev autoconf automake |
| 555 | $ git clone https://github.com/openocd-org/openocd.git openocd |
| 556 | $ cd openocd |
| 557 | $ git submodule init |
| 558 | $ git submodule update |
| 559 | $ ./bootstrap |
| 560 | $ ./configure --prefix=/usr/local/ |
| 561 | $ make -j`nproc` |
| 562 | $ sudo make install |
| 563 | |
| 564 | .. note:: |
| 565 | |
| 566 | The example above uses the GitHub mirror site. See |
| 567 | `git repo information <https://openocd.org/doc/html/Developers.html#OpenOCD-Git-Repository>`_ |
| 568 | information to pick the official git repo. |
| 569 | If a specific version is desired, select the version using `git checkout tag`. |
| 570 | |
| 571 | Installing OpenOCD udev rules |
| 572 | """"""""""""""""""""""""""""" |
| 573 | |
| 574 | The step is not necessary if the distribution supports the OpenOCD, but |
| 575 | if building from a source, ensure that the udev rules are installed |
| 576 | correctly to ensure a sane system. |
| 577 | |
| 578 | .. code-block:: bash |
| 579 | |
| 580 | # Go to the OpenOCD source directory |
| 581 | $ cd openocd |
| 582 | # Copy the udev rules to the correct system location |
| 583 | $ sudo cp ./contrib/60-openocd.rules \ |
| 584 | ./src/JTAG/drivers/libjaylink/contrib/99-libjaylink.rules \ |
| 585 | /etc/udev/rules.d/ |
| 586 | # Get Udev to load the new rules up |
| 587 | $ sudo udevadm control --reload-rules |
| 588 | # Use the new rules on existing connected devices |
| 589 | $ sudo udevadm trigger |
| 590 | |
| 591 | Step 2: Setup GDB |
| 592 | ^^^^^^^^^^^^^^^^^ |
| 593 | |
| 594 | Most systems come with gdb-multiarch package. |
| 595 | |
| 596 | .. code-block:: bash |
| 597 | |
| 598 | # Install gdb-multiarch package |
| 599 | $ sudo apt-get install gdb-multiarch |
| 600 | |
| 601 | Though using GDB natively is normal, developers with interest in using IDE |
| 602 | may find a few of these interesting: |
| 603 | |
| 604 | * `gdb-dashboard <https://github.com/cyrus-and/gdb-dashboard>`_ |
| 605 | * `gef <https://github.com/hugsy/gef>`_ |
| 606 | * `peda <https://github.com/longld/peda>`_ |
| 607 | * `pwndbg <https://github.com/pwndbg/pwndbg>`_ |
| 608 | * `voltron <https://github.com/snare/voltron>`_ |
| 609 | * `ddd <https://www.gnu.org/software/ddd/>`_ |
| 610 | * `vscode <https://www.justinmklam.com/posts/2017/10/vscode-debugger-setup/>`_ |
| 611 | * `vim conque-gdb <https://github.com/vim-scripts/Conque-GDB>`_ |
| 612 | * `emacs realgud <https://github.com/realgud/realgud/wiki/gdb-notes>`_ |
| 613 | * `Lauterbach IDE <https://www2.lauterbach.com/pdf/backend_gdb.pdf>`_ |
| 614 | |
| 615 | .. warning:: |
| 616 | LLDB support for OpenOCD is still a work in progress as of this writing. |
| 617 | Using GDB is probably the safest option at this point in time. |
| 618 | |
| 619 | Step 3: Connect board to PC |
| 620 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 621 | There are few patterns of boards in the ecosystem |
| 622 | |
| 623 | .. k3_rst_include_start_openocd_connect_XDS110 |
| 624 | |
| 625 | **Integrated JTAG adapter/dongle**: The board has a micro-USB connector labelled |
| 626 | XDS110 USB or JTAG. Connect a USB cable to the board to the mentioned port. |
| 627 | |
| 628 | .. note:: |
| 629 | |
| 630 | There are multiple USB ports on a typical board, So, ensure you have read |
| 631 | the user guide for the board and confirmed the silk screen label to ensure |
| 632 | connecting to the correct port. |
| 633 | |
| 634 | .. k3_rst_include_end_openocd_connect_XDS110 |
| 635 | |
| 636 | .. k3_rst_include_start_openocd_connect_cti20 |
| 637 | |
| 638 | **cTI20 connector**: The TI's `cTI20 |
| 639 | <https://software-dl.ti.com/ccs/esd/documents/xdsdebugprobes/emu_JTAG_connectors.html#cti-20-pin-header-information>`_ connector |
| 640 | is probably the most prevelant on TI platforms. Though many |
| 641 | TI boards have an onboard XDS110, cTI20 connector is usually |
| 642 | provided as an alternate scheme to connect alternatives such |
| 643 | as `Lauterbach <https://www.lauterbach.com/>`_ or `XDS560 |
| 644 | <https://www.ti.com/tool/TMDSEMU560V2STM-U>`_. |
| 645 | |
| 646 | To debug on these boards, the following combinations is suggested: |
| 647 | |
| 648 | * `TUMPA <https://www.diygadget.com/JTAG-cables-and-microcontroller-programmers/tiao-usb-multi-protocol-adapter-JTAG-spi-i2c-serial>`_ |
| 649 | or `equivalent dongles supported by OpenOCD. <https://openocd.org/doc/html/Debug-Adapter-Hardware.html#Debug-Adapter-Hardware>`_ |
| 650 | * Cable such as `Tag-connect ribbon cable <https://www.tag-connect.com/product/20-pin-cortex-ribbon-cable-4-length-with-50-mil-connectors>`_ |
| 651 | * Adapter to convert cTI20 to ARM20 such as those from |
| 652 | `Segger <https://www.segger.com/products/debug-probes/j-link/accessories/adapters/ti-cti-20-adapter/>`_ |
| 653 | or `Lauterbach LA-3780 <https://www.lauterbach.com/ad3780.html>`_ |
| 654 | Or optionally, if you have manufacturing capability then you could try |
| 655 | `BeagleBone JTAG Adapter <https://github.com/mmorawiec/BeagleBone-Black-JTAG-Adapters>`_ |
| 656 | |
| 657 | .. warning:: |
| 658 | XDS560 and Lauterbach are proprietary solutions and is not supported by |
| 659 | OpenOCD. |
| 660 | When purchasing an off the shelf adapter/dongle, you do want to be careful |
| 661 | about the signalling though. Please |
| 662 | `read for additional info <https://software-dl.ti.com/ccs/esd/xdsdebugprobes/emu_JTAG_connectors.html>`_. |
| 663 | |
| 664 | .. k3_rst_include_end_openocd_connect_cti20 |
| 665 | |
| 666 | .. k3_rst_include_start_openocd_connect_tag_connect |
| 667 | |
| 668 | **Tag-Connect**: `Tag-Connect <https://www.tag-connect.com/>`_ |
| 669 | pads on the boards which require special cable. Please check the documentation |
| 670 | to `identify <https://www.tag-connect.com/info/legs-or-no-legs>`_ if "legged" |
| 671 | or "no-leg" version of the cable is appropriate for the board. |
| 672 | |
| 673 | To debug on these boards, you will need: |
| 674 | |
| 675 | * `TUMPA <https://www.diygadget.com/JTAG-cables-and-microcontroller-programmers/tiao-usb-multi-protocol-adapter-JTAG-spi-i2c-serial>`_ |
| 676 | or `equivalent dongles supported by OpenOCD <https://openocd.org/doc/html/Debug-Adapter-Hardware.html#Debug-Adapter-Hardware>`_. |
| 677 | * Tag-Connect cable appropriate to the board such as |
| 678 | `TC2050-IDC-NL <https://www.tag-connect.com/product/TC2050-IDC-NL-10-pin-no-legs-cable-with-ribbon-connector>`_ |
| 679 | * In case of no-leg, version, a |
| 680 | `retaining clip <https://www.tag-connect.com/product/tc2050-clip-3pack-retaining-clip>`_ |
| 681 | * Tag-Connect to ARM20 |
| 682 | `adapter <https://www.tag-connect.com/product/tc2050-arm2010-arm-20-pin-to-tc2050-adapter>`_ |
| 683 | |
| 684 | .. note:: |
| 685 | You can optionally use a 3d printed solution such as |
| 686 | `Protective cap <https://www.thingiverse.com/thing:3025584>`_ or |
| 687 | `clip <https://www.thingiverse.com/thing:3035278>`_ to replace |
| 688 | the retaining clip. |
| 689 | |
| 690 | .. warning:: |
| 691 | With the Tag-Connect to ARM20 adapter, Please solder the "Trst" signal for |
| 692 | connection to work. |
| 693 | |
| 694 | .. k3_rst_include_end_openocd_connect_tag_connect |
| 695 | |
| 696 | Debugging with OpenOCD |
| 697 | ^^^^^^^^^^^^^^^^^^^^^^ |
| 698 | |
| 699 | Debugging U-Boot is different from debugging regular user space |
| 700 | applications. The bootloader initialization process involves many boot |
| 701 | media and hardware configuration operations. For K3 devices, there |
| 702 | are also interactions with security firmware. While reloading the |
| 703 | "elf" file works through GDB, developers must be mindful of cascading |
| 704 | initialization's potential consequences. |
| 705 | |
| 706 | Consider the following code change: |
| 707 | |
| 708 | .. code-block:: diff |
| 709 | |
| 710 | --- a/file.c 2023-07-29 10:55:29.647928811 -0500 |
| 711 | +++ b/file.c 2023-07-29 10:55:46.091856816 -0500 |
| 712 | @@ -1,3 +1,3 @@ |
| 713 | val = readl(reg); |
| 714 | -val |= 0x2; |
| 715 | +val |= 0x1; |
| 716 | writel(val, reg); |
| 717 | |
| 718 | Re-running the elf file with the above change will result in the |
| 719 | register setting 0x3 instead of the intended 0x1. There are other |
| 720 | hardware blocks which may not behave very well with a re-initialization |
| 721 | without proper shutdown. |
| 722 | |
| 723 | To help narrow the debug down, it is usually simpler to use the |
| 724 | standard boot media to get to the bootloader and debug only in the area |
| 725 | of interest. |
| 726 | |
| 727 | In general, to debug u-boot spl/u-boot with OpenOCD there are three steps: |
| 728 | |
| 729 | * Modify the code adding a loop to allow the debugger to attach |
| 730 | near the point of interest. Boot up normally to stop at the loop. |
| 731 | * Connect with OpenOCD and step out of the loop. |
| 732 | * Step through the code to find the root of issue. |
| 733 | |
| 734 | Typical debugging involves a few iterations of the above sequence. |
| 735 | Though most bootloader developers like to use printf to debug, |
| 736 | debug with JTAG tends to be most efficient since it is possible to |
| 737 | investigate the code flow and inspect hardware registers without |
| 738 | repeated iterations. |
| 739 | |
| 740 | Code modification |
| 741 | """"""""""""""""" |
| 742 | |
| 743 | * **start.S**: Adding an infinite while loop at the very entry of |
| 744 | U-Boot. For this, look for the corresponding start.S entry file. |
| 745 | This is usually only required when debugging some core SoC or |
| 746 | processor related function. For example: arch/arm/cpu/armv8/start.S or |
| 747 | arch/arm/cpu/armv7/start.S |
| 748 | |
| 749 | .. code-block:: diff |
| 750 | |
| 751 | diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S |
| 752 | index 69e281b086..744929e825 100644 |
| 753 | --- a/arch/arm/cpu/armv7/start.S |
| 754 | +++ b/arch/arm/cpu/armv7/start.S |
| 755 | @@ -37,6 +37,8 @@ |
| 756 | #endif |
| 757 | |
| 758 | reset: |
| 759 | +dead_loop: |
| 760 | + b dead_loop |
| 761 | /* Allow the board to save important registers */ |
| 762 | b save_boot_params |
| 763 | save_boot_params_ret: |
| 764 | |
| 765 | * **board_init_f**: Adding an infinite while loop at the board entry |
| 766 | function. In many cases, it is important to debug the boot process if |
| 767 | any changes are made for board-specific applications. Below is a step |
| 768 | by step process for debugging the boot SPL or Armv8 SPL: |
| 769 | |
| 770 | To debug the boot process in either domain, we will first |
| 771 | add a modification to the code we would like to debug. |
| 772 | In this example, we will debug ``board_init_f`` inside |
| 773 | ``arch/arm/mach-k3/{soc}_init.c``. Since some sections of U-Boot |
| 774 | will be executed multiple times during the bootup process of K3 |
| 775 | devices, we will need to include either ``CONFIG_CPU_ARM64`` or |
| 776 | ``CONFIG_CPU_V7R`` to catch the CPU at the desired place during the |
| 777 | bootup process (Main or Wakeup domains). For example, modify the |
| 778 | file as follows (depending on need): |
| 779 | |
| 780 | .. code-block:: c |
| 781 | |
| 782 | void board_init_f(ulong dummy) |
| 783 | { |
| 784 | . |
| 785 | . |
| 786 | /* Code to run on the R5F (Wakeup/Boot Domain) */ |
| 787 | if (IS_ENABLED(CONFIG_CPU_V7R)) { |
| 788 | volatile int x = 1; |
| 789 | while(x) {}; |
| 790 | } |
| 791 | ... |
| 792 | /* Code to run on the ARMV8 (Main Domain) */ |
| 793 | if (IS_ENABLED(CONFIG_CPU_ARM64)) { |
| 794 | volatile int x = 1; |
| 795 | while(x) {}; |
| 796 | } |
| 797 | . |
| 798 | . |
| 799 | } |
| 800 | |
| 801 | Connecting with OpenOCD for a debug session |
| 802 | """"""""""""""""""""""""""""""""""""""""""" |
| 803 | |
| 804 | Startup OpenOCD to debug the platform as follows: |
| 805 | |
| 806 | * **Integrated JTAG interface**: If the evm has a debugger such as |
| 807 | XDS110 inbuilt, there is typically an evm board support added and a |
| 808 | cfg file will be available. |
| 809 | |
| 810 | .. k3_rst_include_start_openocd_cfg_XDS110 |
| 811 | |
| 812 | .. code-block:: bash |
| 813 | |
| 814 | openocd -f board/{board_of_choice}.cfg |
| 815 | |
| 816 | .. k3_rst_include_end_openocd_cfg_XDS110 |
| 817 | |
| 818 | .. k3_rst_include_start_openocd_cfg_external_intro |
| 819 | |
| 820 | * **External JTAG adapter/interface**: In other cases, where an |
| 821 | adapter/dongle is used, a simple cfg file can be created to integrate the |
| 822 | SoC and adapter information. See `supported TI K3 SoCs |
| 823 | <https://github.com/openocd-org/openocd/blob/master/tcl/target/ti_k3.cfg#L59>`_ |
| 824 | to decide if the SoC is supported or not. |
| 825 | |
| 826 | .. code-block:: bash |
| 827 | |
| 828 | openocd -f openocd_connect.cfg |
| 829 | |
| 830 | .. k3_rst_include_end_openocd_cfg_external_intro |
| 831 | |
| 832 | For example, with BeaglePlay (AM62X platform), the openocd_connect.cfg: |
| 833 | |
| 834 | .. code-block:: tcl |
| 835 | |
| 836 | # TUMPA example: |
| 837 | # http://www.tiaowiki.com/w/TIAO_USB_Multi_Protocol_Adapter_User's_Manual |
| 838 | source [find interface/ftdi/tumpa.cfg] |
| 839 | |
| 840 | transport select jtag |
| 841 | |
| 842 | # default JTAG configuration has only SRST and no TRST |
| 843 | reset_config srst_only srst_push_pull |
| 844 | |
| 845 | # delay after SRST goes inactive |
| 846 | adapter srst delay 20 |
| 847 | |
| 848 | if { ![info exists SOC] } { |
| 849 | # Set the SoC of interest |
| 850 | set SOC am625 |
| 851 | } |
| 852 | |
| 853 | source [find target/ti_k3.cfg] |
| 854 | |
| 855 | ftdi tdo_sample_edge falling |
| 856 | |
| 857 | # Speeds for FT2232H are in multiples of 2, and 32MHz is tops |
| 858 | # max speed we seem to achieve is ~20MHz.. so we pick 16MHz |
| 859 | adapter speed 16000 |
| 860 | |
| 861 | Below is an example of the output of this command: |
| 862 | |
| 863 | .. code-block:: console |
| 864 | |
| 865 | Info : Listening on port 6666 for tcl connections |
| 866 | Info : Listening on port 4444 for telnet connections |
| 867 | Info : XDS110: connected |
| 868 | Info : XDS110: vid/pid = 0451/bef3 |
| 869 | Info : XDS110: firmware version = 3.0.0.20 |
| 870 | Info : XDS110: hardware version = 0x002f |
| 871 | Info : XDS110: connected to target via JTAG |
| 872 | Info : XDS110: TCK set to 2500 kHz |
| 873 | Info : clock speed 2500 kHz |
| 874 | Info : JTAG tap: am625.cpu tap/device found: 0x0bb7e02f (mfg: 0x017 (Texas Instruments), part: 0xbb7e, ver: 0x0) |
| 875 | Info : starting gdb server for am625.cpu.sysctrl on 3333 |
| 876 | Info : Listening on port 3333 for gdb connections |
| 877 | Info : starting gdb server for am625.cpu.a53.0 on 3334 |
| 878 | Info : Listening on port 3334 for gdb connections |
| 879 | Info : starting gdb server for am625.cpu.a53.1 on 3335 |
| 880 | Info : Listening on port 3335 for gdb connections |
| 881 | Info : starting gdb server for am625.cpu.a53.2 on 3336 |
| 882 | Info : Listening on port 3336 for gdb connections |
| 883 | Info : starting gdb server for am625.cpu.a53.3 on 3337 |
| 884 | Info : Listening on port 3337 for gdb connections |
| 885 | Info : starting gdb server for am625.cpu.main0_r5.0 on 3338 |
| 886 | Info : Listening on port 3338 for gdb connections |
| 887 | Info : starting gdb server for am625.cpu.gp_mcu on 3339 |
| 888 | Info : Listening on port 3339 for gdb connections |
| 889 | |
| 890 | .. note:: |
| 891 | Notice the default configuration is non-SMP configuration allowing |
| 892 | for each of the core to be attached and debugged simultaneously. |
| 893 | ARMv8 SPL/U-Boot starts up on cpu0 of a53/a72. |
| 894 | |
| 895 | .. k3_rst_include_start_openocd_cfg_external_gdb |
| 896 | |
| 897 | To debug using this server, use GDB directly or your preferred |
| 898 | GDB-based IDE. To start up GDB in the terminal, run the following |
| 899 | command. |
| 900 | |
| 901 | .. code-block:: bash |
| 902 | |
| 903 | gdb-multiarch |
| 904 | |
| 905 | To connect to your desired core, run the following command within GDB: |
| 906 | |
| 907 | .. code-block:: bash |
| 908 | |
| 909 | target extended-remote localhost:{port for desired core} |
| 910 | |
| 911 | To load symbols: |
| 912 | |
| 913 | .. warning:: |
| 914 | |
| 915 | SPL and U-Boot does a re-location of address compared to where it |
| 916 | is loaded originally. This step takes place after the DDR size is |
| 917 | determined from dt parsing. So, debugging can be split into either |
| 918 | "before re-location" or "after re-location". Please refer to the |
| 919 | file ''doc/README.arm-relocation'' to see how to grab the relocation |
| 920 | address. |
| 921 | |
| 922 | * Prior to relocation: |
| 923 | |
| 924 | .. code-block:: bash |
| 925 | |
| 926 | symbol-file {path to elf file} |
| 927 | |
| 928 | * After relocation: |
| 929 | |
| 930 | .. code-block:: bash |
| 931 | |
| 932 | # Drop old symbol file |
| 933 | symbol-file |
| 934 | # Pick up new relocaddr |
| 935 | add-symbol-file {path to elf file} {relocaddr} |
| 936 | |
| 937 | .. k3_rst_include_end_openocd_cfg_external_gdb |
| 938 | |
| 939 | In the above example of AM625, |
| 940 | |
| 941 | .. code-block:: bash |
| 942 | |
| 943 | target extended-remote localhost:3338 <- R5F (Wakeup Domain) |
| 944 | target extended-remote localhost:3334 <- A53 (Main Domain) |
| 945 | |
| 946 | The core can now be debugged directly within GDB using GDB commands or |
| 947 | if using IDE, as appropriate to the IDE. |
| 948 | |
| 949 | Stepping through the code |
| 950 | """"""""""""""""""""""""" |
| 951 | |
| 952 | `GDB TUI Commands |
| 953 | <https://sourceware.org/gdb/onlinedocs/gdb/TUI-Commands.html>`_ can |
| 954 | help set up the display more sensible for debug. Provide the name |
| 955 | of the layout that can be used to debug. For example, use the GDB |
| 956 | command ``layout src`` after loading the symbols to see the code and |
| 957 | breakpoints. To exit the debug loop added above, add any breakpoints |
| 958 | needed and run the following GDB commands to step out of the debug |
| 959 | loop set in the ``board_init_f`` function. |
| 960 | |
| 961 | .. code-block:: bash |
| 962 | |
| 963 | set x = 0 |
| 964 | continue |
| 965 | |
| 966 | The platform has now been successfully setup to debug with OpenOCD |
| 967 | using GDB commands or a GDB-based IDE. See `OpenOCD documentation for |
| 968 | GDB <https://openocd.org/doc/html/GDB-and-OpenOCD.html>`_ for further |
| 969 | information. |
| 970 | |
| 971 | .. warning:: |
| 972 | |
| 973 | On the K3 family of devices, a watchdog timer within the DMSC is |
| 974 | enabled by default by the ROM bootcode with a timeout of 3 minutes. |
| 975 | The watchdog timer is serviced by System Firmware (SYSFW) or TI |
| 976 | Foundational Security (TIFS) during normal operation. If debugging |
| 977 | the SPL before the SYSFW is loaded, the watchdog timer will not get |
| 978 | serviced automatically and the debug session will reset after 3 |
| 979 | minutes. It is recommended to start debugging SPL code only after |
| 980 | the startup of SYSFW to avoid running into the watchdog timer reset. |
| 981 | |
| 982 | Miscellaneous notes with OpenOCD |
| 983 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 984 | |
| 985 | Currently, OpenOCD does not support tracing for K3 platforms. Tracing |
| 986 | function could be beneficial if the bug in code occurs deep within |
| 987 | nested function and can optionally save developers major trouble of |
| 988 | stepping through a large quantity of code. |