blackmagic-debug / blackmagic

In application debugger for ARM Cortex microcontrollers.
GNU General Public License v3.0
3.23k stars 768 forks source link

Debugging Nuttx fails #38

Closed staroselskii closed 10 years ago

staroselskii commented 10 years ago

Don't know if this is the BMP's issue or Nuttx but if I use J-Link with the same bin, no errors come up.

I'm trying to debug my project with BMP but debugging session fails at the start-up with this error (these messages appear on UART):

Assertion failed at file:sched_removereadytorun.c line: 105 sp: 20004a48 stack base: 20003194 stack size: 00000400 ERROR: Stack pointer is not within the allocated stack

These are commands I send:

target extended-remote /dev/ttyACM1 mon swdp_scan attach 1 monitor vector_catch disable hard set mem inaccessible-by-default off set print pretty

The Nuttx config I'm using barely differs from the stm32f4discovery's one. The only difference is another pin configuration.

The bin is successfully loaded. The only problem is debugging.

UweBonnes commented 10 years ago

The assert is emitted by the application. I wonder how blackmagic should have influence on the stack. Are you sure there is no other difference in your setup then once using J-Link and other using blackmagic?

Otherwise, maybe Gareth can help...

staroselskii commented 10 years ago

https://groups.yahoo.com/neo/groups/nuttx/conversations/topics/5262 the topic related to the problem.

So basically I need a way to prevent BMP from reacting on hardfaults. That is what I've tried to with monitor vector_catch disable hard but it hasn't done any good.

Now I use a hack introduced here: http://www.nuttx.org/doku.php?id=wiki:howtos:jtag-debugging

Is there a way to accomplish the same task without changing the OS code?

UweBonnes commented 10 years ago

Isn't reacting on hardfaults what a debugger is for? But your first post doesn't show some hardfault, but an assert triggered. And the output originates from the user code, not from blackmagic.

And your second post seems related to another problem, unrelated to the first. I use blackmagic a lot in connection with ethernut, where we have WFI in the idle loop too. But ethernut has Systick running at 1 kHz, so the CPU wakes up a lot and has a chance to react on debugger requests. Does nutx have no periodic interrupt?

staroselskii commented 10 years ago

Nuttx uses hardfaults when switching contexts. And BMP interrupts this process.

gsmcmullin commented 10 years ago

When BMP intercepts a hardfault it reports 'target stopped with SIGSEGV'. This is not what you're seeing. Interception of hardfaults is disabled with the command 'monitor vector_catch disable hard', which you are using.

I'll see if I can reproduce this at a later stage when I have hardware to test with, but I suggest you look elsewhere. The interception of hardfaults is very unlikely to be the problem.

Black Sphere Technologies Ltd.

Web: www.blacksphere.co.nz Mobile: +64 27 777 2182 Tel: +64 9 478 8885 Skype: gareth.mcmullin LinkedIn: http://nz.linkedin.com/in/gsmcmullin

potato1992 commented 1 year ago

I have faced similar error with ERROR: Stack pointer is not within the allocated stack, it turns out my program use more stack memory than allocated (2K default).

dragonmux commented 1 year ago

Are you saying you've hit this problem on current release firmware (v1.9.2 or v1.10.0-rc0), or that your issues is historical? Is there a need for this ticket to get re-opened?

potato1992 commented 1 year ago

Are you saying you've hit this problem on current release firmware (v1.9.2 or v1.10.0-rc0), or that your issues is historical? Is there a need for this ticket to get re-opened?

No I was just trying to share an experience of mine, which turns out to be my configuration issue.