OpenOCD-K3

OpenOCD primer – K3 Devices
Date: 2023-09-22
Nishanth Menon
1
Overview
 What is OpenOCD
 Features of OpenOCD
 OpenOCD overview
 OpenOCD Hardware setup: xds110, cTI20, tag-connect
 Building OpenOCD
 OpenOCD integration with IDEs
 Debugging U-Boot
 Debugging Linux Kernel
 Self Hosted Debug
2
What is OpenOCD
OpenOCD (Open On-Chip Debugger) is an open-source software project that
provides debugging and in-circuit programming support for various
microcontrollers and microprocessors. It allows developers to interact with and
control the hardware of embedded systems during both development and
production phases. OpenOCD supports a wide range of target architectures and
interfaces with various hardware debugging probes.
3
Features of OpenOCD
 Debugging: OpenOCD enables developers to perform source-level debugging, inspect memory, set
breakpoints, and single-step through code on embedded systems.
 Hardware Debug Probes: OpenOCD interfaces with hardware debug probes like JTAG (Joint Test
Action Group) and SWD (Serial Wire Debug) adapters to connect to the target hardware.
 GDB Integration: OpenOCD can be used as a target for the GNU Debugger (GDB), allowing
developers to use familiar debugging tools with their embedded systems.
 Scripting: OpenOCD can be scripted to automate various debugging and programming tasks, making it
useful for both manual and automated testing.
 Flash Programming: OpenOCD supports programming the flash memory of microcontrollers and
microprocessors, allowing developers to load and update firmware.
 Support for Various Targets: OpenOCD provides support for a wide range of target architectures,
including ARM, MIPS, RISC-V, and others, making it versatile for different embedded systems.
 Cross-Platform: OpenOCD is cross-platform and can be used on various operating systems, including
Windows, Linux, and macOS.
4
OpenOCD overview
5
K3 Generation — Das U-Boot unknown version documentation
OpenOCD hardware setup – XDS110
K3 Generation — Das U-Boot unknown version documentation
Connect a micro-USB cable to the board to
the mentioned port.
OpenOCD hardware setup – cTI20
K3 Generation — Das U-Boot unknown version documentation
•TUMPA or equivalent dongles supported by OpenOCD.
•Cable such as Tag-connect ribbon cable
•Adapter to convert cTI20 to ARM20 such as those from Segger or Lauterbach LA-3780 Or optionally, if you have
manufacturing capability then you could try BeagleBone JTAG Adapter
OpenOCD hardware setup – tagConnect
K3 Generation — Das U-Boot unknown version documentation
•TUMPA or equivalent dongles supported by OpenOCD.
•Tag-Connect cable appropriate to the board such as TC2050-IDC-NL
•In case of no-leg, version, a retaining clip
•Tag-Connect to ARM20 adapter
Building OpenOCD
9
# Check the packages to be installed: needs deb-src in sources.list
sudo apt build-dep openocd
# The following list is NOT complete - please check the latest
sudo apt-get install libtool pkg-config texinfo libusb-dev 
libusb-1.0.0-dev libftdi-dev libhidapi-dev autoconf automake
git clone https://github.com/openocd-org/openocd.git openocd
cd openocd
git submodule init
git submodule update
./bootstrap
./configure --prefix=/usr/local/
make -j`nproc`
sudo make install
K3 Generation — Das U-Boot unknown version documentation
OpenOCD IDE integration with GDB
gdb-dashboard
GEF (GDB Enhanced Features)
K3 Generation — Das U-Boot unknown version documentation
Debugger Setup with GDB + OpenOCD
in Visual Studio Code (justinmklam.com)
AND MANY MANY MANY MORE!
Debug U-boot
11
diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index 69e281b086..744929e825 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -37,6 +37,8 @@
#endif
reset:
+dead_loop:
+ b dead_loop
/* Allow the board to save important registers */
b save_boot_params
save_boot_params_ret:
K3 Generation — Das U-Boot unknown version documentation
void board_init_f(ulong dummy)
{
.
.
/* Code to run on the R5F (Wakeup/Boot Domain) */
if (IS_ENABLED(CONFIG_CPU_V7R)) {
volatile int x = 1;
while(x) {};
}
...
/* Code to run on the ARMV8 (Main Domain) */
if (IS_ENABLED(CONFIG_ARM64)) {
volatile int x = 1;
while(x) {};
}
.
.
}
Option 1: reset Option 2: board_init_f
Demo – Debug U-Boot
12
K3 Generation — Das U-Boot unknown version documentation
xds110
Console
AM625-SK
Demo – Debug U-Boot – VsCode integration
13
https://gist.github.com/nmenon/c2984e28f1af73292c0bd472c7522460
Debug Kernel
14
Pending Patches (on track to merge in next few
weeks)
https://review.openocd.org/c/openocd/+/7896
https://review.openocd.org/c/openocd/+/7897
https://review.openocd.org/c/openocd/+/7898
• Step 1: Disable kernel options:
• CONFIG_ARM_CORESIGHT_PMU_ARCH_SYSTEM_PMU=n
• CONFIG_CORESIGHT=n
• Step 2: kernel command line options: Add:
• rodata=off cpuidle.off=1 nokaslr
• nosmp – to disable multi-cpu debug
openocd -c 'set V8_SMP_DEBUG 1' -c "set RTOS(am625.cpu.a53.0) hwthread" -f board/ti_am625evm.cfg
Demo – Debug Kernel
15
OpenOCD Self hosted debug
 Debug M4F or R5F from A53 itself.
# Check the packages to be installed: needs deb-src in sources.list
sudo apt build-dep openocd
# The following list is NOT complete - please check the latest
sudo apt-get install libtool pkg-config texinfo libusb-dev 
libusb-1.0.0-dev libftdi-dev libhidapi-dev autoconf automake
git clone https://github.com/openocd-org/openocd.git openocd
cd openocd
git submodule init
git submodule update
./bootstrap
./configure --prefix=/usr/local/ --enable-dmem
make -j`nproc`
sudo make install
sudo openocd -c "set RTOS(am625.cpu.gp_mcu) Zephyr" -f board/ti_am625_swd_native.cfg
References
 https://medium.com/@aliaksandr.kavalchuk/diving-into-jtag-protocol-part-1-
overview-fbdc428d3a16
 https://medium.com/@aliaksandr.kavalchuk/diving-into-jtag-protocol-part-2-
debugging-56a566db3cf8
 https://u-boot.readthedocs.io/en/latest/board/ti/k3.html#common-debugging-
environment-openocd
 https://review.openocd.org/
1 of 17

Recommended

Hardware hacking by
Hardware hackingHardware hacking
Hardware hackingTavish Naruka
3.2K views30 slides
STM -32 by
STM -32STM -32
STM -32SeoTechnoscripts
9 views26 slides
learning STM -32 by
learning STM -32 learning STM -32
learning STM -32 SeoTechnoscripts
5 views26 slides
OpenCR tutorial_icra2017 by
OpenCR tutorial_icra2017 OpenCR tutorial_icra2017
OpenCR tutorial_icra2017 chcbaram
2.1K views18 slides
Embedded Linux BSP Training (Intro) by
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)RuggedBoardGroup
777 views29 slides
Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Bo... by
Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Bo...Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Bo...
Developing Applications for Beagle Bone Black, Raspberry Pi and SoC Single Bo...ryancox
7.6K views38 slides

More Related Content

Similar to OpenOCD-K3

Share the Experience of Using Embedded Development Board by
Share the Experience of Using Embedded Development BoardShare the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development BoardJian-Hong Pan
271 views50 slides
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood by
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hoodEmbedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hoodEmbeddedFest
421 views25 slides
Userspace drivers-2016 by
Userspace drivers-2016Userspace drivers-2016
Userspace drivers-2016Chris Simmonds
1.9K views20 slides
Linxu conj2016 96boards by
Linxu conj2016 96boardsLinxu conj2016 96boards
Linxu conj2016 96boardsLF Events
293 views46 slides
Lab Handson: Power your Creations with Intel Edison! by
Lab Handson: Power your Creations with Intel Edison!Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!Codemotion
2K views66 slides
Getting started with Intel IoT Developer Kit by
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer KitSulamita Garcia
17.8K views67 slides

Similar to OpenOCD-K3(20)

Share the Experience of Using Embedded Development Board by Jian-Hong Pan
Share the Experience of Using Embedded Development BoardShare the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development Board
Jian-Hong Pan271 views
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood by EmbeddedFest
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hoodEmbedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
EmbeddedFest421 views
Linxu conj2016 96boards by LF Events
Linxu conj2016 96boardsLinxu conj2016 96boards
Linxu conj2016 96boards
LF Events293 views
Lab Handson: Power your Creations with Intel Edison! by Codemotion
Lab Handson: Power your Creations with Intel Edison!Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!
Codemotion2K views
Getting started with Intel IoT Developer Kit by Sulamita Garcia
Getting started with Intel IoT Developer KitGetting started with Intel IoT Developer Kit
Getting started with Intel IoT Developer Kit
Sulamita Garcia17.8K views
Stm32 f4 first touch by Benux Wei
Stm32 f4 first touchStm32 f4 first touch
Stm32 f4 first touch
Benux Wei3.6K views
Cross-compilation native sous android by Thierry Gayet
Cross-compilation native sous androidCross-compilation native sous android
Cross-compilation native sous android
Thierry Gayet320 views
IoT with openHAB on pcDuino3B by Jingfeng Liu
IoT with openHAB on pcDuino3BIoT with openHAB on pcDuino3B
IoT with openHAB on pcDuino3B
Jingfeng Liu3.7K views
First Steps Developing Embedded Applications using Heterogeneous Multi-core P... by Toradex
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...
Toradex 692 views
Deploy STM32 family on Zephyr - SFO17-102 by Linaro
Deploy STM32 family on Zephyr - SFO17-102Deploy STM32 family on Zephyr - SFO17-102
Deploy STM32 family on Zephyr - SFO17-102
Linaro2.2K views
Linux Kernel , BSP, Boot Loader, ARM Engineer - Satish profile by Satish Kumar
Linux Kernel , BSP, Boot Loader, ARM Engineer - Satish profileLinux Kernel , BSP, Boot Loader, ARM Engineer - Satish profile
Linux Kernel , BSP, Boot Loader, ARM Engineer - Satish profile
Satish Kumar238 views
pcDuino Presentation at SparkFun by Jingfeng Liu
pcDuino Presentation at SparkFunpcDuino Presentation at SparkFun
pcDuino Presentation at SparkFun
Jingfeng Liu2.4K views
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD by Linaro
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSDLAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
Linaro1.2K views
LAS16-403 - GDB Linux Kernel Awareness by Peter Griffin
LAS16-403 - GDB Linux Kernel Awareness LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness
Peter Griffin121 views
LAS16-403: GDB Linux Kernel Awareness by Linaro
LAS16-403: GDB Linux Kernel AwarenessLAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel Awareness
Linaro1.4K views
IoT Getting Started with Intel® IoT Devkit by Vasily Ryzhonkov
IoT Getting Started with Intel® IoT DevkitIoT Getting Started with Intel® IoT Devkit
IoT Getting Started with Intel® IoT Devkit
Vasily Ryzhonkov5.4K views

Recently uploaded

How I learned to stop worrying and love the dark silicon apocalypse.pdf by
How I learned to stop worrying and love the dark silicon apocalypse.pdfHow I learned to stop worrying and love the dark silicon apocalypse.pdf
How I learned to stop worrying and love the dark silicon apocalypse.pdfTomasz Kowalczewski
24 views66 slides
Design and analysis of a new undergraduate Computer Engineering degree – a me... by
Design and analysis of a new undergraduate Computer Engineering degree – a me...Design and analysis of a new undergraduate Computer Engineering degree – a me...
Design and analysis of a new undergraduate Computer Engineering degree – a me...WaelBadawy6
53 views4 slides
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L... by
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...Anowar Hossain
12 views34 slides
SWM L1-L14_drhasan (Part 1).pdf by
SWM L1-L14_drhasan (Part 1).pdfSWM L1-L14_drhasan (Part 1).pdf
SWM L1-L14_drhasan (Part 1).pdfMahmudHasan747870
48 views150 slides
fakenews_DBDA_Mar23.pptx by
fakenews_DBDA_Mar23.pptxfakenews_DBDA_Mar23.pptx
fakenews_DBDA_Mar23.pptxdeepmitra8
12 views34 slides
String.pptx by
String.pptxString.pptx
String.pptxAnanthi Palanisamy
47 views24 slides

Recently uploaded(20)

How I learned to stop worrying and love the dark silicon apocalypse.pdf by Tomasz Kowalczewski
How I learned to stop worrying and love the dark silicon apocalypse.pdfHow I learned to stop worrying and love the dark silicon apocalypse.pdf
How I learned to stop worrying and love the dark silicon apocalypse.pdf
Design and analysis of a new undergraduate Computer Engineering degree – a me... by WaelBadawy6
Design and analysis of a new undergraduate Computer Engineering degree – a me...Design and analysis of a new undergraduate Computer Engineering degree – a me...
Design and analysis of a new undergraduate Computer Engineering degree – a me...
WaelBadawy653 views
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L... by Anowar Hossain
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...
DevOps to DevSecOps: Enhancing Software Security Throughout The Development L...
Anowar Hossain12 views
fakenews_DBDA_Mar23.pptx by deepmitra8
fakenews_DBDA_Mar23.pptxfakenews_DBDA_Mar23.pptx
fakenews_DBDA_Mar23.pptx
deepmitra812 views
Thermal aware task assignment for multicore processors using genetic algorithm by IJECEIAES
Thermal aware task assignment for multicore processors using genetic algorithm Thermal aware task assignment for multicore processors using genetic algorithm
Thermal aware task assignment for multicore processors using genetic algorithm
IJECEIAES30 views
MSA Website Slideshow (16).pdf by msaucla
MSA Website Slideshow (16).pdfMSA Website Slideshow (16).pdf
MSA Website Slideshow (16).pdf
msaucla46 views
What is Whirling Hygrometer.pdf by IIT KHARAGPUR
What is Whirling Hygrometer.pdfWhat is Whirling Hygrometer.pdf
What is Whirling Hygrometer.pdf
IIT KHARAGPUR 11 views
Informed search algorithms.pptx by Dr.Shweta
Informed search algorithms.pptxInformed search algorithms.pptx
Informed search algorithms.pptx
Dr.Shweta13 views
9_DVD_Dynamic_logic_circuits.pdf by Usha Mehta
9_DVD_Dynamic_logic_circuits.pdf9_DVD_Dynamic_logic_circuits.pdf
9_DVD_Dynamic_logic_circuits.pdf
Usha Mehta28 views
7_DVD_Combinational_MOS_Logic_Circuits.pdf by Usha Mehta
7_DVD_Combinational_MOS_Logic_Circuits.pdf7_DVD_Combinational_MOS_Logic_Circuits.pdf
7_DVD_Combinational_MOS_Logic_Circuits.pdf
Usha Mehta59 views
Machine Element II Course outline.pdf by odatadese1
Machine Element II Course outline.pdfMachine Element II Course outline.pdf
Machine Element II Course outline.pdf
odatadese17 views
Update 42 models(Diode/General ) in SPICE PARK(DEC2023) by Tsuyoshi Horigome
Update 42 models(Diode/General ) in SPICE PARK(DEC2023)Update 42 models(Diode/General ) in SPICE PARK(DEC2023)
Update 42 models(Diode/General ) in SPICE PARK(DEC2023)
STUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptx by AnnieRachelJohn
STUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptxSTUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptx
STUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptx
AnnieRachelJohn31 views

OpenOCD-K3

  • 1. OpenOCD primer – K3 Devices Date: 2023-09-22 Nishanth Menon 1
  • 2. Overview  What is OpenOCD  Features of OpenOCD  OpenOCD overview  OpenOCD Hardware setup: xds110, cTI20, tag-connect  Building OpenOCD  OpenOCD integration with IDEs  Debugging U-Boot  Debugging Linux Kernel  Self Hosted Debug 2
  • 3. What is OpenOCD OpenOCD (Open On-Chip Debugger) is an open-source software project that provides debugging and in-circuit programming support for various microcontrollers and microprocessors. It allows developers to interact with and control the hardware of embedded systems during both development and production phases. OpenOCD supports a wide range of target architectures and interfaces with various hardware debugging probes. 3
  • 4. Features of OpenOCD  Debugging: OpenOCD enables developers to perform source-level debugging, inspect memory, set breakpoints, and single-step through code on embedded systems.  Hardware Debug Probes: OpenOCD interfaces with hardware debug probes like JTAG (Joint Test Action Group) and SWD (Serial Wire Debug) adapters to connect to the target hardware.  GDB Integration: OpenOCD can be used as a target for the GNU Debugger (GDB), allowing developers to use familiar debugging tools with their embedded systems.  Scripting: OpenOCD can be scripted to automate various debugging and programming tasks, making it useful for both manual and automated testing.  Flash Programming: OpenOCD supports programming the flash memory of microcontrollers and microprocessors, allowing developers to load and update firmware.  Support for Various Targets: OpenOCD provides support for a wide range of target architectures, including ARM, MIPS, RISC-V, and others, making it versatile for different embedded systems.  Cross-Platform: OpenOCD is cross-platform and can be used on various operating systems, including Windows, Linux, and macOS. 4
  • 5. OpenOCD overview 5 K3 Generation — Das U-Boot unknown version documentation
  • 6. OpenOCD hardware setup – XDS110 K3 Generation — Das U-Boot unknown version documentation Connect a micro-USB cable to the board to the mentioned port.
  • 7. OpenOCD hardware setup – cTI20 K3 Generation — Das U-Boot unknown version documentation •TUMPA or equivalent dongles supported by OpenOCD. •Cable such as Tag-connect ribbon cable •Adapter to convert cTI20 to ARM20 such as those from Segger or Lauterbach LA-3780 Or optionally, if you have manufacturing capability then you could try BeagleBone JTAG Adapter
  • 8. OpenOCD hardware setup – tagConnect K3 Generation — Das U-Boot unknown version documentation •TUMPA or equivalent dongles supported by OpenOCD. •Tag-Connect cable appropriate to the board such as TC2050-IDC-NL •In case of no-leg, version, a retaining clip •Tag-Connect to ARM20 adapter
  • 9. Building OpenOCD 9 # Check the packages to be installed: needs deb-src in sources.list sudo apt build-dep openocd # The following list is NOT complete - please check the latest sudo apt-get install libtool pkg-config texinfo libusb-dev libusb-1.0.0-dev libftdi-dev libhidapi-dev autoconf automake git clone https://github.com/openocd-org/openocd.git openocd cd openocd git submodule init git submodule update ./bootstrap ./configure --prefix=/usr/local/ make -j`nproc` sudo make install K3 Generation — Das U-Boot unknown version documentation
  • 10. OpenOCD IDE integration with GDB gdb-dashboard GEF (GDB Enhanced Features) K3 Generation — Das U-Boot unknown version documentation Debugger Setup with GDB + OpenOCD in Visual Studio Code (justinmklam.com) AND MANY MANY MANY MORE!
  • 11. Debug U-boot 11 diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 69e281b086..744929e825 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -37,6 +37,8 @@ #endif reset: +dead_loop: + b dead_loop /* Allow the board to save important registers */ b save_boot_params save_boot_params_ret: K3 Generation — Das U-Boot unknown version documentation void board_init_f(ulong dummy) { . . /* Code to run on the R5F (Wakeup/Boot Domain) */ if (IS_ENABLED(CONFIG_CPU_V7R)) { volatile int x = 1; while(x) {}; } ... /* Code to run on the ARMV8 (Main Domain) */ if (IS_ENABLED(CONFIG_ARM64)) { volatile int x = 1; while(x) {}; } . . } Option 1: reset Option 2: board_init_f
  • 12. Demo – Debug U-Boot 12 K3 Generation — Das U-Boot unknown version documentation xds110 Console AM625-SK
  • 13. Demo – Debug U-Boot – VsCode integration 13 https://gist.github.com/nmenon/c2984e28f1af73292c0bd472c7522460
  • 14. Debug Kernel 14 Pending Patches (on track to merge in next few weeks) https://review.openocd.org/c/openocd/+/7896 https://review.openocd.org/c/openocd/+/7897 https://review.openocd.org/c/openocd/+/7898 • Step 1: Disable kernel options: • CONFIG_ARM_CORESIGHT_PMU_ARCH_SYSTEM_PMU=n • CONFIG_CORESIGHT=n • Step 2: kernel command line options: Add: • rodata=off cpuidle.off=1 nokaslr • nosmp – to disable multi-cpu debug openocd -c 'set V8_SMP_DEBUG 1' -c "set RTOS(am625.cpu.a53.0) hwthread" -f board/ti_am625evm.cfg
  • 15. Demo – Debug Kernel 15
  • 16. OpenOCD Self hosted debug  Debug M4F or R5F from A53 itself. # Check the packages to be installed: needs deb-src in sources.list sudo apt build-dep openocd # The following list is NOT complete - please check the latest sudo apt-get install libtool pkg-config texinfo libusb-dev libusb-1.0.0-dev libftdi-dev libhidapi-dev autoconf automake git clone https://github.com/openocd-org/openocd.git openocd cd openocd git submodule init git submodule update ./bootstrap ./configure --prefix=/usr/local/ --enable-dmem make -j`nproc` sudo make install sudo openocd -c "set RTOS(am625.cpu.gp_mcu) Zephyr" -f board/ti_am625_swd_native.cfg