1

I'm running FreeRTOS inside a Zynq ARM. On a ARM system I get an data abort exception. The exception is raised because of an unaligned address given to memcpy(). I would now like to get the caller of memcpy(). That is: i would like to retrive the value of "lr" when within memcpy, before the exception happended. I can set a breakpoint to the data exception vector, but when the breakpoint hits the "lr" is banked away. Is it possible to retrive the "lr" of the usermode bank from within abort mode? Maybe with a cp15 coprocessor read? Thanks Konrad

Solution: Inside FreeRTOS_DataAbortHandler I added a breakpoint and the lines

#       define MODE_USR        0x00000010
#       define I_BIT           0x80
#       define F_BIT           0x40 
mrs     r1, cpsr
msr     cpsr_c,  #(MODE_USR|I_BIT|F_BIT)

after stepping through the last line I can see the pre-abort stacktrace in XSDK.

Konrad Eisele
  • 3,088
  • 20
  • 35
  • I guess you should try `mrs r0, lr_usr`. – Jester Jan 14 '16 at 14:01
  • Assembler doesnt understand that. Im on a Xilinx Zync (ARM-Cortex-A9, a Armv7 i think): Error: Banked registers are not available with this architecture. -- `mrs r0,lr_usr' – Konrad Eisele Jan 14 '16 at 14:08
  • In linux I see this macro _store_user_sp_lr_ in arch/arm/kernel/entry-headers.S , maybe I should try it... – Konrad Eisele Jan 14 '16 at 14:14
  • walk the stack which is compiler/programmer dependent possibly – old_timer Jan 14 '16 at 19:15
  • 1
    [This question](http://stackoverflow.com/q/2784978/3156750) pretty much covers it. The `mrs`/`msr` to banked register instructions require the virtualisation extensions, i.e. Cortex-A7/A15 or newer; on Cortex-A9 you're stuck with switching to system mode or bouncing via memory with `stm^`. – Notlikethat Jan 14 '16 at 22:50
  • The Cortex-A9 will not support `mrs r1, LR_usr`; `ldm rN, {sp,lr}^` is probably best if in ARM mode. You can not mode switch back from user mode, but SYSTEM mode (has not banked registers) has access to the user LR. – artless noise Jan 15 '16 at 17:31

0 Answers0