Linux Debugger configuration: Difference between revisions

From Miosix Wiki
Jump to navigation Jump to search
(Add comment about using cfg scripts included with OpenOCD.)
m (Bold markup rather than italic.)
 
(One intermediate revision by the same user not shown)
Line 15: Line 15:


OpenOCD provides built-in configuration files for many boards, chips and debugging adapters. You can see the entire range of files in the directory <code>/usr/share/openocd/scripts</code>. If Miosix does not provide a configuration file for you, in most cases there will be appropriate scripts available together with OpenOCD.
OpenOCD provides built-in configuration files for many boards, chips and debugging adapters. You can see the entire range of files in the directory <code>/usr/share/openocd/scripts</code>. If Miosix does not provide a configuration file for you, in most cases there will be appropriate scripts available together with OpenOCD.
'''If breakpoints don't work on your board''' you can try adding the option <code>-c 'gdb_breakpoint_override hard'</code> to the OpenOCD invocation. This option disables GDB software breakpoints and always forces the use of hardware breakpoints, which might be needed if OpenOCD provides an incomplete memory map to GDB.


== Debugging with GDB ==
== Debugging with GDB ==

Latest revision as of 20:37, 3 July 2023

The debugging of Miosix on Linux can be done through OpenOCD, that creates a bridge between GDB and the JTAG device.

Setting up OpenOCD

Install OpenOCD

sudo apt-get install openocd # Install OpenOCD for Ubuntu/Debian

Run OpenOCD

The OpenOCD configuration is included in the official Miosix distribution under the path 'miosix/arch'. You must choose the proper config file for the device in use. For example for the stm32f429zi_stm32f4discovery board:

openocd -f miosix/arch/cortexM4_stm32f4/stm32f429zi_stm32f4discovery/stm32f4discovery.cfg

OpenOCD provides built-in configuration files for many boards, chips and debugging adapters. You can see the entire range of files in the directory /usr/share/openocd/scripts. If Miosix does not provide a configuration file for you, in most cases there will be appropriate scripts available together with OpenOCD.

If breakpoints don't work on your board you can try adding the option -c 'gdb_breakpoint_override hard' to the OpenOCD invocation. This option disables GDB software breakpoints and always forces the use of hardware breakpoints, which might be needed if OpenOCD provides an incomplete memory map to GDB.

Debugging with GDB

The GDB used is provided by the official Miosix Toolchain. If you haven't already installed it's time to do it. The debugger must be launched on the ELF binary file.

arm-miosix-eabi-gdb main.elf

Connect GDB

OpenOCD provide a network interface for connect the debugger, the follow command is necessary for establish the connection:

(gdb) target remote <ip>:<port>

The default socket is listening on port 3333 in the loopback interface of your computer. So you can use the default command:

(gdb) target remote :3333

Reset the board

After the connection (and after each change of configuration) you must reset the board in a safe state:

(gdb) monitor reset halt

Flash a new firmware

If you want to upload to the board a new firmware version you can made it through gdb and OpenOCD, you must indicate the binary file and the address of the flash memory of your board:

(gdb) monitor flash write_image erase main.bin 0x08000000

It's often necessary to perform a reset of the board before and after the firmware upload.