Booting the CPU through JTAG debugger. How to exit from debug state and start from newly added PC address

219 views Asked by At

I would like to use the DAP interface in the cortexm4 processor to download application code into a memory that can be accessed by a JTAG debugger. For now, I wanted to follow the following steps given on the ARM forum:

For use cases such as a simple test case, where there is no desire to fully support continuation of normal execution after the test, and where writing to memory at address zero is cumbersome (for example, requiring Flash erase and reprogramming), a "quick and dirty" alternative exists; the already-fetched values from addresses 0x0 and 0x4 can be fully modified by the debugger through the DCRSR and DCRDR functions while the processor is halted in debug state. This requires the Main Stack Pointer to be written with a suitable "top of stack" address in RAM, the DebugReturnAddress (essentially the PC) to be written with the true address of the code entry point, the xPSR to be written with 0x01000000 (setting the EPSR.T bit), and, of course, downloading the executable test code into a suitable (writable and executable) memory region as pointed to by that DebugReturnAddress.

After I write into the PC register through the DCSCR and DCRDR registers with the address of where my code has been stored in memory, I wanted to know how to exit from the debug state and make sure that the CPU starts directly executing from the newly added PC address. Can i use the VECTRESET bit or will it clear the PC value to point to 0 again. Or do I just clear the DEBUGEN bit and disable the VECTOR_RESET_CATCH register to get out of debug state?

How can I make my CPU start from the PC address I want to,after programming the PC value in debug state ?

0

There are 0 answers