Linux Debugger configuration: Difference between revisions
Andreabont (talk | contribs) No edit summary |
(Add comment about using cfg scripts included with OpenOCD.) |
||
Line 13: | Line 13: | ||
openocd -f miosix/arch/cortexM4_stm32f4/stm32f429zi_stm32f4discovery/stm32f4discovery.cfg | openocd -f miosix/arch/cortexM4_stm32f4/stm32f429zi_stm32f4discovery/stm32f4discovery.cfg | ||
</source> | </source> | ||
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. | |||
== Debugging with GDB == | == Debugging with GDB == |
Revision as of 14:36, 29 May 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.
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.