From 06a624f2a3c0c5482e5d084ce0842029b766ea6c Mon Sep 17 00:00:00 2001 From: Sylvio Alves Date: Sun, 5 Sep 2021 16:21:06 -0300 Subject: [PATCH] soc: esp32: add west debug support This adds west debug support for ESP32 and ESP32S2 boards using custom openocd tool. Signed-off-by: Sylvio Alves --- boards/common/esp32.board.cmake | 10 ++++++++++ boards/xtensa/esp32/board.cmake | 14 ++++++++++++++ boards/xtensa/esp32s2_saola/board.cmake | 14 ++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/boards/common/esp32.board.cmake b/boards/common/esp32.board.cmake index 092f8635220..b36eb977968 100644 --- a/boards/common/esp32.board.cmake +++ b/boards/common/esp32.board.cmake @@ -1,6 +1,16 @@ # SPDX-License-Identifier: Apache-2.0 board_set_flasher_ifnset(esp32) +board_set_debugger_ifnset(openocd) + +board_runner_args(openocd --no-init --no-halt --no-targets --no-load) +board_runner_args(openocd --gdb-init "set remote hardware-watchpoint-limit 2") +board_runner_args(openocd --gdb-init "set disassemble-next-line on") +board_runner_args(openocd --gdb-init "set print pretty on") + +board_runner_args(openocd --gdb-init "flushregs") +board_runner_args(openocd --gdb-init "mon reset halt") +board_runner_args(openocd --gdb-init "thb main") set(ESP_IDF_PATH ${ZEPHYR_ESPRESSIF_MODULE_DIR}) assert(ESP_IDF_PATH "ESP_IDF_PATH is not set") diff --git a/boards/xtensa/esp32/board.cmake b/boards/xtensa/esp32/board.cmake index 71735daa671..0030e44477e 100644 --- a/boards/xtensa/esp32/board.cmake +++ b/boards/xtensa/esp32/board.cmake @@ -1,3 +1,17 @@ # SPDX-License-Identifier: Apache-2.0 +board_runner_args(openocd --cmd-pre-init "set ESP_RTOS none") +board_runner_args(openocd --cmd-pre-init "set ESP32_ONLYCPU 1") + +# select FT2232 as default interface (as in ESP-WROVER-KIT or ESP-Prog) +board_runner_args(openocd --config "interface/ftdi/esp32_devkitj_v1.cfg") +board_runner_args(openocd --config "target/esp32.cfg") + +set (ESPRESSIF_OPENOCD_TOOL ${ESPRESSIF_TOOLCHAIN_PATH}/openocd-esp32/bin/openocd) +set (ESPRESSIF_OPENOCD_SCRIPTS ${ESPRESSIF_TOOLCHAIN_PATH}/openocd-esp32/share/openocd/scripts) + +set(OPENOCD ${ESPRESSIF_OPENOCD_TOOL}) +set(OPENOCD_DEFAULT_PATH ${ESPRESSIF_OPENOCD_SCRIPTS}) + include(${ZEPHYR_BASE}/boards/common/esp32.board.cmake) +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) diff --git a/boards/xtensa/esp32s2_saola/board.cmake b/boards/xtensa/esp32s2_saola/board.cmake index 71735daa671..a44bded314a 100644 --- a/boards/xtensa/esp32s2_saola/board.cmake +++ b/boards/xtensa/esp32s2_saola/board.cmake @@ -1,3 +1,17 @@ # SPDX-License-Identifier: Apache-2.0 +board_runner_args(openocd --cmd-pre-init "set ESP_RTOS none") +board_runner_args(openocd --cmd-pre-init "set ESP32_ONLYCPU 1") + +# select FT2232 as default interface (as in ESP-WROVER-KIT or ESP-Prog) +board_runner_args(openocd --config "interface/ftdi/esp32s2_kaluga_v1.cfg") +board_runner_args(openocd --config "target/esp32s2.cfg") + +set (ESPRESSIF_OPENOCD_TOOL ${ESPRESSIF_TOOLCHAIN_PATH}/openocd-esp32/bin/openocd) +set (ESPRESSIF_OPENOCD_SCRIPTS ${ESPRESSIF_TOOLCHAIN_PATH}/openocd-esp32/share/openocd/scripts) + +set(OPENOCD ${ESPRESSIF_OPENOCD_TOOL}) +set(OPENOCD_DEFAULT_PATH ${ESPRESSIF_OPENOCD_SCRIPTS}) + include(${ZEPHYR_BASE}/boards/common/esp32.board.cmake) +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)