Hello!
Xtensa ISA reference mention data breakpoint registers, and ESP-IDF even has the code (xt_utils, set_watchpoint).
But how can these be used?
I mean, after I write the data address/length in a corresponding DBREAKA, DBREAKC registers, what would happen on data access?
An interrupt? Which on? How to hook on it?
I went with the gdbstub code, but quickly get lost. Is there any documentation on xtensa arch component of esp-idf? I mean, examples, docs, with these xt_... functions.
Thanks!
PS: Oh I forgot to mention what it is all about. I would like to get a control, wwhen one of FreeRTOS tasks accesses memory region of interest. After taking control and performing some job, control must be returned to the task which triggered the watchpoint.
HW data watchpoints
Re: HW data watchpoints
The breakpoints trigger a debug interrupt, which by default triggers the panic handler.
The most compatible way to insert code in here may be to wrap the panic handler to do your own thing. Example code is e.g. here. To wrap the panic handler, you need to put these lines into your projects CMakeLists.txt. Note that you need to have gdbstub disabled, otherwise that takes precedence.
The most compatible way to insert code in here may be to wrap the panic handler to do your own thing. Example code is e.g. here. To wrap the panic handler, you need to put these lines into your projects CMakeLists.txt. Note that you need to have gdbstub disabled, otherwise that takes precedence.
Re: HW data watchpoints
Oh.. Thanks for the reply.The breakpoints trigger a debug interrupt, which by default triggers the panic handler.
The most compatible way to insert code in here may be to wrap the panic handler to do your own thing. Example code is e.g. here. To wrap the panic handler, you need to put these lines into your projects CMakeLists.txt. Note that you need to have gdbstub disabled, otherwise that takes precedence.
Finally I had achieved what I wanted, by intercepting debug interrupt vector.
I am trying to make a memory logger. It uses HW watchpoint #0 to catch memory access and then, in the interrupt handler I reset watchpoint and setup a HW breakpoint on the next instruction and then return from an interrupt (thus retrying instruction again). When breakpoint hits, I just rearm my watchpoint and disable a breakpoint.
I tried your approach (wrapping around panic() call) didn't not work, because _xt_debugexception calls panic handler via callx0, and this call does not return.
In the same handler function the gdb stub is called via "j" instruction. So I decided to replace (thanks god it is weak declaration) whole xt_debugexception with my own handler - made up from gdbstub panic handler and _xt_debugexception handler.
And it worked. Memory logger catches access to certain MMIOs of interest and logs access attempts and then let the instruction (load or store) to proceed.
May be someone can find it useful.
Thanks!
Slava.
Slava.
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot], Google [Bot], Qwantbot, Semrush [Bot] and 0 guests
