Posts

Showing posts from May, 2024

rp2040 + BMP : Debugging code in RAM ?

  The RP2040 has a lot of RAM (264 kB) that is faster than the external flash and easier to use. It makes sense to put smallish code there to speed up the build/load/debug cycles until it works. Additionally, putting code in ram is a good way to speed up execution and/or deal with flash erase/writing. and.... it does not work well, the breakpoints are not triggering. How come ? The flash starts at address 0x1000 0000, the RAM starts at 0x2000 0000 BUT if you look at the cortex M0 breakpoint unit it can only put so called hw breakpoint between 0 and 0x1FFF FFFF, so it cannot put hw breakpoint in the RP2040 ram. As a result we need to use software breakpoint. It means replacing the opcode of the line you want to break on by a "brk #0" and putting back the old opcode when you stop.  Gdb does that through using Z0 for sw breakpoint and Z1 for hw breakpoint. Let's add that to swindle. There is a basic/naive implementation of ARM sw breakpoint on the dev branch of swindle, now ...