November 23, 2024, 02:23:10 AM

openocd and arm-none-eabi-gdb problem

Started by sleepy joe, September 09, 2013, 09:43:59 PM

Previous topic - Next topic

sleepy joe

Hi,I have the Olimex sam7-p256 dev board
and the Olimex ARM-USB-OCD-H,
and using Windows xp professional,
and have installed the olimex software package (Eclipse, Yagarto, Openocd),
says it works 'out of the box'.   Alas, no!
I found that none of the examples compiled, it seemed the makefiles refer to a different strain of
toolchain, and those that I could modify successfully had project files and the like missing.

However after much meddling, I have had limited success at compiling a binary file, but here's the crunch,
I can only programme my board via Telnet.
The gdb server will not communicate properly and boms out using either eclipse, or through DOS.

The gdb I have is arm-none-eabi-gdb.exe
and I use openocd-0.6.1.exe

The following shows the gdb session:-

---------------------------------------
<gdb> target remote localhost:3333
Remote debugging using localhost:3333
Remote communication error: No error.
<gdb>
----------------------------------------
and the openocd response:-

info : accepting 'gdb' connection from 3333
Error: Target not halted
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to
prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
----------------------------------------------
I haven't found anything that touches on this problem anywhere in Google land,
does anyone have a clue why this is happening?

Regards.

LubOlimex

Hey sleepy joe,

If any of the examples didn't compile successfully without modifying it then probably one of these two events occurred:

1. The default install path contained "space" character which confused the compiler.
2. When you have made an example "active" you didn't click in one of its source files (to highlight the project). This confused the compiler again due to the fact it doesn't know which project exactly is highlighted.

I installed the IDE again and the project compiled fine, here is a screenshot: http://i.imgur.com/Cmf3YvC.jpg.

Please refer to this long forum post here, where a lot of things are explained: https://www.olimex.com/forum/index.php?topic=760.0

Best regards,
Lub/OLIMEX
Technical support and documentation manager at Olimex

sleepy joe

Hi, thanks for the reply.
The issues I am having with compiling with Eclipse are down to my understanding of the envoironment, and getting to grips with the types of other ancillary files required for a project.
I will in time master at least some of what I need to know.

However, the real bug bear is the failure of GDB to communicate with openocd,
So effectivly, I cannot programme or debug using gdb with Eclipse.

I can compile some programmes using Eclipse, but then I need to shut it down and open two DOS windows (cmd).
    One to run openocd in, and one to run a Telnet session in, I can then successfuly programme my board.

I have read all the posts relating to openocd or JTAG problems but none have the type of failure that I have described, which is most frustrating.
Regards.

LubOlimex

#3
Hey joe,

When you start the IDE and you open a project that you have successfully compiled; then you try to choose the correct debugger configuration from the drop-down menu (like shown here: http://i.imgur.com/5y9XHM7.png) and then you choose the flash settings (like shown here: http://i.imgur.com/prT43pw.png). Finally you click debug button.

Just to confirm is it what you do?

Normally you don't need two CMD windows with Telnet if you are using our Eclipse IDE this is done automatically and there is a windows showing the output from the terminal (for debugging and monitoring purposes).

Best regards,
Lub/OLIMEX
Technical support and documentation manager at Olimex

sleepy joe

Hi Lub/OLIMEX
Thanks for your response.
I have tried to debug using the exact same method you have shown just as all the tutorials explain, but eclipse will not connect to gdb !
when I click on the debugger, I get the expected result.  the console output displays the following :-

Open On-Chip Debugger 0.6.1 (2012-10-07-10:34)
Licensed under GNU GPL v2
For bug reports, read
   http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
srst_only srst_pulls_trst srst_gates_jtag srst_open_drain
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
adapter speed: 10000 kHz
Warn : use 'at91sam7s.cpu' as target identifier, not '0'
Info : max TCK change to: 30000 kHz
Info : clock speed 10000 kHz
Info : JTAG tap: at91sam7s.cpu tap/device found: 0x3f0f0f0f (mfg: 0x787, part: 0xf0f0, ver: 0x3)
Info : Embedded ICE version 1
Info : at91sam7s.cpu: hardware has 2 breakpoint/watchpoint units

And then I click on the flash settings.  the console output displays the following :-


46-gdb-set confirm off
46^done
47-gdb-set width 0
(gdb)
47^done
(gdb)
48-gdb-set height 0
48^done
(gdb)
49-interpreter-exec console echo
49^done
(gdb)
50-gdb-show prompt
50^done,value="(gdb) "
(gdb)
51 target remote localhost:3333
target remote localhost:3333
&"target remote localhost:3333\n"
&"Remote connection closed\n"
51^error,msg="Remote connection closed"
Remote connection closed
(gdb)
52 monitor halt
&"monitor halt\n"
monitor halt
"monitor" command not supported by this target.
&"\"monitor\" command not supported by this target.\n"
52^error,msg="\"monitor\" command not supported by this target."
(gdb)
53 monitor arm7_9 force_hw_breakpoints enable
monitor arm7_9 force_hw_breakpoints enable
"monitor" command not supported by this target.
&"monitor arm7_9 force_hw_breakpoints enable\n"
&"\"monitor\" command not supported by this target.\n"
53^error,msg="\"monitor\" command not supported by this target."
(gdb)

and so on for every command!
The debugger console then adds the folloing messages:-

Error: Target not halted
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected

So you see, thats why I have to open two command windows and do it the long way using Telnet.
I thought that there could be some issues with Eclipse or its settings, or the PATH variables etc. etc

So I copied the file arm-none-eabi-gdb.exe and the file openocd-0.6.1.exe
as well as openocd's config files to a folder of their own,and once more opened two command windows.
I ran openocd and the window displayed the same as above.
I ran arm-none-eabi-gdb and I got the following:-

GNU gdb (GDB) 7.1
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-mingw32 --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb)

when I try to connect by typing:-  target remote localhost:3333
it produces the errors listed in my first post, so I would safetly say that this isn't an issue with Eclipse
or The machine PATH variables, but I am stumped by this one!
Regards.

Evgeny

#5
Hi!

I have the same issue.
When gdb connects to openocd first time - all works fine.
Also, if I terminate gdb when my program is suspended in breakpoint then gdb handles the termination, and openocd  allows further connections.

But if I trying to terminate gdb or pause running program after Resume, then Eclipse shows error message
"Target request failed: Failed to Interrupt" after about 20 seconds. There is no any console output from both gdb and openocd.
After this all subsequent attempts of gdb to connect to openocd are failed with error.
gdb says:
> Remote communication error: No error.

Openocd says:
> Info : rejected 'gdb' connection, no more connections allowed

It seems the openocd tries to hold the connection with killed gdb.

The only workaround I found is restarting openocd each time.

My logs are below



openocd console (all works fine here):

Open On-Chip Debugger 0.6.1 (2012-10-07-10:34)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
cortex_m3 reset_config sysresetreq
Info : J-Link initialization started / target CPU reset initiated
Info : J-Link ARM-OB STM32 compiled Dec 15 2010 11:30:03
Info : J-Link caps 0x88ea5833
Info : J-Link hw version 70000
Info : J-Link hw type J-Link
Info : J-Link max mem block 10328
Info : J-Link configuration
Info : USB-Address: 0xff
Info : Kickstart power on JTAG-pin 19: 0xd1e22e00
Info : Vref = 3.300 TCK = 1 TDI = 0 TDO = 1 TMS = 0 SRST = 0 TRST = 0
Info : J-Link JTAG Interface ready
Info : clock speed 1000 kHz
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020, part: 0x6413, ver: 0x0)
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection from 3333
Info : device id = 0x10016413
Info : flash size = 1024kbytes
Warn : acknowledgment received, but no packet pending
undefined debug reason 6 - target needs reset
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020, part: 0x6413, ver: 0x0)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080019a0 msp: 0x20020000
background polling: on
TAP: stm32f4x.cpu (enabled)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080019a0 msp: 0x20020000
auto erase enabled
wrote 16384 bytes from file main.bin in 1.162000s (13.769 KiB/s)
requesting target halt and executing a soft reset
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x01000000 pc: 0x080019a0 msp: 0x20020000
background polling: on
TAP: stm32f4x.cpu (enabled)
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x01000000 pc: 0x080019a0 msp: 0x20020000


gdb console

target remote localhost:3333
0x00000000 in ?? ()
monitor reset halt
JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020, part: 0x6413, ver: 0x0)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080019a0 msp: 0x20020000
monitor wait_halt
monitor sleep 100
monitor poll
background polling: on
TAP: stm32f4x.cpu (enabled)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080019a0 msp: 0x20020000
monitor flash write_image erase main.bin 0x08000000
auto erase enabled
wrote 16384 bytes from file main.bin in 1.162000s (13.769 KiB/s)
monitor sleep 200
monitor soft_reset_halt
requesting target halt and executing a soft reset
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x01000000 pc: 0x080019a0 msp: 0x20020000
monitor wait_halt
monitor poll
background polling: on
TAP: stm32f4x.cpu (enabled)
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x01000000 pc: 0x080019a0 msp: 0x20020000
thbreak main
Hardware assisted breakpoint 1 at 0x800018c: file main.c, line 77.
continue

Temporary breakpoint 1, main () at main.c:77
77   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
(actually the program is already not in brealpoint)

Terminating gdb does not produces any console output.

Then I run debug again.
openocd:

Info : rejected 'gdb' connection, no more connections allowed


gdb:

target remote localhost:3333
Remote communication error: No error.
monitor reset halt
"monitor" command not supported by this target.
monitor wait_halt
"monitor" command not supported by this target.
monitor sleep 100
"monitor" command not supported by this target.
monitor poll
"monitor" command not supported by this target.
monitor flash write_image erase main.bin 0x08000000
"monitor" command not supported by this target.
monitor sleep 200
"monitor" command not supported by this target.
monitor soft_reset_halt
"monitor" command not supported by this target.
monitor wait_halt
"monitor" command not supported by this target.
monitor poll
"monitor" command not supported by this target.
thbreak main
No hardware breakpoint support in the target.
continue
The program is not being run.