From 3d720ab1f43b7e65312f72c5d0454a3eac91d141 Mon Sep 17 00:00:00 2001 From: Gustavo de Souza dos Reis Date: Wed, 4 Oct 2023 08:52:03 -0300 Subject: [PATCH] Add suport for xvc probe --- .github/workflows/build.yml | 1 + README.md | 2 +- probe/openocd.cfg.in | 2 +- probe/openocd.cmake | 15 ++++++++++++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a7888952..b3064c010 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,6 +19,7 @@ jobs: - { flags: -DBOARD=afc -DVERSION=4.0 -DDEBUG_PROBE=jlink -DOPENOCD_TRANSPORT=swd } - { flags: -DBOARD=afc -DVERSION=4.0 -DDEBUG_PROBE=cmsis-dap -DOPENOCD_TRANSPORT=swd } - { flags: -DBOARD=afc -DVERSION=4.0 -DDEBUG_PROBE=digilent_jtag_hs3 -DOPENOCD_TRANSPORT=jtag } + - { flags: -DBOARD=afc -DVERSION=4.0 -DDEBUG_PROBE=xvc -DOPENOCD_TRANSPORT=jtag -DXVC_HOST=host -DXVC_PORT=0000} steps: - uses: actions/checkout@v3 with: diff --git a/README.md b/README.md index 65c758447..d31c1e27e 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ To make a debug build (to include symbols into elf file, turn off optimizations, ## Programming ### OpenOCD -Flashing the MMC microcontroller via SWD/JTAG is supported for CMSIS-DAP and Jlink compatible probes through OpenOCD. You can specify the debug probe with the flag `-DDEBUG_PROBE=`, valid options are `cmsis-dap` (default) and `jlink`. +Flashing the MMC microcontroller via SWD/JTAG is supported for CMSIS-DAP and Jlink compatible probes through OpenOCD. You can specify the debug probe with the flag `-DDEBUG_PROBE=`, valid options are `cmsis-dap` (default), `jlink`, `digilent_jtag_hs3` and `xvc` (support is not merged to the official OpenOCD source yet, so you build our patched version: https://github.com/lnls-dig/openocd/tree/fix-afcv3-flashing). cmake ~/openmmc/ -DBOARD=afc -DVERSION=3.1 -DDEBUG_PROBE=cmsis-dap diff --git a/probe/openocd.cfg.in b/probe/openocd.cfg.in index 7ce39aabb..94a8e7c81 100644 --- a/probe/openocd.cfg.in +++ b/probe/openocd.cfg.in @@ -1,4 +1,4 @@ -source [find ${OPENOCD_DEBUG_PROBE_FILE}] +${OPENOCD_DEBUG_PROBE_CMD} transport select ${OPENOCD_TRANSPORT} diff --git a/probe/openocd.cmake b/probe/openocd.cmake index 6f8636b88..e8f8a552a 100644 --- a/probe/openocd.cmake +++ b/probe/openocd.cmake @@ -23,14 +23,23 @@ else() # Selects the OpenOCD debug probe file if(${DEBUG_PROBE} STREQUAL "digilent_jtag_hs3") - set(OPENOCD_DEBUG_PROBE_FILE "interface/ftdi/digilent_jtag_hs3.cfg") + set(OPENOCD_DEBUG_PROBE_CMD "source [find interface/ftdi/digilent_jtag_hs3.cfg]") check_probe_transport("jtag" ${OPENOCD_TRANSPORT}) elseif(${DEBUG_PROBE} STREQUAL "cmsis-dap") - set(OPENOCD_DEBUG_PROBE_FILE "interface/cmsis-dap.cfg") + set(OPENOCD_DEBUG_PROBE_CMD "source [find interface/cmsis-dap.cfg]") check_probe_transport("jtag;swd" ${OPENOCD_TRANSPORT}) elseif(${DEBUG_PROBE} STREQUAL "jlink") - set(OPENOCD_DEBUG_PROBE_FILE "interface/jlink.cfg") + set(OPENOCD_DEBUG_PROBE_CMD "source [find interface/jlink.cfg]") check_probe_transport("jtag;swd" ${OPENOCD_TRANSPORT}) + elseif(${DEBUG_PROBE} STREQUAL "xvc") + if(NOT XVC_HOST) + message(FATAL_ERROR "No xvc host selected, use -DXVC_HOST= to select it.") + elseif(NOT XVC_PORT) + message(FATAL_ERROR "No xvc port selected, use -DXVC_PORT= to select it.") + else() + set(OPENOCD_DEBUG_PROBE_CMD "adapter driver xvc\nxvc_host ${XVC_HOST}\nxvc_port ${XVC_PORT}\nreset_config none") + check_probe_transport("jtag" ${OPENOCD_TRANSPORT}) + endif() else() message(FATAL_ERROR "${DEBUG_PROBE} not supported!") endif()