From a4400dbe6cfb4a62e452689a801a3a7ce2baa340 Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Wed, 19 Jun 2024 17:18:21 +0200 Subject: [PATCH] boards: st: stm32h5 boards has openOCD runner from upstream Define the support /openocd.cfg and the board.cmake to add the openOCD as runner for the stm32h5x boards. Note that the openOCD is hack downloaded and build from from https://github.com/STMicroelectronics/OpenOCD Signed-off-by: Francois Ramu --- boards/st/nucleo_h533re/board.cmake | 6 +++ boards/st/nucleo_h533re/doc/index.rst | 28 ++++++++++++++ boards/st/nucleo_h533re/support/openocd.cfg | 23 +++++++++++ boards/st/nucleo_h563zi/board.cmake | 6 +++ boards/st/nucleo_h563zi/doc/index.rst | 29 ++++++++++++++ boards/st/nucleo_h563zi/support/openocd.cfg | 23 +++++++++++ boards/st/stm32h573i_dk/board.cmake | 7 +++- boards/st/stm32h573i_dk/doc/index.rst | 43 ++++++++++++++++++++- boards/st/stm32h573i_dk/support/openocd.cfg | 23 +++++++++++ 9 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 boards/st/nucleo_h533re/support/openocd.cfg create mode 100644 boards/st/nucleo_h563zi/support/openocd.cfg create mode 100644 boards/st/stm32h573i_dk/support/openocd.cfg diff --git a/boards/st/nucleo_h533re/board.cmake b/boards/st/nucleo_h533re/board.cmake index 97abaa6f577..32d2caa6514 100644 --- a/boards/st/nucleo_h533re/board.cmake +++ b/boards/st/nucleo_h533re/board.cmake @@ -6,6 +6,12 @@ board_runner_args(pyocd "--target=stm32h533retx") board_runner_args(jlink "--device=STM32H533RE" "--reset-after-load") +board_runner_args(openocd "--tcl-port=6666") +board_runner_args(openocd --cmd-pre-init "gdb_report_data_abort enable") +board_runner_args(openocd "--no-halt") + include(${ZEPHYR_BASE}/boards/common/stm32cubeprogrammer.board.cmake) include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +# FIXME: official openocd runner not yet available. diff --git a/boards/st/nucleo_h533re/doc/index.rst b/boards/st/nucleo_h533re/doc/index.rst index 7a8e5ff560f..7b391463944 100644 --- a/boards/st/nucleo_h533re/doc/index.rst +++ b/boards/st/nucleo_h533re/doc/index.rst @@ -233,6 +233,24 @@ Applications for the ``nucleo_h533re`` board can be built and flashed in the usual way (see :ref:`build_an_application` and :ref:`application_run` for more details). +OpenOCD Support +=============== + +For now, openocd support for stm32h5 is not available on upstream OpenOCD. +You can check `OpenOCD official Github mirror`_. +In order to use it though, you should clone from the cutomized +`STMicroelectronics OpenOCD Github`_ and compile it following usual README guidelines. +Once it is done, you can set the OPENOCD and OPENOCD_DEFAULT_PATH variables in +:zephyr_file:`boards/st/nucleo_h533re/board.cmake` to point the build +to the paths of the OpenOCD binary and its scripts, before +including the common openocd.board.cmake file: + + .. code-block:: none + + set(OPENOCD "/src/openocd" CACHE FILEPATH "" FORCE) + set(OPENOCD_DEFAULT_PATH /tcl) + include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) + Flashing ======== @@ -255,6 +273,10 @@ This can be done by executing the following commands. $ pyocd pack --install stm32h5 +Alternatively, the openocd interface will be supported by a next openocd version. +When available, OpenOCD could be used in the same way as other tools. + + Flashing an application to Nucleo H533RE ------------------------------------------ @@ -306,3 +328,9 @@ You can debug an application in the usual way. Here is an example for the .. _STM32CubeProgrammer: https://www.st.com/en/development-tools/stm32cubeprog.html + +.. _OpenOCD official Github mirror: + https://github.com/openocd-org/openocd/ + +.. _STMicroelectronics OpenOCD Github: + https://github.com/STMicroelectronics/OpenOCD/tree/openocd-cubeide-r6 diff --git a/boards/st/nucleo_h533re/support/openocd.cfg b/boards/st/nucleo_h533re/support/openocd.cfg new file mode 100644 index 00000000000..58bdb604dcc --- /dev/null +++ b/boards/st/nucleo_h533re/support/openocd.cfg @@ -0,0 +1,23 @@ +source [find interface/stlink-dap.cfg] + +source [find target/stm32h5x.cfg] + +transport select "dapdirect_swd" + +set CHIPNAME STM32H533RETX +set BOARDNAME NUCLEO-STM32H533RE + +# Reset configuration +# use hardware reset, connect under reset +# connect_assert_srst needed if low power mode application running (WFI...) +reset_config srst_only srst_nogate connect_assert_srst +set CONNECT_UNDER_RESET 1 +set CORE_RESET 0 + +# Due to the use of connect_assert_srst, running gdb requires +# to reset halt just after openocd init. +rename init old_init +proc init {} { + old_init + reset halt +} diff --git a/boards/st/nucleo_h563zi/board.cmake b/boards/st/nucleo_h563zi/board.cmake index 24b1a15215c..50f4c3f2699 100644 --- a/boards/st/nucleo_h563zi/board.cmake +++ b/boards/st/nucleo_h563zi/board.cmake @@ -6,6 +6,12 @@ board_runner_args(pyocd "--target=stm32h563zitx") board_runner_args(jlink "--device=STM32H563ZI" "--reset-after-load") +board_runner_args(openocd "--tcl-port=6666") +board_runner_args(openocd --cmd-pre-init "gdb_report_data_abort enable") +board_runner_args(openocd "--no-halt") + include(${ZEPHYR_BASE}/boards/common/stm32cubeprogrammer.board.cmake) include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) +#include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +# FIXME: official openocd runner not yet available. diff --git a/boards/st/nucleo_h563zi/doc/index.rst b/boards/st/nucleo_h563zi/doc/index.rst index ecb32665261..24b9dcd4ed3 100644 --- a/boards/st/nucleo_h563zi/doc/index.rst +++ b/boards/st/nucleo_h563zi/doc/index.rst @@ -247,6 +247,25 @@ Applications for the ``nucleo_h563zi`` board can be built and flashed in the usual way (see :ref:`build_an_application` and :ref:`application_run` for more details). +OpenOCD Support +=============== + +For now, openocd support for stm32h5 is not available on upstream OpenOCD. +You can check `OpenOCD official Github mirror`_. +In order to use it though, you should clone from the cutomized +`STMicroelectronics OpenOCD Github`_ and compile it following usual README guidelines. +Once it is done, you can set the OPENOCD and OPENOCD_DEFAULT_PATH variables in +:zephyr_file:`boards/st/nucleo_h563zi/board.cmake` to point the build +to the paths of the OpenOCD binary and its scripts, before +including the common openocd.board.cmake file: + + .. code-block:: none + + set(OPENOCD "/src/openocd" CACHE FILEPATH "" FORCE) + set(OPENOCD_DEFAULT_PATH /tcl) + include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) + + Flashing ======== @@ -269,6 +288,10 @@ This can be done by executing the following commands. $ pyocd pack --install stm32h5 +Alternatively, the openocd interface will be supported by a next openocd version. +When available, OpenOCD could be used in the same way as other tools. + + Flashing an application to Nucleo H563ZI ------------------------------------------ @@ -320,3 +343,9 @@ You can debug an application in the usual way. Here is an example for the .. _STM32CubeProgrammer: https://www.st.com/en/development-tools/stm32cubeprog.html + +.. _OpenOCD official Github mirror: + https://github.com/openocd-org/openocd/ + +.. _STMicroelectronics OpenOCD Github: + https://github.com/STMicroelectronics/OpenOCD/tree/openocd-cubeide-r6 diff --git a/boards/st/nucleo_h563zi/support/openocd.cfg b/boards/st/nucleo_h563zi/support/openocd.cfg new file mode 100644 index 00000000000..33aca4cc0c6 --- /dev/null +++ b/boards/st/nucleo_h563zi/support/openocd.cfg @@ -0,0 +1,23 @@ +source [find interface/stlink-dap.cfg] + +source [find target/stm32h5x.cfg] + +transport select "dapdirect_swd" + +set CHIPNAME STM32H563ZITX +set BOARDNAME NUCLEO-STM32H563ZI + +# Reset configuration +# use hardware reset, connect under reset +# connect_assert_srst needed if low power mode application running (WFI...) +reset_config srst_only srst_nogate connect_assert_srst +set CONNECT_UNDER_RESET 1 +set CORE_RESET 0 + +# Due to the use of connect_assert_srst, running gdb requires +# to reset halt just after openocd init. +rename init old_init +proc init {} { + old_init + reset halt +} diff --git a/boards/st/stm32h573i_dk/board.cmake b/boards/st/stm32h573i_dk/board.cmake index 762f2e32b85..ec3b6dacdc1 100644 --- a/boards/st/stm32h573i_dk/board.cmake +++ b/boards/st/stm32h573i_dk/board.cmake @@ -9,6 +9,11 @@ endif() board_runner_args(pyocd "--target=stm32h573iikx") +board_runner_args(openocd "--tcl-port=6666") +board_runner_args(openocd --cmd-pre-init "gdb_report_data_abort enable") +board_runner_args(openocd "--no-halt") + include(${ZEPHYR_BASE}/boards/common/stm32cubeprogrammer.board.cmake) include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) -# FIXME: openocd runner not yet available. +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +# FIXME: official openocd runner not yet available. diff --git a/boards/st/stm32h573i_dk/doc/index.rst b/boards/st/stm32h573i_dk/doc/index.rst index 72fba315ace..adde4178232 100644 --- a/boards/st/stm32h573i_dk/doc/index.rst +++ b/boards/st/stm32h573i_dk/doc/index.rst @@ -249,13 +249,48 @@ Applications for the ``stm32h573i_dk`` board configuration can be built and flashed in the usual way (see :ref:`build_an_application` and :ref:`application_run` for more details). +OpenOCD Support +=============== + +For now, openocd support for stm32h5 is not available on upstream OpenOCD. +You can check `OpenOCD official Github mirror`_. +In order to use it though, you should clone from the cutomized +`STMicroelectronics OpenOCD Github`_ and compile it following usual README guidelines. +Once it is done, you can set the OPENOCD and OPENOCD_DEFAULT_PATH variables in +:zephyr_file:`boards/st/stm32h573i_dk/board.cmake` to point the build +to the paths of the OpenOCD binary and its scripts, before +including the common openocd.board.cmake file: + + .. code-block:: none + + set(OPENOCD "/src/openocd" CACHE FILEPATH "" FORCE) + set(OPENOCD_DEFAULT_PATH /tcl) + include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) + + Flashing ======== STM32H573I-DK Discovery board includes an ST-LINK/V3E embedded debug tool interface. Support is available on STM32CubeProgrammer V2.13.0. -Alternatively, this interface will be supported by a next openocd version. + +Alternatively, pyocd or jlink via an external probe can also be used to flash +and debug the board if west is told to use it as runner, which can be done by +passing either or ``-r pyocd``, or ``-r jlink``. + +For pyocd additional target information needs to be installed. +This can be done by executing the following commands. + +.. code-block:: console + + $ pyocd pack --update + $ pyocd pack --install stm32h5 + + +Alternatively, the openocd interface will be supported by a next openocd version. +When available, OpenOCD could be used in the same way as other tools. + Flashing an application to STM32H573I-DK Discovery -------------------------------------------------- @@ -317,3 +352,9 @@ example for the :ref:`hello_world` application. .. _STM32CubeProgrammer: https://www.st.com/en/development-tools/stm32cubeprog.html + +.. _OpenOCD official Github mirror: + https://github.com/openocd-org/openocd/ + +.. _STMicroelectronics OpenOCD Github: + https://github.com/STMicroelectronics/OpenOCD/tree/openocd-cubeide-r6 diff --git a/boards/st/stm32h573i_dk/support/openocd.cfg b/boards/st/stm32h573i_dk/support/openocd.cfg new file mode 100644 index 00000000000..2e5a829460c --- /dev/null +++ b/boards/st/stm32h573i_dk/support/openocd.cfg @@ -0,0 +1,23 @@ +source [find interface/stlink-dap.cfg] + +source [find target/stm32h5x.cfg] + +transport select "dapdirect_swd" + +set CHIPNAME STM32H573IIKXQ +set BOARDNAME STM32H573I-DK + +# Reset configuration +# use hardware reset, connect under reset +# connect_assert_srst needed if low power mode application running (WFI...) +reset_config srst_only srst_nogate connect_assert_srst +set CONNECT_UNDER_RESET 1 +set CORE_RESET 0 + +# Due to the use of connect_assert_srst, running gdb requires +# to reset halt just after openocd init. +rename init old_init +proc init {} { + old_init + reset halt +}