SW breakpoint for the CH32V203 (and similar)
The WCH doc clearly states the QingKev4b does not have hardware breakpoints. We saw that a bit earlier.
The CH32V203 among others is a QingKeV4b.
I've added support for flash software breakpoint for the CH32V[2/3]xx to swindle. It is still a bit experimental.
When such software breakpoints are used, under the hood the following happens :
- Identify the page where the breakpoint is ( 256 bytes page for the CH32V[2/3]xx
- Read the page
- Store the 16 bits where the breakpoint is
- Replace those 16 bits by a "ebreak" opcode
- Erase the page
- Write the modified page
When removing the breakpoint the same thing happens except we put back the original opcode.
It is a bit slow, but usable. The main drawback is that it will speed up flash wearing a lot.
The framework is in place, if and when need it will be easy to add such functions to other chips.
The main difference with other flashing operations are :
- we want to use the smaller size possible. Usually we aim a bit higher to speed up things.
- we try to change as little things as possible. Using a flashstub would make things more brittle as it changes a lof of things (change registers, change ram content, change flags,...) It would be more difficult to restore things EXACTLY as they were.
Comments
Post a Comment