[En-Nut-Discussion] Nut/OS thread stackpointer overwritten on ARM7S

Michael Bieri mibieri at ee.ethz.ch
Sun Nov 25 19:07:29 CET 2007


I 've got a very strange bug in my Nut/OS application: The stackpointer 
in NUTTHREADINFO.td_sp is overwritten with the value 0x600000D3.

Some additional information:
- I use an AT91SAM7S256 on an olimex dev board, for debugging, I use 
olimex' ARM-USB-OCD together with GDB in Eclipse.
- The problem occurs in MmCardReadOrVerify (mmcard.c:465) when I try to 
mount an SD-Card with volid = _open(BLKDEV_NAME ":1/" FSDEV_NAME, 
- Very strange: The problem seems to occur on different locations, 
probably depending on my debugging. (When I do single steps, the problem 
normally occurs earlier, but in every case in MmCardReadOrVeryify or 
functions called by this - mostly on/after returning to MmCardReadOrVerify)
- And very strange, too: In assembly-instruction stepping mode, I caught 
the problem several times occuring immediately after an LDMIA 
instruction, this instruction loads some values from memory to 
registers. But how can this overwrite my NUTTHREADINFO.td_sp, that is 
stored in memory (and not in a register.)?
- Further, the problem only occurs if I compile with the -O0 parameter, 
using -Os does not make any problems. But of course, I need -O0 for 

Does anyone know anything about this problem? I've got no further idea 
to solve this...

Thanks a lot,

More information about the En-Nut-Discussion mailing list