GDB Connection Problem

Asked by andre

Hi, I'm using this toolchain for compiling software for a STM32F4 processor.
I integrated the toolchain into Code::Blocks and also wanted to use the Debugging features now.
I'm using the STM32F4 Discovery Board with the integrated ST-Link. As GDB-Server I'm using the one Provided by "Atollic Studio for ARM Lite" (The GDB-Server runs fine with the GDB provided by Atoolic Studio so i guess there isn't the problem..)

But I'm running into some trouble when I'm trying to connect to the GDB-Server:

#############################################################################

C:\Users\andre\Projekte\STM32F4-Test\bin\Debug>"c:\Program Files (x86)\GNU Tools
 ARM Embedded\4.6 2012q1\bin\arm-none-eabi-gdb.exe" STM32F4-Test.elf
GNU gdb (GNU Tools for ARM Embedded Processors) 7.3.1.20120316-cvs
Copyright (C) 2011 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=i586-mingw32 --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from C:\Users\andre\Projekte\STM32F4-Test\bin\Debug/STM32F4-Test
.elf...done.
(gdb) target remote localhost:61234
Remote debugging using localhost:61234
Remote 'g' packet reply is too long: 0000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000220ffffffffbb2
60008000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000020000041
(gdb)

#############################################################################

I hope you could give me a hint where I could start looking for the problem as i don't want to have to use printf everywhere for debugging.

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Terry Guo
Solved:
Last query:
Last reply:
Revision history for this message
Best Terry Guo (terry.guo) said :
#1

The "g" packet sent from your gdb client to Atollic gdb server was requiring all the target registers information. It is kind of handshake thing during the set up of connection. The error is due to the assumption of gdb client isn't consistent with the information returned from the gdb server.

The detailed cause is:
For you case, the gdb client figures out target register information from your ELF file which I assume is compiled for armv7-m or armv7e-m. Apparently those architectures don't contain any legacy FPA registers. That's also the recent GDB regards. You gdb client thinks so too. But the Atollic gdb server doesn't think so. For some reason, it returns register info which contains eight 96bit FPA registers. That breaks the assumption of gdb client and causes the complain of "reply is too long".

There are two solutions for this issue:
1) Pick up another GDB server which can return correct target register info. For STM32F4 board, there is a specific open source GDB server for STLINK at https://github.com/texane/stlink. You can give it a shot.

2) Or compose a special target description xml file which contains armv7-m core registers and faked FPA registers, then use gdb command "set tdesc filename YOUR-XML-FILE" to let the gdb client also assume the target contains FPA registers.

Meanwhile I am gonna to talk to Atollic to see if they can do something to their GDB server. But it will take some time.

Here is an example XML file for your reference:

<?xml version="1.0"?>
<!-- Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->
<!-- A target description for an M-profile device, for stubs that
transfer registers using the historical fpa layout. -->
<!DOCTYPE target SYSTEM "gdb-target.dtd">
<target>
<feature name="org.gnu.gdb.arm.m-profile">
<reg name="r0" bitsize="32"/>
<reg name="r1" bitsize="32"/>
<reg name="r2" bitsize="32"/>
<reg name="r3" bitsize="32"/>
<reg name="r4" bitsize="32"/>
<reg name="r5" bitsize="32"/>
<reg name="r6" bitsize="32"/>
<reg name="r7" bitsize="32"/>
<reg name="r8" bitsize="32"/>
<reg name="r9" bitsize="32"/>
<reg name="r10" bitsize="32"/>
<reg name="r11" bitsize="32"/>
<reg name="r12" bitsize="32"/>
<reg name="sp" bitsize="32" type="data_ptr"/>
<reg name="lr" bitsize="32"/>
<reg name="pc" bitsize="32" type="code_ptr"/>
<!-- Slack for unused FPA registers (f0-f7 + fps).
See arm-fpa.xml. -->
<reg name="" bitsize="96" type="arm_fpa_ext" regnum="16"/>
<reg name="" bitsize="96" type="arm_fpa_ext"/>
<reg name="" bitsize="96" type="arm_fpa_ext"/>
<reg name="" bitsize="96" type="arm_fpa_ext"/>
<reg name="" bitsize="96" type="arm_fpa_ext"/>
<reg name="" bitsize="96" type="arm_fpa_ext"/>
<reg name="" bitsize="96" type="arm_fpa_ext"/>
<reg name="" bitsize="96" type="arm_fpa_ext"/>
<reg name="" bitsize="32"/>
<reg name="xpsr" bitsize="32" regnum="25"/>
</feature>
</target>

Thanks for trying out our tool chain and please let me know if you have any question.

Terry

Revision history for this message
andre (andre-wittmann) said :
#2

Thanks Terry Guo, that solved my question.

Revision history for this message
andre (andre-wittmann) said :
#3

1) I already tried the ST-Link which worked - but the flashing of the device took about 4 minutes each which wasn't acceptable for me so i looked for another solution

2) that xml file worked great - thanks!

Revision history for this message
Roth Kalman (rothkalman) said :
#4

Hello everyone!

I have an issue related to Atollic ST-LINK GDB server and arm-none-eabi-gdb.

I am using Eclipse, and I added a RUN procedure which starts the ST-LINK GDB server. It looks like the server stands up properly.

After this I open cmd.exe, jumping to the directory which contains my test.elf file.

I type : "arm-none-eabi-gdb test.elf"

After this i am getting a good response, gdb see my test.elf file properly. Now I want to connect to ST-LINK GDB server:
"target remote localhost:61234"

After this command the server collapses and returns error code 37.

I cannot figure out what causes this collapse, any idea?

(I am using the same STM32F4 discovery board)

Revision history for this message
Terry Guo (terry.guo) said :
#5

Just from the gdb server log, I think the server has a problem to handle gdb client's query package. Better to post your issue in Atollic support forum.

[0.230] STM32_AppReset(): NVIC_DFSR_REG = 0x00000009
[0.233] STM32_AppReset(): NVIC_CFGFSR_REG = 0x00000000
[0.235] STM32_AppReset(): XPSR = 0x01000000
[0.236] STM32_InitDevice(): ST_LINK Major version =2 Jtag version =16
[0.236] STM32_InitDevice(): ST_LINK VID=1155 PID=14152
[0.237] STM32_InitDevice(): ST_LINK device status: HALT_MODE
[0.243] stm32_reset_hw_wtchpt_module(): Hardware watchpoint supported by the target
[0.252] create_stm32_flash_device(): FuncEntry
[0.254] create_stm32_flash_device(): STM32 device: id =20006411
[0.255] create_stm32_flash_device(): STM32 device: Flash size =1024
[0.256] create_stm32_flash_device(): FuncExit
[0.256] read_f2_option_bytes(): FuncEntry
[0.260] read_f2_option_bytes(): FuncExit
[0.260] main(): Start Logging
[0.265] Socket_WaitForTrueStudioConnection(): Waiting for TrueSTUDIO client to connect on port 4242 ...
[3.732] Socket_WaitForTrueStudioConnection(): TrueSTUDIO client connected.
[3.733] Socket_WaitForTrueStudioConnection(): Receive buffer size set to 65536 bytes.
[3.733] Socket_Write(): Tx: #60a$

[3.733] Socket_Read(): Rx: +$qSupported:multiprocess+;qRelocInsn+#2a
[3.835] main(): Error while waiting for debugger connection, error 37.

Revision history for this message
Terry Guo (terry.guo) said :
#6

I tried with Atollic GDB from same Atollic IDE package and got below errors:

(gdb) target remote :4242
Remote debugging using :4242
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Ignoring packet error, continuing...
warning: Invalid remote reply: timeout

Seems to me that the gdb server has some kind of problems.