I was trying to write a register context saving/restoring when I came across a weird behaviour.
My code (sorry, tried to format tens of times, but the editor WANTS to make asm a table):
When the exception is returned from, the calling function:
msg = "returned from SVC\r\n";
serial_io.put_string(msg, util_str_len(msg)+1);
asm volatile (
);
msg = "cpsr = ";
util_word_to_hex(scratchpad, tmp1);
serial_io.put_string(scratchpad, 9);
serial_io.put_string("\r\n", 3);
outputs "returned from SVC" and "cpsr = 60000013".
Why the "00000002"? the barriers don't seem to have any effect.
Flu is always terrible.
I know it's not appropriate for this kind of debugging, but if you at some other point needs a 32-bit value and you only have a LED, try this:
repeat(32){ LED(1); delay_ms(200); LED(0); delay_ms(100); LED(value >> 31) &1; value = value << 1; delay_ms(500); LED(0); delay_ms(100); } delay_ms(5000);
This should give you enough time to write the bit values down on a piece of paper.
The quick flashes are there in order to separate the bits visually.
JTAG should not need to be 5V; I think it only needs to be 3.3V, even for 5V devices. It just needs 5V tolerant I/O-pins.
(I prefer JTAG-lock-pick Tiny 2 myself; it's both JTAG and SWD and works very well with all the targets I know; furthermore I think it's compatible with the KEIL tools). Freddie Chopin might be able to tell you more about it.
Your LED idea is clever! Maybe I'll try next time.
I think I'm getting a scent of what's going on. The debuggee interrupt doesn't return where it should.
I guess I have to check my context handling still more carefully - especially the stacks. To avoid overflowing the debuggee's stacks I switch into mine, and then switch back at return.
I copied the breakpoint command and cont command that gdb sends, then I used gdb upto loading the program, disconnected and switched to terminal where I gave the breakpoint command and cont-command manually.
And I finally got to see something...
I got carried away...
Bus Blaster ( Bus Blaster - DP ) could be an option...