You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(57) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(14) |
Nov
(36) |
Dec
(7) |
2007 |
Jan
(48) |
Feb
(10) |
Mar
(17) |
Apr
(8) |
May
(35) |
Jun
(28) |
Jul
(50) |
Aug
(71) |
Sep
(40) |
Oct
(19) |
Nov
(22) |
Dec
(143) |
2008 |
Jan
(184) |
Feb
(549) |
Mar
(381) |
Apr
(388) |
May
(148) |
Jun
(128) |
Jul
(502) |
Aug
(243) |
Sep
(136) |
Oct
(327) |
Nov
(252) |
Dec
(475) |
2009 |
Jan
(344) |
Feb
(185) |
Mar
(338) |
Apr
(826) |
May
(1559) |
Jun
(1429) |
Jul
(817) |
Aug
(451) |
Sep
(639) |
Oct
(935) |
Nov
(1222) |
Dec
(826) |
2010 |
Jan
(552) |
Feb
(532) |
Mar
(355) |
Apr
(206) |
May
(162) |
Jun
(203) |
Jul
(168) |
Aug
(232) |
Sep
(270) |
Oct
(259) |
Nov
(439) |
Dec
(468) |
2011 |
Jan
(224) |
Feb
(249) |
Mar
(278) |
Apr
(381) |
May
(316) |
Jun
(637) |
Jul
(544) |
Aug
(465) |
Sep
(159) |
Oct
(440) |
Nov
(139) |
Dec
|
2012 |
Jan
(204) |
Feb
(383) |
Mar
(295) |
Apr
(196) |
May
(590) |
Jun
(158) |
Jul
(167) |
Aug
(177) |
Sep
(179) |
Oct
(301) |
Nov
(144) |
Dec
(173) |
2013 |
Jan
(299) |
Feb
(120) |
Mar
(238) |
Apr
(140) |
May
(69) |
Jun
(133) |
Jul
(160) |
Aug
(107) |
Sep
(164) |
Oct
(196) |
Nov
(105) |
Dec
(74) |
2014 |
Jan
(205) |
Feb
(156) |
Mar
(175) |
Apr
(181) |
May
(162) |
Jun
(158) |
Jul
(117) |
Aug
(109) |
Sep
(148) |
Oct
(106) |
Nov
(82) |
Dec
(72) |
2015 |
Jan
(191) |
Feb
(205) |
Mar
(197) |
Apr
(163) |
May
(136) |
Jun
(36) |
Jul
(79) |
Aug
(55) |
Sep
(64) |
Oct
(146) |
Nov
(142) |
Dec
(78) |
2016 |
Jan
(65) |
Feb
(190) |
Mar
(53) |
Apr
(38) |
May
(95) |
Jun
(53) |
Jul
(58) |
Aug
(113) |
Sep
(96) |
Oct
(59) |
Nov
(136) |
Dec
(124) |
2017 |
Jan
(80) |
Feb
(109) |
Mar
(163) |
Apr
(78) |
May
(61) |
Jun
(73) |
Jul
(29) |
Aug
(47) |
Sep
(60) |
Oct
(76) |
Nov
(48) |
Dec
(35) |
2018 |
Jan
(138) |
Feb
(84) |
Mar
(109) |
Apr
(49) |
May
(24) |
Jun
(62) |
Jul
(96) |
Aug
(116) |
Sep
(53) |
Oct
(99) |
Nov
(80) |
Dec
(88) |
2019 |
Jan
(100) |
Feb
(141) |
Mar
(72) |
Apr
(174) |
May
(129) |
Jun
(102) |
Jul
(52) |
Aug
(45) |
Sep
(28) |
Oct
(43) |
Nov
(78) |
Dec
(47) |
2020 |
Jan
(113) |
Feb
(72) |
Mar
(94) |
Apr
(141) |
May
(82) |
Jun
(68) |
Jul
(125) |
Aug
(76) |
Sep
(33) |
Oct
(184) |
Nov
(61) |
Dec
(95) |
2021 |
Jan
(109) |
Feb
(77) |
Mar
(145) |
Apr
(116) |
May
(134) |
Jun
(113) |
Jul
(71) |
Aug
(118) |
Sep
(116) |
Oct
(92) |
Nov
(124) |
Dec
(68) |
2022 |
Jan
(57) |
Feb
(61) |
Mar
(57) |
Apr
(74) |
May
(86) |
Jun
(80) |
Jul
(43) |
Aug
(85) |
Sep
(120) |
Oct
(88) |
Nov
(100) |
Dec
(108) |
2023 |
Jan
(39) |
Feb
(56) |
Mar
(92) |
Apr
(81) |
May
(84) |
Jun
(72) |
Jul
(182) |
Aug
(82) |
Sep
(54) |
Oct
(68) |
Nov
(67) |
Dec
(75) |
2024 |
Jan
(79) |
Feb
(65) |
Mar
(42) |
Apr
(47) |
May
(68) |
Jun
(111) |
Jul
(43) |
Aug
(73) |
Sep
(100) |
Oct
(35) |
Nov
(100) |
Dec
(99) |
2025 |
Jan
(71) |
Feb
(68) |
Mar
(44) |
Apr
(40) |
May
(92) |
Jun
(39) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ge...@op...> - 2025-06-26 16:41:11
|
This is an automated email from Gerrit. "Ivan <Iva...@in...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8887 -- gerrit commit 98d7b4a87bcc00fa6e994e9fdc0fb978239e7823 Author: kryvosheiaivan <Iva...@in...> Date: Thu Jun 26 19:20:39 2025 +0300 armv8m: Add support for msplim/psplim for targets with no secext When armv8m does not have security extension, it still has msplim/psplim regs implemented, which is described in Cortex-M33 Devices Generic User Guide Document ID: 100235_0100_05_en, or at the link: https://developer.arm.com/documentation/100230/0002/functional-description/programmers-model/processor-core-registers-summary Tested on cyw20829 along with gdb v14.2.1 Change-Id: I4f060e4df742c6773e79ce0481697361202d544c Signed-off-by: kryvosheiaivan <Iva...@in...> diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 8eaf70f60a..94cd3f683b 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -2716,10 +2716,26 @@ int cortex_m_examine(struct target *target) if (armv7m->fp_feature != FPV5_MVE_F && armv7m->fp_feature != FPV5_MVE_I) armv7m->arm.core_cache->reg_list[ARMV8M_VPR].exist = false; - if (!cortex_m_has_tz(target)) + bool cm_has_tz = cortex_m_has_tz(target); + if (!cm_has_tz) for (size_t idx = ARMV8M_FIRST_REG; idx <= ARMV8M_LAST_REG; idx++) armv7m->arm.core_cache->reg_list[idx].exist = false; + /* The MSPLIM_NS and PSPLIM_NS registers are always present on ARMv8M, regardless of TZ */ + if (armv7m->arm.arch == ARM_ARCH_V8M) { + armv7m->arm.core_cache->reg_list[ARMV8M_MSPLIM_NS].exist = true; + armv7m->arm.core_cache->reg_list[ARMV8M_PSPLIM_NS].exist = true; + + /* If TZ is not implemented, rename xSPLIM_NS to simply xSPLIM */ + if (!cm_has_tz) { + const char* feature_name = "armv8m.no.secext"; + armv7m->arm.core_cache->reg_list[ARMV8M_MSPLIM_NS].name = "msplim"; + armv7m->arm.core_cache->reg_list[ARMV8M_PSPLIM_NS].name = "psplim"; + armv7m->arm.core_cache->reg_list[ARMV8M_MSPLIM_NS].feature->name = feature_name; + armv7m->arm.core_cache->reg_list[ARMV8M_PSPLIM_NS].feature->name = feature_name; + } + } + if (!armv7m->is_hla_target) { if (cortex_m->core_info->flags & CORTEX_M_F_TAR_AUTOINCR_BLOCK_4K) /* Cortex-M3/M4 have 4096 bytes autoincrement range, -- |
From: <ge...@op...> - 2025-06-23 17:43:56
|
This is an automated email from Gerrit. "Nishanth Menon <nm...@ti...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8975 -- gerrit commit a6fcd0a653404501c6d0d84f15180adabd7fd6ab Author: Nishanth Menon <nm...@ti...> Date: Mon Jun 23 12:41:04 2025 -0500 tcl/board/ti_*_swd_native.cfg: Add explicit transport info We use swd emulation in direct memory operations. Instead of relying on deprecated autoselect of transport, explicitly state swd as transport scheme. Change-Id: Iec7e2ad18edd365992cd7ba88558494bccf49fd2 Signed-off-by: Nishanth Menon <nm...@ti...> diff --git a/tcl/board/ti_am625_swd_native.cfg b/tcl/board/ti_am625_swd_native.cfg index dc4b20579d..65314fe5dc 100644 --- a/tcl/board/ti_am625_swd_native.cfg +++ b/tcl/board/ti_am625_swd_native.cfg @@ -14,6 +14,7 @@ # We are using dmem, which uses dapdirect_swd transport adapter driver dmem +transport select swd if { ![info exists SOC] } { set SOC am625 diff --git a/tcl/board/ti_am62a7_swd_native.cfg b/tcl/board/ti_am62a7_swd_native.cfg index 99fc0b0b38..3d5e892289 100644 --- a/tcl/board/ti_am62a7_swd_native.cfg +++ b/tcl/board/ti_am62a7_swd_native.cfg @@ -14,6 +14,7 @@ # We are using dmem, which uses dapdirect_swd transport adapter driver dmem +transport select swd if { ![info exists SOC] } { set SOC am62a7 diff --git a/tcl/board/ti_am62p_swd_native.cfg b/tcl/board/ti_am62p_swd_native.cfg index fa549f3585..a8c6bd1204 100644 --- a/tcl/board/ti_am62p_swd_native.cfg +++ b/tcl/board/ti_am62p_swd_native.cfg @@ -14,6 +14,7 @@ # We are using dmem, which uses dapdirect_swd transport adapter driver dmem +transport select swd if { ![info exists SOC] } { set SOC am62p diff --git a/tcl/board/ti_j721e_swd_native.cfg b/tcl/board/ti_j721e_swd_native.cfg index 3041c3c345..38316387af 100644 --- a/tcl/board/ti_j721e_swd_native.cfg +++ b/tcl/board/ti_j721e_swd_native.cfg @@ -14,6 +14,7 @@ # We are using dmem, which uses dapdirect_swd transport adapter driver dmem +transport select swd if { ![info exists SOC] } { set SOC j721e diff --git a/tcl/board/ti_j722s_swd_native.cfg b/tcl/board/ti_j722s_swd_native.cfg index bbe0d508c8..a171ec3586 100644 --- a/tcl/board/ti_j722s_swd_native.cfg +++ b/tcl/board/ti_j722s_swd_native.cfg @@ -15,6 +15,7 @@ # We are using dmem, which uses dapdirect_swd transport adapter driver dmem +transport select swd if { ![info exists SOC] } { set SOC j722s -- |
From: <ge...@op...> - 2025-06-22 09:23:47
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8974 -- gerrit commit 13cf15ffdc6b9fd5ecd52e7db3603f17f0b62dd3 Author: Antonio Borneo <bor...@gm...> Date: Sun Jun 22 11:03:41 2025 +0200 jtag/drivers: dmem: fix build on Linux 32 bits On 32 bits machine both 'uintptr_t' and pointers are 32 bit. The cast (volatile uint32_t *)((uintptr_t)dmem_emu_virt_base_addr + addr) fails with error error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] in lines 100 and 109 because: - 'addr' is a 'uint64_t'; - adding 'uintptr_t' and 'uint64_t' returns a 64 bit value; - cast the 64 bit to 'uint32_t *' is an error. In the code the value passed to 'addr' is always 32 bit wide, so there is no need to pass it as 'uint64_t'. Change the type of 'addr' to 'uint32_t'. Fix also some format string to fit both 32 and 64 bits machines. Change-Id: I90ff7cd3731cb24a0fc91fe7b69c532b5c698ba0 Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/jtag/drivers/dmem.c b/src/jtag/drivers/dmem.c index e50e84aeeb..b5c6a794fa 100644 --- a/src/jtag/drivers/dmem.c +++ b/src/jtag/drivers/dmem.c @@ -93,14 +93,14 @@ static bool dmem_is_emulated_ap(struct adiv5_ap *ap, unsigned int *idx) return false; } -static void dmem_emu_set_ap_reg(uint64_t addr, uint32_t val) +static void dmem_emu_set_ap_reg(uint32_t addr, uint32_t val) { addr &= ~ARM_APB_PADDR31; *(volatile uint32_t *)((uintptr_t)dmem_emu_virt_base_addr + addr) = val; } -static uint32_t dmem_emu_get_ap_reg(uint64_t addr) +static uint32_t dmem_emu_get_ap_reg(uint32_t addr) { uint32_t val; @@ -519,7 +519,7 @@ static int dmem_dap_init(void) MAP_SHARED, dmem_fd, dmem_mapped_start); if (dmem_map_base == MAP_FAILED) { - LOG_ERROR("Mapping address 0x%lx for 0x%lx bytes failed!", + LOG_ERROR("Mapping address 0x%zx for 0x%zx bytes failed!", dmem_mapped_start, dmem_mapped_size); goto error_fail; } @@ -543,7 +543,7 @@ static int dmem_dap_init(void) MAP_SHARED, dmem_fd, dmem_mapped_start); if (dmem_emu_map_base == MAP_FAILED) { - LOG_ERROR("Mapping EMU address 0x%lx for 0x%lx bytes failed!", + LOG_ERROR("Mapping EMU address 0x%" PRIx64 " for 0x%" PRIx64 " bytes failed!", dmem_emu_base_address, dmem_emu_size); goto error_fail; } -- |
From: <ge...@op...> - 2025-06-22 06:43:41
|
This is an automated email from Gerrit. "Brian Kuschak <bku...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8973 -- gerrit commit 76734b1388535aeff1a87715880b0c6e3945970c Author: Brian Kuschak <bku...@gm...> Date: Wed Jun 11 12:41:04 2025 +0800 jtag/drivers/cmsis_dap: add new backend cmsis_dap_tcp Create a new backend for cmsis_dap driver that allows CMSIS-DAP protocol to run over TCP/IP instead of USB. An implementation of the firmware for an SWD programmer that uses this cmsis_dap_tcp protocol can be found at the link below. https://github.com/bkuschak/cmsis_dap_tcp_esp32 Using this cmsis_dap_tcp backend with the firmware above, flashing a 64KB image to an STM32 completes in about 8 seconds. Change-Id: I6e3e45016bd16ef2259561b1046788f5536b0687 Signed-off-by: Brian Kuschak <bku...@gm...> diff --git a/configure.ac b/configure.ac index 4b94716299..22e5e7bd05 100644 --- a/configure.ac +++ b/configure.ac @@ -206,6 +206,9 @@ m4_define([HOST_ARM_OR_AARCH64_BITBANG_ADAPTERS], [[imx_gpio], [Bitbanging on NXP IMX processors], [IMX_GPIO]], [[am335xgpio], [Bitbanging on AM335x (as found in Beaglebones)], [AM335XGPIO]]]) +m4_define([CMSIS_DAP_TCP_ADAPTER], + [[[cmsis_dap_tcp], [CMSIS-DAP v2 compliant dongle (TCP)], [CMSIS_DAP_TCP]]]) + # The word 'Adapter' in "Dummy Adapter" below must begin with a capital letter # because there is an M4 macro called 'adapter'. m4_define([DUMMY_ADAPTER], @@ -338,7 +341,8 @@ AC_ARG_ADAPTERS([ JTAG_VPI_ADAPTER, RSHIM_ADAPTER, PCIE_ADAPTERS, - LIBJAYLINK_ADAPTERS + LIBJAYLINK_ADAPTERS, + CMSIS_DAP_TCP_ADAPTER ],[auto]) AC_ARG_ADAPTERS([ @@ -648,6 +652,7 @@ PROCESS_ADAPTERS([LIBFTDI_USB1_ADAPTERS], ["x$use_libftdi" = "xyes" -a "x$use_li PROCESS_ADAPTERS([LIBGPIOD_ADAPTERS], ["x$use_libgpiod" = "xyes"], [Linux libgpiod]) PROCESS_ADAPTERS([SYSFSGPIO_ADAPTER], ["x$is_linux" = "xyes"], [Linux sysfs]) PROCESS_ADAPTERS([REMOTE_BITBANG_ADAPTER], [true], [unused]) +PROCESS_ADAPTERS([CMSIS_DAP_TCP_ADAPTER], [true], [unused]) PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], ["x$use_internal_libjaylink" = "xyes" -o "x$use_libjaylink" = "xyes"], [libjaylink-0.2]) PROCESS_ADAPTERS([PCIE_ADAPTERS], ["x$is_linux" = "xyes" -a "x$ac_cv_header_linux_pci_h" = "xyes"], [Linux build]) PROCESS_ADAPTERS([SERIAL_PORT_ADAPTERS], ["x$can_build_buspirate" = "xyes"], @@ -854,6 +859,7 @@ m4_foreach([adapter], [USB1_ADAPTERS, AMTJTAGACCEL_ADAPTER, HOST_ARM_BITBANG_ADAPTERS, HOST_ARM_OR_AARCH64_BITBANG_ADAPTERS, + CMSIS_DAP_TCP_ADAPTER, DUMMY_ADAPTER, OPTIONAL_LIBRARIES, COVERAGE], diff --git a/src/helper/replacements.h b/src/helper/replacements.h index ecc0e5e955..95322e96ac 100644 --- a/src/helper/replacements.h +++ b/src/helper/replacements.h @@ -225,6 +225,20 @@ static inline int socket_select(int max_fd, #endif } +static inline int socket_timeout(int fd, unsigned long timeout_msec) +{ +#ifdef _WIN32 + DWORD timeout = timeout_msec; + return setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout, + sizeof(timeout)); +#else + struct timeval tv; + tv.tv_sec = timeout_msec / 1000; + tv.tv_usec = (timeout_msec % 1000) * 1000; + return setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof(tv)); +#endif +} + #ifndef HAVE_ELF_H typedef uint32_t Elf32_Addr; diff --git a/src/jtag/drivers/Makefile.am b/src/jtag/drivers/Makefile.am index b0dd8e3ad1..0942777145 100644 --- a/src/jtag/drivers/Makefile.am +++ b/src/jtag/drivers/Makefile.am @@ -198,6 +198,10 @@ if !CMSIS_DAP_HID DRIVERFILES += %D%/cmsis_dap.c endif endif +if CMSIS_DAP_TCP +DRIVERFILES += %D%/cmsis_dap_tcp.c +DRIVERFILES += %D%/cmsis_dap.c +endif if IMX_GPIO DRIVERFILES += %D%/imx_gpio.c endif diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index 2bfcfcc2b0..7f8eabeb43 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -52,9 +52,16 @@ const struct cmsis_dap_backend cmsis_dap_hid_backend = { }; #endif +#if BUILD_CMSIS_DAP_TCP == 0 +const struct cmsis_dap_backend cmsis_dap_tcp_backend = { + .name = "tcp" +}; +#endif + static const struct cmsis_dap_backend *const cmsis_dap_backends[] = { &cmsis_dap_usb_backend, &cmsis_dap_hid_backend, + &cmsis_dap_tcp_backend, }; /* USB Config */ @@ -2272,8 +2279,8 @@ static const struct command_registration cmsis_dap_subcommand_handlers[] = { .name = "backend", .handler = &cmsis_dap_handle_backend_command, .mode = COMMAND_CONFIG, - .help = "set the communication backend to use (USB bulk or HID).", - .usage = "(auto | usb_bulk | hid)", + .help = "set the communication backend to use (USB bulk or HID, or TCP).", + .usage = "(auto | usb_bulk | hid | tcp)", }, { .name = "quirk", @@ -2290,6 +2297,15 @@ static const struct command_registration cmsis_dap_subcommand_handlers[] = { .help = "USB bulk backend-specific commands", .usage = "<cmd>", }, +#endif +#if BUILD_CMSIS_DAP_TCP + { + .name = "tcp", + .chain = cmsis_dap_tcp_subcommand_handlers, + .mode = COMMAND_ANY, + .help = "TCP backend-specific commands", + .usage = "<cmd>", + }, #endif COMMAND_REGISTRATION_DONE }; diff --git a/src/jtag/drivers/cmsis_dap.h b/src/jtag/drivers/cmsis_dap.h index aded0e54a3..1052bd3589 100644 --- a/src/jtag/drivers/cmsis_dap.h +++ b/src/jtag/drivers/cmsis_dap.h @@ -78,7 +78,9 @@ struct cmsis_dap_backend { extern const struct cmsis_dap_backend cmsis_dap_hid_backend; extern const struct cmsis_dap_backend cmsis_dap_usb_backend; +extern const struct cmsis_dap_backend cmsis_dap_tcp_backend; extern const struct command_registration cmsis_dap_usb_subcommand_handlers[]; +extern const struct command_registration cmsis_dap_tcp_subcommand_handlers[]; #define REPORT_ID_SIZE 1 diff --git a/src/jtag/drivers/cmsis_dap_tcp.c b/src/jtag/drivers/cmsis_dap_tcp.c new file mode 100644 index 0000000000..b44df9a10e --- /dev/null +++ b/src/jtag/drivers/cmsis_dap_tcp.c @@ -0,0 +1,351 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +/*************************************************************************** + * Provides CMSIS-DAP protocol over a TCP/IP socket. * + * UART and SWO are currently unsupported. * + * * + * Copyright (C) 2025 by Brian Kuschak <bku...@gm...> * + * * + * Adapted from cmsis_dap_usb_hid.c. Copyright (C) 2013-2018 by: * + * Mickaël Thomas <mic...@gm...> * + * Maksym Hilliaka <ot...@fr...> * + * Phillip Pearson <pp...@my...> * + * Paul Fertser <fer...@gm...> * + * mike brown <mi...@th...> * + * Spencer Oliver <sp...@sp...> * + * * + * Example usage: * + * adapter driver cmsis-dap * + * cmsis-dap backend tcp * + * cmsis-dap tcp host 192.168.1.4 * + * cmsis-dap tcp dap_port 4441 * + * transport select swd * + * adapter speed 2000 * + * * + ***************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <hidapi.h> +#include <netdb.h> +#include <netinet/tcp.h> +#include <stdbool.h> +#include <string.h> +#include <sys/socket.h> +#include <sys/types.h> + +#include "helper/command.h" +#include "helper/log.h" +#include "helper/replacements.h" +#include "helper/system.h" +#include "cmsis_dap.h" + +#define STRINGIFY(x) #x + +// If the protocol changes in the future, the SIGNATURE should also be changed. +#define DAP_PKT_HDR_SIGNATURE 0x00504144 // "DAP" +#define DAP_PKT_TYPE_REQUEST 0x01 +#define DAP_PKT_TYPE_RESPONSE 0x02 + +#define CMSIS_DAP_TCP_PORT 4441 // Default. Can be overridden. +#define CMSIS_DAP_PACKET_SIZE 1024 // Max payload size not including + // header. + +// CMSIS-DAP requests are variable length. With CMSIS-DAP over USB, the +// transfer sizes are preserved by the USB stack. However, TCP/IP is stream +// oriented so we perform our own packetization to preserve the boundaries +// between each request. This short header is prepended to each CMSIS-DAP +// request and response before being sent over the socket. Little endian format +// is used for multibyte values. +struct cmsis_dap_tcp_packet_hdr { + uint32_t signature; // "DAP" + uint16_t length; // Not including header length. + uint8_t packet_type; + uint8_t reserved; // Reserved for future use. +}; + +struct cmsis_dap_backend_data { + int sockfd; +}; + +static char *cmsis_dap_tcp_host; +static char *cmsis_dap_tcp_dap_port = STRINGIFY(CMSIS_DAP_TCP_PORT); + +static void cmsis_dap_tcp_close(struct cmsis_dap *dap); +static int cmsis_dap_tcp_alloc(struct cmsis_dap *dap, unsigned int pkt_sz); +static void cmsis_dap_tcp_free(struct cmsis_dap *dap); + +static int cmsis_dap_tcp_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t + pids[], const char *serial) +{ + // Ignore vids, pids, serial. We use host and port subcommands instead. + (void)vids; + (void)pids; + (void)serial; + + dap->bdata = malloc(sizeof(struct cmsis_dap_backend_data)); + if (!dap->bdata) { + LOG_ERROR("CMSIS-DAP: unable to allocate memory"); + return ERROR_FAIL; + } + + struct addrinfo hints = { + .ai_family = AF_UNSPEC, + .ai_socktype = SOCK_STREAM + }; + struct addrinfo *result, *rp; + int fd = 0; + + LOG_INFO("CMSIS-DAP: Connecting to %s:%s using TCP backend", + cmsis_dap_tcp_host ? cmsis_dap_tcp_host : "localhost", + cmsis_dap_tcp_dap_port); + + /* Some of the following code was taken from remote_bitbang.c */ + /* Obtain address(es) matching host/port */ + int s = getaddrinfo(cmsis_dap_tcp_host, cmsis_dap_tcp_dap_port, &hints, + &result); + if (s != 0) { + LOG_ERROR("CMSIS-DAP: getaddrinfo: %s\n", gai_strerror(s)); + free(dap->bdata); + return ERROR_FAIL; + } + + /* getaddrinfo() returns a list of address structures. + Try each address until we successfully connect(2). + If socket(2) (or connect(2)) fails, we (close the socket + and) try the next address. */ + + for (rp = result; rp ; rp = rp->ai_next) { + fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); + if (fd == -1) + continue; + + if (connect(fd, rp->ai_addr, rp->ai_addrlen) != -1) { + LOG_DEBUG("Connected."); + break; /* Success */ + } + + close(fd); + } + + freeaddrinfo(result); + + if (!rp) { /* No address succeeded */ + LOG_ERROR("CMSIS-DAP: unable to connect to device %s:%s", + cmsis_dap_tcp_host ? cmsis_dap_tcp_host : "localhost", + cmsis_dap_tcp_dap_port); + log_socket_error("Failed to connect"); + free(dap->bdata); + dap->bdata = NULL; + return ERROR_FAIL; + } + + /* Set NODELAY to minimize latency. */ + int one = 1; + /* On Windows optval has to be a const char *. */ + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const char *)&one, sizeof(one)); + + dap->bdata->sockfd = fd; + + int retval = cmsis_dap_tcp_alloc(dap, CMSIS_DAP_PACKET_SIZE); + if (retval != ERROR_OK) { + cmsis_dap_tcp_close(dap); + return ERROR_FAIL; + } + return ERROR_OK; +} + +static void cmsis_dap_tcp_close(struct cmsis_dap *dap) +{ + if (close_socket(dap->bdata->sockfd) != 0) { + log_socket_error("close_socket"); + } + + if(dap->bdata) + free(dap->bdata); + dap->bdata = NULL; + cmsis_dap_tcp_free(dap); +} + +static int cmsis_dap_tcp_read(struct cmsis_dap *dap, int transfer_timeout_ms, + enum cmsis_dap_blocking blocking) +{ + int wait_ms = (blocking == CMSIS_DAP_NON_BLOCKING) ? 0 : + transfer_timeout_ms; + socket_timeout(dap->bdata->sockfd, wait_ms); + + if(blocking == CMSIS_DAP_NON_BLOCKING) + socket_nonblock(dap->bdata->sockfd); + else + socket_block(dap->bdata->sockfd); + + // Read the header first to find the length, then read the rest. + struct cmsis_dap_tcp_packet_hdr *header = (void*)dap->packet_buffer; + int retval = read_socket(dap->bdata->sockfd, dap->packet_buffer, + sizeof(*header)); + LOG_DEBUG_IO("Reading header returned %d", retval); + + if (retval == 0) { + return ERROR_TIMEOUT_REACHED; + } else if (retval == -1) { + if (errno == EAGAIN || errno == EWOULDBLOCK) { + return ERROR_TIMEOUT_REACHED; + } else { + LOG_ERROR("CMSIS-DAP: error reading header"); + log_socket_error("read_socket"); + return ERROR_FAIL; + } + } else if (retval != sizeof(*header)) { + log_socket_error("read_socket header short read"); + return ERROR_FAIL; + } + + header->signature = le_to_h_u32((void*)&header->signature); + header->length = le_to_h_u16((void*)&header->length); + + if(header->signature != DAP_PKT_HDR_SIGNATURE) { + LOG_ERROR("CMSIS-DAP: Unrecognized packet signature 0x%08x", + header->signature); + return ERROR_FAIL; + } else if(header->packet_type != DAP_PKT_TYPE_RESPONSE) { + LOG_ERROR("CMSIS-DAP: Unrecognized packet type 0x%02x", + header->packet_type); + return ERROR_FAIL; + } else if(header->length + sizeof(*header) > dap->packet_buffer_size) { + LOG_ERROR("CMSIS-DAP: Packet length %d too large to fit.", + header->length); + return ERROR_FAIL; + } + + LOG_DEBUG_IO("Reading %d bytes...", header->length); + retval = read_socket(dap->bdata->sockfd, dap->packet_buffer + + sizeof(*header), header->length); + + if (retval == 0) { + return ERROR_TIMEOUT_REACHED; + } else if (retval == -1) { + LOG_ERROR("CMSIS-DAP: error reading data"); + log_socket_error("read_socket"); + return ERROR_FAIL; + } else if (retval != header->length) { + log_socket_error("read_socket short read"); + return ERROR_FAIL; + } + return retval; +} + +static int cmsis_dap_tcp_write(struct cmsis_dap *dap, int txlen, int + timeout_ms) +{ + (void) timeout_ms; + + struct cmsis_dap_tcp_packet_hdr *header = (void*)dap->packet_buffer; + const unsigned int len = txlen + sizeof(*header); + if(len > dap->packet_buffer_size) { + LOG_ERROR("CMSIS-DAP: Packet length %d exceeds TCP buffer size!", len); + return ERROR_FAIL; + } + + /* Set the header values. */ + h_u32_to_le((void*)&header->signature, DAP_PKT_HDR_SIGNATURE); + h_u16_to_le((void*)&header->length, txlen); + header->packet_type = DAP_PKT_TYPE_REQUEST; + header->reserved = 0; + + /* write data to device */ + LOG_DEBUG_IO("Writing %d bytes", len); + int retval = write_socket(dap->bdata->sockfd, dap->packet_buffer, len); + if (retval < 0) { + log_socket_error("write_socket"); + return ERROR_FAIL; + } else if (retval != (int)len) { + LOG_ERROR("CMSIS-DAP: error writing data"); + log_socket_error("write_socket short write"); + return ERROR_FAIL; + } + return retval; +} + +static int cmsis_dap_tcp_alloc(struct cmsis_dap *dap, unsigned int pkt_sz) +{ + // Reserve space for the packet header. + struct cmsis_dap_tcp_packet_hdr header; + unsigned int packet_buffer_size = pkt_sz + sizeof(header); + uint8_t *buf = malloc(packet_buffer_size); + if (!buf) { + LOG_ERROR("CMSIS-DAP: unable to allocate CMSIS-DAP packet buffer"); + return ERROR_FAIL; + } + + dap->packet_buffer = buf; + dap->packet_size = pkt_sz; + dap->packet_usable_size = pkt_sz; + dap->packet_buffer_size = packet_buffer_size; + + dap->command = dap->packet_buffer + sizeof(header); + dap->response = dap->packet_buffer + sizeof(header); + return ERROR_OK; +} + +static void cmsis_dap_tcp_free(struct cmsis_dap *dap) +{ + free(dap->packet_buffer); + dap->packet_buffer = NULL; +} + +static void cmsis_dap_tcp_cancel_all(struct cmsis_dap *dap) +{ +} + +COMMAND_HANDLER(cmsis_dap_handle_tcp_dap_port) +{ + if (CMD_ARGC == 1) + cmsis_dap_tcp_dap_port = strdup(CMD_ARGV[0]); + else + LOG_ERROR("CMSIS-DAP: expected exactly one argument to " + "cmsis-dap tcp dap_port <port_number>"); + + return ERROR_OK; +} + +COMMAND_HANDLER(cmsis_dap_handle_tcp_host) +{ + if (CMD_ARGC == 1) + cmsis_dap_tcp_host = strdup(CMD_ARGV[0]); + else + LOG_ERROR("CMSIS-DAP: expected exactly one argument to " + "cmsis-dap tcp host <host_name>"); + + return ERROR_OK; +} + +const struct command_registration cmsis_dap_tcp_subcommand_handlers[] = { + { + .name = "host", + .handler = &cmsis_dap_handle_tcp_host, + .mode = COMMAND_CONFIG, + .help = "set the host name to use (for TCP backend only)", + .usage = "<host_name>", + }, + { + .name = "dap_port", + .handler = &cmsis_dap_handle_tcp_dap_port, + .mode = COMMAND_CONFIG, + .help = "set the port number to use for DAP (for TCP backend only)", + .usage = "<port_number>", + }, + COMMAND_REGISTRATION_DONE +}; + +const struct cmsis_dap_backend cmsis_dap_tcp_backend = { + .name = "tcp", + .open = cmsis_dap_tcp_open, + .close = cmsis_dap_tcp_close, + .read = cmsis_dap_tcp_read, + .write = cmsis_dap_tcp_write, + .packet_buffer_alloc = cmsis_dap_tcp_alloc, + .packet_buffer_free = cmsis_dap_tcp_free, + .cancel_all = cmsis_dap_tcp_cancel_all, +}; diff --git a/tcl/interface/cmsis-dap-tcp.cfg b/tcl/interface/cmsis-dap-tcp.cfg new file mode 100644 index 0000000000..ddd9971c19 --- /dev/null +++ b/tcl/interface/cmsis-dap-tcp.cfg @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# +# cmsis-dap-tcp - CMSIS-DAP protocol over TCP/IP. +# +# Change the host and dap_port parameters to match your programmer. +# + +adapter driver cmsis-dap +cmsis-dap backend tcp +cmsis-dap tcp host 192.168.1.4 +cmsis-dap tcp dap_port 4441 -- |
From: <ge...@op...> - 2025-06-21 20:20:31
|
This is an automated email from Gerrit. "R. Diez <rdi...@rd...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8972 -- gerrit commit b666a44c73527731cd6620a0df524971b34e0ed2 Author: R. Diez <rdi...@rd...> Date: Sat Jun 21 22:05:17 2025 +0200 configure.ac: rename M4 macro 'adapter' to prevent accidental conflicts Also remove a comment about such a conflict which had been already noticed. Change-Id: I6f301ccbd1261ea1c15c44a02d3f34f0cf5cb9f4 Signed-off-by: R. Diez <rdi...@rd...> diff --git a/configure.ac b/configure.ac index 4b94716299..5a05f3171c 100644 --- a/configure.ac +++ b/configure.ac @@ -206,8 +206,6 @@ m4_define([HOST_ARM_OR_AARCH64_BITBANG_ADAPTERS], [[imx_gpio], [Bitbanging on NXP IMX processors], [IMX_GPIO]], [[am335xgpio], [Bitbanging on AM335x (as found in Beaglebones)], [AM335XGPIO]]]) -# The word 'Adapter' in "Dummy Adapter" below must begin with a capital letter -# because there is an M4 macro called 'adapter'. m4_define([DUMMY_ADAPTER], [[[dummy], [Dummy Adapter], [DUMMY]]]) @@ -309,15 +307,15 @@ AC_ARG_ENABLE([dmem], [build_dmem=$enableval], [build_dmem=no]) m4_define([AC_ARG_ADAPTERS], [ - m4_foreach([adapter], [$1], - [AC_ARG_ENABLE(ADAPTER_OPT([adapter]), - AS_HELP_STRING([--enable-ADAPTER_OPT([adapter])[[[=yes/no/auto]]]], - [Enable building support for the ]ADAPTER_DESC([adapter])[ (default is $2)]), + m4_foreach([adapterTuple], [$1], + [AC_ARG_ENABLE(ADAPTER_OPT([adapterTuple]), + AS_HELP_STRING([--enable-ADAPTER_OPT([adapterTuple])[[[=yes/no/auto]]]], + [Enable building support for the ]ADAPTER_DESC([adapterTuple])[ (default is $2)]), [case "${enableval}" in yes|no|auto) ;; - *) AC_MSG_ERROR([Option --enable-ADAPTER_OPT([adapter]) has invalid value "${enableval}".]) ;; + *) AC_MSG_ERROR([Option --enable-ADAPTER_OPT([adapterTuple]) has invalid value "${enableval}".]) ;; esac], - [ADAPTER_VAR([adapter])=$2]) + [ADAPTER_VAR([adapterTuple])=$2]) ]) ]) @@ -622,21 +620,23 @@ PKG_CHECK_MODULES([LIBJAYLINK], [libjaylink >= 0.2], # Arg $3: What prerequisites are missing, to be shown in an error message # if an adapter was requested but cannot be enabled. m4_define([PROCESS_ADAPTERS], [ - m4_foreach([adapter], [$1], [ + m4_foreach([adapterTuple], [$1], [ AS_IF([test $2], [ - AS_IF([test "x$ADAPTER_VAR([adapter])" != "xno"], [ - AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [1], [1 if you want the ]ADAPTER_DESC([adapter]).) + AS_IF([test "x$ADAPTER_VAR([adapterTuple])" != "xno"], [ + AC_DEFINE([BUILD_]ADAPTER_SYM([adapterTuple]), [1], + [1 if you want the ]ADAPTER_DESC([adapterTuple]).) ], [ - AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).) + AC_DEFINE([BUILD_]ADAPTER_SYM([adapterTuple]), [0], + [0 if you do not want the ]ADAPTER_DESC([adapterTuple]).) ]) ], [ - AS_IF([test "x$ADAPTER_VAR([adapter])" = "xyes"], [ - AC_MSG_ERROR([$3 is required for [adapter] "ADAPTER_DESC([adapter])".]) + AS_IF([test "x$ADAPTER_VAR([adapterTuple])" = "xyes"], [ + AC_MSG_ERROR([$3 is required for [adapterTuple] "ADAPTER_DESC([adapterTuple])".]) ]) - ADAPTER_VAR([adapter])=no - AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).) + ADAPTER_VAR([adapterTuple])=no + AC_DEFINE([BUILD_]ADAPTER_SYM([adapterTuple]), [0], [0 if you do not want the ]ADAPTER_DESC([adapterTuple]).) ]) - AM_CONDITIONAL(ADAPTER_SYM([adapter]), [test "x$ADAPTER_VAR([adapter])" != "xno"]) + AM_CONDITIONAL(ADAPTER_SYM([adapterTuple]), [test "x$ADAPTER_VAR([adapterTuple])" != "xno"]) ]) ]) @@ -839,7 +839,7 @@ echo echo echo OpenOCD configuration summary echo --------------------------------------------------- -m4_foreach([adapter], [USB1_ADAPTERS, +m4_foreach([adapterTuple], [USB1_ADAPTERS, HIDAPI_ADAPTERS, HIDAPI_USB1_ADAPTERS, LIBFTDI_ADAPTERS, LIBFTDI_USB1_ADAPTERS, LIBGPIOD_ADAPTERS, @@ -857,8 +857,8 @@ m4_foreach([adapter], [USB1_ADAPTERS, DUMMY_ADAPTER, OPTIONAL_LIBRARIES, COVERAGE], - [s=m4_format(["%-49s"], ADAPTER_DESC([adapter])) - AS_CASE([$ADAPTER_VAR([adapter])], + [s=m4_format(["%-49s"], ADAPTER_DESC([adapterTuple])) + AS_CASE([$ADAPTER_VAR([adapterTuple])], [auto], [ echo "$s"yes '(auto)' ], @@ -870,8 +870,8 @@ m4_foreach([adapter], [USB1_ADAPTERS, ], [ AC_MSG_ERROR(m4_normalize([ - Error in [adapter] "ADAPTER_ARG([adapter])": Variable "ADAPTER_VAR([adapter])" - has invalid value "$ADAPTER_VAR([adapter])".])) + Error in [adapterTuple] "ADAPTER_ARG([adapterTuple])": Variable "ADAPTER_VAR([adapterTuple])" + has invalid value "$ADAPTER_VAR([adapterTuple])".])) ]) ]) echo -- |
From: <ge...@op...> - 2025-06-21 19:49:15
|
This is an automated email from Gerrit. "R. Diez <rdi...@rd...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8971 -- gerrit commit ee2055fa23a972151dc4d18316a3adaa704f33a4 Author: R. Diez <rdi...@rd...> Date: Sat Jun 21 21:41:38 2025 +0200 configure.ac: show the dmem adapter in the config summary Also enable this adapter by default (auto). Change-Id: I61597c8572115f838ab0c92021163436eb7b0d59 Signed-off-by: R. Diez <rdi...@rd...> diff --git a/configure.ac b/configure.ac index 4b94716299..e995246a1d 100644 --- a/configure.ac +++ b/configure.ac @@ -165,6 +165,9 @@ m4_define([LIBFTDI_USB1_ADAPTERS], m4_define([LIBGPIOD_ADAPTERS], [[[linuxgpiod], [Linux GPIO bitbang through libgpiod], [LINUXGPIOD]]]) +m4_define([DMEM_ADAPTER], + [[[dmem], [CoreSight Direct Memory], [DMEM]]]) + m4_define([SYSFSGPIO_ADAPTER], [[[sysfsgpio], [Linux GPIO bitbang through sysfs], [SYSFSGPIO]]]) @@ -304,10 +307,6 @@ AS_IF([test "x$debug_malloc" = "xyes" -a "x$have_glibc" = "xyes"], [ AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging]) ]) -AC_ARG_ENABLE([dmem], - AS_HELP_STRING([--enable-dmem], [Enable building the dmem driver]), - [build_dmem=$enableval], [build_dmem=no]) - m4_define([AC_ARG_ADAPTERS], [ m4_foreach([adapter], [$1], [AC_ARG_ENABLE(ADAPTER_OPT([adapter]), @@ -328,6 +327,7 @@ AC_ARG_ADAPTERS([ LIBFTDI_ADAPTERS, LIBFTDI_USB1_ADAPTERS, LIBGPIOD_ADAPTERS, + DMEM_ADAPTER, SYSFSGPIO_ADAPTER, REMOTE_BITBANG_ADAPTER, LINUXSPIDEV_ADAPTER, @@ -505,12 +505,6 @@ AS_IF([test "x$build_parport" = "xyes"], [ AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.]) ]) -AS_IF([test "x$build_dmem" = "xyes"], [ - AC_DEFINE([BUILD_DMEM], [1], [1 if you want to debug via Direct Mem.]) -], [ - AC_DEFINE([BUILD_DMEM], [0], [0 if you don't want to debug via Direct Mem.]) -]) - AS_IF([test "x$ADAPTER_VAR([dummy])" != "xno"], [ build_bitbang=yes ]) @@ -646,6 +640,7 @@ PROCESS_ADAPTERS([HIDAPI_USB1_ADAPTERS], ["x$use_hidapi" = "xyes" -a "x$use_libu PROCESS_ADAPTERS([LIBFTDI_ADAPTERS], ["x$use_libftdi" = "xyes"], [libftdi]) PROCESS_ADAPTERS([LIBFTDI_USB1_ADAPTERS], ["x$use_libftdi" = "xyes" -a "x$use_libusb1" = "xyes"], [libftdi and libusb-1.x]) PROCESS_ADAPTERS([LIBGPIOD_ADAPTERS], ["x$use_libgpiod" = "xyes"], [Linux libgpiod]) +PROCESS_ADAPTERS([DMEM_ADAPTER], ["x$is_linux" = "xyes"], [Linux /dev/mem]) PROCESS_ADAPTERS([SYSFSGPIO_ADAPTER], ["x$is_linux" = "xyes"], [Linux sysfs]) PROCESS_ADAPTERS([REMOTE_BITBANG_ADAPTER], [true], [unused]) PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], ["x$use_internal_libjaylink" = "xyes" -o "x$use_libjaylink" = "xyes"], [libjaylink-0.2]) @@ -744,7 +739,6 @@ AM_CONDITIONAL([USE_LIBFTDI], [test "x$use_libftdi" = "xyes"]) AM_CONDITIONAL([USE_LIBGPIOD], [test "x$use_libgpiod" = "xyes"]) AM_CONDITIONAL([USE_HIDAPI], [test "x$use_hidapi" = "xyes"]) AM_CONDITIONAL([USE_LIBJAYLINK], [test "x$use_libjaylink" = "xyes"]) -AM_CONDITIONAL([DMEM], [test "x$build_dmem" = "xyes"]) AM_CONDITIONAL([HAVE_CAPSTONE], [test "x$enable_capstone" != "xno"]) AM_CONDITIONAL([INTERNAL_JIMTCL], [test "x$use_internal_jimtcl" = "xyes"]) @@ -843,6 +837,7 @@ m4_foreach([adapter], [USB1_ADAPTERS, HIDAPI_ADAPTERS, HIDAPI_USB1_ADAPTERS, LIBFTDI_ADAPTERS, LIBFTDI_USB1_ADAPTERS, LIBGPIOD_ADAPTERS, + DMEM_ADAPTER, SYSFSGPIO_ADAPTER, REMOTE_BITBANG_ADAPTER, LIBJAYLINK_ADAPTERS, PCIE_ADAPTERS, SERIAL_PORT_ADAPTERS, -- |
From: <ge...@op...> - 2025-06-21 10:16:50
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8970 -- gerrit commit 439c3caf6d798661aa77b0f9cdd0631696528479 Author: Antonio Borneo <bor...@gm...> Date: Sat Jun 21 12:11:24 2025 +0200 helper: types: fix proper return type in example of ARRAY_SIZE() The example in the comment above the declaration of the macro ARRAY_SIZE() assigns the value to a variable of type 'unsigned' that is not allowed by the coding style (should be 'unsigned int') and is not correct since the macro uses 'sizeof()' and the type returned is 'size_t'. Fix the comment. Change-Id: I18c32b5328a229ab74b56dafab46a064ce5d23c5 Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/helper/types.h b/src/helper/types.h index 53249e5b79..b3edd21184 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -51,7 +51,7 @@ * Compute the number of elements of a variable length array. * <code> * const char *strs[] = { "a", "b", "c" }; - * unsigned num_strs = ARRAY_SIZE(strs); + * size_t num_strs = ARRAY_SIZE(strs); * </code> */ #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) -- |
From: <ge...@op...> - 2025-06-20 09:20:12
|
This is an automated email from Gerrit. "zapb <de...@za...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8969 -- gerrit commit 798470fe30a42456ad2d1526d8730dbb2dc091a8 Author: Marc Schink <de...@za...> Date: Fri Jun 20 11:18:03 2025 +0200 tcl/board: Add config for TMS570LS12x development kit Tested on the corresponding hardware. Change-Id: Ic98141c450bb981cc7853c93b38195c7930bc7d3 Signed-off-by: Marc Schink <de...@za...> diff --git a/tcl/board/ti/launchxl2-tms57012.cfg b/tcl/board/ti/launchxl2-tms57012.cfg new file mode 100644 index 0000000000..99cb26e204 --- /dev/null +++ b/tcl/board/ti/launchxl2-tms57012.cfg @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# Hercules TMS570LS12x LaunchPad Development Kit +# https://www.ti.com/tool/LAUNCHXL2-TMS57012 + +source [find interface/xds110.cfg] + +transport select jtag + +source [find target/ti_tms570ls1x.cfg] -- |
From: <ge...@op...> - 2025-06-20 09:06:03
|
This is an automated email from Gerrit. "zapb <de...@za...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8965 -- gerrit commit 22bb335b17502e60b619d6568b428371025cbbb6 Author: Marc Schink <de...@za...> Date: Fri Jun 20 10:53:09 2025 +0200 target/armv7a: Hide multiprocessing support message Print a debug message about missing multiprocessing support rather than an error message. Change-Id: Ia1581f7284747d8a92096d6f5515f891c8069f71 Signed-off-by: Marc Schink <de...@za...> diff --git a/src/target/armv7a.c b/src/target/armv7a.c index 4d353dec65..651241b772 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -263,7 +263,7 @@ static int armv7a_read_mpidr(struct target *target) armv7a->multi_threading_processor == 1 ? "SMT" : "no SMT"); } else - LOG_ERROR("MPIDR not in multiprocessor format"); + LOG_DEBUG("MPIDR not in multiprocessor format"); done: dpm->finish(dpm); -- |
From: <ge...@op...> - 2025-06-20 09:06:03
|
This is an automated email from Gerrit. "zapb <de...@za...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8967 -- gerrit commit a5c20cce0194996ac848d6df32259d2472fb2b85 Author: Marc Schink <de...@za...> Date: Fri Jun 20 10:44:21 2025 +0200 target/armv4: Use LOG_TARGET_xxx() Use LOG_TARGET_xxx() for log messages as it is used for other targets. While at it, rework the log messages. For example by removing spaces or punctuation marks at the end of the message. Change-Id: I295001876d40527ec8f35c2aec8d562a29e57b26 Signed-off-by: Marc Schink <de...@za...> diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 597dc8990c..22cdba8ced 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -437,7 +437,7 @@ const int armv4_5_core_reg_map[9][17] = { static const char *arm_core_state_string(struct arm *arm) { if (arm->core_state > ARRAY_SIZE(arm_state_strings)) { - LOG_ERROR("core_state exceeds table size"); + LOG_TARGET_ERROR(arm->target, "core_state exceeds table size"); return "Unknown"; } @@ -483,20 +483,20 @@ void arm_set_cpsr(struct arm *arm, uint32_t cpsr) if (cpsr & (1 << 5)) { /* T */ if (cpsr & (1 << 24)) { /* J */ - LOG_WARNING("ThumbEE -- incomplete support"); + LOG_TARGET_WARNING(arm->target, "ThumbEE -- incomplete support"); state = ARM_STATE_THUMB_EE; } else state = ARM_STATE_THUMB; } else { if (cpsr & (1 << 24)) { /* J */ - LOG_ERROR("Jazelle state handling is BROKEN!"); + LOG_TARGET_ERROR(arm->target, "Jazelle state handling is broken"); state = ARM_STATE_JAZELLE; } else state = ARM_STATE_ARM; } arm->core_state = state; - LOG_DEBUG("set CPSR %#8.8" PRIx32 ": %s mode, %s state", cpsr, + LOG_TARGET_DEBUG(arm->target, "set CPSR %#8.8" PRIx32 ": %s mode, %s state", cpsr, arm_mode_name(mode), arm_core_state_string(arm)); } @@ -521,7 +521,7 @@ struct reg *arm_reg_current(struct arm *arm, unsigned int regnum) return NULL; if (!arm->map) { - LOG_ERROR("Register map is not available yet, the target is not fully initialised"); + LOG_TARGET_ERROR(arm->target, "Register map is not available yet, the target is not fully initialised"); r = arm->core_cache->reg_list + regnum; } else r = arm->core_cache->reg_list + arm->map[regnum]; @@ -530,7 +530,7 @@ struct reg *arm_reg_current(struct arm *arm, unsigned int regnum) * that doesn't support it... */ if (!r) { - LOG_ERROR("Invalid CPSR mode"); + LOG_TARGET_ERROR(arm->target, "Invalid CPSR mode"); r = arm->core_cache->reg_list + regnum; } @@ -631,7 +631,7 @@ static int armv4_5_set_core_reg(struct reg *reg, uint8_t *buf) */ if (armv4_5_target->core_mode != (enum arm_mode)(value & 0x1f)) { - LOG_DEBUG("changing ARM core mode to '%s'", + LOG_TARGET_DEBUG(target, "changing ARM core mode to '%s'", arm_mode_name(value & 0x1f)); value &= ~((1 << 24) | (1 << 5)); uint8_t t[4]; @@ -798,7 +798,7 @@ int arm_arch_state(struct target *target) struct arm *arm = target_to_arm(target); if (arm->common_magic != ARM_COMMON_MAGIC) { - LOG_ERROR("BUG: called for a non-ARM target"); + LOG_TARGET_ERROR(target, "BUG: called for a non-ARM target"); return ERROR_FAIL; } @@ -806,7 +806,7 @@ int arm_arch_state(struct target *target) if (target->semihosting && target->semihosting->hit_fileio) return ERROR_OK; - LOG_USER("target halted in %s state due to %s, current mode: %s\n" + LOG_TARGET_USER(target, "target halted in %s state due to %s, current mode: %s\n" "cpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "%s%s", arm_core_state_string(arm), debug_reason_name(target), @@ -1291,7 +1291,7 @@ int arm_get_gdb_reg_list(struct target *target, unsigned int i; if (!is_arm_mode(arm->core_mode)) { - LOG_ERROR("not a valid arm core mode - communication failure?"); + LOG_TARGET_ERROR(target, "not a valid arm core mode - communication failure?"); return ERROR_FAIL; } @@ -1362,7 +1362,7 @@ int arm_get_gdb_reg_list(struct target *target, return ERROR_OK; default: - LOG_ERROR("not a valid register class type in query."); + LOG_TARGET_ERROR(target, "not a valid register class type in query"); return ERROR_FAIL; } } @@ -1391,8 +1391,7 @@ static int armv4_5_run_algorithm_completion(struct target *target, /* fast exit: ARMv5+ code can use BKPT */ if (exit_point && buf_get_u32(arm->pc->value, 0, 32) != exit_point) { - LOG_WARNING( - "target reentered debug state, but not at the desired exit point: 0x%4.4" PRIx32 "", + LOG_TARGET_ERROR(target, "reentered debug state, but not at the desired exit point: 0x%4.4" PRIx32, buf_get_u32(arm->pc->value, 0, 32)); return ERROR_TARGET_TIMEOUT; } @@ -1417,10 +1416,10 @@ int armv4_5_run_algorithm_inner(struct target *target, int i; int retval = ERROR_OK; - LOG_DEBUG("Running algorithm"); + LOG_TARGET_DEBUG(target, "Running algorithm"); if (arm_algorithm_info->common_magic != ARM_COMMON_MAGIC) { - LOG_ERROR("current target isn't an ARMV4/5 target"); + LOG_TARGET_ERROR(target, "current target isn't an ARMV4/5 target"); return ERROR_TARGET_INVALID; } @@ -1430,13 +1429,13 @@ int armv4_5_run_algorithm_inner(struct target *target, } if (!is_arm_mode(arm->core_mode)) { - LOG_ERROR("not a valid arm core mode - communication failure?"); + LOG_TARGET_ERROR(target, "not a valid arm core mode - communication failure?"); return ERROR_FAIL; } /* armv5 and later can terminate with BKPT instruction; less overhead */ if (!exit_point && arm->arch == ARM_ARCH_V4) { - LOG_ERROR("ARMv4 target needs HW breakpoint location"); + LOG_TARGET_ERROR(target, "ARMv4 target needs HW breakpoint location"); return ERROR_FAIL; } @@ -1470,12 +1469,12 @@ int armv4_5_run_algorithm_inner(struct target *target, struct reg *reg = register_get_by_name(arm->core_cache, reg_params[i].reg_name, false); if (!reg) { - LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name); + LOG_TARGET_ERROR(target, "BUG: register '%s' not found", reg_params[i].reg_name); return ERROR_COMMAND_SYNTAX_ERROR; } if (reg->size != reg_params[i].size) { - LOG_ERROR("BUG: register '%s' size doesn't match reg_params[i].size", + LOG_TARGET_ERROR(target, "BUG: register '%s' size doesn't match reg_params[i].size", reg_params[i].reg_name); return ERROR_COMMAND_SYNTAX_ERROR; } @@ -1491,12 +1490,12 @@ int armv4_5_run_algorithm_inner(struct target *target, else if (arm->core_state == ARM_STATE_THUMB) exit_breakpoint_size = 2; else { - LOG_ERROR("BUG: can't execute algorithms when not in ARM or Thumb state"); + LOG_TARGET_ERROR(target, "BUG: can't execute algorithms when not in ARM or Thumb state"); return ERROR_COMMAND_SYNTAX_ERROR; } if (arm_algorithm_info->core_mode != ARM_MODE_ANY) { - LOG_DEBUG("setting core_mode: 0x%2.2x", + LOG_TARGET_DEBUG(target, "setting core_mode: 0x%2.2x", arm_algorithm_info->core_mode); buf_set_u32(arm->cpsr->value, 0, 5, arm_algorithm_info->core_mode); @@ -1509,7 +1508,7 @@ int armv4_5_run_algorithm_inner(struct target *target, retval = breakpoint_add(target, exit_point, exit_breakpoint_size, BKPT_HARD); if (retval != ERROR_OK) { - LOG_ERROR("can't add HW breakpoint to terminate algorithm"); + LOG_TARGET_ERROR(target, "can't add HW breakpoint to terminate algorithm"); return ERROR_TARGET_FAILURE; } } @@ -1542,13 +1541,13 @@ int armv4_5_run_algorithm_inner(struct target *target, reg_params[i].reg_name, false); if (!reg) { - LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name); + LOG_TARGET_ERROR(target, "BUG: register '%s' not found", reg_params[i].reg_name); retval = ERROR_COMMAND_SYNTAX_ERROR; continue; } if (reg->size != reg_params[i].size) { - LOG_ERROR( + LOG_TARGET_ERROR(target, "BUG: register '%s' size doesn't match reg_params[i].size", reg_params[i].reg_name); retval = ERROR_COMMAND_SYNTAX_ERROR; @@ -1667,7 +1666,7 @@ int arm_checksum_memory(struct target *target, if (retval == ERROR_OK) *checksum = buf_get_u32(reg_params[0].value, 0, 32); else - LOG_ERROR("error executing ARM crc algorithm"); + LOG_TARGET_ERROR(target, "error executing ARM CRC algorithm"); destroy_reg_param(®_params[0]); destroy_reg_param(®_params[1]); @@ -1702,7 +1701,7 @@ int arm_blank_check_memory(struct target *target, assert(sizeof(check_code_le) % 4 == 0); if (erased_value != 0xff) { - LOG_ERROR("Erase value 0x%02" PRIx8 " not yet supported for ARMv4/v5 targets", + LOG_TARGET_ERROR(target, "Erase value 0x%02" PRIx8 " not yet supported for ARMv4/v5 targets", erased_value); return ERROR_FAIL; } @@ -1781,7 +1780,7 @@ static int arm_default_mrc(struct target *target, int cpnum, uint32_t crn, uint32_t crm, uint32_t *value) { - LOG_ERROR("%s doesn't implement MRC", target_type_name(target)); + LOG_TARGET_ERROR(target, "%s doesn't implement MRC", target_type_name(target)); return ERROR_FAIL; } @@ -1789,7 +1788,7 @@ static int arm_default_mrrc(struct target *target, int cpnum, uint32_t op, uint32_t crm, uint64_t *value) { - LOG_ERROR("%s doesn't implement MRRC", target_type_name(target)); + LOG_TARGET_ERROR(target, "%s doesn't implement MRRC", target_type_name(target)); return ERROR_FAIL; } @@ -1798,7 +1797,7 @@ static int arm_default_mcr(struct target *target, int cpnum, uint32_t crn, uint32_t crm, uint32_t value) { - LOG_ERROR("%s doesn't implement MCR", target_type_name(target)); + LOG_TARGET_ERROR(target, "%s doesn't implement MCR", target_type_name(target)); return ERROR_FAIL; } @@ -1806,7 +1805,7 @@ static int arm_default_mcrr(struct target *target, int cpnum, uint32_t op, uint32_t crm, uint64_t value) { - LOG_ERROR("%s doesn't implement MCRR", target_type_name(target)); + LOG_TARGET_ERROR(target, "%s doesn't implement MCRR", target_type_name(target)); return ERROR_FAIL; } -- |
From: <ge...@op...> - 2025-06-20 09:05:59
|
This is an automated email from Gerrit. "zapb <de...@za...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8966 -- gerrit commit 17d8529441e7a8fd6465a74f5136bc7f2c65a653 Author: Marc Schink <de...@za...> Date: Fri Jun 20 10:30:03 2025 +0200 target/armv7a: Use LOG_TARGET_xxx() Use LOG_TARGET_xxx() to indicate which target the message belongs to. Change-Id: Ic40c61a779c1a1ebdc96ebc56b27541fff5e6205 Signed-off-by: Marc Schink <de...@za...> diff --git a/src/target/armv7a.c b/src/target/armv7a.c index 651241b772..2bbafd420f 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -68,9 +68,9 @@ static void armv7a_show_fault_registers(struct target *target) if (retval != ERROR_OK) goto done; - LOG_USER("Data fault registers DFSR: %8.8" PRIx32 + LOG_TARGET_USER(target, "Data fault registers DFSR: %8.8" PRIx32 ", DFAR: %8.8" PRIx32, dfsr, dfar); - LOG_USER("Instruction fault registers IFSR: %8.8" PRIx32 + LOG_TARGET_USER(target, "Instruction fault registers IFSR: %8.8" PRIx32 ", IFAR: %8.8" PRIx32, ifsr, ifar); done: @@ -134,7 +134,7 @@ int armv7a_read_ttbcr(struct target *target) if (retval != ERROR_OK) goto done; - LOG_DEBUG("ttbcr %" PRIx32, ttbcr); + LOG_TARGET_DEBUG(target, "ttbcr %" PRIx32, ttbcr); ttbcr_n = ttbcr & 0x7; armv7a->armv7a_mmu.ttbcr = ttbcr; @@ -169,7 +169,7 @@ int armv7a_read_ttbcr(struct target *target) armv7a->armv7a_mmu.ttbr_mask[0] = 7 << (32 - ttbcr_n); } - LOG_DEBUG("ttbr1 %s, ttbr0_mask %" PRIx32 " ttbr1_mask %" PRIx32, + LOG_TARGET_DEBUG(target, "ttbr1 %s, ttbr0_mask %" PRIx32 " ttbr1_mask %" PRIx32, (ttbcr_n != 0) ? "used" : "not used", armv7a->armv7a_mmu.ttbr_mask[0], armv7a->armv7a_mmu.ttbr_mask[1]); @@ -248,14 +248,13 @@ static int armv7a_read_mpidr(struct target *target) /* Is register in Multiprocessing Extensions register format? */ if (mpidr & MPIDR_MP_EXT) { - LOG_DEBUG("%s: MPIDR 0x%" PRIx32, target_name(target), mpidr); + LOG_TARGET_DEBUG(target, "%s: MPIDR 0x%" PRIx32, target_name(target), mpidr); armv7a->multi_processor_system = (mpidr >> 30) & 1; armv7a->multi_threading_processor = (mpidr >> 24) & 1; armv7a->level2_id = (mpidr >> 16) & 0xf; armv7a->cluster_id = (mpidr >> 8) & 0xf; armv7a->cpu_id = mpidr & 0xf; - LOG_INFO("%s: MPIDR level2 %x, cluster %x, core %x, %s, %s", - target_name(target), + LOG_TARGET_INFO(target, "MPIDR level2 %x, cluster %x, core %x, %s, %s", armv7a->level2_id, armv7a->cluster_id, armv7a->cpu_id, @@ -263,7 +262,7 @@ static int armv7a_read_mpidr(struct target *target) armv7a->multi_threading_processor == 1 ? "SMT" : "no SMT"); } else - LOG_DEBUG("MPIDR not in multiprocessor format"); + LOG_TARGET_DEBUG(target, "MPIDR not in multiprocessor format"); done: dpm->finish(dpm); @@ -338,7 +337,7 @@ int armv7a_identify_cache(struct target *target) cache->iminline = 4UL << (ctr & 0xf); cache->dminline = 4UL << ((ctr & 0xf0000) >> 16); - LOG_DEBUG("ctr %" PRIx32 " ctr.iminline %" PRIu32 " ctr.dminline %" PRIu32, + LOG_TARGET_DEBUG(target, "ctr %" PRIx32 " ctr.iminline %" PRIu32 " ctr.dminline %" PRIu32, ctr, cache->iminline, cache->dminline); /* retrieve CLIDR @@ -350,7 +349,7 @@ int armv7a_identify_cache(struct target *target) goto done; cache->loc = (clidr & 0x7000000) >> 24; - LOG_DEBUG("Number of cache levels to PoC %" PRId32, cache->loc); + LOG_TARGET_DEBUG(target, "Number of cache levels to PoC %" PRId32, cache->loc); /* retrieve selected cache for later restore * MRC p15, 2,<Rd>, c0, c0, 0; Read CSSELR */ @@ -378,13 +377,13 @@ int armv7a_identify_cache(struct target *target) goto done; cache->arch[cl].d_u_size = decode_cache_reg(cache_reg); - LOG_DEBUG("data/unified cache index %" PRIu32 " << %" PRIu32 ", way %" PRIu32 " << %" PRIu32, + LOG_TARGET_DEBUG(target, "data/unified cache index %" PRIu32 " << %" PRIu32 ", way %" PRIu32 " << %" PRIu32, cache->arch[cl].d_u_size.index, cache->arch[cl].d_u_size.index_shift, cache->arch[cl].d_u_size.way, cache->arch[cl].d_u_size.way_shift); - LOG_DEBUG("cacheline %" PRIu32 " bytes %" PRIu32 " KBytes asso %" PRIu32 " ways", + LOG_TARGET_DEBUG(target, "cacheline %" PRIu32 " bytes %" PRIu32 " KBytes asso %" PRIu32 " ways", cache->arch[cl].d_u_size.linelen, cache->arch[cl].d_u_size.cachesize, cache->arch[cl].d_u_size.associativity); @@ -398,13 +397,13 @@ int armv7a_identify_cache(struct target *target) goto done; cache->arch[cl].i_size = decode_cache_reg(cache_reg); - LOG_DEBUG("instruction cache index %" PRIu32 " << %" PRIu32 ", way %" PRIu32 " << %" PRIu32, + LOG_TARGET_DEBUG(target, "instruction cache index %" PRIu32 " << %" PRIu32 ", way %" PRIu32 " << %" PRIu32, cache->arch[cl].i_size.index, cache->arch[cl].i_size.index_shift, cache->arch[cl].i_size.way, cache->arch[cl].i_size.way_shift); - LOG_DEBUG("cacheline %" PRIu32 " bytes %" PRIu32 " KBytes asso %" PRIu32 " ways", + LOG_TARGET_DEBUG(target, "cacheline %" PRIu32 " bytes %" PRIu32 " KBytes asso %" PRIu32 " ways", cache->arch[cl].i_size.linelen, cache->arch[cl].i_size.cachesize, cache->arch[cl].i_size.associativity); @@ -445,7 +444,7 @@ static int armv7a_setup_semihosting(struct target *target, int enable) armv7a->debug_base + CPUDBG_VCR, &vcr); if (ret < 0) { - LOG_ERROR("Failed to read VCR register\n"); + LOG_TARGET_ERROR(target, "Failed to read VCR register"); return ret; } @@ -458,7 +457,7 @@ static int armv7a_setup_semihosting(struct target *target, int enable) armv7a->debug_base + CPUDBG_VCR, vcr); if (ret < 0) - LOG_ERROR("Failed to write VCR register\n"); + LOG_TARGET_ERROR(target, "Failed to write VCR register"); return ret; } @@ -489,18 +488,18 @@ int armv7a_arch_state(struct target *target) struct arm *arm = &armv7a->arm; if (armv7a->common_magic != ARMV7_COMMON_MAGIC) { - LOG_ERROR("BUG: called for a non-ARMv7A target"); + LOG_TARGET_ERROR(target, "BUG: called for a non-ARMv7A target"); return ERROR_COMMAND_SYNTAX_ERROR; } arm_arch_state(target); if (armv7a->is_armv7r) { - LOG_USER("D-Cache: %s, I-Cache: %s", + LOG_TARGET_USER(target, "D-Cache: %s, I-Cache: %s", state[armv7a->armv7a_mmu.armv7a_cache.d_u_cache_enabled], state[armv7a->armv7a_mmu.armv7a_cache.i_cache_enabled]); } else { - LOG_USER("MMU: %s, D-Cache: %s, I-Cache: %s", + LOG_TARGET_USER(target, "MMU: %s, D-Cache: %s, I-Cache: %s", state[armv7a->armv7a_mmu.mmu_enabled], state[armv7a->armv7a_mmu.armv7a_cache.d_u_cache_enabled], state[armv7a->armv7a_mmu.armv7a_cache.i_cache_enabled]); -- |
From: <ge...@op...> - 2025-06-20 09:05:59
|
This is an automated email from Gerrit. "zapb <de...@za...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8964 -- gerrit commit fcf0cf3a05c4d96039cf954ca0a2657e0a2e3d85 Author: Marc Schink <de...@za...> Date: Fri Jun 20 10:17:12 2025 +0200 target/arm_dpm: Use LOG_TARGET_xxx() Use LOG_TARGET_xxx() to indicate which target the message belongs to. While at it, rework the log messages. For example, using correct format specifiers. Change-Id: I05031e0ae25fe9e7bc38dfb781b6623a967fd533 Signed-off-by: Marc Schink <de...@za...> diff --git a/src/target/arm_dpm.c b/src/target/arm_dpm.c index 0b2db77c5c..8ab464d0ab 100644 --- a/src/target/arm_dpm.c +++ b/src/target/arm_dpm.c @@ -50,9 +50,8 @@ static int dpm_mrc(struct target *target, int cpnum, if (retval != ERROR_OK) return retval; - LOG_DEBUG("MRC p%d, %d, r0, c%d, c%d, %d", cpnum, - (int) op1, (int) crn, - (int) crm, (int) op2); + LOG_TARGET_DEBUG(target, "MRC p%d, %" PRId32 ", r0, c%" PRId32 ", c%" PRId32 ", %" PRId32, + cpnum, op1, crn, crm, op2); /* read coprocessor register into R0; return via DCC */ retval = dpm->instr_read_data_r0(dpm, @@ -74,8 +73,8 @@ static int dpm_mrrc(struct target *target, int cpnum, if (retval != ERROR_OK) return retval; - LOG_DEBUG("MRRC p%d, %d, r0, r1, c%d", cpnum, - (int)op, (int)crm); + LOG_TARGET_DEBUG(target, "MRRC p%d, %" PRId32 ", r0, r1, c%" PRId32, + cpnum, op, crm); /* read coprocessor register into R0, R1; return via DCC */ retval = dpm->instr_read_data_r0_r1(dpm, @@ -98,9 +97,8 @@ static int dpm_mcr(struct target *target, int cpnum, if (retval != ERROR_OK) return retval; - LOG_DEBUG("MCR p%d, %d, r0, c%d, c%d, %d", cpnum, - (int) op1, (int) crn, - (int) crm, (int) op2); + LOG_TARGET_DEBUG(target, "MCR p%d, %" PRId32 ", r0, c%" PRId32 ", c%" PRId32 ", %" PRId32, + cpnum, op1, crn, crm, op2); /* read DCC into r0; then write coprocessor register from R0 */ retval = dpm->instr_write_data_r0(dpm, @@ -122,8 +120,8 @@ static int dpm_mcrr(struct target *target, int cpnum, if (retval != ERROR_OK) return retval; - LOG_DEBUG("MCRR p%d, %d, r0, r1, c%d", cpnum, - (int)op, (int)crm); + LOG_TARGET_DEBUG(target, "MCRR p%d, %" PRId32 ", r0, r1, c%" PRId32, + cpnum, op, crm); /* read DCC into r0, r1; then write coprocessor register from R0, R1 */ retval = dpm->instr_write_data_r0_r1(dpm, @@ -198,7 +196,8 @@ static int dpm_read_reg_u64(struct arm_dpm *dpm, struct reg *r, unsigned int reg buf_set_u32(r->value + 4, 0, 32, value_r1); r->valid = true; r->dirty = false; - LOG_DEBUG("READ: %s, %8.8" PRIx32 ", %8.8" PRIx32, r->name, value_r0, value_r1); + LOG_TARGET_DEBUG(dpm->arm->target, "READ: %s, %8.8" PRIx32 ", %8.8" PRIx32, + r->name, value_r0, value_r1); } return retval; @@ -237,10 +236,10 @@ int arm_dpm_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned int regnum) break; case ARM_STATE_JAZELLE: /* core-specific ... ? */ - LOG_WARNING("Jazelle PC adjustment unknown"); + LOG_TARGET_WARNING(dpm->arm->target, "Jazelle PC adjustment unknown"); break; default: - LOG_WARNING("unknown core state"); + LOG_TARGET_WARNING(dpm->arm->target, "unknown core state"); break; } break; @@ -265,7 +264,8 @@ int arm_dpm_read_reg(struct arm_dpm *dpm, struct reg *r, unsigned int regnum) buf_set_u32(r->value, 0, 32, value); r->valid = true; r->dirty = false; - LOG_DEBUG("READ: %s, %8.8" PRIx32, r->name, value); + LOG_TARGET_DEBUG(dpm->arm->target, "READ: %s, %8.8" PRIx32, r->name, + value); } return retval; @@ -301,7 +301,8 @@ static int dpm_write_reg_u64(struct arm_dpm *dpm, struct reg *r, unsigned int re if (retval == ERROR_OK) { r->dirty = false; - LOG_DEBUG("WRITE: %s, %8.8" PRIx32 ", %8.8" PRIx32, r->name, value_r0, value_r1); + LOG_TARGET_DEBUG(dpm->arm->target, "WRITE: %s, %8.8" PRIx32 ", %8.8" PRIx32, + r->name, value_r0, value_r1); } return retval; @@ -349,7 +350,8 @@ static int dpm_write_reg(struct arm_dpm *dpm, struct reg *r, unsigned int regnum if (retval == ERROR_OK) { r->dirty = false; - LOG_DEBUG("WRITE: %s, %8.8" PRIx32, r->name, value); + LOG_TARGET_DEBUG(dpm->arm->target, "WRITE: %s, %8.8" PRIx32, r->name, + value); } return retval; @@ -463,9 +465,8 @@ static int dpm_maybe_update_bpwp(struct arm_dpm *dpm, bool bpwp, xp->address, xp->control); if (retval != ERROR_OK) - LOG_ERROR("%s: can't %s HW %spoint %d", + LOG_TARGET_ERROR(dpm->arm->target, "can't %s HW %spoint %d", disable ? "disable" : "enable", - target_name(dpm->arm->target), (xp->number < 16) ? "break" : "watch", xp->number & 0xf); done: @@ -670,7 +671,7 @@ static enum arm_mode dpm_mapmode(struct arm *arm, case ARM_VFP_V3_D0 ... ARM_VFP_V3_FPSCR: return mode; default: - LOG_WARNING("invalid register #%u", num); + LOG_TARGET_WARNING(arm->target, "invalid register #%u", num); break; } return ARM_MODE_ANY; @@ -885,7 +886,7 @@ static int dpm_bpwp_setup(struct arm_dpm *dpm, struct dpm_bpwp *xp, } /* FALL THROUGH */ default: - LOG_ERROR("unsupported {break,watch}point length/alignment"); + LOG_TARGET_ERROR(dpm->arm->target, "unsupported {break,watch}point length/alignment"); return ERROR_COMMAND_SYNTAX_ERROR; } @@ -899,7 +900,7 @@ static int dpm_bpwp_setup(struct arm_dpm *dpm, struct dpm_bpwp *xp, xp->control = control; xp->dirty = true; - LOG_DEBUG("BPWP: addr %8.8" PRIx32 ", control %" PRIx32 ", number %d", + LOG_TARGET_DEBUG(dpm->arm->target, "BPWP: addr %8.8" PRIx32 ", control %" PRIx32 ", number %d", xp->address, control, xp->number); /* hardware is updated in write_dirty_registers() */ @@ -919,7 +920,7 @@ static int dpm_add_breakpoint(struct target *target, struct breakpoint *bp) /* FIXME we need a generic solution for software breakpoints. */ if (bp->type == BKPT_SOFT) - LOG_DEBUG("using HW bkpt, not SW..."); + LOG_TARGET_DEBUG(dpm->arm->target, "using HW breakpoint instead of SW"); for (unsigned int i = 0; i < dpm->nbp; i++) { if (!dpm->dbp[i].bp) { @@ -963,7 +964,7 @@ static int dpm_watchpoint_setup(struct arm_dpm *dpm, unsigned int index_t, /* this hardware doesn't support data value matching or masking */ if (wp->mask != WATCHPOINT_IGNORE_DATA_VALUE_MASK) { - LOG_DEBUG("watchpoint values and masking not supported"); + LOG_TARGET_ERROR(dpm->arm->target, "watchpoint values and masking not supported"); return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; } @@ -1143,8 +1144,8 @@ int arm_dpm_setup(struct arm_dpm *dpm) return ERROR_FAIL; } - LOG_INFO("%s: hardware has %d breakpoints, %d watchpoints", - target_name(target), dpm->nbp, dpm->nwp); + LOG_TARGET_INFO(target, "hardware has %d breakpoints, %d watchpoints", + dpm->nbp, dpm->nwp); /* REVISIT ... and some of those breakpoints could match * execution context IDs... @@ -1172,8 +1173,7 @@ int arm_dpm_initialize(struct arm_dpm *dpm) (void) dpm->bpwp_disable(dpm, 16 + i); } } else - LOG_WARNING("%s: can't disable breakpoints and watchpoints", - target_name(dpm->arm->target)); + LOG_TARGET_WARNING(dpm->arm->target, "can't disable breakpoints and watchpoints"); return ERROR_OK; } -- |
From: <ge...@op...> - 2025-06-20 09:05:59
|
This is an automated email from Gerrit. "zapb <de...@za...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8968 -- gerrit commit 0668f8077bea61c1fb9544c3392c100b14acd79d Author: Marc Schink <de...@za...> Date: Fri Jun 20 10:47:23 2025 +0200 target/armv4: Use command_print() instead of LOG_ERROR() Use command_print() in order to provide an error message to the caller. Change-Id: I9f1a2ef07a102e1d6e755f3680bed0f7183b5c9c Signed-off-by: Marc Schink <de...@za...> diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 22cdba8ced..d907615691 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -842,7 +842,7 @@ COMMAND_HANDLER(handle_armv4_5_reg_command) } if (!is_arm_mode(arm->core_mode)) { - LOG_ERROR("not a valid arm core mode - communication failure?"); + command_print(CMD, "not a valid arm core mode - communication failure?"); return ERROR_FAIL; } @@ -954,7 +954,7 @@ COMMAND_HANDLER(handle_arm_disassemble_command) struct target *target = get_current_target(CMD_CTX); if (!target) { - LOG_ERROR("No target selected"); + command_print(CMD, "No target selected"); return ERROR_FAIL; } -- |
From: <ge...@op...> - 2025-06-19 21:47:28
|
This is an automated email from Gerrit. "zapb <de...@za...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8963 -- gerrit commit 0bd7fc9155f84c79978dbb29cd7a4affd2d83516 Author: Marc Schink <de...@za...> Date: Thu Jun 19 23:44:23 2025 +0200 doc: Fix 'add_help_text' and 'add_usage_text' usage Remove the quotation marks as they are used for strings and not parameter names. Change-Id: I7bb25eb251427e89256b73cf697d8ec5c1b401dc Signed-off-by: Marc Schink <de...@za...> diff --git a/doc/openocd.texi b/doc/openocd.texi index db63fe06db..3ce57897b7 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -9870,11 +9870,11 @@ Requests the current target to map the specified @var{virtual_address} to its corresponding physical address, and displays the result. @end deffn -@deffn {Command} {add_help_text} 'command_name' 'help-string' +@deffn {Command} {add_help_text} command_name help_string Add or replace help text on the given @var{command_name}. @end deffn -@deffn {Command} {add_usage_text} 'command_name' 'help-string' +@deffn {Command} {add_usage_text} command_name help_string Add or replace usage text on the given @var{command_name}. @end deffn -- |
From: <ge...@op...> - 2025-06-19 08:31:50
|
This is an automated email from Gerrit. "zapb <de...@za...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8962 -- gerrit commit 4c5db683f6087ab6c4f4ada0d79410f76826b498 Author: Marc Schink <de...@za...> Date: Thu Jun 19 10:28:36 2025 +0200 tcl/target/lsch3_common: Remove 'mem2array' The 'mem2array' function is deprecated and replaced by 'read_memory'. Change-Id: Iea54a390d67978d20dbb99ab6f7f4178dda481c2 Reported-by: Paul Fertser <fer...@gm...> Signed-off-by: Marc Schink <de...@za...> diff --git a/tcl/target/lsch3_common.cfg b/tcl/target/lsch3_common.cfg index f48d59b9d8..ad88b2e1b3 100644 --- a/tcl/target/lsch3_common.cfg +++ b/tcl/target/lsch3_common.cfg @@ -51,8 +51,8 @@ proc release_cpu {cpu} { } # Release the cpu; it will start executing something bogus - mem2array regs 32 $RST_BRRL 1 - mww $RST_BRRL [expr {$regs(0) | 1 << $cpu}] + set reg [read_memory $RST_BRRL 32 1] + mww $RST_BRRL [expr {$reg | 1 << $cpu}] if {$not_halted} { resume -- |
From: <ge...@op...> - 2025-06-19 07:09:08
|
This is an automated email from Gerrit. "Tomas Vanek <va...@fb...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8959 -- gerrit commit 6136cd82f0c4b7a220097674be4e4a24e6b7b780 Author: Tomas Vanek <va...@fb...> Date: Tue Jun 17 16:23:12 2025 +0200 target/cortex_m: introduce security manipulation routines Running target algorithms on ARMv8M may require core in secure mode with SAU and MPU off (as set after reset). cortex_m_set_secure() forces this mode with optional save of the previous state. cortex_m_security_restore() restores previously saved state. Change-Id: Ia71826db47ee7b0557eaffd55244ce13eacbcb4b Signed-off-by: Tomas Vanek <va...@fb...> diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index ba9d83d79f..5fddfb91c8 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -2562,6 +2562,112 @@ static bool cortex_m_has_tz(struct target *target) return (dauthstatus & DAUTHSTATUS_SID_MASK) != 0; } +int cortex_m_set_secure(struct target *target, struct cortex_m_saved_security *ssec) +{ + if (ssec) { + ssec->dscsr_dirty = false; + ssec->sau_ctrl_dirty = false; + ssec->mpu_ctrl_dirty = false; + } + + if (!cortex_m_has_tz(target)) + return ERROR_OK; + + uint32_t dscsr; + int retval = target_read_u32(target, DCB_DSCSR, &dscsr); + if (retval != ERROR_OK) { + LOG_ERROR("ARMv8M set secure: DSCSR read failed"); + return retval; + } + if (!(dscsr & DSCSR_CDS)) { + if (ssec) { + ssec->dscsr_dirty = true; + ssec->dscsr = dscsr; + } + LOG_DEBUG("Setting Current Domain Secure in DSCSR"); + retval = target_write_u32(target, DCB_DSCSR, DSCSR_CDS); + if (retval != ERROR_OK) { + LOG_ERROR("ARMv8M set secure: DSCSR write failed"); + return retval; + } + } + + uint32_t sau_ctrl; + retval = target_read_u32(target, SAU_CTRL, &sau_ctrl); + if (retval != ERROR_OK) { + LOG_ERROR("ARMv8M set secure: SAU_CTRL read failed"); + return retval; + } + if (sau_ctrl & SAU_CTRL_ENABLE) { + if (ssec) { + ssec->sau_ctrl_dirty = true; + ssec->sau_ctrl = sau_ctrl; + } + retval = target_write_u32(target, SAU_CTRL, sau_ctrl & ~SAU_CTRL_ENABLE); + if (retval != ERROR_OK) { + LOG_ERROR("ARMv8M set secure: SAU_CTRL write failed"); + return retval; + } + } + + uint32_t mpu_ctrl; + retval = target_read_u32(target, MPU_CTRL, &mpu_ctrl); + if (retval != ERROR_OK) { + LOG_ERROR("ARMv8M set secure: MPU_CTRL read failed"); + return retval; + } + if (mpu_ctrl & MPU_CTRL_ENABLE) { + if (ssec) { + ssec->mpu_ctrl_dirty = true; + ssec->mpu_ctrl = mpu_ctrl; + } + retval = target_write_u32(target, MPU_CTRL, mpu_ctrl & ~MPU_CTRL_ENABLE); + if (retval != ERROR_OK) { + LOG_ERROR("ARMv8M set secure: MPU_CTRL write failed"); + return retval; + } + } + return ERROR_OK; +} + +int cortex_m_security_restore(struct target *target, struct cortex_m_saved_security *ssec) +{ + int retval; + if (!cortex_m_has_tz(target)) + return ERROR_OK; + + if (!ssec) + return ERROR_OK; + + if (ssec->mpu_ctrl_dirty) { + retval = target_write_u32(target, MPU_CTRL, ssec->mpu_ctrl); + if (retval != ERROR_OK) { + LOG_ERROR("ARMv8M security restore: MPU_CTRL write failed"); + return retval; + } + ssec->mpu_ctrl_dirty = false; + } + + if (ssec->sau_ctrl_dirty) { + retval = target_write_u32(target, SAU_CTRL, ssec->sau_ctrl); + if (retval != ERROR_OK) { + LOG_ERROR("ARMv8M security restore: SAU_CTRL write failed"); + return retval; + } + ssec->sau_ctrl_dirty = false; + } + + if (ssec->dscsr_dirty) { + LOG_DEBUG("Restoring Current Domain Security in DSCSR"); + retval = target_write_u32(target, DCB_DSCSR, ssec->dscsr & ~DSCSR_CDSKEY); + if (retval != ERROR_OK) { + LOG_ERROR("ARMv8M set secure: DSCSR write failed"); + return retval; + } + ssec->dscsr_dirty = false; + } + return ERROR_OK; +} #define MVFR0 0xE000EF40 #define MVFR0_SP_MASK 0x000000F0 diff --git a/src/target/cortex_m.h b/src/target/cortex_m.h index 144f24560c..82b2c1ecde 100644 --- a/src/target/cortex_m.h +++ b/src/target/cortex_m.h @@ -167,6 +167,8 @@ struct cortex_m_part_info { #define NVIC_DFSR 0xE000ED30 #define NVIC_MMFAR 0xE000ED34 #define NVIC_BFAR 0xE000ED38 +#define MPU_CTRL 0xE000ED94 +#define SAU_CTRL 0xE000EDD0 #define NVIC_SFSR 0xE000EDE4 #define NVIC_SFAR 0xE000EDE8 @@ -184,6 +186,9 @@ struct cortex_m_part_info { #define DFSR_VCATCH 8 #define DFSR_EXTERNAL 16 +#define MPU_CTRL_ENABLE BIT(0) +#define SAU_CTRL_ENABLE BIT(0) + #define FPCR_CODE 0 #define FPCR_LITERAL 1 #define FPCR_REPLACE_REMAP (0ul << 30) @@ -264,6 +269,15 @@ struct cortex_m_common { bool incorrect_halt_erratum; }; +struct cortex_m_saved_security { + bool dscsr_dirty; + uint32_t dscsr; + bool sau_ctrl_dirty; + uint32_t sau_ctrl; + bool mpu_ctrl_dirty; + uint32_t mpu_ctrl; +}; + static inline bool is_cortex_m_or_hla(const struct cortex_m_common *cortex_m) { return cortex_m->common_magic == CORTEX_M_COMMON_MAGIC; @@ -341,4 +355,17 @@ void cortex_m_deinit_target(struct target *target); int cortex_m_profiling(struct target *target, uint32_t *samples, uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds); +/** + * Forces Cortex-M core to the basic secure context with SAU and MPU off + * @param ssec pointer to save previous security state or NULL + * @returns error code or ERROR_OK if secure mode was set or is not applicable + * (not ARMv8M with security extension) + */ +int cortex_m_set_secure(struct target *target, struct cortex_m_saved_security *ssec); + +/** + * Restores saved security context to MPU_CTRL, SAU_CTRL and DSCSR + */ +int cortex_m_security_restore(struct target *target, struct cortex_m_saved_security *ssec); + #endif /* OPENOCD_TARGET_CORTEX_M_H */ -- |
From: <ge...@op...> - 2025-06-19 07:09:02
|
This is an automated email from Gerrit. "Tomas Vanek <va...@fb...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8961 -- gerrit commit 770a06534392ac66134581eff0fe6f683fdcf306 Author: Tomas Vanek <va...@fb...> Date: Wed Jun 18 12:01:08 2025 +0200 flash/nor/rp2xxx: save ACCESSCTRL over ROM API calls Especially after the flash probe (used in gdb-attach event) we need to completely restore the original security state to allow 'resume' or gdb 'continue' without injecting strange errors to application code. Save all ACCESSCTRL registers potentially changed by triggering CFGRESET. Restore them at cleanup. Fixes: commit ea775d49fc71 ("flash/nor/rp2040: add RP2350 support") Change-Id: I964886d5b1d0269497c343811ee4dcd5c31953db Signed-off-by: Tomas Vanek <va...@fb...> diff --git a/src/flash/nor/rp2xxx.c b/src/flash/nor/rp2xxx.c index fa13ec527f..7011904873 100644 --- a/src/flash/nor/rp2xxx.c +++ b/src/flash/nor/rp2xxx.c @@ -41,10 +41,18 @@ #define BOOTROM_STATE_RESET_OTHER_CORE 0x02 #define BOOTROM_STATE_RESET_GLOBAL_STATE 0x04 -#define ACCESSCTRL_LOCK_OFFSET 0x40060000u -#define ACCESSCTRL_LOCK_DEBUG_BITS 0x00000008u -#define ACCESSCTRL_CFGRESET_OFFSET 0x40060008u -#define ACCESSCTRL_WRITE_PASSWORD 0xacce0000u +#define ACCESSCTRL_LOCK_OFFSET 0x40060000u +#define ACCESSCTRL_CFGRESET_OFFSET 0x40060008u +#define ACCESSCTRL_GPIO_NSMASK0_OFFSET 0x4006000cu +#define ACCESSCTRL_GPIO_ROM_OFFSET 0x40060014u +#define ACCESSCTRL_GPIO_XIP_AUX_OFFSET 0x400600e8u + +#define ACCESSCTRL_SAVE_BASE ACCESSCTRL_GPIO_NSMASK0_OFFSET +#define ACCESSCTRL_SAVE_SIZE \ + (ACCESSCTRL_GPIO_XIP_AUX_OFFSET + 4 - ACCESSCTRL_SAVE_BASE) + +#define ACCESSCTRL_LOCK_DEBUG_BITS 0x00000008u +#define ACCESSCTRL_WRITE_PASSWORD 0xacce0000u #define RP2040_SSI_DR0 0x18000060 #define RP2040_QSPI_CTRL 0x4001800c @@ -211,6 +219,8 @@ struct rp2xxx_flash_bank { unsigned int sfdp_dummy, sfdp_dummy_detect; struct cortex_m_saved_security saved_security; + bool accessctrl_dirty; + uint8_t saved_accessctrl[ACCESSCTRL_SAVE_SIZE]; /* in target byte order */ }; #ifndef LOG_ROM_SYMBOL_DEBUG @@ -601,8 +611,28 @@ static int rp2xxx_call_rom_func(struct target *target, struct rp2xxx_flash_bank return rp2xxx_call_rom_func_batch(target, priv, &call, 1); } -static int rp2350_init_accessctrl(struct target *target) +static int rp2350_save_accessctrl(struct target *target, struct rp2xxx_flash_bank *priv) { + return target_read_memory(target, ACCESSCTRL_SAVE_BASE, 4, ACCESSCTRL_SAVE_SIZE / 4, + priv->saved_accessctrl); +} + +static int rp2350_restore_accessctrl(struct target *target, struct rp2xxx_flash_bank *priv) +{ + // Add write passwords to all ACCESSCTRL regs from ACCESSCTRL_GPIO_ROM to the end + // (exclude not keyed ACCESSCTRL_GPIO_NSMASK0 and ACCESSCTRL_GPIO_NSMASK1 + for (unsigned int i = ACCESSCTRL_GPIO_ROM_OFFSET - ACCESSCTRL_SAVE_BASE; + i < ACCESSCTRL_SAVE_SIZE; i += 4) + target_buffer_set_u32(target, priv->saved_accessctrl + i, + target_buffer_get_u32(target, priv->saved_accessctrl + i) | ACCESSCTRL_WRITE_PASSWORD); + + return target_write_memory(target, ACCESSCTRL_SAVE_BASE, 4, ACCESSCTRL_SAVE_SIZE / 4, + priv->saved_accessctrl); +} + +static int rp2350_init_accessctrl(struct target *target, struct rp2xxx_flash_bank *priv) +{ + priv->accessctrl_dirty = false; // Attempt to reset ACCESSCTRL, in case Secure access to SRAM has been // blocked, which will stop us from loading/running algorithms such as RCP // init. (Also ROM, QMI regs are needed later) @@ -620,6 +650,11 @@ static int rp2350_init_accessctrl(struct target *target) if (accessctrl_lock_reg & ACCESSCTRL_LOCK_DEBUG_BITS) { LOG_ERROR("ACCESSCTRL is locked, so can't reset permissions. Following steps might fail"); } else { + int retval = rp2350_save_accessctrl(target, priv); + if (retval == ERROR_OK) + priv->accessctrl_dirty = true; + // Don't fail on save ACCESSCTRL error, not vital for ROM API call + LOG_DEBUG("Reset ACCESSCTRL permissions via CFGRESET"); return target_write_u32(target, ACCESSCTRL_CFGRESET_OFFSET, ACCESSCTRL_WRITE_PASSWORD | 1u); } @@ -704,7 +739,7 @@ static int setup_for_raw_flash_cmd(struct target *target, struct rp2xxx_flash_ba } if (IS_RP2350(priv->id)) { - err = rp2350_init_accessctrl(target); + err = rp2350_init_accessctrl(target, priv); if (err != ERROR_OK) { LOG_ERROR("Failed to init ACCESSCTRL before ROM call"); return err; @@ -833,12 +868,19 @@ static void cleanup_after_raw_flash_cmd(struct target *target, struct rp2xxx_fla LOG_DEBUG("Cleaning up after flash operations"); if (IS_RP2350(priv->id)) { - /* TODO: restore ACCESSCTRL */ - if (is_arm(target_to_arm(target))) { - int retval = cortex_m_security_restore(target, &priv->saved_security); - if (retval != ERROR_OK) - LOG_WARNING("RP2xxx: security state was not restored properly. Debug 'resume' will probably fail, use 'reset' instead"); + int retval1 = ERROR_OK; + if (priv->accessctrl_dirty) { + retval1 = rp2350_restore_accessctrl(target, priv); + priv->accessctrl_dirty = false; } + + int retval2 = ERROR_OK; + if (is_arm(target_to_arm(target))) + retval2 = cortex_m_security_restore(target, &priv->saved_security); + + if (retval1 != ERROR_OK || retval2 != ERROR_OK) + LOG_WARNING("RP2xxx: security state was not restored properly. Debug 'resume' will probably fail, use 'reset' instead"); + /* Don't fail on security restore error, not vital for flash operation */ } if (priv->stack) { target_free_working_area(target, priv->stack); -- |
From: <ge...@op...> - 2025-06-19 07:09:02
|
This is an automated email from Gerrit. "Tomas Vanek <va...@fb...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8960 -- gerrit commit baae57625afd9410204ab2ab338849230e650106 Author: Tomas Vanek <va...@fb...> Date: Wed Jun 18 09:44:03 2025 +0200 flash/nor/rp2xxx: save security state over target algo RP2040 and RP2350 flash driver runs a ROM API target algorithm in probe to setup QSPI command interface. The Cortex-M33 core of RP2350 has to be in secure mode with SAU and MPU switched off to ensure ROM API call working properly. Especially after the flash probe (used in gdb-attach event) we need to completely restore the original security state to allow 'resume' or gdb 'continue' without injecting strange errors to application code. Use cortex_m support to set secure mode and to restore it back. Fixes: commit ea775d49fc71 ("flash/nor/rp2040: add RP2350 support") Change-Id: I72096bfecbb45a8aa4d3a7a37ad140532b3b00b2 Signed-off-by: Tomas Vanek <va...@fb...> diff --git a/src/flash/nor/rp2xxx.c b/src/flash/nor/rp2xxx.c index 85c5911041..fa13ec527f 100644 --- a/src/flash/nor/rp2xxx.c +++ b/src/flash/nor/rp2xxx.c @@ -209,6 +209,8 @@ struct rp2xxx_flash_bank { bool size_override; struct flash_device spi_dev; /* detected model of SPI flash */ unsigned int sfdp_dummy, sfdp_dummy_detect; + + struct cortex_m_saved_security saved_security; }; #ifndef LOG_ROM_SYMBOL_DEBUG @@ -630,23 +632,12 @@ static int rp2350_init_arm_core0(struct target *target, struct rp2xxx_flash_bank // run in the Secure state, so flip the state now before attempting to // execute any code on the core. int retval; - uint32_t dscsr; - retval = target_read_u32(target, DCB_DSCSR, &dscsr); + retval = cortex_m_set_secure(target, &priv->saved_security); if (retval != ERROR_OK) { - LOG_ERROR("RP2350 init ARM core: DSCSR read failed"); + LOG_ERROR("RP2350 init ARM core: set secure mode failed"); return retval; } - LOG_DEBUG("DSCSR: 0x%08" PRIx32, dscsr); - if (!(dscsr & DSCSR_CDS)) { - LOG_DEBUG("Setting Current Domain Secure in DSCSR"); - retval = target_write_u32(target, DCB_DSCSR, (dscsr & ~DSCSR_CDSKEY) | DSCSR_CDS); - if (retval != ERROR_OK) { - LOG_ERROR("RP2350 init ARM core: DSCSR read failed"); - return retval; - } - } - if (!priv->stack) { LOG_ERROR("No stack for flash programming code"); return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; @@ -840,6 +831,15 @@ static void cleanup_after_raw_flash_cmd(struct target *target, struct rp2xxx_fla driver state. Best to clean up our allocations manually after completing each flash call, so we know to make fresh ones next time. */ LOG_DEBUG("Cleaning up after flash operations"); + + if (IS_RP2350(priv->id)) { + /* TODO: restore ACCESSCTRL */ + if (is_arm(target_to_arm(target))) { + int retval = cortex_m_security_restore(target, &priv->saved_security); + if (retval != ERROR_OK) + LOG_WARNING("RP2xxx: security state was not restored properly. Debug 'resume' will probably fail, use 'reset' instead"); + } + } if (priv->stack) { target_free_working_area(target, priv->stack); priv->stack = 0; -- |
From: <ge...@op...> - 2025-06-17 18:25:53
|
This is an automated email from Gerrit. "Daniel Goehring <dgo...@os...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8958 -- gerrit commit fa7f15dc829077f2541c9017055cec2044657abd Author: Daniel Goehring <dgo...@os...> Date: Thu Jun 12 18:32:30 2025 -0400 breakpoint: SMP updates wrt arp_examine support Modify SMP breakpoint logic to support a per-core granularity. Before setting and removing breakpoints/watchpoints for a processor core contained in a SMP group, verify the core is halted and examined. For software breakpoints, assign the breakpoint to the current selected processor target, not the first target in the SMP group. Also verify at least one target in a SMP group is examined before setting the breakpoint/watchpoint. Change-Id: I9923ed20ea02ad92cce5ea12558f95e0ae1b161a Signed-off-by: Daniel Goehring <dgo...@os...> diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c index a080416291..7f79daf538 100644 --- a/src/target/breakpoints.c +++ b/src/target/breakpoints.c @@ -211,18 +211,25 @@ int breakpoint_add(struct target *target, enum breakpoint_type type) { if (target->smp) { + bool breakpoint_set = false; struct target_list *head; - if (type == BKPT_SOFT) { - head = list_first_entry(target->smp_targets, struct target_list, lh); - return breakpoint_add_internal(head->target, address, length, type); - } + if (type == BKPT_SOFT) + return breakpoint_add_internal(target, address, length, type); foreach_smp_target(head, target->smp_targets) { struct target *curr = head->target; - int retval = breakpoint_add_internal(curr, address, length, type); - if (retval != ERROR_OK) - return retval; + if (target_was_examined(curr) && curr->state == TARGET_HALTED) { + int retval = breakpoint_add_internal(curr, address, length, type); + if (retval != ERROR_OK) + return retval; + breakpoint_set = true; + } + } + + if (!breakpoint_set) { + LOG_ERROR("Unable to set breakpoint. All SMP targets are in the examine deferred state."); + return ERROR_FAIL; } return ERROR_OK; @@ -237,13 +244,22 @@ int context_breakpoint_add(struct target *target, enum breakpoint_type type) { if (target->smp) { + bool breakpoint_set = false; struct target_list *head; foreach_smp_target(head, target->smp_targets) { struct target *curr = head->target; - int retval = context_breakpoint_add_internal(curr, asid, length, type); - if (retval != ERROR_OK) - return retval; + if (target_was_examined(curr) && curr->state == TARGET_HALTED) { + int retval = context_breakpoint_add_internal(curr, asid, length, type); + if (retval != ERROR_OK) + return retval; + breakpoint_set = true; + } + } + + if (!breakpoint_set) { + LOG_ERROR("Unable to set context breakpoint. All SMP targets are in the examine deferred state."); + return ERROR_FAIL; } return ERROR_OK; @@ -259,13 +275,22 @@ int hybrid_breakpoint_add(struct target *target, enum breakpoint_type type) { if (target->smp) { + bool breakpoint_set = false; struct target_list *head; foreach_smp_target(head, target->smp_targets) { struct target *curr = head->target; - int retval = hybrid_breakpoint_add_internal(curr, address, asid, length, type); - if (retval != ERROR_OK) - return retval; + if (target_was_examined(curr) && curr->state == TARGET_HALTED) { + int retval = hybrid_breakpoint_add_internal(curr, address, asid, length, type); + if (retval != ERROR_OK) + return retval; + breakpoint_set = true; + } + } + + if (!breakpoint_set) { + LOG_ERROR("Unable to set hybrid breakpoint. All SMP targets are in the examine deferred state."); + return ERROR_FAIL; } return ERROR_OK; @@ -350,18 +375,19 @@ int breakpoint_remove(struct target *target, target_addr_t address) foreach_smp_target(head, target->smp_targets) { struct target *curr = head->target; - int status = breakpoint_remove_internal(curr, address); + if (target_was_examined(curr) && curr->state == TARGET_HALTED) { + int status = breakpoint_remove_internal(curr, address); - if (status != ERROR_BREAKPOINT_NOT_FOUND) { - num_found_breakpoints++; + if (status != ERROR_BREAKPOINT_NOT_FOUND) { + num_found_breakpoints++; - if (status != ERROR_OK) { - LOG_TARGET_ERROR(curr, "failed to remove breakpoint at address " TARGET_ADDR_FMT, address); - retval = status; + if (status != ERROR_OK) { + LOG_TARGET_ERROR(curr, "failed to remove breakpoint at address " TARGET_ADDR_FMT, address); + retval = status; + } } } } - } else { retval = breakpoint_remove_internal(target, address); @@ -396,6 +422,7 @@ static int watchpoint_free(struct target *target, struct watchpoint *watchpoint_ if (!watchpoint) return ERROR_OK; + retval = target_remove_watchpoint(target, watchpoint); if (retval != ERROR_OK) { LOG_TARGET_ERROR(target, "could not remove watchpoint #%d on this target", @@ -436,14 +463,16 @@ static int breakpoint_watchpoint_remove_all(struct target *target, enum breakpoi foreach_smp_target(head, target->smp_targets) { struct target *curr = head->target; - int status = ERROR_OK; - if (bp_wp == BREAKPOINT) - status = breakpoint_remove_all_internal(curr); - else - status = watchpoint_remove_all_internal(curr); + if (target_was_examined(curr) && curr->state == TARGET_HALTED) { + int status = ERROR_OK; + if (bp_wp == BREAKPOINT) + status = breakpoint_remove_all_internal(curr); + else + status = watchpoint_remove_all_internal(curr); - if (status != ERROR_OK) - retval = status; + if (status != ERROR_OK) + retval = status; + } } } else { if (bp_wp == BREAKPOINT) @@ -468,16 +497,18 @@ int watchpoint_remove_all(struct target *target) int breakpoint_clear_target(struct target *target) { int retval = ERROR_OK; - if (target->smp) { struct target_list *head; foreach_smp_target(head, target->smp_targets) { struct target *curr = head->target; - int status = breakpoint_remove_all_internal(curr); - if (status != ERROR_OK) - retval = status; + if (target_was_examined(curr) && curr->state == TARGET_HALTED) { + int status = breakpoint_remove_all_internal(curr); + + if (status != ERROR_OK) + retval = status; + } } } else { retval = breakpoint_remove_all_internal(target); @@ -569,13 +600,22 @@ int watchpoint_add(struct target *target, target_addr_t address, unsigned int length, enum watchpoint_rw rw, uint64_t value, uint64_t mask) { if (target->smp) { + bool watchpoint_set = false; struct target_list *head; foreach_smp_target(head, target->smp_targets) { struct target *curr = head->target; - int retval = watchpoint_add_internal(curr, address, length, rw, value, mask); - if (retval != ERROR_OK) - return retval; + if (target_was_examined(curr) && curr->state == TARGET_HALTED) { + int retval = watchpoint_add_internal(curr, address, length, rw, value, mask); + if (retval != ERROR_OK) + return retval; + watchpoint_set = true; + } + } + + if (!watchpoint_set) { + LOG_ERROR("Unable to set watchpoint. All SMP targets are in the examine deferred state."); + return ERROR_FAIL; } return ERROR_OK; @@ -611,14 +651,16 @@ int watchpoint_remove(struct target *target, target_addr_t address) foreach_smp_target(head, target->smp_targets) { struct target *curr = head->target; - int status = watchpoint_remove_internal(curr, address); + if (target_was_examined(curr) && curr->state == TARGET_HALTED) { + int status = watchpoint_remove_internal(curr, address); - if (status != ERROR_WATCHPOINT_NOT_FOUND) { - num_found_watchpoints++; + if (status != ERROR_WATCHPOINT_NOT_FOUND) { + num_found_watchpoints++; - if (status != ERROR_OK) { - LOG_TARGET_ERROR(curr, "failed to remove watchpoint at address " TARGET_ADDR_FMT, address); - retval = status; + if (status != ERROR_OK) { + LOG_TARGET_ERROR(curr, "failed to remove watchpoint at address " TARGET_ADDR_FMT, address); + retval = status; + } } } } -- |
From: <ge...@op...> - 2025-06-17 11:27:13
|
This is an automated email from Gerrit. "Jan Matyas <jan...@co...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8957 -- gerrit commit 0afaa0b7b5b63ee3b51ee73d0a72a16e5f1927e5 Author: Jan Matyas <jan...@co...> Date: Tue Jun 17 13:17:23 2025 +0200 openocd.c: 'init' should fail if GDB service cannot be created If it is not possible to create a GDB service for a certain target (for example the given TCP port is already occupied), the "init" command should fail, but it currently does not. Fix this by checking the return code of gdb_target_add_all(). Steps to reproduce: 1) Make the port 3333/tcp occupied. For example by: nc -l 3333 2) In another terminal, launch OpenOCD. Use the gdb_port 3333 (which is the default). For example: path/to/your/openocd \ -c "adapter driver ..." \ -c "jtag newtap ..." -c "target create ..." 3) Observe the outcome: Before this patch: Error "couldn't bind gdb to socket on port 3333: Address already in use" is displayed but OpenOCD keeps running. After this patch: The error message is displayed and OpenOCD exits - as expected. Change-Id: I63c283a9a1095167b78e69e9ee879c378a6b9f2a Signed-off-by: Jan Matyas <jan...@co...> diff --git a/src/openocd.c b/src/openocd.c index 3fbece3955..e63a9661a3 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -170,7 +170,8 @@ COMMAND_HANDLER(handle_init_command) jtag_poll_unmask(save_poll_mask); /* initialize telnet subsystem */ - gdb_target_add_all(all_targets); + if (gdb_target_add_all(all_targets) != ERROR_OK) + return ERROR_FAIL; target_register_event_callback(log_target_callback_event_handler, CMD_CTX); -- |
From: <ge...@op...> - 2025-06-17 09:07:56
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8956 -- gerrit commit c98954f893d2d608f0b3dd041862c1717d116b9c Author: Antonio Borneo <bor...@gm...> Date: Sat Sep 28 17:58:51 2024 +0200 jimtcl: anticipate possible change in jimtcl Current jimtcl release 0.83 has been tagged on 2024-08-28 and the new 0.84 is on the way. A new change [1] in jimtcl branch 'master-next', potentially to be merged in 0.85, breaks the build of OpenOCD. OpenOCD releases are not frequent and jimtcl is now by default an external build dependency. The change [1], once gets merged, would force OpenOCD to deliver a fix release to support it. Anticipate the change [1] by detecting it at compile time, without relying on jimtcl version, and providing an alternative code. Link: https://github.com/msteveb/jimtcl/commit/b09e50834824 [1] Change-Id: I61bf100d447083258aea222aaf15608b7cbe2e57 Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/helper/command.c b/src/helper/command.c index b70081a4dd..04f4f9a54c 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -45,17 +45,22 @@ static enum command_mode get_command_mode(Jim_Interp *interp, const char *cmd_na /* set of functions to wrap jimtcl internal data */ static inline bool jimcmd_is_proc(Jim_Cmd *cmd) { +#if defined(JIM_CMD_ISPROC) + // JIM_VERSION >= 84 + return cmd->flags & JIM_CMD_ISPROC; +#else return cmd->isproc; +#endif } bool jimcmd_is_oocd_command(Jim_Cmd *cmd) { - return !cmd->isproc && cmd->u.native.cmdProc == jim_command_dispatch; + return !jimcmd_is_proc(cmd) && cmd->u.native.cmdProc == jim_command_dispatch; } void *jimcmd_privdata(Jim_Cmd *cmd) { - return cmd->isproc ? NULL : cmd->u.native.privData; + return jimcmd_is_proc(cmd) ? NULL : cmd->u.native.privData; } static int command_retval_set(Jim_Interp *interp, int retval) -- |
From: <ge...@op...> - 2025-06-16 08:06:46
|
This is an automated email from Gerrit. "zapb <de...@za...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8955 -- gerrit commit 136ab3e97265b9e37d49b9e0bd88ae031c08960d Author: Marc Schink <de...@za...> Date: Mon Jun 16 10:04:44 2025 +0200 Fix 'find' and 'ocd_find' usage Remove the quotation marks as they are used for strings and not parameter names. Change-Id: Ib0629e1465f821f91cd1e837f4ef8c752013b6b7 Signed-off-by: Marc Schink <de...@za...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 4ad66ee5f4..db63fe06db 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -1382,11 +1382,11 @@ Read the OpenOCD source code (and Developer's Guide) if you have a new kind of hardware interface and need to provide a driver for it. -@deffn {Command} {find} 'filename' +@deffn {Command} {find} filename Prints full path to @var{filename} according to OpenOCD search rules. @end deffn -@deffn {Command} {ocd_find} 'filename' +@deffn {Command} {ocd_find} filename Prints full path to @var{filename} according to OpenOCD search rules. This is a low level function used by the @command{find}. Usually you want to use @command{find}, instead. -- |
From: <ge...@op...> - 2025-06-15 20:47:00
|
This is an automated email from Gerrit. "zapb <de...@za...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8954 -- gerrit commit c56306f4ff3c68ddb74d836eb0c7140dc2d7a120 Author: Marc Schink <de...@za...> Date: Sun Jun 15 22:44:53 2025 +0200 doc: Fix 'add_script_search_dir' usage The 'directory' parameter is not optional. Change-Id: Ifbc7b311692157dae0621dfa6d35a24b8fe8cbb2 Signed-off-by: Marc Schink <de...@za...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 4ad66ee5f4..ec856757d4 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -9335,7 +9335,7 @@ Redirect logging to @var{filename}. If used without an argument or stderr. @end deffn -@deffn {Command} {add_script_search_dir} [directory] +@deffn {Command} {add_script_search_dir} directory Add @var{directory} to the file/script search path. @end deffn -- |
From: <ge...@op...> - 2025-06-14 15:52:05
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8951 -- gerrit commit b2e2bc8bcbb04e008b4827fd16f80c17319c1d28 Author: Antonio Borneo <bor...@gm...> Date: Sat Jun 14 14:51:43 2025 +0200 target: sort the targets by alphabetic order Add comments to require the list of targets to be kept sorted. Change-Id: Ie3d7e3f5d55a9f9214dc179c5c986b6682f59412 Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/target/target.c b/src/target/target.c index fd0e0116b5..8bf654a272 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -71,44 +71,45 @@ static int target_gdb_fileio_end_default(struct target *target, int retcode, int fileio_errno, bool ctrl_c); static struct target_type *target_types[] = { + // Keep in alphabetic order this list of targets + &aarch64_target, + &arcv2_target, + &arm11_target, + &arm720t_target, &arm7tdmi_target, - &arm9tdmi_target, &arm920t_target, - &arm720t_target, - &arm966e_target, - &arm946e_target, &arm926ejs_target, - &fa526_target, - &feroceon_target, - &dragonite_target, - &xscale_target, - &xtensa_chip_target, - &cortexm_target, + &arm946e_target, + &arm966e_target, + &arm9tdmi_target, + &armv8r_target, + &avr32_ap7k_target, + &avr_target, &cortexa_target, + &cortexm_target, &cortexr4_target, - &arm11_target, - &ls1_sap_target, - &mips_m4k_target, - &avr_target, + &dragonite_target, &dsp563xx_target, &dsp5680xx_target, - &testee_target, - &avr32_ap7k_target, - &hla_target, - &esp32_target, + &esirisc_target, &esp32s2_target, &esp32s3_target, + &esp32_target, + &fa526_target, + &feroceon_target, + &hla_target, + &ls1_sap_target, + &mem_ap_target, + &mips_m4k_target, + &mips_mips64_target, &or1k_target, - &quark_x10xx_target, &quark_d20xx_target, - &stm8_target, + &quark_x10xx_target, &riscv_target, - &mem_ap_target, - &esirisc_target, - &arcv2_target, - &aarch64_target, - &armv8r_target, - &mips_mips64_target, + &stm8_target, + &testee_target, + &xscale_target, + &xtensa_chip_target, NULL, }; diff --git a/src/target/target_type.h b/src/target/target_type.h index 5b0dc5a6c0..a146fab763 100644 --- a/src/target/target_type.h +++ b/src/target/target_type.h @@ -307,6 +307,7 @@ struct target_type { unsigned int (*data_bits)(struct target *target); }; +// Keep in alphabetic order this list of targets extern struct target_type aarch64_target; extern struct target_type arcv2_target; extern struct target_type arm11_target; -- |
From: <ge...@op...> - 2025-06-14 15:42:07
|
This is an automated email from Gerrit. "Antonio Borneo <bor...@gm...>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8948 -- gerrit commit dddc8c0b7125ddcf448611e247ceec7b9058de51 Author: Antonio Borneo <bor...@gm...> Date: Sat Jun 14 13:53:50 2025 +0200 flash: nand: sort the drivers by alphabetic order Add comments to require the list of drivers to be kept sorted. Change-Id: I21b52cc1f5e679b0ebf7797e204248507f53557b Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/flash/nand/driver.c b/src/flash/nand/driver.c index 5d99102c85..69b3ba9618 100644 --- a/src/flash/nand/driver.c +++ b/src/flash/nand/driver.c @@ -14,20 +14,21 @@ #include "driver.h" static struct nand_flash_controller *nand_flash_controllers[] = { - &nonce_nand_controller, + // Keep in alphabetic order the list of drivers + &at91sam9_nand_controller, &davinci_nand_controller, + &imx31_nand_flash_controller, &lpc3180_nand_controller, &lpc32xx_nand_controller, + &mxc_nand_flash_controller, + &nonce_nand_controller, + &nuc910_nand_controller, &orion_nand_controller, &s3c2410_nand_controller, &s3c2412_nand_controller, &s3c2440_nand_controller, &s3c2443_nand_controller, &s3c6400_nand_controller, - &mxc_nand_flash_controller, - &imx31_nand_flash_controller, - &at91sam9_nand_controller, - &nuc910_nand_controller, NULL }; diff --git a/src/flash/nand/driver.h b/src/flash/nand/driver.h index 4e84f10fbd..d26e77c75b 100644 --- a/src/flash/nand/driver.h +++ b/src/flash/nand/driver.h @@ -89,6 +89,7 @@ typedef int (*nand_driver_walker_t)(struct nand_flash_controller *c, void *); */ int nand_driver_walk(nand_driver_walker_t f, void *x); +// Keep in alphabetic order the list of drivers extern struct nand_flash_controller at91sam9_nand_controller; extern struct nand_flash_controller davinci_nand_controller; extern struct nand_flash_controller imx31_nand_flash_controller; -- |