source [find target/swj-dp.tcl] source [find mem_helper.tcl] set _CHIPNAME rp2040 set _CPUTAPID 0x01002927 set _ENDIAN little swj_newdap $_CHIPNAME.rescue_dp cpu -dp-id $_CPUTAPID -instance-id 0xf set _TARGETNAME_0 $_CHIPNAME.rescue dap create $_TARGETNAME_0.dap -chain-position $_CHIPNAME.rescue_dp.cpu -ignore-syspwrupack # Have to init before we can do dpreg commands init # The rescue debug port uses the AP CTRL/STAT bit DBGPWRUPREQ to reset the # PSM (power on state machine) of the RP2040 with a flag set in the # VREG_AND_POR_CHIP_RESET register. Once the reset is released # (by clearing the DBGPWRUPREQ flag), the bootrom will run, see this flag, # and halt. Allowing the user to load some fresh code, rather than loading # the potentially broken code stored in flash # Clear DBGPWRUPREQ $_TARGETNAME_0.dap dpreg 0x4 0x00000000 # Verifying CTRL/STAT is 0 $_TARGETNAME_0.dap dpreg 0x4 echo "Now attach a debugger to your RP2040 and load some code"