Montag, 6. November 2017

This article describes how to setup an Eclipse project so that it is possible to debug a program running on the NXHX51-ETM eval board from Hilscher. Hopefully the procedure should be similar for other processors/eval boards.
This tutorial expects that you have setup your project in eclipse and that it compiles using the GCC cross compiler.

Prerequisites

 The following software is needed to be able to debug:

gdb Standalone

 You can try to debug the program on the command line first to check if everything is woking fine.

Find Program Entry Point

The program entry point has to be determined so that the program counter can be set to the correct position before running the program.
The entry point can be determined with the readelf tool:
"<Path to netx Studio GCC-installation>\arm-none-eabi-readelf.exe" -l "<ELF-file>"

Example for ELF entry point


Starting OpenOCD

 The debug server can be started with the following command:
"<path to openocd>\bin\openocd.exe" -c "gdb_port 3333" -c "adapter_khz 1000" -s "<path to netx openocd scripts>" -f interface\hilscher_nxhx_onboard.cfg -f board\hilscher_nxhx51.cfg -c "load_image <ELF-file> 0x0 elf" -c "puts gdb-server-ready"
It ist importand to replace the "\" with "/" in the path of the elf-file for the load_image command.
The path to the script OpenOCD script files would be:
%ProgramData%\Hilscher GmbH\netX Studio CDT\BuildTools\openocd

Starting gdb

The debugger can then be started with the following command:
"<path to netx Studio GCC-installation>\arm-none-eabi-gdb.exe" --eval-command="target remote localhost:3333" "<ELF-file>"
If you use the Hilscher compiler the GCC installation is in the following directory:
%ProgramData%\Hilscher GmbH\netX Studio CDT\BuildTools\arm-none-eabi-gcc\4.5.2\bin

Debugging Using Eclipse

Before setting up Eclipse make sure you have installed the GNU MCU Eclipse plugin.

Setup Eclipse

 Create a new debug configuration in Eclipse. Go to Run -> Debug Configurations... and create a new GDB Hardware Debugging configuration.
 Select the ELF-file which should be debugged and select Disable auto build if needed.
 In the Debugger dialog select the path to the GCC installation. Select Use remote target and select GNU ARM OpenOCD as JTAG Device. Select the Port number which was given as command line argument to OpenOCD.
Set the program counter to the entry point which was determined previously in the Startup dialog and store the settings with Apply.

Start Debug Session

First start OpenOCD:
"<path to openocd>\bin\openocd.exe" -c "gdb_port 3333" -c "adapter_khz 1000" -s "<path to netx openocd scripts>" -f interface\hilscher_nxhx_onboard.cfg -f board\hilscher_nxhx51.cfg -c "load_image <ELF-file> 0x0 elf"
Then start the previously configured debug session.

Example Scripts to Run Program Directly on Target

environment.cmd
run_openocd.cmd

Keine Kommentare:

Kommentar veröffentlichen