Skip to content

Commit

Permalink
Enable debugging RP2350 in RISC-V mode with right OpenOCD config
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgerhardt committed Oct 6, 2024
1 parent 088a074 commit 08a7a28
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,22 @@ def _add_default_debug_tools(self, board):
return board

def configure_debug_session(self, debug_config):
is_riscv = False
if "board_build.mcu" in debug_config.env_options:
is_riscv = debug_config.env_options["board_build.mcu"] == "rp2350-riscv"
adapter_speed = debug_config.speed or "1000"
server_options = debug_config.server or {}
server_arguments = server_options.get("arguments", [])
server_arguments:list[str] = server_options.get("arguments", [])
# This is ugly but the only way I found this to be working.
# We need to give OpenOCD the rp2350-riscv.cfg config if we're in RISC-V mode
# (set dynamically by board_build.mcu = rp2350-riscv in the platformio.ini of the project)
# Somehow that can not yet be determined when we're inside _add_default_debug_tools(),
# So we have to patch this up afterwards.
if is_riscv:
try:
server_arguments[server_arguments.index("target/rp2350.cfg")] = "target/rp2350-riscv.cfg"
except:
pass
if "interface/cmsis-dap.cfg" in server_arguments or "interface/picoprobe.cfg" in server_arguments:
server_arguments.extend(
["-c", "adapter speed %s" % adapter_speed]
Expand Down

0 comments on commit 08a7a28

Please sign in to comment.