I use a Cortex-A7 board and write start up code.
I try to use Security Extension.
I use `smc` instruction and make cpu mode monitor mode.
In the monitor handler, I tried to changed stack pointer value for calling other functions.
But after execute `ldr sp, =_stack_start`, sp value is 0x0 (Of course, _stack_start is not 0x0 and I check it in the assembler code).
Therefore, after `push` some registers and `pop` those registers, the data abort excetpions occurred!
How can I change the sp value?
I do not use OpenOCD with my CubieBoard2, as I'm just running Linux from a SD card on this one.
Looking further into this, I'm not sure the LS1021A is supported in OpenOCD yet (eg. I do not think there's a driver for it).
To see the currently supported boards, list the contents of /usr/local/share/openocd/scripts/board/
To see the possible targets, list the contents of /usr/local/share/openocd/scripts/target/
If you feel like writing a driver for it, let me know, and I'll point you in the right direction - but it may be something that requires a fair amount of work.
Another way might be to try a differnt IDE. Which one are you using right now ?
I think that means sp actually has the right value and it's the debugger that does not know how to read the registers properly.
I think so too, because following push and pop instructions correctly worked.
But I don't know how to configure OpenOCD for my board.
Could you show me your configuration file for CubieBoard2?
Have you tried using OpenOCD ?
I try to do another test:
ldr r0, =_stack_start
mov sp, r0
mov r1, sp
I checked the value with J-Link debugger, and r0 is _stack_start value and sp is 0x0.
But r1 is _stack_start value correctly.
Therefore, it seems to the J-Link problem.
It sounds like you're using a board without an operating system, is this correct ?
Yes, I'm using a board without an OS.
I use TWR-LS1021A board.
I tried to load the value to r0 at first and then move sp like this:
mov r0, #0x1000
These code cannot change the sp value though the r0 value is not 0x0.
I checked the manual of ARMv7-A, but I cannot find such a description that we cannot change the sp value in the monitor mode.
If it's a CubieBoard2, then I may be able to do some tests (I'm running Cubian on mine)
I do not know why this is happening (it does not sound logical that this should happen at all, but there must be a reason somewhere).
Try doing a few tests...
ldr r0,=_stack_start
mov sp,r0
mov r0,0x01000000
ldr r0,new_stack
(other code here)
b main
newstack:
.word 0x02000000
...etc.
The first snippet I mentioned may give you exactly the same result as you had before, but at least you can see the value of r0 first.