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