# Problem debugging FreeRTOS application with GDB

**URL:** <https://forums.freertos.org/t/problem-debugging-freertos-application-with-gdb/6001>\
**Category:** Kernel\
**Created:** [June 23, 2016, 10:46am UTC](https://forums.freertos.org/t/problem-debugging-freertos-application-with-gdb/6001 "2016-06-23T10:46:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 23, 2016, 10:46am UTC](https://forums.freertos.org/t/problem-debugging-freertos-application-with-gdb/6001/1 "2016-06-23T10:46:36Z")

</div>

**[alexc63](https://sourceforge.net/u/alexc63/)** wrote on [Thursday, June 23, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/6e725b01/#4436):

Hello everybody,  
I have the following problem.

The scenario first:

- Custom board (fully tested) with Kinetis K10 MCU
- Kinetis Design Studio 3.0.0
- Pemicro Multilink Universal debugger
- FreeRTOS 9.0.0 (I’m using the GCC / Cortex M3 port)
- I’m not using Processor Expert

The problem: when debugging a program with FreeRTOS, I can set breakpoints and step through code, but when I try to return from a function by stepping on its last instruction (i.e. closing curly bracket), gdb crashes. In the console I get the following errors:

_Unable to go into background mode.  
Error communicating to target processor - try a RESET.  
PE-ERROR: TARGET IS RUNNING_

The same program works as expected if I let it run without debugging. Please note that when I debug a program that doesn’t use FreeRTOS everything works like a charm.

In assembler, the offending instruction that causes the crash to happen is ‘mov sp,r7’. I noticed that at this point the PSP is used instead of MSP. After stepping on this instruction the crash occurs and the disassembly window shows: -\_\_isr\_vector followed by rows of : 0xffffffff.

Also, in FreeRTOSConfig.h, I have defined configTASK\_RETURN\_ADDRESS 0 /\* return address of task is zero \*/ as suggested in some posts.

Thank you in advance for your help, which would be greatly appreciated.  
Alex

---

<div class="post-metadata">

**Author:** ![McuOnEclipse](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/mcuoneclipse/32/32_2.png) [@McuOnEclipse](https://forums.freertos.org/u/McuOnEclipse)\
**Post date:** [June 23, 2016, 11:05am UTC](https://forums.freertos.org/t/problem-debugging-freertos-application-with-gdb/6001/2 "2016-06-23T11:05:36Z")

</div>

**[xz8987f](https://sourceforge.net/u/xz8987f/)** wrote on [Thursday, June 23, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/6e725b01/#7911):

Hi Alex,  
I have not seen anything like this. But I would recommend that you check if you have the latest P&E plugins installed. Use the Eclipse menu  
Help \> Install New Software  
and use the follwing upate site:  
[http://www.pemicro.com/eclipse/updates](http://www.pemicro.com/eclipse/updates)

I hope this helps,  
Erich

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 23, 2016, 4:07pm UTC](https://forums.freertos.org/t/problem-debugging-freertos-application-with-gdb/6001/3 "2016-06-23T16:07:27Z")

</div>

**[alexc63](https://sourceforge.net/u/alexc63/)** wrote on [Thursday, June 23, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/6e725b01/#7911/aed0):

Hi Erich,  
Thank you for your quick reply. I actually tried with two different PC’s, one with the latest P&E plugins installed. Unfortunately in both cases GDB crashes … (also, on the PC with the latest plugins, sometimes the disassembly window doesn’t show any code (just a series of dots …); closing this window and reopening it with Window - Show View - Disassembly doesn’t work either).  
I really don’t know what’s going on. Any ideas ? Would you rule out a HW problem (although it seems very unlikely to me) ?

Thank you  
Alex

---

<div class="post-metadata">

**Author:** ![McuOnEclipse](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/mcuoneclipse/32/32_2.png) [@McuOnEclipse](https://forums.freertos.org/u/McuOnEclipse)\
**Post date:** [June 23, 2016, 6:03pm UTC](https://forums.freertos.org/t/problem-debugging-freertos-application-with-gdb/6001/4 "2016-06-23T18:03:28Z")

</div>

**[xz8987f](https://sourceforge.net/u/xz8987f/)** wrote on [Thursday, June 23, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/6e725b01/#333e):

Hi Alex,  
I don’t have a K10, but I don’t think it is a hardware problem or like that. If you have access to a Segger J-Link, then you could try a different debug connection. The message ‘unable to go into background mode’ indicates that the debugger is not able to talk anymore to the target. This typically happens with low voltage (power supply problem).

Erich

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [June 24, 2016, 2:00pm UTC](https://forums.freertos.org/t/problem-debugging-freertos-application-with-gdb/6001/5 "2016-06-24T14:00:31Z")

</div>

**[alexc63](https://sourceforge.net/u/alexc63/)** wrote on [Friday, June 24, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/6e725b01/#333e/b0fe):

Hi Erich,  
Thank you for your reply. Unfortunately I don’t have a Segger J-Link to try another connection. To me it looks like a GDB problem. Here is what I get in the GDB console after the crash:

**129,750 =thread-group-exited,id=“i1”  
129,750 ~"/home/build/work/GCC-4-8-build/src/gdb/gdb/thread.c:72: internal-error: inferior\_thread: Assertion tp failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? "  
129,750 ~"(y or n) [answered Y; input not from terminal]"  
129,750 ~"/home/build/work/GCC-4-8-build/src/gdb/gdb/thread.c:72: internal-error: inferior\_thread: Assertion tp failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? "  
129,750 ~"(y or n) [answered Y; input not from terminal]"  
129,785 63-gdb-exit**

Does the above give you any indication about what may be wrong ?

Thanks again for your help  
Alex

---

<div class="post-metadata">

**Author:** ![McuOnEclipse](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/mcuoneclipse/32/32_2.png) [@McuOnEclipse](https://forums.freertos.org/u/McuOnEclipse)\
**Post date:** [June 25, 2016, 2:43pm UTC](https://forums.freertos.org/t/problem-debugging-freertos-application-with-gdb/6001/6 "2016-06-25T14:43:55Z")

</div>

**[xz8987f](https://sourceforge.net/u/xz8987f/)** wrote on [Saturday, June 25, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/6e725b01/#ff20):

Hi Alex,  
no, this does not tell me what the problem is. You might try with a later version of GDB, maybe this helps.  
Erich
