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