You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(75) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(70) |
Feb
(20) |
Mar
(52) |
Apr
(149) |
May
(387) |
Jun
(466) |
Jul
(133) |
Aug
(87) |
Sep
(122) |
Oct
(140) |
Nov
(185) |
Dec
(105) |
2010 |
Jan
(85) |
Feb
(45) |
Mar
(75) |
Apr
(17) |
May
(41) |
Jun
(52) |
Jul
(33) |
Aug
(29) |
Sep
(36) |
Oct
(15) |
Nov
(26) |
Dec
(34) |
2011 |
Jan
(26) |
Feb
(25) |
Mar
(26) |
Apr
(29) |
May
(20) |
Jun
(27) |
Jul
(15) |
Aug
(32) |
Sep
(13) |
Oct
(64) |
Nov
(60) |
Dec
(10) |
2012 |
Jan
(64) |
Feb
(63) |
Mar
(39) |
Apr
(43) |
May
(54) |
Jun
(11) |
Jul
(30) |
Aug
(45) |
Sep
(11) |
Oct
(70) |
Nov
(24) |
Dec
(23) |
2013 |
Jan
(17) |
Feb
(8) |
Mar
(35) |
Apr
(40) |
May
(20) |
Jun
(24) |
Jul
(36) |
Aug
(25) |
Sep
(42) |
Oct
(40) |
Nov
(9) |
Dec
(21) |
2014 |
Jan
(29) |
Feb
(24) |
Mar
(60) |
Apr
(22) |
May
(22) |
Jun
(46) |
Jul
(11) |
Aug
(23) |
Sep
(26) |
Oct
(10) |
Nov
(14) |
Dec
(2) |
2015 |
Jan
(28) |
Feb
(47) |
Mar
(33) |
Apr
(58) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(8) |
Sep
(12) |
Oct
(25) |
Nov
(58) |
Dec
(21) |
2016 |
Jan
(12) |
Feb
(40) |
Mar
(2) |
Apr
(1) |
May
(67) |
Jun
(2) |
Jul
(5) |
Aug
(36) |
Sep
|
Oct
(24) |
Nov
(17) |
Dec
(50) |
2017 |
Jan
(14) |
Feb
(16) |
Mar
(2) |
Apr
(35) |
May
(14) |
Jun
(16) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
(19) |
Nov
|
Dec
(16) |
2018 |
Jan
(55) |
Feb
(11) |
Mar
(34) |
Apr
(14) |
May
(4) |
Jun
(20) |
Jul
(39) |
Aug
(16) |
Sep
(17) |
Oct
(16) |
Nov
(20) |
Dec
(30) |
2019 |
Jan
(29) |
Feb
(24) |
Mar
(37) |
Apr
(26) |
May
(19) |
Jun
(21) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(12) |
Nov
(12) |
Dec
(12) |
2020 |
Jan
(47) |
Feb
(36) |
Mar
(54) |
Apr
(44) |
May
(37) |
Jun
(19) |
Jul
(32) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(32) |
Dec
(11) |
2021 |
Jan
(14) |
Feb
(5) |
Mar
(40) |
Apr
(32) |
May
(42) |
Jun
(31) |
Jul
(29) |
Aug
(47) |
Sep
(38) |
Oct
(17) |
Nov
(74) |
Dec
(33) |
2022 |
Jan
(11) |
Feb
(15) |
Mar
(40) |
Apr
(21) |
May
(39) |
Jun
(44) |
Jul
(19) |
Aug
(46) |
Sep
(79) |
Oct
(35) |
Nov
(21) |
Dec
(15) |
2023 |
Jan
(56) |
Feb
(13) |
Mar
(43) |
Apr
(28) |
May
(60) |
Jun
(15) |
Jul
(29) |
Aug
(28) |
Sep
(32) |
Oct
(21) |
Nov
(42) |
Dec
(39) |
2024 |
Jan
(35) |
Feb
(17) |
Mar
(28) |
Apr
(7) |
May
(14) |
Jun
(35) |
Jul
(30) |
Aug
(35) |
Sep
(30) |
Oct
(28) |
Nov
(38) |
Dec
(18) |
2025 |
Jan
(21) |
Feb
(28) |
Mar
(36) |
Apr
(35) |
May
(34) |
Jun
(58) |
Jul
(9) |
Aug
(54) |
Sep
(47) |
Oct
|
Nov
|
Dec
|
From: openocd-gerrit <ope...@us...> - 2025-09-30 07:23:08
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via e5888bda38f4952e2ae92f7dc5b25fc9a2d1c2b3 (commit) from 896738264e92b74a17250dab639999a2743d0b7c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e5888bda38f4952e2ae92f7dc5b25fc9a2d1c2b3 Author: Samuel Obuch <sam...@es...> Date: Mon Aug 18 22:05:55 2025 +0200 target/breakpoints: drop duplicate breakpoint/watchpoint "clear_target" functions We need to cleanup watchpoints on all targets in SMP group when GDB connects. Otherwise, the targets will not be consistent. Once thats fixed, both *_clear_target functions clearly duplicate the corresponding *_remove_all functions. Change-Id: I8e85dbc66fd3e596990d631ed2aed22959a8ca60 Signed-off-by: Samuel Obuch <sam...@es...> Reviewed-on: https://review.openocd.org/c/openocd/+/9086 Reviewed-by: Evgeniy Naydanov <evg...@sy...> Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 356dd6ec4..080e3360a 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -1041,8 +1041,8 @@ static int gdb_new_connection(struct connection *connection) * GDB session could leave dangling breakpoints if e.g. communication * timed out. */ - breakpoint_clear_target(target); - watchpoint_clear_target(target); + breakpoint_remove_all(target); + watchpoint_remove_all(target); /* Since version 3.95 (gdb-19990504), with the exclusion of 6.5~6.8, GDB * sends an ACK at connection with the following comment in its source code: @@ -3219,8 +3219,8 @@ static void gdb_restart_inferior(struct connection *connection, const char *pack struct gdb_connection *gdb_con = connection->priv; struct target *target = get_target_from_connection(connection); - breakpoint_clear_target(target); - watchpoint_clear_target(target); + breakpoint_remove_all(target); + watchpoint_remove_all(target); command_run_linef(connection->cmd_ctx, "ocd_gdb_restart %s", target_name(target)); /* set connection as attached after reset */ diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c index 54a6145ca..7254eac7d 100644 --- a/src/target/breakpoints.c +++ b/src/target/breakpoints.c @@ -412,6 +412,8 @@ static int watchpoint_free(struct target *target, struct watchpoint *watchpoint_ static int watchpoint_remove_all_internal(struct target *target) { + LOG_TARGET_DEBUG(target, "Delete all watchpoints"); + struct watchpoint *watchpoint = target->watchpoints; int retval = ERROR_OK; @@ -465,27 +467,6 @@ int watchpoint_remove_all(struct target *target) return breakpoint_watchpoint_remove_all(target, WATCHPOINT); } -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; - } - } else { - retval = breakpoint_remove_all_internal(target); - } - - return retval; -} - struct breakpoint *breakpoint_find(struct target *target, target_addr_t address) { struct breakpoint *breakpoint = target->breakpoints; @@ -641,23 +622,6 @@ int watchpoint_remove(struct target *target, target_addr_t address) return retval; } -int watchpoint_clear_target(struct target *target) -{ - LOG_TARGET_DEBUG(target, "Delete all watchpoints"); - - struct watchpoint *watchpoint = target->watchpoints; - int retval = ERROR_OK; - - while (watchpoint) { - struct watchpoint *tmp = watchpoint; - watchpoint = watchpoint->next; - int status = watchpoint_free(target, tmp); - if (status != ERROR_OK) - retval = status; - } - return retval; -} - int watchpoint_hit(struct target *target, enum watchpoint_rw *rw, target_addr_t *address) { diff --git a/src/target/breakpoints.h b/src/target/breakpoints.h index 0789267c7..d547a687f 100644 --- a/src/target/breakpoints.h +++ b/src/target/breakpoints.h @@ -50,7 +50,6 @@ struct watchpoint { int unique_id; }; -int breakpoint_clear_target(struct target *target); int breakpoint_add(struct target *target, target_addr_t address, unsigned int length, enum breakpoint_type type); int context_breakpoint_add(struct target *target, @@ -69,7 +68,6 @@ static inline void breakpoint_hw_set(struct breakpoint *breakpoint, unsigned int breakpoint->number = hw_number; } -int watchpoint_clear_target(struct target *target); int watchpoint_add(struct target *target, target_addr_t address, unsigned int length, enum watchpoint_rw rw, uint64_t value, uint64_t mask); ----------------------------------------------------------------------- Summary of changes: src/server/gdb_server.c | 8 ++++---- src/target/breakpoints.c | 40 ++-------------------------------------- src/target/breakpoints.h | 2 -- 3 files changed, 6 insertions(+), 44 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 15:22:55
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 896738264e92b74a17250dab639999a2743d0b7c (commit) from 5bf63333138896120349cbcd48af815aeab5e185 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 896738264e92b74a17250dab639999a2743d0b7c Author: Brian Kuschak <bku...@gm...> Date: Thu Sep 18 13:41:24 2025 +0800 jtag/drivers/cmsis_dap_tcp: fix socket handling for Windows Windows does not support socket recv() with a combination of MSG_PEEK and MSG_WAITALL flags. Work around this limitation in a way that works for both Windows and other platforms. Change-Id: Ib77e2cc872e5fe3d1fc41034010b86390131fff3 Fixes: https://sourceforge.net/p/openocd/tickets/457/ Signed-off-by: Brian Kuschak <bku...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9136 Reviewed-by: IRON ALEKS <8ir...@gm...> Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins diff --git a/src/jtag/drivers/cmsis_dap_tcp.c b/src/jtag/drivers/cmsis_dap_tcp.c index 8a96cd624..7894550fe 100644 --- a/src/jtag/drivers/cmsis_dap_tcp.c +++ b/src/jtag/drivers/cmsis_dap_tcp.c @@ -20,6 +20,10 @@ #include "config.h" #endif +#ifdef HAVE_ARPA_INET_H +#include <arpa/inet.h> +#endif +#include <errno.h> #ifdef HAVE_NETDB_H #include <netdb.h> #endif @@ -28,10 +32,21 @@ #endif #include <stdbool.h> #include <string.h> +#ifdef HAVE_SYS_IOCTL_H +#include <sys/ioctl.h> +#endif #ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif #include <sys/types.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#ifdef _WIN32 +#include <winsock2.h> +#include <ws2tcpip.h> +#endif #include "helper/command.h" #include "helper/log.h" @@ -193,19 +208,107 @@ static void cmsis_dap_tcp_close(struct cmsis_dap *dap) cmsis_dap_tcp_free(dap); } +static int socket_bytes_available(int sock, unsigned int *out_avail) +{ +#ifdef _WIN32 + u_long avail = 0; + if (ioctlsocket((SOCKET)sock, FIONREAD, &avail) == SOCKET_ERROR) + return -1; +#else + int avail = 0; + if (ioctl(sock, FIONREAD, &avail) < 0) + return -1; +#endif + *out_avail = avail; + return 0; +} + static inline int readall_socket(int handle, void *buffer, unsigned int count) { // Return after all count bytes available, or timeout, or error. return recv(handle, buffer, count, MSG_WAITALL); } -static inline int peekall_socket(int handle, void *buffer, unsigned int count) +static int peekall_socket(int handle, void *buffer, unsigned int count, + enum cmsis_dap_blocking blocking, unsigned int timeout_ms) { - /* Data remains unread on the socket until recv() is called later without + /* Windows doesn't support MSG_PEEK in combination with MSG_WAITALL: + * return recv(handle, buffer, count, MSG_PEEK | MSG_WAITALL); + * + * So, use this method instead which should work for Windows and others. + * + * Data remains unread on the socket until recv() is called later without * the MSG_PEEK flag. Return after all count bytes available, or timeout, * or error. */ - return recv(handle, buffer, count, MSG_PEEK | MSG_WAITALL); + + if (count == 0) + return 0; + + while (true) { + int ret; + unsigned int avail; + if (socket_bytes_available(handle, &avail) < 0) + return -1; + + if (avail >= count) { + ret = recv(handle, (char *)buffer, (int)count, MSG_PEEK); + if (ret < 0) { +#ifdef _WIN32 + int err = WSAGetLastError(); + if (err == WSAEINTR) + continue; + if (err == WSAEWOULDBLOCK) + return -1; +#else + if (errno == EINTR) + continue; + if (errno == EAGAIN || errno == EWOULDBLOCK) + return -1; // Timeout or nonblocking. +#endif + } + return ret; // 0: Closed, <0: Other error, >0 Success. + } + + // Not enough data available. + if (blocking == CMSIS_DAP_NON_BLOCKING) { +#ifdef _WIN32 + WSASetLastError(WSAEWOULDBLOCK); +#else + errno = EAGAIN; +#endif + return -1; + } + + // Blocking wait. + fd_set rfds; + FD_ZERO(&rfds); + FD_SET(handle, &rfds); + + struct timeval tv; + tv.tv_sec = timeout_ms / 1000; + tv.tv_usec = (timeout_ms % 1000) * 1000; + + ret = select(handle + 1, &rfds, NULL, NULL, &tv); + if (ret > 0) + continue; // Readable + + if (ret == 0) { // Timeout +#ifdef _WIN32 + WSASetLastError(WSAEWOULDBLOCK); +#else + errno = EAGAIN; +#endif + return -1; + } + + // Error +#ifndef _WIN32 + if (errno == EINTR) + continue; +#endif + return ret; + } } static int cmsis_dap_tcp_read(struct cmsis_dap *dap, int transfer_timeout_ms, @@ -232,7 +335,7 @@ static int cmsis_dap_tcp_read(struct cmsis_dap *dap, int transfer_timeout_ms, // Peek at the header first to find the length. int retval = peekall_socket(dap->bdata->sockfd, dap->packet_buffer, - HEADER_SIZE); + HEADER_SIZE, blocking, wait_ms); LOG_DEBUG_IO("Reading header returned %d", retval); if (retval == 0) { LOG_DEBUG_IO("CMSIS-DAP: tcp timeout reached 1"); ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/cmsis_dap_tcp.c | 111 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 107 insertions(+), 4 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 15:22:35
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 5bf63333138896120349cbcd48af815aeab5e185 (commit) from 32afb0ab04e773edd57bb64e428a24708c127c82 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 5bf63333138896120349cbcd48af815aeab5e185 Author: Brian Kuschak <bku...@gm...> Date: Thu Sep 18 16:19:40 2025 +0800 tools/scripts: symbol added to camelcase.txt This Windows symbol is camelcase. Change-Id: I2427de43e070592cf0c36c160c53c2bdfe96e524 Signed-off-by: Brian Kuschak <bku...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9137 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/tools/scripts/camelcase.txt b/tools/scripts/camelcase.txt index 058df4d80..1c782ee35 100644 --- a/tools/scripts/camelcase.txt +++ b/tools/scripts/camelcase.txt @@ -172,6 +172,7 @@ Sleep WaitForSingleObject WSACleanup WSAGetLastError +WSASetLastError WSAStartup dwHighDateTime dwLowDateTime ----------------------------------------------------------------------- Summary of changes: tools/scripts/camelcase.txt | 1 + 1 file changed, 1 insertion(+) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:56:56
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 32afb0ab04e773edd57bb64e428a24708c127c82 (commit) via 9e2a11c2f22792400077e81950f8ff7ef5fae874 (commit) via c92cc6b5703cd85497011d2221f008372921b192 (commit) via f64421d07e09bc6addc15ab363db250c5ba5a228 (commit) from 4b311d3b8f4221938eabccda23f99c4d64ca8dcb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 32afb0ab04e773edd57bb64e428a24708c127c82 Author: Tomas Vanek <va...@fb...> Date: Thu Sep 11 22:12:05 2025 +0200 jtag: linuxgpiod: log memory allocation errors Log error in case of NULL calloc() return. Change-Id: I40c5cba5b92cd39e9a8f7e6d420e11afc8747b3e Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/9119 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 323160b1a..cc738e9a3 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -52,8 +52,10 @@ static struct gpiod_line_settings *gpiod_line_settings_new(void) struct gpiod_line_settings *rv; rv = calloc(sizeof(struct gpiod_line_settings), 1); - if (!rv) + if (!rv) { + LOG_ERROR("No memory for gpiod line settings"); return NULL; + } return rv; } @@ -128,8 +130,10 @@ static struct gpiod_line_config *gpiod_line_config_new(void) struct gpiod_line_config *rv; rv = calloc(sizeof(struct gpiod_line_config), 1); - if (!rv) + if (!rv) { + LOG_ERROR("No memory for gpiod line config"); return NULL; + } return rv; } @@ -159,8 +163,10 @@ static struct gpiod_request_config *gpiod_request_config_new(void) struct gpiod_request_config *rv; rv = calloc(sizeof(struct gpiod_request_config), 1); - if (!rv) + if (!rv) { + LOG_ERROR("No memory for gpiod request config"); return NULL; + } return rv; } @@ -194,8 +200,10 @@ static struct gpiod_line_request *gpiod_chip_request_lines(struct gpiod_chip *ch assert(req_cfg); line_req = calloc(sizeof(struct gpiod_line_request), 1); - if (!line_req) + if (!line_req) { + LOG_ERROR("No memory for gpiod line request"); return NULL; + } line_req->gpio_line = gpiod_chip_get_line(chip, line_cfg->gpio_num); if (!line_req->gpio_line) { commit 9e2a11c2f22792400077e81950f8ff7ef5fae874 Author: Michael Heimpold <mh...@he...> Date: Sat Apr 20 19:01:30 2024 +0200 jtag: linuxgpiod: finalize emulation of libgpiod v2 API for older versions This finalizes the work that has begun to emulate v2 API for older libgpiod versions. It also add the required autotools/pkg-config stuff to detect the available libgpiod version. Change-Id: I2c3a60ce607ed9601b01d22d5d9b8af953944941 Signed-off-by: Michael Heimpold <mh...@he...> Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/8226 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/configure.ac b/configure.ac index 3060940ed..ed26d45e1 100644 --- a/configure.ac +++ b/configure.ac @@ -583,12 +583,19 @@ PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [ PKG_CHECK_MODULES([LIBFTDI], [libftdi], [use_libftdi=yes], [use_libftdi=no]) ]) -PKG_CHECK_MODULES([LIBGPIOD], [libgpiod < 2.0], [ +PKG_CHECK_MODULES([LIBGPIOD], [libgpiod >= 2.0] , [ use_libgpiod=yes - AC_DEFINE([HAVE_LIBGPIOD_V1], [1], [define if libgpiod is version v1.x]) - PKG_CHECK_EXISTS([libgpiod >= 1.5], - [AC_DEFINE([HAVE_LIBGPIOD1_FLAGS_BIAS], [1], [define if libgpiod v1 has line request flags bias])]) -], [use_libgpiod=no]) +], [ + PKG_CHECK_MODULES([LIBGPIOD], [libgpiod], [ + use_libgpiod=yes + AC_DEFINE([HAVE_LIBGPIOD_V1], [1], [define if libgpiod is version v1.x]) + + PKG_CHECK_EXISTS([libgpiod >= 1.5], + [AC_DEFINE([HAVE_LIBGPIOD1_FLAGS_BIAS], [1], [define if libgpiod v1 has line request flags bias])]) + ], [ + use_libgpiod=no + ]) +]) PKG_CHECK_MODULES([LIBJAYLINK], [libjaylink >= 0.2], [use_libjaylink=yes], [use_libjaylink=no]) diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index f5d2cf457..323160b1a 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -39,8 +39,6 @@ #define GPIOD_LINE_BIAS_PULL_UP GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP #define GPIOD_LINE_BIAS_PULL_DOWN GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN -#define gpiod_request_config gpiod_line_request_config - struct gpiod_line_settings { int direction; int value; @@ -49,48 +47,20 @@ struct gpiod_line_settings { int active_low; }; -struct gpiod_line_config { - unsigned int gpio_num; - struct gpiod_line_settings *line_settings; -}; - static struct gpiod_line_settings *gpiod_line_settings_new(void) { - static struct gpiod_line_settings my; - - my = (struct gpiod_line_settings) { 0 }; - - return &my; -} - -static struct gpiod_line_config *gpiod_line_config_new(void) -{ - static struct gpiod_line_config my; - - my = (struct gpiod_line_config) { 0 }; - - return &my; -} - -static struct gpiod_request_config *gpiod_request_config_new(void) -{ - static struct gpiod_request_config my; + struct gpiod_line_settings *rv; - my = (struct gpiod_request_config) { NULL, 0, 0 }; + rv = calloc(sizeof(struct gpiod_line_settings), 1); + if (!rv) + return NULL; - return &my; + return rv; } static void gpiod_line_settings_free(struct gpiod_line_settings *settings) { -} - -static void gpiod_line_config_free(struct gpiod_line_config *config) -{ -} - -static void gpiod_request_config_free(struct gpiod_request_config *config) -{ + free(settings); } static int gpiod_line_settings_set_direction(struct gpiod_line_settings *settings, @@ -123,12 +93,6 @@ static void gpiod_line_settings_set_active_low(struct gpiod_line_settings *setti settings->active_low = GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; } -static void gpiod_request_config_set_consumer(struct gpiod_request_config *config, - const char *consumer) -{ - config->consumer = consumer; -} - #ifdef HAVE_LIBGPIOD1_FLAGS_BIAS static int gpiod_line_settings_set_bias(struct gpiod_line_settings *settings, int bias) @@ -145,18 +109,180 @@ static int gpiod_line_settings_set_bias(struct gpiod_line_settings *settings, in if (bias == GPIOD_LINE_BIAS_DISABLED) return 0; - LOG_WARNING("linuxgpiod: ignoring request for pull-%s: not supported by gpiod v%s", + LOG_WARNING("linuxgpiod: ignoring request for pull-%s: not supported by libgpiod v%s", (bias == GPIOD_LINE_BIAS_PULL_UP) ? "up" : "down", gpiod_version_string()); - return -1; + return 0; } #endif /* HAVE_LIBGPIOD1_FLAGS_BIAS */ + +struct gpiod_line_config { + unsigned int gpio_num; + struct gpiod_line_settings *line_settings; +}; + +static struct gpiod_line_config *gpiod_line_config_new(void) +{ + struct gpiod_line_config *rv; + + rv = calloc(sizeof(struct gpiod_line_config), 1); + if (!rv) + return NULL; + + return rv; +} + +static void gpiod_line_config_free(struct gpiod_line_config *config) +{ + free(config); +} + +static int gpiod_line_config_add_line_settings(struct gpiod_line_config *config, + const unsigned int *offsets, size_t num_offsets, struct gpiod_line_settings *settings) +{ + assert(num_offsets == 1); + + config->gpio_num = *offsets; + config->line_settings = settings; + + return 0; +} + +struct gpiod_request_config { + const char *consumer; +}; + +static struct gpiod_request_config *gpiod_request_config_new(void) +{ + struct gpiod_request_config *rv; + + rv = calloc(sizeof(struct gpiod_request_config), 1); + if (!rv) + return NULL; + + return rv; +} + +static void gpiod_request_config_free(struct gpiod_request_config *config) +{ + free(config); +} + +static void gpiod_request_config_set_consumer(struct gpiod_request_config *config, + const char *consumer) +{ + config->consumer = consumer; +} + +struct gpiod_line_request { + struct gpiod_line *gpio_line; + struct gpiod_chip *chip; + struct gpiod_request_config *req_cfg; + struct gpiod_line_config *line_cfg; +}; + +static void gpiod_line_request_release(struct gpiod_line_request *request); + +static struct gpiod_line_request *gpiod_chip_request_lines(struct gpiod_chip *chip, + struct gpiod_request_config *req_cfg, struct gpiod_line_config *line_cfg) +{ + struct gpiod_line_request *line_req; + int rv, flags = 0; + + assert(req_cfg); + + line_req = calloc(sizeof(struct gpiod_line_request), 1); + if (!line_req) + return NULL; + + line_req->gpio_line = gpiod_chip_get_line(chip, line_cfg->gpio_num); + if (!line_req->gpio_line) { + free(line_req); + return NULL; + } + + /* remember stuff in case we need to reconfigure later */ + line_req->chip = chip; + line_req->req_cfg = gpiod_request_config_new(); + *line_req->req_cfg = *req_cfg; + line_req->line_cfg = line_cfg; + + flags |= line_cfg->line_settings->drive; + flags |= line_cfg->line_settings->bias; + flags |= line_cfg->line_settings->active_low; + + struct gpiod_line_request_config config = { + .consumer = line_req->req_cfg->consumer, + .request_type = line_cfg->line_settings->direction, + .flags = flags, + }; + + rv = gpiod_line_request(line_req->gpio_line, &config, line_cfg->line_settings->value); + if (rv < 0) { + gpiod_line_request_release(line_req); + return NULL; + } + + return line_req; +} + +static int gpiod_line_request_get_value(struct gpiod_line_request *request, + __attribute__((unused)) unsigned int offset) +{ + return gpiod_line_get_value(request->gpio_line); +} + +static int gpiod_line_request_set_value(struct gpiod_line_request *request, + __attribute__((unused)) unsigned int offset, int value) +{ + return gpiod_line_set_value(request->gpio_line, value); +} + +static void gpiod_line_request_release(struct gpiod_line_request *request) +{ + gpiod_request_config_free(request->req_cfg); + gpiod_line_release(request->gpio_line); + free(request); +} + +static int gpiod_line_request_reconfigure_lines(struct gpiod_line_request *request, + struct gpiod_line_config *line_cfg) +{ + int rv, flags = 0; + + /* in libgpiod v1 we have to release the line and re-aquire it */ + gpiod_line_release(request->gpio_line); + request->gpio_line = gpiod_chip_get_line(request->chip, request->line_cfg->gpio_num); + if (!request->gpio_line) + return -1; + + flags |= line_cfg->line_settings->drive; + flags |= line_cfg->line_settings->bias; + flags |= line_cfg->line_settings->active_low; + + struct gpiod_line_request_config config = { + .consumer = request->req_cfg->consumer, + .request_type = line_cfg->line_settings->direction, + .flags = flags, + }; + + rv = gpiod_line_request(request->gpio_line, &config, line_cfg->line_settings->value); + if (rv < 0) + return -1; + + /* remember updated line_cfg */ + request->line_cfg = line_cfg; + return 0; +} + #endif /* HAVE_LIBGPIOD_V1 */ static struct gpiod_chip *gpiod_chip[ADAPTER_GPIO_IDX_NUM] = {}; -static struct gpiod_line *gpiod_line[ADAPTER_GPIO_IDX_NUM] = {}; +static struct gpiod_line_settings *gpiod_line_settings[ADAPTER_GPIO_IDX_NUM] = {}; +static struct gpiod_line_config *gpiod_line_config[ADAPTER_GPIO_IDX_NUM] = {}; +static struct gpiod_line_request *gpiod_line_req[ADAPTER_GPIO_IDX_NUM] = {}; static int last_swclk; static int last_swdio; @@ -165,6 +291,20 @@ static bool swdio_input; static const struct adapter_gpio_config *adapter_gpio_config; +/* Helper to get/set a single line */ +static int linuxgpiod_line_get_value(enum adapter_gpio_config_index idx) +{ + return gpiod_line_request_get_value(gpiod_line_req[idx], + adapter_gpio_config[idx].gpio_num); +} + +static int linuxgpiod_line_set_value(enum adapter_gpio_config_index idx, int value) +{ + return gpiod_line_request_set_value(gpiod_line_req[idx], + adapter_gpio_config[idx].gpio_num, + value); +} + /* * Helper function to determine if gpio config is valid * @@ -182,7 +322,7 @@ static enum bb_value linuxgpiod_read(void) { int retval; - retval = gpiod_line_get_value(gpiod_line[ADAPTER_GPIO_IDX_TDO]); + retval = linuxgpiod_line_get_value(ADAPTER_GPIO_IDX_TDO); if (retval < 0) { LOG_WARNING("reading tdo failed"); return 0; @@ -215,20 +355,20 @@ static int linuxgpiod_write(int tck, int tms, int tdi) } if (tdi != last_tdi) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_TDI], tdi); + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_TDI, tdi); if (retval < 0) LOG_WARNING("writing tdi failed"); } if (tms != last_tms) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_TMS], tms); + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_TMS, tms); if (retval < 0) LOG_WARNING("writing tms failed"); } /* write clk last */ if (tck != last_tck) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_TCK], tck); + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_TCK, tck); if (retval < 0) LOG_WARNING("writing tck failed"); } @@ -244,7 +384,7 @@ static int linuxgpiod_swdio_read(void) { int retval; - retval = gpiod_line_get_value(gpiod_line[ADAPTER_GPIO_IDX_SWDIO]); + retval = linuxgpiod_line_get_value(ADAPTER_GPIO_IDX_SWDIO); if (retval < 0) { LOG_WARNING("Fail read swdio"); return 0; @@ -257,30 +397,54 @@ static void linuxgpiod_swdio_drive(bool is_output) { int retval; - /* - * FIXME: change direction requires release and re-require the line - * https://stackoverflow.com/questions/58735140/ - * this would change in future libgpiod - */ - gpiod_line_release(gpiod_line[ADAPTER_GPIO_IDX_SWDIO]); - if (is_output) { - if (gpiod_line[ADAPTER_GPIO_IDX_SWDIO_DIR]) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_SWDIO_DIR], 1); + if (gpiod_line_req[ADAPTER_GPIO_IDX_SWDIO_DIR]) { + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_SWDIO_DIR, 1); if (retval < 0) - LOG_WARNING("Fail set swdio_dir"); + LOG_WARNING("Failed to set swdio_dir=1"); } - retval = gpiod_line_request_output(gpiod_line[ADAPTER_GPIO_IDX_SWDIO], "OpenOCD", 1); + + retval = gpiod_line_settings_set_direction(gpiod_line_settings[ADAPTER_GPIO_IDX_SWDIO], + GPIOD_LINE_DIRECTION_OUTPUT); + if (retval < 0) + LOG_WARNING("Failed to set new direction of swdio"); + + retval = gpiod_line_settings_set_output_value(gpiod_line_settings[ADAPTER_GPIO_IDX_SWDIO], + GPIOD_LINE_VALUE_ACTIVE); + if (retval < 0) + LOG_WARNING("Failed to set output value of swdio"); + + retval = gpiod_line_config_add_line_settings(gpiod_line_config[ADAPTER_GPIO_IDX_SWDIO], + &adapter_gpio_config[ADAPTER_GPIO_IDX_SWDIO].gpio_num, 1, + gpiod_line_settings[ADAPTER_GPIO_IDX_SWDIO]); if (retval < 0) - LOG_WARNING("Fail request_output line swdio"); + LOG_WARNING("Failed to apply output configuration to swdio"); + + retval = gpiod_line_request_reconfigure_lines(gpiod_line_req[ADAPTER_GPIO_IDX_SWDIO], + gpiod_line_config[ADAPTER_GPIO_IDX_SWDIO]); + if (retval < 0) + LOG_WARNING("Failed to switch swdio to output"); } else { - retval = gpiod_line_request_input(gpiod_line[ADAPTER_GPIO_IDX_SWDIO], "OpenOCD"); + retval = gpiod_line_settings_set_direction(gpiod_line_settings[ADAPTER_GPIO_IDX_SWDIO], + GPIOD_LINE_DIRECTION_INPUT); + if (retval < 0) + LOG_WARNING("Failed to switch swdio to output"); + + retval = gpiod_line_config_add_line_settings(gpiod_line_config[ADAPTER_GPIO_IDX_SWDIO], + &adapter_gpio_config[ADAPTER_GPIO_IDX_SWDIO].gpio_num, 1, + gpiod_line_settings[ADAPTER_GPIO_IDX_SWDIO]); if (retval < 0) - LOG_WARNING("Fail request_input line swdio"); - if (gpiod_line[ADAPTER_GPIO_IDX_SWDIO_DIR]) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_SWDIO_DIR], 0); + LOG_WARNING("Failed to apply input configuration to swdio"); + + retval = gpiod_line_request_reconfigure_lines(gpiod_line_req[ADAPTER_GPIO_IDX_SWDIO], + gpiod_line_config[ADAPTER_GPIO_IDX_SWDIO]); + if (retval < 0) + LOG_WARNING("Failed to switch swdio to input"); + + if (gpiod_line_req[ADAPTER_GPIO_IDX_SWDIO_DIR]) { + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_SWDIO_DIR, 0); if (retval < 0) - LOG_WARNING("Fail set swdio_dir"); + LOG_WARNING("Failed to set swdio_dir=0"); } } @@ -294,7 +458,7 @@ static int linuxgpiod_swd_write(int swclk, int swdio) if (!swdio_input) { if (!last_stored || swdio != last_swdio) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_SWDIO], swdio); + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_SWDIO, swdio); if (retval < 0) LOG_WARNING("Fail set swdio"); } @@ -302,7 +466,7 @@ static int linuxgpiod_swd_write(int swclk, int swdio) /* write swclk last */ if (!last_stored || swclk != last_swclk) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_SWCLK], swclk); + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_SWCLK, swclk); if (retval < 0) LOG_WARNING("Fail set swclk"); } @@ -321,7 +485,7 @@ static int linuxgpiod_blink(bool on) if (!is_gpio_config_valid(ADAPTER_GPIO_IDX_LED)) return ERROR_OK; - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_LED], on ? 1 : 0); + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_LED, on); if (retval < 0) LOG_WARNING("Fail set led"); return retval; @@ -348,17 +512,17 @@ static int linuxgpiod_reset(int trst, int srst) LOG_DEBUG("linuxgpiod_reset"); /* - * active low behaviour handled by "adaptor gpio" command and + * active low behavior handled by "adaptor gpio" command and * GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW flag when requesting the line. */ - if (gpiod_line[ADAPTER_GPIO_IDX_SRST]) { - retval1 = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_SRST], srst); + if (gpiod_line_req[ADAPTER_GPIO_IDX_SRST]) { + retval1 = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_SRST, srst); if (retval1 < 0) LOG_WARNING("set srst value failed"); } - if (gpiod_line[ADAPTER_GPIO_IDX_TRST]) { - retval2 = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_TRST], trst); + if (gpiod_line_req[ADAPTER_GPIO_IDX_TRST]) { + retval2 = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_TRST, trst); if (retval2 < 0) LOG_WARNING("set trst value failed"); } @@ -390,9 +554,17 @@ static bool linuxgpiod_swd_mode_possible(void) static inline void helper_release(enum adapter_gpio_config_index idx) { - if (gpiod_line[idx]) { - gpiod_line_release(gpiod_line[idx]); - gpiod_line[idx] = NULL; + if (gpiod_line_req[idx]) { + gpiod_line_request_release(gpiod_line_req[idx]); + gpiod_line_req[idx] = NULL; + } + if (gpiod_line_config[idx]) { + gpiod_line_config_free(gpiod_line_config[idx]); + gpiod_line_config[idx] = NULL; + } + if (gpiod_line_settings[idx]) { + gpiod_line_settings_free(gpiod_line_settings[idx]); + gpiod_line_settings[idx] = NULL; } if (gpiod_chip[idx]) { gpiod_chip_close(gpiod_chip[idx]); @@ -411,97 +583,108 @@ static int linuxgpiod_quit(void) static int helper_get_line(enum adapter_gpio_config_index idx) { + struct gpiod_request_config *req_cfg = NULL; char chip_path[24]; + int rv = 0; if (!is_gpio_config_valid(idx)) return ERROR_OK; - int flags = 0, retval; - snprintf(chip_path, sizeof(chip_path), "/dev/gpiochip%u", adapter_gpio_config[idx].chip_num); gpiod_chip[idx] = gpiod_chip_open(chip_path); + if (!gpiod_chip[idx]) { LOG_ERROR("Cannot open LinuxGPIOD chip %d for %s", adapter_gpio_config[idx].chip_num, adapter_gpio_get_name(idx)); return ERROR_JTAG_INIT_FAILED; } - gpiod_line[idx] = gpiod_chip_get_line(gpiod_chip[idx], adapter_gpio_config[idx].gpio_num); - if (!gpiod_line[idx]) { - LOG_ERROR("Error get line %s", adapter_gpio_get_name(idx)); - return ERROR_JTAG_INIT_FAILED; - } - - struct gpiod_line_settings *line_settings = gpiod_line_settings_new(); - struct gpiod_line_config *line_config = gpiod_line_config_new(); - struct gpiod_request_config *req_cfg = gpiod_request_config_new(); + gpiod_line_settings[idx] = gpiod_line_settings_new(); + gpiod_line_config[idx] = gpiod_line_config_new(); + req_cfg = gpiod_request_config_new(); - if (!line_settings || !line_config || !req_cfg) { + if (!gpiod_line_settings[idx] || !gpiod_line_config[idx] || !req_cfg) { LOG_ERROR("Cannot configure LinuxGPIOD line for %s", adapter_gpio_get_name(idx)); - retval = ERROR_JTAG_INIT_FAILED; - goto err_out; + gpiod_request_config_free(req_cfg); + return ERROR_JTAG_INIT_FAILED; } gpiod_request_config_set_consumer(req_cfg, "OpenOCD"); switch (adapter_gpio_config[idx].init_state) { case ADAPTER_GPIO_INIT_STATE_INPUT: - gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_INPUT); + rv = gpiod_line_settings_set_direction(gpiod_line_settings[idx], GPIOD_LINE_DIRECTION_INPUT); break; case ADAPTER_GPIO_INIT_STATE_INACTIVE: - gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_OUTPUT); - gpiod_line_settings_set_output_value(line_settings, GPIOD_LINE_VALUE_INACTIVE); + rv = gpiod_line_settings_set_direction(gpiod_line_settings[idx], GPIOD_LINE_DIRECTION_OUTPUT); + rv |= gpiod_line_settings_set_output_value(gpiod_line_settings[idx], GPIOD_LINE_VALUE_INACTIVE); break; case ADAPTER_GPIO_INIT_STATE_ACTIVE: - gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_OUTPUT); - gpiod_line_settings_set_output_value(line_settings, GPIOD_LINE_VALUE_ACTIVE); + rv = gpiod_line_settings_set_direction(gpiod_line_settings[idx], GPIOD_LINE_DIRECTION_OUTPUT); + rv |= gpiod_line_settings_set_output_value(gpiod_line_settings[idx], GPIOD_LINE_VALUE_ACTIVE); break; } + if (rv < 0) { + LOG_ERROR("Error while configuring LinuxGPIOD line init state for %s", adapter_gpio_get_name(idx)); + gpiod_request_config_free(req_cfg); + return ERROR_JTAG_INIT_FAILED; + } switch (adapter_gpio_config[idx].drive) { case ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL: - gpiod_line_settings_set_drive(line_settings, GPIOD_LINE_DRIVE_PUSH_PULL); + rv = gpiod_line_settings_set_drive(gpiod_line_settings[idx], GPIOD_LINE_DRIVE_PUSH_PULL); break; case ADAPTER_GPIO_DRIVE_MODE_OPEN_DRAIN: - gpiod_line_settings_set_drive(line_settings, GPIOD_LINE_DRIVE_OPEN_DRAIN); + rv = gpiod_line_settings_set_drive(gpiod_line_settings[idx], GPIOD_LINE_DRIVE_OPEN_DRAIN); break; case ADAPTER_GPIO_DRIVE_MODE_OPEN_SOURCE: - gpiod_line_settings_set_drive(line_settings, GPIOD_LINE_DRIVE_OPEN_SOURCE); + rv = gpiod_line_settings_set_drive(gpiod_line_settings[idx], GPIOD_LINE_DRIVE_OPEN_SOURCE); break; } + if (rv < 0) { + LOG_ERROR("Error while configuring LinuxGPIOD line driving for %s", adapter_gpio_get_name(idx)); + gpiod_request_config_free(req_cfg); + return ERROR_JTAG_INIT_FAILED; + } switch (adapter_gpio_config[idx].pull) { case ADAPTER_GPIO_PULL_NONE: - gpiod_line_settings_set_bias(line_settings, GPIOD_LINE_BIAS_DISABLED); + rv = gpiod_line_settings_set_bias(gpiod_line_settings[idx], GPIOD_LINE_BIAS_DISABLED); break; case ADAPTER_GPIO_PULL_UP: - gpiod_line_settings_set_bias(line_settings, GPIOD_LINE_BIAS_PULL_UP); + rv = gpiod_line_settings_set_bias(gpiod_line_settings[idx], GPIOD_LINE_BIAS_PULL_UP); break; case ADAPTER_GPIO_PULL_DOWN: - gpiod_line_settings_set_bias(line_settings, GPIOD_LINE_BIAS_PULL_DOWN); + rv = gpiod_line_settings_set_bias(gpiod_line_settings[idx], GPIOD_LINE_BIAS_PULL_DOWN); break; } + if (rv < 0) { + LOG_ERROR("Error while configuring LinuxGPIOD line biasing for %s", adapter_gpio_get_name(idx)); + gpiod_request_config_free(req_cfg); + return ERROR_JTAG_INIT_FAILED; + } - gpiod_line_settings_set_active_low(line_settings, adapter_gpio_config[idx].active_low); - - req_cfg->request_type = line_settings->direction; - req_cfg->flags = flags | line_settings->drive | line_settings->bias | line_settings->active_low; + gpiod_line_settings_set_active_low(gpiod_line_settings[idx], adapter_gpio_config[idx].active_low); - retval = gpiod_line_request(gpiod_line[idx], req_cfg, line_settings->value); - if (retval < 0) { - LOG_ERROR("Error requesting gpio line %s", adapter_gpio_get_name(idx)); - retval = ERROR_JTAG_INIT_FAILED; - goto err_out; + rv = gpiod_line_config_add_line_settings(gpiod_line_config[idx], + &adapter_gpio_config[idx].gpio_num, 1, + gpiod_line_settings[idx]); + if (rv < 0) { + LOG_ERROR("Error configuring gpio line %s", adapter_gpio_get_name(idx)); + gpiod_request_config_free(req_cfg); + return ERROR_JTAG_INIT_FAILED; } - retval = ERROR_OK; + gpiod_line_req[idx] = gpiod_chip_request_lines(gpiod_chip[idx], req_cfg, gpiod_line_config[idx]); -err_out: - gpiod_line_settings_free(line_settings); - gpiod_line_config_free(line_config); gpiod_request_config_free(req_cfg); - return retval; + if (!gpiod_line_req[idx]) { + LOG_ERROR("Error requesting gpio line %s", adapter_gpio_get_name(idx)); + return ERROR_JTAG_INIT_FAILED; + } + + return ERROR_OK; } static int linuxgpiod_init(void) commit c92cc6b5703cd85497011d2221f008372921b192 Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 21:15:48 2024 +0200 jtag: linuxgpiod: use libgpiod v2 API for gpiod_line_request() Work in progress. Target is to replace v1 gpiod_line_request() Define and use dummy functions from v2 for v1: - gpiod_line_config_new(), - gpiod_line_config_free(), Not yet used: - gpiod_line_config_add_line_settings(), - gpiod_chip_request_lines(). Change-Id: I9e2d3013845c5d12942f5e07c9721fcd151d6840 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8207 Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 4369175f7..f5d2cf457 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -49,6 +49,11 @@ struct gpiod_line_settings { int active_low; }; +struct gpiod_line_config { + unsigned int gpio_num; + struct gpiod_line_settings *line_settings; +}; + static struct gpiod_line_settings *gpiod_line_settings_new(void) { static struct gpiod_line_settings my; @@ -58,6 +63,15 @@ static struct gpiod_line_settings *gpiod_line_settings_new(void) return &my; } +static struct gpiod_line_config *gpiod_line_config_new(void) +{ + static struct gpiod_line_config my; + + my = (struct gpiod_line_config) { 0 }; + + return &my; +} + static struct gpiod_request_config *gpiod_request_config_new(void) { static struct gpiod_request_config my; @@ -71,6 +85,10 @@ static void gpiod_line_settings_free(struct gpiod_line_settings *settings) { } +static void gpiod_line_config_free(struct gpiod_line_config *config) +{ +} + static void gpiod_request_config_free(struct gpiod_request_config *config) { } @@ -415,9 +433,10 @@ static int helper_get_line(enum adapter_gpio_config_index idx) } struct gpiod_line_settings *line_settings = gpiod_line_settings_new(); + struct gpiod_line_config *line_config = gpiod_line_config_new(); struct gpiod_request_config *req_cfg = gpiod_request_config_new(); - if (!line_settings || !req_cfg) { + if (!line_settings || !line_config || !req_cfg) { LOG_ERROR("Cannot configure LinuxGPIOD line for %s", adapter_gpio_get_name(idx)); retval = ERROR_JTAG_INIT_FAILED; goto err_out; @@ -479,6 +498,7 @@ static int helper_get_line(enum adapter_gpio_config_index idx) err_out: gpiod_line_settings_free(line_settings); + gpiod_line_config_free(line_config); gpiod_request_config_free(req_cfg); return retval; commit f64421d07e09bc6addc15ab363db250c5ba5a228 Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 18:32:45 2024 +0200 jtag: linuxgpiod: use libgpiod v2 API to set gpio active_low Define and use dummy functions from v2 for v1: - gpiod_line_settings_set_active_low(). Change-Id: I2c00e1a71950215c47dc07d71af4f319434a266a Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8206 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index dc9b9f5d5..4369175f7 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -46,6 +46,7 @@ struct gpiod_line_settings { int value; int drive; int bias; + int active_low; }; static struct gpiod_line_settings *gpiod_line_settings_new(void) @@ -97,6 +98,13 @@ static int gpiod_line_settings_set_drive(struct gpiod_line_settings *settings, i return 0; } +static void gpiod_line_settings_set_active_low(struct gpiod_line_settings *settings, + bool active_low) +{ + if (active_low) + settings->active_low = GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; +} + static void gpiod_request_config_set_consumer(struct gpiod_request_config *config, const char *consumer) { @@ -455,11 +463,10 @@ static int helper_get_line(enum adapter_gpio_config_index idx) break; } - if (adapter_gpio_config[idx].active_low) - flags |= GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; + gpiod_line_settings_set_active_low(line_settings, adapter_gpio_config[idx].active_low); req_cfg->request_type = line_settings->direction; - req_cfg->flags = flags | line_settings->drive | line_settings->bias; + req_cfg->flags = flags | line_settings->drive | line_settings->bias | line_settings->active_low; retval = gpiod_line_request(gpiod_line[idx], req_cfg, line_settings->value); if (retval < 0) { ----------------------------------------------------------------------- Summary of changes: configure.ac | 17 +- src/jtag/drivers/linuxgpiod.c | 408 ++++++++++++++++++++++++++++++++---------- 2 files changed, 325 insertions(+), 100 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:56:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 4b311d3b8f4221938eabccda23f99c4d64ca8dcb (commit) via 78ea8c7fb4755089d4190c580dbf6bb60c7721e1 (commit) from 981ae530fc4fcca57a5e66b0459783b92ccbc29f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4b311d3b8f4221938eabccda23f99c4d64ca8dcb Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 18:25:49 2024 +0200 jtag: linuxgpiod: use libgpiod v2 API to set gpio bias Define and use dummy functions from v2 for v1: - gpiod_line_settings_set_bias(). Change-Id: I96d32b6200d3bb6ca7c16e7a18e3860f367b5008 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8205 Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 6afb1dcc9..dc9b9f5d5 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -35,12 +35,17 @@ #define GPIOD_LINE_DRIVE_OPEN_DRAIN GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN #define GPIOD_LINE_DRIVE_OPEN_SOURCE GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE +#define GPIOD_LINE_BIAS_DISABLED GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE +#define GPIOD_LINE_BIAS_PULL_UP GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP +#define GPIOD_LINE_BIAS_PULL_DOWN GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN + #define gpiod_request_config gpiod_line_request_config struct gpiod_line_settings { int direction; int value; int drive; + int bias; }; static struct gpiod_line_settings *gpiod_line_settings_new(void) @@ -98,6 +103,30 @@ static void gpiod_request_config_set_consumer(struct gpiod_request_config *confi config->consumer = consumer; } +#ifdef HAVE_LIBGPIOD1_FLAGS_BIAS + +static int gpiod_line_settings_set_bias(struct gpiod_line_settings *settings, int bias) +{ + settings->bias = bias; + + return 0; +} + +#else /* HAVE_LIBGPIOD1_FLAGS_BIAS */ + +static int gpiod_line_settings_set_bias(struct gpiod_line_settings *settings, int bias) +{ + if (bias == GPIOD_LINE_BIAS_DISABLED) + return 0; + + LOG_WARNING("linuxgpiod: ignoring request for pull-%s: not supported by gpiod v%s", + (bias == GPIOD_LINE_BIAS_PULL_UP) ? "up" : "down", + gpiod_version_string()); + + return -1; +} + +#endif /* HAVE_LIBGPIOD1_FLAGS_BIAS */ #endif /* HAVE_LIBGPIOD_V1 */ static struct gpiod_chip *gpiod_chip[ADAPTER_GPIO_IDX_NUM] = {}; @@ -416,25 +445,13 @@ static int helper_get_line(enum adapter_gpio_config_index idx) switch (adapter_gpio_config[idx].pull) { case ADAPTER_GPIO_PULL_NONE: -#ifdef HAVE_LIBGPIOD1_FLAGS_BIAS - flags |= GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE; -#endif + gpiod_line_settings_set_bias(line_settings, GPIOD_LINE_BIAS_DISABLED); break; case ADAPTER_GPIO_PULL_UP: -#ifdef HAVE_LIBGPIOD1_FLAGS_BIAS - flags |= GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP; -#else - LOG_WARNING("linuxgpiod: ignoring request for pull-up on %s: not supported by gpiod v%s", - adapter_gpio_get_name(idx), gpiod_version_string()); -#endif + gpiod_line_settings_set_bias(line_settings, GPIOD_LINE_BIAS_PULL_UP); break; case ADAPTER_GPIO_PULL_DOWN: -#ifdef HAVE_LIBGPIOD1_FLAGS_BIAS - flags |= GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN; -#else - LOG_WARNING("linuxgpiod: ignoring request for pull-down on %s: not supported by gpiod v%s", - adapter_gpio_get_name(idx), gpiod_version_string()); -#endif + gpiod_line_settings_set_bias(line_settings, GPIOD_LINE_BIAS_PULL_DOWN); break; } @@ -442,7 +459,7 @@ static int helper_get_line(enum adapter_gpio_config_index idx) flags |= GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; req_cfg->request_type = line_settings->direction; - req_cfg->flags = flags | line_settings->drive; + req_cfg->flags = flags | line_settings->drive | line_settings->bias; retval = gpiod_line_request(gpiod_line[idx], req_cfg, line_settings->value); if (retval < 0) { commit 78ea8c7fb4755089d4190c580dbf6bb60c7721e1 Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 18:15:48 2024 +0200 jtag: linuxgpiod: use libgpiod v2 API to set gpio drive Define and use dummy functions from v2 for v1: - gpiod_line_settings_set_drive(). Change-Id: Ic058e85c441c9f8db63919be5166172be5b72221 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8204 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index fa0b38ebb..6afb1dcc9 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -31,11 +31,16 @@ #define GPIOD_LINE_VALUE_INACTIVE 0 #define GPIOD_LINE_VALUE_ACTIVE 1 +#define GPIOD_LINE_DRIVE_PUSH_PULL 0 +#define GPIOD_LINE_DRIVE_OPEN_DRAIN GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN +#define GPIOD_LINE_DRIVE_OPEN_SOURCE GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE + #define gpiod_request_config gpiod_line_request_config struct gpiod_line_settings { int direction; int value; + int drive; }; static struct gpiod_line_settings *gpiod_line_settings_new(void) @@ -80,6 +85,13 @@ static int gpiod_line_settings_set_output_value(struct gpiod_line_settings *sett return 0; } +static int gpiod_line_settings_set_drive(struct gpiod_line_settings *settings, int drive) +{ + settings->drive = drive; + + return 0; +} + static void gpiod_request_config_set_consumer(struct gpiod_request_config *config, const char *consumer) { @@ -392,12 +404,13 @@ static int helper_get_line(enum adapter_gpio_config_index idx) switch (adapter_gpio_config[idx].drive) { case ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL: + gpiod_line_settings_set_drive(line_settings, GPIOD_LINE_DRIVE_PUSH_PULL); break; case ADAPTER_GPIO_DRIVE_MODE_OPEN_DRAIN: - flags |= GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN; + gpiod_line_settings_set_drive(line_settings, GPIOD_LINE_DRIVE_OPEN_DRAIN); break; case ADAPTER_GPIO_DRIVE_MODE_OPEN_SOURCE: - flags |= GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE; + gpiod_line_settings_set_drive(line_settings, GPIOD_LINE_DRIVE_OPEN_SOURCE); break; } @@ -429,7 +442,7 @@ static int helper_get_line(enum adapter_gpio_config_index idx) flags |= GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; req_cfg->request_type = line_settings->direction; - req_cfg->flags = flags; + req_cfg->flags = flags | line_settings->drive; retval = gpiod_line_request(gpiod_line[idx], req_cfg, line_settings->value); if (retval < 0) { ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/linuxgpiod.c | 66 +++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 18 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:55:46
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 981ae530fc4fcca57a5e66b0459783b92ccbc29f (commit) via fcbdab78c918f6dc014d953836ef66e03e07c336 (commit) from 82d0aac95b7440f62ee29e1888809c52503a3220 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 981ae530fc4fcca57a5e66b0459783b92ccbc29f Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 17:45:07 2024 +0200 jtag: linuxgpiod: use libgpiod v2 to set gpio state Define and use dummy functions from v2 for v1: - gpiod_line_settings_new(), - gpiod_line_settings_free(), - gpiod_line_settings_set_direction(), - gpiod_line_settings_set_output_value(). Change-Id: I7d147fa49daf1d008744fab5bf0001c570ea43d6 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8203 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 6336a56d0..fa0b38ebb 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -25,8 +25,28 @@ */ #ifdef HAVE_LIBGPIOD_V1 +#define GPIOD_LINE_DIRECTION_INPUT GPIOD_LINE_REQUEST_DIRECTION_INPUT +#define GPIOD_LINE_DIRECTION_OUTPUT GPIOD_LINE_REQUEST_DIRECTION_OUTPUT + +#define GPIOD_LINE_VALUE_INACTIVE 0 +#define GPIOD_LINE_VALUE_ACTIVE 1 + #define gpiod_request_config gpiod_line_request_config +struct gpiod_line_settings { + int direction; + int value; +}; + +static struct gpiod_line_settings *gpiod_line_settings_new(void) +{ + static struct gpiod_line_settings my; + + my = (struct gpiod_line_settings) { 0 }; + + return &my; +} + static struct gpiod_request_config *gpiod_request_config_new(void) { static struct gpiod_request_config my; @@ -36,10 +56,30 @@ static struct gpiod_request_config *gpiod_request_config_new(void) return &my; } +static void gpiod_line_settings_free(struct gpiod_line_settings *settings) +{ +} + static void gpiod_request_config_free(struct gpiod_request_config *config) { } +static int gpiod_line_settings_set_direction(struct gpiod_line_settings *settings, + int direction) +{ + settings->direction = direction; + + return 0; +} + +static int gpiod_line_settings_set_output_value(struct gpiod_line_settings *settings, + int value) +{ + settings->value = value; + + return 0; +} + static void gpiod_request_config_set_consumer(struct gpiod_request_config *config, const char *consumer) { @@ -309,7 +349,7 @@ static int helper_get_line(enum adapter_gpio_config_index idx) if (!is_gpio_config_valid(idx)) return ERROR_OK; - int dir = GPIOD_LINE_REQUEST_DIRECTION_INPUT, flags = 0, val = 0, retval; + int flags = 0, retval; snprintf(chip_path, sizeof(chip_path), "/dev/gpiochip%u", adapter_gpio_config[idx].chip_num); gpiod_chip[idx] = gpiod_chip_open(chip_path); @@ -325,8 +365,10 @@ static int helper_get_line(enum adapter_gpio_config_index idx) return ERROR_JTAG_INIT_FAILED; } + struct gpiod_line_settings *line_settings = gpiod_line_settings_new(); struct gpiod_request_config *req_cfg = gpiod_request_config_new(); - if (!req_cfg) { + + if (!line_settings || !req_cfg) { LOG_ERROR("Cannot configure LinuxGPIOD line for %s", adapter_gpio_get_name(idx)); retval = ERROR_JTAG_INIT_FAILED; goto err_out; @@ -336,15 +378,15 @@ static int helper_get_line(enum adapter_gpio_config_index idx) switch (adapter_gpio_config[idx].init_state) { case ADAPTER_GPIO_INIT_STATE_INPUT: - dir = GPIOD_LINE_REQUEST_DIRECTION_INPUT; + gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_INPUT); break; case ADAPTER_GPIO_INIT_STATE_INACTIVE: - dir = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT; - val = 0; + gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_OUTPUT); + gpiod_line_settings_set_output_value(line_settings, GPIOD_LINE_VALUE_INACTIVE); break; case ADAPTER_GPIO_INIT_STATE_ACTIVE: - dir = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT; - val = 1; + gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_OUTPUT); + gpiod_line_settings_set_output_value(line_settings, GPIOD_LINE_VALUE_ACTIVE); break; } @@ -386,10 +428,10 @@ static int helper_get_line(enum adapter_gpio_config_index idx) if (adapter_gpio_config[idx].active_low) flags |= GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; - req_cfg->request_type = dir; + req_cfg->request_type = line_settings->direction; req_cfg->flags = flags; - retval = gpiod_line_request(gpiod_line[idx], req_cfg, val); + retval = gpiod_line_request(gpiod_line[idx], req_cfg, line_settings->value); if (retval < 0) { LOG_ERROR("Error requesting gpio line %s", adapter_gpio_get_name(idx)); retval = ERROR_JTAG_INIT_FAILED; @@ -399,6 +441,7 @@ static int helper_get_line(enum adapter_gpio_config_index idx) retval = ERROR_OK; err_out: + gpiod_line_settings_free(line_settings); gpiod_request_config_free(req_cfg); return retval; commit fcbdab78c918f6dc014d953836ef66e03e07c336 Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 17:18:40 2024 +0200 jtag: linuxgpiod: wrap gpiod_request_config from libgpiod v2 Reorganize the code of helper_get_line() for label err_out. Define and use dummy functions from v2 for v1: - gpiod_request_config_new(), - gpiod_request_config_free(), - gpiod_request_config_set_consumer(). Change-Id: Ide7cd8459941a5a863c425a2b5abf1fb4a075874 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8202 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 6f71205ca..6336a56d0 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -19,6 +19,35 @@ #include <transport/transport.h> #include "bitbang.h" +/* + * In case of libgpiod v1, use as much as possible API from v2 plus + * the dummy wrappers below. + */ +#ifdef HAVE_LIBGPIOD_V1 + +#define gpiod_request_config gpiod_line_request_config + +static struct gpiod_request_config *gpiod_request_config_new(void) +{ + static struct gpiod_request_config my; + + my = (struct gpiod_request_config) { NULL, 0, 0 }; + + return &my; +} + +static void gpiod_request_config_free(struct gpiod_request_config *config) +{ +} + +static void gpiod_request_config_set_consumer(struct gpiod_request_config *config, + const char *consumer) +{ + config->consumer = consumer; +} + +#endif /* HAVE_LIBGPIOD_V1 */ + static struct gpiod_chip *gpiod_chip[ADAPTER_GPIO_IDX_NUM] = {}; static struct gpiod_line *gpiod_line[ADAPTER_GPIO_IDX_NUM] = {}; @@ -296,6 +325,15 @@ static int helper_get_line(enum adapter_gpio_config_index idx) return ERROR_JTAG_INIT_FAILED; } + struct gpiod_request_config *req_cfg = gpiod_request_config_new(); + if (!req_cfg) { + LOG_ERROR("Cannot configure LinuxGPIOD line for %s", adapter_gpio_get_name(idx)); + retval = ERROR_JTAG_INIT_FAILED; + goto err_out; + } + + gpiod_request_config_set_consumer(req_cfg, "OpenOCD"); + switch (adapter_gpio_config[idx].init_state) { case ADAPTER_GPIO_INIT_STATE_INPUT: dir = GPIOD_LINE_REQUEST_DIRECTION_INPUT; @@ -348,19 +386,22 @@ static int helper_get_line(enum adapter_gpio_config_index idx) if (adapter_gpio_config[idx].active_low) flags |= GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; - struct gpiod_line_request_config config = { - .consumer = "OpenOCD", - .request_type = dir, - .flags = flags, - }; + req_cfg->request_type = dir; + req_cfg->flags = flags; - retval = gpiod_line_request(gpiod_line[idx], &config, val); + retval = gpiod_line_request(gpiod_line[idx], req_cfg, val); if (retval < 0) { LOG_ERROR("Error requesting gpio line %s", adapter_gpio_get_name(idx)); - return ERROR_JTAG_INIT_FAILED; + retval = ERROR_JTAG_INIT_FAILED; + goto err_out; } - return ERROR_OK; + retval = ERROR_OK; + +err_out: + gpiod_request_config_free(req_cfg); + + return retval; } static int linuxgpiod_init(void) ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/linuxgpiod.c | 112 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 98 insertions(+), 14 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:55:28
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 82d0aac95b7440f62ee29e1888809c52503a3220 (commit) from 601d478015dcbd96ce9dcde57f8004b9a13fd311 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 82d0aac95b7440f62ee29e1888809c52503a3220 Author: Michael Heimpold <mh...@he...> Date: Sun Sep 14 11:47:10 2025 +0200 jtag: linuxgpiod: add macro HAVE_LIBGPIOD_V1 To prepare the support for libgpiod v2, add a macro to report the old version v1 of the library. Extracted part of 8226: jtag: linuxgpiod: finalize emulation of libgpiod v2 API for older versions Link: https://review.openocd.org/c/openocd/+/8226 Change-Id: Ib9c4e495b326770fabadbc752df8aa0a920b1831 Signed-off-by: Michael Heimpold <mh...@he...> Signed-off-by: Tomas Vanek <va...@fb...> Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9118 Tested-by: jenkins diff --git a/configure.ac b/configure.ac index 01077847b..3060940ed 100644 --- a/configure.ac +++ b/configure.ac @@ -585,6 +585,7 @@ PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [ PKG_CHECK_MODULES([LIBGPIOD], [libgpiod < 2.0], [ use_libgpiod=yes + AC_DEFINE([HAVE_LIBGPIOD_V1], [1], [define if libgpiod is version v1.x]) PKG_CHECK_EXISTS([libgpiod >= 1.5], [AC_DEFINE([HAVE_LIBGPIOD1_FLAGS_BIAS], [1], [define if libgpiod v1 has line request flags bias])]) ], [use_libgpiod=no]) ----------------------------------------------------------------------- Summary of changes: configure.ac | 1 + 1 file changed, 1 insertion(+) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:54:22
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 601d478015dcbd96ce9dcde57f8004b9a13fd311 (commit) from 27ab12dd82de8154724db96b921d6b0ed650eb2d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 601d478015dcbd96ce9dcde57f8004b9a13fd311 Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 16:00:14 2024 +0200 jtag: linuxgpiod: replace gpiod_chip_open_by_number() Preparing for libgpiod v2, replace v1 specific function gpiod_chip_open_by_number() with the common v1 & v2 function gpiod_chip_open(). Change-Id: I5f0f9bef739f4097fb74f78b5b6e2fe823c1ab87 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8201 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 36c7e0493..6f71205ca 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -275,12 +275,15 @@ static int linuxgpiod_quit(void) static int helper_get_line(enum adapter_gpio_config_index idx) { + char chip_path[24]; + if (!is_gpio_config_valid(idx)) return ERROR_OK; int dir = GPIOD_LINE_REQUEST_DIRECTION_INPUT, flags = 0, val = 0, retval; - gpiod_chip[idx] = gpiod_chip_open_by_number(adapter_gpio_config[idx].chip_num); + snprintf(chip_path, sizeof(chip_path), "/dev/gpiochip%u", adapter_gpio_config[idx].chip_num); + gpiod_chip[idx] = gpiod_chip_open(chip_path); if (!gpiod_chip[idx]) { LOG_ERROR("Cannot open LinuxGPIOD chip %d for %s", adapter_gpio_config[idx].chip_num, adapter_gpio_get_name(idx)); ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/linuxgpiod.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:53:56
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 27ab12dd82de8154724db96b921d6b0ed650eb2d (commit) from 3b03e439dee2f1b3959f38246fa44a51210e7108 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 27ab12dd82de8154724db96b921d6b0ed650eb2d Author: Antonio Borneo <bor...@gm...> Date: Sat Sep 13 20:41:31 2025 +0200 target: extend registers match on 'get_reg' and 'set_reg' Some target, like aarch64, has more than one bank of registers. Let the commands 'get_reg' and 'set_reg' to search the register name in all banks, as is already done in command 'reg'. Change-Id: Iae350a52f993790c5546925a2f7f81fbdb3f49b8 Signed-off-by: Antonio Borneo <bor...@gm...> Fixes: e8e62c5aca49 ("target/tcl: Add get_reg function") Fixes: da7328010165 ("target/tcl: Add set_reg function") Reviewed-on: https://review.openocd.org/c/openocd/+/9122 Tested-by: jenkins Reviewed-by: zapb <de...@za...> diff --git a/src/target/target.c b/src/target/target.c index 1bdbee19a..bdf0ff244 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -4745,7 +4745,7 @@ COMMAND_HANDLER(handle_target_get_reg) const char *reg_name = Jim_String(elem); - struct reg *reg = register_get_by_name(target->reg_cache, reg_name, false); + struct reg *reg = register_get_by_name(target->reg_cache, reg_name, true); if (!reg || !reg->exist) { command_print(CMD, "unknown register '%s'", reg_name); @@ -4803,7 +4803,7 @@ COMMAND_HANDLER(handle_set_reg_command) for (unsigned int i = 0; i < length; i += 2) { const char *reg_name = Jim_String(dict[i]); const char *reg_value = Jim_String(dict[i + 1]); - struct reg *reg = register_get_by_name(target->reg_cache, reg_name, false); + struct reg *reg = register_get_by_name(target->reg_cache, reg_name, true); if (!reg || !reg->exist) { command_print(CMD, "unknown register '%s'", reg_name); ----------------------------------------------------------------------- Summary of changes: src/target/target.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:53:13
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 3b03e439dee2f1b3959f38246fa44a51210e7108 (commit) from 4ae92ee3b9c8c2eaa07dc22262cdc2c1eec6412d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3b03e439dee2f1b3959f38246fa44a51210e7108 Author: Daniel Anselmi <dan...@gm...> Date: Fri Sep 12 23:42:21 2025 +0200 tcl/board/digilent_zybo: clarify supported/tested hardware Clarify that this config has been tested with the Zybo board but not with the Zybo Z7 board. Change-Id: Id826480444364e5916f25c1c219c5ddaa3ec827d Signed-off-by: Daniel Anselmi <dan...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9019 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/tcl/board/digilent_zybo.cfg b/tcl/board/digilent_zybo.cfg index 97d54302a..8573399f8 100644 --- a/tcl/board/digilent_zybo.cfg +++ b/tcl/board/digilent_zybo.cfg @@ -1,8 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-or-later -# digilent zybo +# Digilent Zybo # https://digilent.com/reference/programmable-logic/zybo/start +# Tested with the Zybo board from Digilent (older). +# Not tested with the Zybo Z7 board from Digilent (newer). + adapter driver ftdi ftdi channel 0 ----------------------------------------------------------------------- Summary of changes: tcl/board/digilent_zybo.cfg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-20 04:48:56
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 4ae92ee3b9c8c2eaa07dc22262cdc2c1eec6412d (commit) from 0732a9bb7b3066ca10cd178986e9baea0f57f161 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4ae92ee3b9c8c2eaa07dc22262cdc2c1eec6412d Author: Paul Fertser <fer...@gm...> Date: Wed Sep 17 19:19:24 2025 +0300 tcl/target/rp2040: fix reset-init rom_api_call invocation The reset-init handler needs to call the ROM API function to enable XIP from flash. Correct syntax for this command is to supply two-letter function code as the first argument, flash bank number sholudn't be there. Reported-by: Thomas D. Dean <to...@wa...> Fixes: 376d11c2e38303094976186d59502ab7d3073452 Signed-off-by: Paul Fertser <fer...@gm...> Change-Id: I94713630300ead32bc9db6a1a77658fa5d5214d4 Reviewed-on: https://review.openocd.org/c/openocd/+/9134 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/tcl/target/rp2040.cfg b/tcl/target/rp2040.cfg index dab3f8da3..262de4418 100644 --- a/tcl/target/rp2040.cfg +++ b/tcl/target/rp2040.cfg @@ -85,7 +85,7 @@ if { $_USE_CORE != 1 } { # After a rescue reset or if halted in BOOTSEL connect the flash to enable # reads from the XIP cached mapping area - $_TARGETNAME_0 configure -event reset-init { rp2xxx rom_api_call 0 CX } + $_TARGETNAME_0 configure -event reset-init { rp2xxx rom_api_call CX } } # core 1 ----------------------------------------------------------------------- Summary of changes: tcl/target/rp2040.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-13 12:07:07
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 0732a9bb7b3066ca10cd178986e9baea0f57f161 (commit) via db2cd0f5a593858e3d956549b5d353cb05d48757 (commit) from e10fb1e2a4bd36ea8b47eb2ddc85cccf53e05a47 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0732a9bb7b3066ca10cd178986e9baea0f57f161 Author: Marc Schink <de...@za...> Date: Mon Sep 1 17:09:33 2025 +0200 doc/manual: Drop LaTeX style guide LaTeX is not used for the documentation but only as (intermediate) output format. Developers do not need to write any LaTeX code at all and will not need to do so in the future, so we do not need a style guide. Remove the section on LaTeX from the style guide to make it clearer and avoid confusion. Change-Id: I238a35445616f39e38104ad0ff50ab246dd5990f Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9110 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/doc/manual/primer/docs.txt b/doc/manual/primer/docs.txt index 1aefa17e6..ccf4550d5 100644 --- a/doc/manual/primer/docs.txt +++ b/doc/manual/primer/docs.txt @@ -16,7 +16,6 @@ OpenOCD presently produces several kinds of documentation: - Provides overview, usage, reference, and FAQ for each device. - Written using LaTeX language with custom macros. - Created with 'make references'. - - See @subpage primerlatex and @ref stylelatex. - The Manual: - Focuses on developing the OpenOCD software. - Details the architecture, driver interfaces, and processes. @@ -44,19 +43,6 @@ the Texinfo web site for the Texinfo manual and more information. OpenOCD style guidelines for Texinfo documentation can be found on the @ref styletexinfo page. - */ -/** @page primerlatex LaTeX Primer - -The OpenOCD project provides a number of reference guides using the -LaTeX typesetting language. - -- OpenOCD Quick Reference Sheets -- OpenOCD Hardware Reference Guides - -These documents have not yet been produced, so this Primer serves as -a placeholder to describe how they are created and can be extended. -The same holds true for the @ref stylelatex page. - */ /** @page primerdoxygen Doxygen Primer @@ -118,7 +104,6 @@ This file contains the Doxygen source code for the @ref primerdocs. The @ref primerdocs page also contains the following sections: - @ref primertexinfo -- @ref primerlatex - @ref primerdoxygen */ diff --git a/doc/manual/style.txt b/doc/manual/style.txt index f7a12988f..fa08f4de9 100644 --- a/doc/manual/style.txt +++ b/doc/manual/style.txt @@ -22,7 +22,6 @@ providing documentation, either as part of the C code or stand-alone. - @subpage styledoxygen - @subpage styletexinfo -- @subpage stylelatex Feedback would be welcome to improve the OpenOCD guidelines. @@ -449,13 +448,6 @@ be as productive as possible. Needing to look at OpenOCD source code, to figure out how to use it is a bad sign, though it's OK to need to look at the User's guide to figure out what a config script is doing. - */ -/** @page stylelatex LaTeX Style Guide - -This page needs to provide style guidelines for using LaTeX, the -typesetting language used by The References for OpenOCD Hardware. -Likewise, the @ref primerlatex for using this guide needs to be completed. - */ /** @page styleperl Perl Style Guide @@ -510,7 +502,6 @@ documentation languages: - @ref stylec - @ref styledoxygen - @ref styletexinfo -- @ref stylelatex - @ref styleperl - @ref styleautotools commit db2cd0f5a593858e3d956549b5d353cb05d48757 Author: Marc Schink <de...@za...> Date: Thu Feb 6 10:07:03 2025 +0100 README.Windows: Remove outdated pkg-config section pkg-config [1] and the compatible tool pkgconf [2] are available via the package manager as for other systems. No need to install it manually from other sources. [1] https://packages.msys2.org/packages/mingw-w64-x86_64-pkg-config [2] https://packages.msys2.org/package/mingw-w64-x86_64-pkgconf Change-Id: I36e115fce8ab542aa0377483f24e4a374faeef58 Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9108 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/README.Windows b/README.Windows index 64bf5c0c6..293eed975 100644 --- a/README.Windows +++ b/README.Windows @@ -10,18 +10,6 @@ host. See README for the generic instructions. Also, the MSYS2 project provides both ready-made binaries and an easy way to self-compile from their software repository out of the box. -Native MinGW-w64/MSYS compilation ------------------------------ - -As MSYS doesn't come with pkg-config pre-installed, you need to add it -manually. The easiest way to do that is to download pkg-config-lite -from: - - http://sourceforge.net/projects/pkgconfiglite/ - -Then simply unzip the archive to the root directory of your MinGW-w64 -installation. - USB adapters ------------ ----------------------------------------------------------------------- Summary of changes: README.Windows | 12 ------------ doc/manual/primer/docs.txt | 15 --------------- doc/manual/style.txt | 9 --------- 3 files changed, 36 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-12 16:42:09
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via e10fb1e2a4bd36ea8b47eb2ddc85cccf53e05a47 (commit) from 874be7dc034f0f09f25861c8545a104c6d0c3e22 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e10fb1e2a4bd36ea8b47eb2ddc85cccf53e05a47 Author: Ryan QIAN <jia...@hp...> Date: Wed Sep 10 12:23:26 2025 +0800 gdb_server: Fix buffer size calculation for snprintf null terminator The buffer size check was using len + 4 but snprintf requires additional space for the null terminator. The snprintf call formats '#%02x' which needs 4 bytes total (1 for '#', 2 for checksum, 1 for null terminator). The original check of len + 4 was insufficient and could cause snprintf to truncate the checksum and replace the last character with '\0', leading to malformed GDB packets. Fix by changing the buffer size check from len + 4 to len + 5 (1 for '$', 1 for '#', 2 for checksum, 1 for null terminator) to provide adequate space for snprintf's null terminator. Change-Id: Ibf8b3c3f5e4d5ac5be795b8e688e055453798afe Signed-off-by: Ryan QIAN <jia...@hp...> Reviewed-on: https://review.openocd.org/c/openocd/+/9117 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index e06412db5..356dd6ec4 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -474,7 +474,7 @@ static int gdb_put_packet_inner(struct connection *connection, char local_buffer[1024]; local_buffer[0] = '$'; - if ((size_t)len + 4 <= sizeof(local_buffer)) { + if ((size_t)len + 5 <= sizeof(local_buffer)) { /* performance gain on smaller packets by only a single call to gdb_write() */ memcpy(local_buffer + 1, buffer, len++); len += snprintf(local_buffer + len, sizeof(local_buffer) - len, "#%02x", my_checksum); ----------------------------------------------------------------------- Summary of changes: src/server/gdb_server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-12 16:41:23
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 874be7dc034f0f09f25861c8545a104c6d0c3e22 (commit) from a6752a1671f7387ee3232bf84fe27a3746a55ac9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 874be7dc034f0f09f25861c8545a104c6d0c3e22 Author: Tomas Vanek <va...@fb...> Date: Thu Sep 4 15:04:12 2025 +0200 tcl/target/rp2040: fix typo in the comment and use better wording. Change-Id: I733283a957957354bdf527240be73b711631e372 Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/9112 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/tcl/target/rp2040.cfg b/tcl/target/rp2040.cfg index da88a3125..dab3f8da3 100644 --- a/tcl/target/rp2040.cfg +++ b/tcl/target/rp2040.cfg @@ -83,7 +83,7 @@ if { $_USE_CORE != 1 } { # srst does not exist; use SYSRESETREQ to perform a soft reset $_TARGETNAME_0 cortex_m reset_config sysresetreq - # After a rescue reset and fi BOOTSEL is halted connect the flash to enable + # After a rescue reset or if halted in BOOTSEL connect the flash to enable # reads from the XIP cached mapping area $_TARGETNAME_0 configure -event reset-init { rp2xxx rom_api_call 0 CX } } ----------------------------------------------------------------------- Summary of changes: tcl/target/rp2040.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-12 16:40:25
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via a6752a1671f7387ee3232bf84fe27a3746a55ac9 (commit) from c2cfeee471bd4a1b77ab1c30329200bb5fd37af4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a6752a1671f7387ee3232bf84fe27a3746a55ac9 Author: Samuel Obuch <sam...@es...> Date: Mon Sep 8 12:25:32 2025 +0200 jtag/drivers/cmsis_dap: fix build with cmsis_dap_tcp backend For some hosts build fails after the recent cmsis_dap_tcp addition (see commit fcff4b712c53 ("jtag/drivers/cmsis_dap: add new backend cmsis_dap_tcp") or https://review.openocd.org/c/openocd/+/8973) - Header 'hidapi.h' may not be available and should not be needed here. - Global pointer variable is not guaranteed to be treated as a constant expression even with const modifier. Use global array instead, to avoid 'error: initializer element is not constant', as address of a global array is a constant expression. Change-Id: I0c72ff52340f546a5f635663a8fde28c99176d1b Signed-off-by: Samuel Obuch <sam...@es...> Reviewed-on: https://review.openocd.org/c/openocd/+/9115 Tested-by: jenkins Reviewed-by: Brian Kuschak <bku...@gm...> Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/cmsis_dap_tcp.c b/src/jtag/drivers/cmsis_dap_tcp.c index a654c6bff..8a96cd624 100644 --- a/src/jtag/drivers/cmsis_dap_tcp.c +++ b/src/jtag/drivers/cmsis_dap_tcp.c @@ -20,7 +20,6 @@ #include "config.h" #endif -#include <hidapi.h> #ifdef HAVE_NETDB_H #include <netdb.h> #endif @@ -90,7 +89,7 @@ struct cmsis_dap_backend_data { }; static char *cmsis_dap_tcp_host; -static char *const cmsis_dap_tcp_port_default = STRINGIFY(CMSIS_DAP_TCP_PORT); +static char cmsis_dap_tcp_port_default[] = STRINGIFY(CMSIS_DAP_TCP_PORT); static char *cmsis_dap_tcp_port = cmsis_dap_tcp_port_default; static int cmsis_dap_tcp_min_timeout_ms = DEFAULT_MIN_TIMEOUT_MS; ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/cmsis_dap_tcp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-10 05:01:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via c2cfeee471bd4a1b77ab1c30329200bb5fd37af4 (commit) from 9279a489d466529e94ff8abc92e3565f6b1fc010 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c2cfeee471bd4a1b77ab1c30329200bb5fd37af4 Author: Peter Lawrence <maj...@gm...> Date: Thu Aug 28 17:18:03 2025 -0500 add tcl/board/pico2-debug.cfg; update tcl/board/pico-debug.cfg pico-debug and pico2-debug are virtual CMSIS-DAP adapters that run on the otherwise dormant second core of the RP2040 and RP2350 respectively. Change-Id: Ifd7dcbbabeb86c738cc58854add0e897633197de Signed-off-by: Peter Lawrence <maj...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9099 Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins diff --git a/tcl/board/pico-debug.cfg b/tcl/board/pico-debug.cfg index ba59f860a..8139663f2 100644 --- a/tcl/board/pico-debug.cfg +++ b/tcl/board/pico-debug.cfg @@ -6,5 +6,5 @@ source [find interface/cmsis-dap.cfg] adapter speed 4000 -set CHIPNAME rp2040 -source [find target/rp2040-core0.cfg] +set USE_CORE 0 +source [find target/rp2040.cfg] diff --git a/tcl/board/pico2-debug.cfg b/tcl/board/pico2-debug.cfg new file mode 100644 index 000000000..d0a4c6af5 --- /dev/null +++ b/tcl/board/pico2-debug.cfg @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# pico2-debug is a virtual CMSIS-DAP debug adapter +# it runs on the very same RP2350 target being debugged without additional hardware +# https://github.com/majbthrd/pico2-debug + +source [find interface/cmsis-dap.cfg] +adapter speed 4000 + +set USE_CORE 0 +source [find target/rp2350.cfg] ----------------------------------------------------------------------- Summary of changes: tcl/board/pico-debug.cfg | 4 ++-- tcl/board/pico2-debug.cfg | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tcl/board/pico2-debug.cfg hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 11:42:24
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 9279a489d466529e94ff8abc92e3565f6b1fc010 (commit) from ddef9cf73b1a39a2cf07ab04c8aee3aae1caae98 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 9279a489d466529e94ff8abc92e3565f6b1fc010 Author: Marc Schink <de...@za...> Date: Sun Jul 27 14:26:35 2025 +0200 target/stm8: Remove useless parentheses Parentheses are not necessary here, remove them. Change-Id: I793639fbef38688045104d351fb4e5320f1eba2a Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9058 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/src/target/stm8.c b/src/target/stm8.c index 1fc028b4d..05989eeb9 100644 --- a/src/target/stm8.c +++ b/src/target/stm8.c @@ -704,13 +704,13 @@ static int stm8_write_flash(struct target *target, enum mem_type type, int res; switch (type) { - case (FLASH): + case FLASH: stm8_unlock_flash(target); break; - case (EEPROM): + case EEPROM: stm8_unlock_eeprom(target); break; - case (OPTION): + case OPTION: stm8_unlock_eeprom(target); opt = OPT; break; ----------------------------------------------------------------------- Summary of changes: src/target/stm8.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 11:42:09
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via ddef9cf73b1a39a2cf07ab04c8aee3aae1caae98 (commit) from 0cd8b6a9d950e7f5e1d83bb62ce98c71116aee70 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ddef9cf73b1a39a2cf07ab04c8aee3aae1caae98 Author: Antonio Borneo <bor...@gm...> Date: Sat Jul 26 15:46:26 2025 +0200 target: align switch and case statements The coding style requires the 'case' to be at the same indentation level of its 'switch' statement. Align the code accordingly. While there: - add space around the operators; - drop useless empty line. Skip all riscv code, as it is going to be updated soon from the external fork. No changes are reported by git log -p -w --ignore-blank-lines --patience Change-Id: I2691dfdd2b6734143e14160b46183623e9773539 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9051 Tested-by: jenkins diff --git a/src/target/aarch64.c b/src/target/aarch64.c index 9539a6437..ed9cb48aa 100644 --- a/src/target/aarch64.c +++ b/src/target/aarch64.c @@ -613,22 +613,22 @@ static int aarch64_restore_one(struct target *target, bool current, * kill the return address */ switch (arm->core_state) { - case ARM_STATE_ARM: - resume_pc &= 0xFFFFFFFC; - break; - case ARM_STATE_AARCH64: - resume_pc &= 0xFFFFFFFFFFFFFFFCULL; - break; - case ARM_STATE_THUMB: - case ARM_STATE_THUMB_EE: - /* When the return address is loaded into PC - * bit 0 must be 1 to stay in Thumb state - */ - resume_pc |= 0x1; - break; - case ARM_STATE_JAZELLE: - LOG_ERROR("How do I resume into Jazelle state??"); - return ERROR_FAIL; + case ARM_STATE_ARM: + resume_pc &= 0xFFFFFFFC; + break; + case ARM_STATE_AARCH64: + resume_pc &= 0xFFFFFFFFFFFFFFFCULL; + break; + case ARM_STATE_THUMB: + case ARM_STATE_THUMB_EE: + /* When the return address is loaded into PC + * bit 0 must be 1 to stay in Thumb state + */ + resume_pc |= 0x1; + break; + case ARM_STATE_JAZELLE: + LOG_ERROR("How do I resume into Jazelle state??"); + return ERROR_FAIL; } LOG_DEBUG("resume pc = 0x%016" PRIx64, resume_pc); buf_set_u64(arm->pc->value, 0, 64, resume_pc); @@ -3026,14 +3026,14 @@ COMMAND_HANDLER(aarch64_handle_disassemble_command) target_addr_t address; switch (CMD_ARGC) { - case 2: - COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], count); - /* FALL THROUGH */ - case 1: - COMMAND_PARSE_ADDRESS(CMD_ARGV[0], address); - break; - default: - return ERROR_COMMAND_SYNTAX_ERROR; + case 2: + COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], count); + /* FALL THROUGH */ + case 1: + COMMAND_PARSE_ADDRESS(CMD_ARGV[0], address); + break; + default: + return ERROR_COMMAND_SYNTAX_ERROR; } return a64_disassemble(CMD, target, address, count); diff --git a/src/target/arc.c b/src/target/arc.c index f2482c25e..638e22099 100644 --- a/src/target/arc.c +++ b/src/target/arc.c @@ -1892,18 +1892,18 @@ static int arc_set_watchpoint(struct target *target, int enable = AP_AC_TT_DISABLE; switch (watchpoint->rw) { - case WPT_READ: - enable = AP_AC_TT_READ; - break; - case WPT_WRITE: - enable = AP_AC_TT_WRITE; - break; - case WPT_ACCESS: - enable = AP_AC_TT_READWRITE; - break; - default: - LOG_TARGET_ERROR(target, "BUG: watchpoint->rw neither read, write nor access"); - return ERROR_FAIL; + case WPT_READ: + enable = AP_AC_TT_READ; + break; + case WPT_WRITE: + enable = AP_AC_TT_WRITE; + break; + case WPT_ACCESS: + enable = AP_AC_TT_READWRITE; + break; + default: + LOG_TARGET_ERROR(target, "BUG: watchpoint->rw neither read, write nor access"); + return ERROR_FAIL; } int retval = arc_configure_actionpoint(target, wp_num, diff --git a/src/target/arc_cmd.c b/src/target/arc_cmd.c index bf8a8aa28..2e42398d2 100644 --- a/src/target/arc_cmd.c +++ b/src/target/arc_cmd.c @@ -709,29 +709,29 @@ COMMAND_HANDLER(arc_handle_get_reg_field) int retval = arc_reg_get_field(target, reg_name, field_name, &value); switch (retval) { - case ERROR_OK: - break; - case ERROR_ARC_REGISTER_NOT_FOUND: - command_print(CMD, - "Register `%s' has not been found.", reg_name); - return ERROR_COMMAND_ARGUMENT_INVALID; - case ERROR_ARC_REGISTER_IS_NOT_STRUCT: - command_print(CMD, - "Register `%s' must have 'struct' type.", reg_name); - return ERROR_COMMAND_ARGUMENT_INVALID; - case ERROR_ARC_REGISTER_FIELD_NOT_FOUND: - command_print(CMD, - "Field `%s' has not been found in register `%s'.", - field_name, reg_name); - return ERROR_COMMAND_ARGUMENT_INVALID; - case ERROR_ARC_FIELD_IS_NOT_BITFIELD: - command_print(CMD, - "Field `%s' is not a 'bitfield' field in a structure.", - field_name); - return ERROR_COMMAND_ARGUMENT_INVALID; - default: - /* Pass through other errors. */ - return retval; + case ERROR_OK: + break; + case ERROR_ARC_REGISTER_NOT_FOUND: + command_print(CMD, + "Register `%s' has not been found.", reg_name); + return ERROR_COMMAND_ARGUMENT_INVALID; + case ERROR_ARC_REGISTER_IS_NOT_STRUCT: + command_print(CMD, + "Register `%s' must have 'struct' type.", reg_name); + return ERROR_COMMAND_ARGUMENT_INVALID; + case ERROR_ARC_REGISTER_FIELD_NOT_FOUND: + command_print(CMD, + "Field `%s' has not been found in register `%s'.", + field_name, reg_name); + return ERROR_COMMAND_ARGUMENT_INVALID; + case ERROR_ARC_FIELD_IS_NOT_BITFIELD: + command_print(CMD, + "Field `%s' is not a 'bitfield' field in a structure.", + field_name); + return ERROR_COMMAND_ARGUMENT_INVALID; + default: + /* Pass through other errors. */ + return retval; } command_print(CMD, "0x%" PRIx32, value); diff --git a/src/target/arm11.c b/src/target/arm11.c index a3e3ef843..81026c68c 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -414,19 +414,19 @@ static uint32_t arm11_nextpc(struct arm11_common *arm11, bool current, * kill the return address */ switch (arm11->arm.core_state) { - case ARM_STATE_ARM: - address &= 0xFFFFFFFC; - break; - case ARM_STATE_THUMB: - /* When the return address is loaded into PC - * bit 0 must be 1 to stay in Thumb state - */ - address |= 0x1; - break; - - /* catch-all for JAZELLE and THUMB_EE */ - default: - break; + case ARM_STATE_ARM: + address &= 0xFFFFFFFC; + break; + case ARM_STATE_THUMB: + /* When the return address is loaded into PC + * bit 0 must be 1 to stay in Thumb state + */ + address |= 0x1; + break; + + /* catch-all for JAZELLE and THUMB_EE */ + default: + break; } buf_set_u32(value, 0, 32, address); @@ -819,44 +819,44 @@ static int arm11_read_memory_inner(struct target *target, return retval; switch (size) { - case 1: - arm11->arm.core_cache->reg_list[1].dirty = true; + case 1: + arm11->arm.core_cache->reg_list[1].dirty = true; - for (size_t i = 0; i < count; i++) { - /* ldrb r1, [r0], #1 */ - /* ldrb r1, [r0] */ - CHECK_RETVAL(arm11_run_instr_no_data1(arm11, - !arm11_config_memrw_no_increment ? 0xe4d01001 : 0xe5d01000)); + for (size_t i = 0; i < count; i++) { + /* ldrb r1, [r0], #1 */ + /* ldrb r1, [r0] */ + CHECK_RETVAL(arm11_run_instr_no_data1(arm11, + !arm11_config_memrw_no_increment ? 0xe4d01001 : 0xe5d01000)); - uint32_t res; - /* MCR p14,0,R1,c0,c5,0 */ - CHECK_RETVAL(arm11_run_instr_data_from_core(arm11, 0xEE001E15, &res, 1)); + uint32_t res; + /* MCR p14,0,R1,c0,c5,0 */ + CHECK_RETVAL(arm11_run_instr_data_from_core(arm11, 0xEE001E15, &res, 1)); - *buffer++ = res; - } + *buffer++ = res; + } - break; + break; - case 2: - arm11->arm.core_cache->reg_list[1].dirty = true; + case 2: + arm11->arm.core_cache->reg_list[1].dirty = true; - for (size_t i = 0; i < count; i++) { - /* ldrh r1, [r0], #2 */ - CHECK_RETVAL(arm11_run_instr_no_data1(arm11, - !arm11_config_memrw_no_increment ? 0xe0d010b2 : 0xe1d010b0)); + for (size_t i = 0; i < count; i++) { + /* ldrh r1, [r0], #2 */ + CHECK_RETVAL(arm11_run_instr_no_data1(arm11, + !arm11_config_memrw_no_increment ? 0xe0d010b2 : 0xe1d010b0)); - uint32_t res; + uint32_t res; - /* MCR p14,0,R1,c0,c5,0 */ - CHECK_RETVAL(arm11_run_instr_data_from_core(arm11, 0xEE001E15, &res, 1)); + /* MCR p14,0,R1,c0,c5,0 */ + CHECK_RETVAL(arm11_run_instr_data_from_core(arm11, 0xEE001E15, &res, 1)); - uint16_t svalue = res; - memcpy(buffer + i * sizeof(uint16_t), &svalue, sizeof(uint16_t)); - } + uint16_t svalue = res; + memcpy(buffer + i * sizeof(uint16_t), &svalue, sizeof(uint16_t)); + } - break; + break; - case 4: + case 4: { uint32_t instr = !arm11_config_memrw_no_increment ? 0xecb05e01 : 0xed905e00; /** \todo TODO: buffer cast to uint32_t* causes alignment warnings */ @@ -925,52 +925,52 @@ static int arm11_write_memory_inner(struct target *target, bool burst = arm11->memwrite_burst && (count > 1); switch (size) { - case 1: - arm11->arm.core_cache->reg_list[1].dirty = true; - - for (size_t i = 0; i < count; i++) { - /* load r1 from DCC with byte data */ - /* MRC p14,0,r1,c0,c5,0 */ - retval = arm11_run_instr_data_to_core1(arm11, 0xee101e15, *buffer++); - if (retval != ERROR_OK) - return retval; - - /* write r1 to memory */ - /* strb r1, [r0], #1 */ - /* strb r1, [r0] */ - retval = arm11_run_instr_no_data1(arm11, - !no_increment ? 0xe4c01001 : 0xe5c01000); - if (retval != ERROR_OK) - return retval; - } + case 1: + arm11->arm.core_cache->reg_list[1].dirty = true; - break; + for (size_t i = 0; i < count; i++) { + /* load r1 from DCC with byte data */ + /* MRC p14,0,r1,c0,c5,0 */ + retval = arm11_run_instr_data_to_core1(arm11, 0xee101e15, *buffer++); + if (retval != ERROR_OK) + return retval; - case 2: - arm11->arm.core_cache->reg_list[1].dirty = true; - - for (size_t i = 0; i < count; i++) { - uint16_t value; - memcpy(&value, buffer + i * sizeof(uint16_t), sizeof(uint16_t)); - - /* load r1 from DCC with halfword data */ - /* MRC p14,0,r1,c0,c5,0 */ - retval = arm11_run_instr_data_to_core1(arm11, 0xee101e15, value); - if (retval != ERROR_OK) - return retval; - - /* write r1 to memory */ - /* strh r1, [r0], #2 */ - /* strh r1, [r0] */ - retval = arm11_run_instr_no_data1(arm11, - !no_increment ? 0xe0c010b2 : 0xe1c010b0); - if (retval != ERROR_OK) - return retval; - } + /* write r1 to memory */ + /* strb r1, [r0], #1 */ + /* strb r1, [r0] */ + retval = arm11_run_instr_no_data1(arm11, + !no_increment ? 0xe4c01001 : 0xe5c01000); + if (retval != ERROR_OK) + return retval; + } - break; + break; + + case 2: + arm11->arm.core_cache->reg_list[1].dirty = true; - case 4: + for (size_t i = 0; i < count; i++) { + uint16_t value; + memcpy(&value, buffer + i * sizeof(uint16_t), sizeof(uint16_t)); + + /* load r1 from DCC with halfword data */ + /* MRC p14,0,r1,c0,c5,0 */ + retval = arm11_run_instr_data_to_core1(arm11, 0xee101e15, value); + if (retval != ERROR_OK) + return retval; + + /* write r1 to memory */ + /* strh r1, [r0], #2 */ + /* strh r1, [r0] */ + retval = arm11_run_instr_no_data1(arm11, + !no_increment ? 0xe0c010b2 : 0xe1c010b0); + if (retval != ERROR_OK) + return retval; + } + + break; + + case 4: { /* stream word data through DCC directly to memory */ /* increment: STC p14,c5,[R0],#4 */ @@ -1159,34 +1159,34 @@ static int arm11_examine(struct target *target) /* assume the manufacturer id is ok; check the part # */ switch ((device_id >> 12) & 0xFFFF) { - case 0x7B36: - type = "ARM1136"; - break; - case 0x7B37: - type = "ARM11 MPCore"; - break; - case 0x7B56: - type = "ARM1156"; - break; - case 0x7B76: - arm11->arm.core_type = ARM_CORE_TYPE_SEC_EXT; - /* NOTE: could default arm11->hardware_step to true */ - type = "ARM1176"; - break; - default: - LOG_ERROR("unexpected ARM11 ID code"); - return ERROR_FAIL; + case 0x7B36: + type = "ARM1136"; + break; + case 0x7B37: + type = "ARM11 MPCore"; + break; + case 0x7B56: + type = "ARM1156"; + break; + case 0x7B76: + arm11->arm.core_type = ARM_CORE_TYPE_SEC_EXT; + /* NOTE: could default arm11->hardware_step to true */ + type = "ARM1176"; + break; + default: + LOG_ERROR("unexpected ARM11 ID code"); + return ERROR_FAIL; } LOG_INFO("found %s", type); /* unlikely this could ever fail, but ... */ switch ((didr >> 16) & 0x0F) { - case ARM11_DEBUG_V6: - case ARM11_DEBUG_V61: /* supports security extensions */ - break; - default: - LOG_ERROR("Only ARM v6 and v6.1 debug supported."); - return ERROR_FAIL; + case ARM11_DEBUG_V6: + case ARM11_DEBUG_V61: /* supports security extensions */ + break; + default: + LOG_ERROR("Only ARM v6 and v6.1 debug supported."); + return ERROR_FAIL; } arm11->brp = ((didr >> 24) & 0x0F) + 1; @@ -1250,13 +1250,13 @@ COMMAND_HANDLER(arm11_handle_vcr) struct arm11_common *arm11 = target_to_arm11(target); switch (CMD_ARGC) { - case 0: - break; - case 1: - COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], arm11->vcr); - break; - default: - return ERROR_COMMAND_SYNTAX_ERROR; + case 0: + break; + case 1: + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], arm11->vcr); + break; + default: + return ERROR_COMMAND_SYNTAX_ERROR; } LOG_INFO("VCR 0x%08" PRIx32, arm11->vcr); diff --git a/src/target/arm11_dbgtap.c b/src/target/arm11_dbgtap.c index 4c7211365..4c2fedaeb 100644 --- a/src/target/arm11_dbgtap.c +++ b/src/target/arm11_dbgtap.c @@ -85,30 +85,30 @@ static const char *arm11_ir_to_string(uint8_t ir) const char *s = "unknown"; switch (ir) { - case ARM11_EXTEST: - s = "EXTEST"; - break; - case ARM11_SCAN_N: - s = "SCAN_N"; - break; - case ARM11_RESTART: - s = "RESTART"; - break; - case ARM11_HALT: - s = "HALT"; - break; - case ARM11_INTEST: - s = "INTEST"; - break; - case ARM11_ITRSEL: - s = "ITRSEL"; - break; - case ARM11_IDCODE: - s = "IDCODE"; - break; - case ARM11_BYPASS: - s = "BYPASS"; - break; + case ARM11_EXTEST: + s = "EXTEST"; + break; + case ARM11_SCAN_N: + s = "SCAN_N"; + break; + case ARM11_RESTART: + s = "RESTART"; + break; + case ARM11_HALT: + s = "HALT"; + break; + case ARM11_INTEST: + s = "INTEST"; + break; + case ARM11_ITRSEL: + s = "ITRSEL"; + break; + case ARM11_IDCODE: + s = "IDCODE"; + break; + case ARM11_BYPASS: + s = "BYPASS"; + break; } return s; } @@ -1061,17 +1061,17 @@ static int arm11_bpwp_enable(struct arm_dpm *dpm, unsigned int index_t, action[1].value = control; switch (index_t) { - case 0 ... 15: - action[0].address = ARM11_SC7_BVR0 + index_t; - action[1].address = ARM11_SC7_BCR0 + index_t; - break; - case 16 ... 32: - index_t -= 16; - action[0].address = ARM11_SC7_WVR0 + index_t; - action[1].address = ARM11_SC7_WCR0 + index_t; - break; - default: - return ERROR_FAIL; + case 0 ... 15: + action[0].address = ARM11_SC7_BVR0 + index_t; + action[1].address = ARM11_SC7_BCR0 + index_t; + break; + case 16 ... 32: + index_t -= 16; + action[0].address = ARM11_SC7_WVR0 + index_t; + action[1].address = ARM11_SC7_WCR0 + index_t; + break; + default: + return ERROR_FAIL; } arm11->bpwp_n += 2; @@ -1090,15 +1090,15 @@ static int arm11_bpwp_disable(struct arm_dpm *dpm, unsigned int index_t) action[0].value = 0; switch (index_t) { - case 0 ... 15: - action[0].address = ARM11_SC7_BCR0 + index_t; - break; - case 16 ... 32: - index_t -= 16; - action[0].address = ARM11_SC7_WCR0 + index_t; - break; - default: - return ERROR_FAIL; + case 0 ... 15: + action[0].address = ARM11_SC7_BCR0 + index_t; + break; + case 16 ... 32: + index_t -= 16; + action[0].address = ARM11_SC7_WCR0 + index_t; + break; + default: + return ERROR_FAIL; } arm11->bpwp_n += 1; diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index 3a066e07d..c4bedcd85 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -2136,18 +2136,48 @@ int arm7_9_read_memory(struct target *target, arm7_9->write_core_regs(target, 0x1, reg); switch (size) { - case 4: - while (num_accesses < count) { - uint32_t reg_list; - thisrun_accesses = - ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); - reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; + case 4: + while (num_accesses < count) { + uint32_t reg_list; + thisrun_accesses = + ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); + reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; + + if (last_reg <= thisrun_accesses) + last_reg = thisrun_accesses; + + arm7_9->load_word_regs(target, reg_list); + + /* fast memory reads are only safe when the target is running + * from a sufficiently high clock (32 kHz is usually too slow) + */ + if (arm7_9->fast_memory_access) + retval = arm7_9_execute_fast_sys_speed(target); + else + retval = arm7_9_execute_sys_speed(target); + if (retval != ERROR_OK) + return retval; - if (last_reg <= thisrun_accesses) - last_reg = thisrun_accesses; + arm7_9->read_core_regs_target_buffer(target, reg_list, buffer, 4); - arm7_9->load_word_regs(target, reg_list); + /* advance buffer, count number of accesses */ + buffer += thisrun_accesses * 4; + num_accesses += thisrun_accesses; + keep_alive(); + } + break; + case 2: + while (num_accesses < count) { + uint32_t reg_list; + thisrun_accesses = + ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); + reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; + + for (i = 1; i <= thisrun_accesses; i++) { + if (i > last_reg) + last_reg = i; + arm7_9->load_hword_reg(target, i); /* fast memory reads are only safe when the target is running * from a sufficiently high clock (32 kHz is usually too slow) */ @@ -2158,78 +2188,48 @@ int arm7_9_read_memory(struct target *target, if (retval != ERROR_OK) return retval; - arm7_9->read_core_regs_target_buffer(target, reg_list, buffer, 4); - - /* advance buffer, count number of accesses */ - buffer += thisrun_accesses * 4; - num_accesses += thisrun_accesses; - - keep_alive(); } - break; - case 2: - while (num_accesses < count) { - uint32_t reg_list; - thisrun_accesses = - ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); - reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; - - for (i = 1; i <= thisrun_accesses; i++) { - if (i > last_reg) - last_reg = i; - arm7_9->load_hword_reg(target, i); - /* fast memory reads are only safe when the target is running - * from a sufficiently high clock (32 kHz is usually too slow) - */ - if (arm7_9->fast_memory_access) - retval = arm7_9_execute_fast_sys_speed(target); - else - retval = arm7_9_execute_sys_speed(target); - if (retval != ERROR_OK) - return retval; - } - - arm7_9->read_core_regs_target_buffer(target, reg_list, buffer, 2); + arm7_9->read_core_regs_target_buffer(target, reg_list, buffer, 2); - /* advance buffer, count number of accesses */ - buffer += thisrun_accesses * 2; - num_accesses += thisrun_accesses; + /* advance buffer, count number of accesses */ + buffer += thisrun_accesses * 2; + num_accesses += thisrun_accesses; - keep_alive(); + keep_alive(); + } + break; + case 1: + while (num_accesses < count) { + uint32_t reg_list; + thisrun_accesses = + ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); + reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; + + for (i = 1; i <= thisrun_accesses; i++) { + if (i > last_reg) + last_reg = i; + arm7_9->load_byte_reg(target, i); + /* fast memory reads are only safe when the target is running + * from a sufficiently high clock (32 kHz is usually too slow) + */ + if (arm7_9->fast_memory_access) + retval = arm7_9_execute_fast_sys_speed(target); + else + retval = arm7_9_execute_sys_speed(target); + if (retval != ERROR_OK) + return retval; } - break; - case 1: - while (num_accesses < count) { - uint32_t reg_list; - thisrun_accesses = - ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); - reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; - - for (i = 1; i <= thisrun_accesses; i++) { - if (i > last_reg) - last_reg = i; - arm7_9->load_byte_reg(target, i); - /* fast memory reads are only safe when the target is running - * from a sufficiently high clock (32 kHz is usually too slow) - */ - if (arm7_9->fast_memory_access) - retval = arm7_9_execute_fast_sys_speed(target); - else - retval = arm7_9_execute_sys_speed(target); - if (retval != ERROR_OK) - return retval; - } - arm7_9->read_core_regs_target_buffer(target, reg_list, buffer, 1); + arm7_9->read_core_regs_target_buffer(target, reg_list, buffer, 1); - /* advance buffer, count number of accesses */ - buffer += thisrun_accesses * 1; - num_accesses += thisrun_accesses; + /* advance buffer, count number of accesses */ + buffer += thisrun_accesses * 1; + num_accesses += thisrun_accesses; - keep_alive(); - } - break; + keep_alive(); + } + break; } if (!is_arm_mode(arm->core_mode)) @@ -2308,23 +2308,67 @@ int arm7_9_write_memory(struct target *target, embeddedice_store_reg(dbg_ctrl); switch (size) { - case 4: - while (num_accesses < count) { - uint32_t reg_list; - thisrun_accesses = - ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); - reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; - - for (i = 1; i <= thisrun_accesses; i++) { - if (i > last_reg) - last_reg = i; - reg[i] = target_buffer_get_u32(target, buffer); - buffer += 4; - } + case 4: + while (num_accesses < count) { + uint32_t reg_list; + thisrun_accesses = + ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); + reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; + + for (i = 1; i <= thisrun_accesses; i++) { + if (i > last_reg) + last_reg = i; + reg[i] = target_buffer_get_u32(target, buffer); + buffer += 4; + } + + arm7_9->write_core_regs(target, reg_list, reg); - arm7_9->write_core_regs(target, reg_list, reg); + arm7_9->store_word_regs(target, reg_list); - arm7_9->store_word_regs(target, reg_list); + /* fast memory writes are only safe when the target is running + * from a sufficiently high clock (32 kHz is usually too slow) + */ + if (arm7_9->fast_memory_access) { + retval = arm7_9_execute_fast_sys_speed(target); + } else { + retval = arm7_9_execute_sys_speed(target); + + /* + * if memory writes are made when the clock is running slow + * (i.e. 32 kHz) which is necessary in some scripts to reconfigure + * processor operations after a "reset halt" or "reset init", + * need to immediately stroke the keep alive or will end up with + * gdb "keep alive not sent error message" problem. + */ + + keep_alive(); + } + + if (retval != ERROR_OK) + return retval; + + num_accesses += thisrun_accesses; + } + break; + case 2: + while (num_accesses < count) { + uint32_t reg_list; + thisrun_accesses = + ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); + reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; + + for (i = 1; i <= thisrun_accesses; i++) { + if (i > last_reg) + last_reg = i; + reg[i] = target_buffer_get_u16(target, buffer) & 0xffff; + buffer += 2; + } + + arm7_9->write_core_regs(target, reg_list, reg); + + for (i = 1; i <= thisrun_accesses; i++) { + arm7_9->store_hword_reg(target, i); /* fast memory writes are only safe when the target is running * from a sufficiently high clock (32 kHz is usually too slow) @@ -2347,99 +2391,55 @@ int arm7_9_write_memory(struct target *target, if (retval != ERROR_OK) return retval; + } - num_accesses += thisrun_accesses; + num_accesses += thisrun_accesses; + } + break; + case 1: + while (num_accesses < count) { + uint32_t reg_list; + thisrun_accesses = + ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); + reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; + + for (i = 1; i <= thisrun_accesses; i++) { + if (i > last_reg) + last_reg = i; + reg[i] = *buffer++ & 0xff; } - break; - case 2: - while (num_accesses < count) { - uint32_t reg_list; - thisrun_accesses = - ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); - reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; - - for (i = 1; i <= thisrun_accesses; i++) { - if (i > last_reg) - last_reg = i; - reg[i] = target_buffer_get_u16(target, buffer) & 0xffff; - buffer += 2; - } - arm7_9->write_core_regs(target, reg_list, reg); + arm7_9->write_core_regs(target, reg_list, reg); - for (i = 1; i <= thisrun_accesses; i++) { - arm7_9->store_hword_reg(target, i); + for (i = 1; i <= thisrun_accesses; i++) { + arm7_9->store_byte_reg(target, i); + /* fast memory writes are only safe when the target is running + * from a sufficiently high clock (32 kHz is usually too slow) + */ + if (arm7_9->fast_memory_access) { + retval = arm7_9_execute_fast_sys_speed(target); + } else { + retval = arm7_9_execute_sys_speed(target); - /* fast memory writes are only safe when the target is running - * from a sufficiently high clock (32 kHz is usually too slow) + /* + * if memory writes are made when the clock is running slow + * (i.e. 32 kHz) which is necessary in some scripts to reconfigure + * processor operations after a "reset halt" or "reset init", + * need to immediately stroke the keep alive or will end up with + * gdb "keep alive not sent error message" problem. */ - if (arm7_9->fast_memory_access) { - retval = arm7_9_execute_fast_sys_speed(target); - } else { - retval = arm7_9_execute_sys_speed(target); - - /* - * if memory writes are made when the clock is running slow - * (i.e. 32 kHz) which is necessary in some scripts to reconfigure - * processor operations after a "reset halt" or "reset init", - * need to immediately stroke the keep alive or will end up with - * gdb "keep alive not sent error message" problem. - */ - - keep_alive(); - } - - if (retval != ERROR_OK) - return retval; - } - num_accesses += thisrun_accesses; - } - break; - case 1: - while (num_accesses < count) { - uint32_t reg_list; - thisrun_accesses = - ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); - reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; - - for (i = 1; i <= thisrun_accesses; i++) { - if (i > last_reg) - last_reg = i; - reg[i] = *buffer++ & 0xff; + keep_alive(); } - arm7_9->write_core_regs(target, reg_list, reg); - - for (i = 1; i <= thisrun_accesses; i++) { - arm7_9->store_byte_reg(target, i); - /* fast memory writes are only safe when the target is running - * from a sufficiently high clock (32 kHz is usually too slow) - */ - if (arm7_9->fast_memory_access) { - retval = arm7_9_execute_fast_sys_speed(target); - } else { - retval = arm7_9_execute_sys_speed(target); - - /* - * if memory writes are made when the clock is running slow - * (i.e. 32 kHz) which is necessary in some scripts to reconfigure - * processor operations after a "reset halt" or "reset init", - * need to immediately stroke the keep alive or will end up with - * gdb "keep alive not sent error message" problem. - */ - - keep_alive(); - } - - if (retval != ERROR_OK) - return retval; - - } + if (retval != ERROR_OK) + return retval; - num_accesses += thisrun_accesses; } - break; + + num_accesses += thisrun_accesses; + } + break; } /* Re-Set DBGACK */ diff --git a/src/target/arm7tdmi.c b/src/target/arm7tdmi.c index 2f59254af..fea6a3ff2 100644 --- a/src/target/arm7tdmi.c +++ b/src/target/arm7tdmi.c @@ -327,15 +327,15 @@ static void arm7tdmi_read_core_regs_target_buffer(struct target *target, /* nothing fetched, STM still in EXECUTE (1 + i cycle), read databus */ if (mask & (1 << i)) { switch (size) { - case 4: - arm7tdmi_clock_data_in_endianness(jtag_info, buf_u32++, 4, be); - break; - case 2: - arm7tdmi_clock_data_in_endianness(jtag_info, buf_u16++, 2, be); - break; - case 1: - arm7tdmi_clock_data_in_endianness(jtag_info, buf_u8++, 1, be); - break; + case 4: + arm7tdmi_clock_data_in_endianness(jtag_info, buf_u32++, 4, be); + break; + case 2: + arm7tdmi_clock_data_in_endianness(jtag_info, buf_u16++, 2, be); + break; + case 1: + arm7tdmi_clock_data_in_endianness(jtag_info, buf_u8++, 1, be); + break; } } } diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index 55ddb6313..0b77981ae 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -221,88 +221,88 @@ static int arm926ejs_examine_debug_reason(struct target *target) debug_reason = buf_get_u32(dbg_stat->value, 6, 4); switch (debug_reason) { - case 0: - LOG_DEBUG("no *NEW* debug entry (?missed one?)"); - /* ... since last restart or debug reset ... */ - target->debug_reason = DBG_REASON_DBGRQ; - break; - case 1: - LOG_DEBUG("breakpoint from EICE unit 0"); - target->debug_reason = DBG_REASON_BREAKPOINT; - break; - case 2: - LOG_DEBUG("breakpoint from EICE unit 1"); - target->debug_reason = DBG_REASON_BREAKPOINT; - break; - case 3: - LOG_DEBUG("soft breakpoint (BKPT instruction)"); - target->debug_reason = DBG_REASON_BREAKPOINT; - break; - case 4: - LOG_DEBUG("vector catch breakpoint"); - target->debug_reason = DBG_REASON_BREAKPOINT; - break; - case 5: - LOG_DEBUG("external breakpoint"); - target->debug_reason = DBG_REASON_BREAKPOINT; - break; - case 6: - LOG_DEBUG("watchpoint from EICE unit 0"); - target->debug_reason = DBG_REASON_WATCHPOINT; - break; - case 7: - LOG_DEBUG("watchpoint from EICE unit 1"); - target->debug_reason = DBG_REASON_WATCHPOINT; - break; - case 8: - LOG_DEBUG("external watchpoint"); - target->debug_reason = DBG_REASON_WATCHPOINT; - break; - case 9: - LOG_DEBUG("internal debug request"); - target->debug_reason = DBG_REASON_DBGRQ; - break; - case 10: - LOG_DEBUG("external debug request"); - target->debug_reason = DBG_REASON_DBGRQ; - break; - case 11: - LOG_DEBUG("debug re-entry from system speed access"); - /* This is normal when connecting to something that's - * already halted, or in some related code paths, but - * otherwise is surprising (and presumably wrong). - */ - switch (target->debug_reason) { - case DBG_REASON_DBGRQ: - break; - default: - LOG_ERROR("unexpected -- debug re-entry"); - /* FALLTHROUGH */ - case DBG_REASON_UNDEFINED: - target->debug_reason = DBG_REASON_DBGRQ; - break; - } - break; - case 12: - /* FIX!!!! here be dragons!!! We need to fail here so - * the target will interpreted as halted but we won't - * try to talk to it right now... a resume + halt seems - * to sync things up again. Please send an email to - * openocd development mailing list if you have hardware - * to donate to look into this problem.... - */ - LOG_WARNING("WARNING: mystery debug reason MOE = 0xc. Try issuing a resume + halt."); - target->debug_reason = DBG_REASON_DBGRQ; + case 0: + LOG_DEBUG("no *NEW* debug entry (?missed one?)"); + /* ... since last restart or debug reset ... */ + target->debug_reason = DBG_REASON_DBGRQ; + break; + case 1: + LOG_DEBUG("breakpoint from EICE unit 0"); + target->debug_reason = DBG_REASON_BREAKPOINT; + break; + case 2: + LOG_DEBUG("breakpoint from EICE unit 1"); + target->debug_reason = DBG_REASON_BREAKPOINT; + break; + case 3: + LOG_DEBUG("soft breakpoint (BKPT instruction)"); + target->debug_reason = DBG_REASON_BREAKPOINT; + break; + case 4: + LOG_DEBUG("vector catch breakpoint"); + target->debug_reason = DBG_REASON_BREAKPOINT; + break; + case 5: + LOG_DEBUG("external breakpoint"); + target->debug_reason = DBG_REASON_BREAKPOINT; + break; + case 6: + LOG_DEBUG("watchpoint from EICE unit 0"); + target->debug_reason = DBG_REASON_WATCHPOINT; + break; + case 7: + LOG_DEBUG("watchpoint from EICE unit 1"); + target->debug_reason = DBG_REASON_WATCHPOINT; + break; + case 8: + LOG_DEBUG("external watchpoint"); + target->debug_reason = DBG_REASON_WATCHPOINT; + break; + case 9: + LOG_DEBUG("internal debug request"); + target->debug_reason = DBG_REASON_DBGRQ; + break; + case 10: + LOG_DEBUG("external debug request"); + target->debug_reason = DBG_REASON_DBGRQ; + break; + case 11: + LOG_DEBUG("debug re-entry from system speed access"); + /* This is normal when connecting to something that's + * already halted, or in some related code paths, but + * otherwise is surprising (and presumably wrong). + */ + switch (target->debug_reason) { + case DBG_REASON_DBGRQ: break; default: - LOG_WARNING("WARNING: unknown debug reason: 0x%x", debug_reason); - /* Oh agony! should we interpret this as a halt request or - * that the target stopped on it's own accord? - */ + LOG_ERROR("unexpected -- debug re-entry"); + /* FALLTHROUGH */ + case DBG_REASON_UNDEFINED: target->debug_reason = DBG_REASON_DBGRQ; - /* if we fail here, we won't talk to the target and it will - * be reported to be in the halted state */ break; + } + break; + case 12: + /* FIX!!!! here be dragons!!! We need to fail here so + * the target will interpreted as halted but we won't + * try to talk to it right now... a resume + halt seems + * to sync things up again. Please send an email to + * openocd development mailing list if you have hardware + * to donate to look into this problem.... + */ + LOG_WARNING("WARNING: mystery debug reason MOE = 0xc. Try issuing a resume + halt."); + target->debug_reason = DBG_REASON_DBGRQ; + break; + default: + LOG_WARNING("WARNING: unknown debug reason: 0x%x", debug_reason); + /* Oh agony! should we interpret this as a halt request or + * that the target stopped on it's own accord? + */ + target->debug_reason = DBG_REASON_DBGRQ; + /* if we fail here, we won't talk to the target and it will + * be reported to be in the halted state */ + break; } return ERROR_OK; diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c index 8ab12de32..34b4ba2ce 100644 --- a/src/target/arm9tdmi.c +++ b/src/target/arm9tdmi.c @@ -398,15 +398,15 @@ static void arm9tdmi_read_core_regs_target_buffer(struct target *target, if (mask & (1 << i)) /* nothing fetched, STM in MEMORY (i'th cycle) */ switch (size) { - case 4: - arm9tdmi_clock_data_in_endianness(jtag_info, buf_u32++, 4, be); - break; - case 2: - arm9tdmi_clock_data_in_endianness(jtag_info, buf_u16++, 2, be); - break; - case 1: - arm9tdmi_clock_data_in_endianness(jtag_info, buf_u8++, 1, be); - break; + case 4: + arm9tdmi_clock_data_in_endianness(jtag_info, buf_u32++, 4, be); + break; + case 2: + arm9tdmi_clock_data_in_endianness(jtag_info, buf_u16++, 2, be); + break; + case 1: + arm9tdmi_clock_data_in_endianness(jtag_info, buf_u8++, 1, be); + break; } } } diff --git a/src/target/arm_dap.c b/src/target/arm_dap.c index be5e63c7c..5ba5e1c38 100644 --- a/src/target/arm_dap.c +++ b/src/target/arm_dap.c @@ -442,28 +442,28 @@ COMMAND_HANDLER(handle_dap_info_command) } switch (CMD_ARGC) { - case 0: - apsel = dap->apsel; - break; - case 1: - if (!strcmp(CMD_ARGV[0], "root")) { - if (!is_adiv6(dap)) { - command_print(CMD, "Option \"root\" not allowed with ADIv5 DAP"); - return ERROR_COMMAND_ARGUMENT_INVALID; - } - int retval = adiv6_dap_read_baseptr(CMD, dap, &apsel); - if (retval != ERROR_OK) { - command_print(CMD, "Failed reading DAP baseptr"); - return retval; - } - break; + case 0: + apsel = dap->apsel; + break; + case 1: + if (!strcmp(CMD_ARGV[0], "root")) { + if (!is_adiv6(dap)) { + command_print(CMD, "Option \"root\" not allowed with ADIv5 DAP"); + return ERROR_COMMAND_ARGUMENT_INVALID; + } + int retval = adiv6_dap_read_baseptr(CMD, dap, &apsel); + if (retval != ERROR_OK) { + command_print(CMD, "Failed reading DAP baseptr"); + return retval; } - COMMAND_PARSE_NUMBER(u64, CMD_ARGV[0], apsel); - if (!is_ap_num_valid(dap, apsel)) - return ERROR_COMMAND_SYNTAX_ERROR; break; - default: + } + COMMAND_PARSE_NUMBER(u64, CMD_ARGV[0], apsel); + if (!is_ap_num_valid(dap, apsel)) return ERROR_COMMAND_SYNTAX_ERROR; + break; + default: + return ERROR_COMMAND_SYNTAX_ERROR; } struct adiv5_ap *ap = dap_get_ap(dap, apsel); diff --git a/src/target/arm_disassembler.c b/src/target/arm_disassembler.c index 820b2c02b..6dea19f93 100644 --- a/src/target/arm_disassembler.c +++ b/src/target/arm_disassembler.c @@ -248,39 +248,39 @@ static int evaluate_srs(uint32_t opcode, const char *mode = ""; switch ((opcode >> 23) & 0x3) { - case 0: - mode = "DA"; - break; - case 1: - /* "IA" is default */ - break; - case 2: - mode = "DB"; - break; - case 3: - mode = "IB"; - break; + case 0: + mode = "DA"; + break; + case 1: + /* "IA" is default */ + break; + case 2: + mode = "DB"; + break; + case 3: + mode = "IB"; + break; } switch (opcode & 0x0e500000) { - case 0x08400000: - snprintf(instruction->text, 128, "0x%8.8" PRIx32 - "\t0x%8.8" PRIx32 - "\tSRS%s\tSP%s, #%" PRIu32, - address, opcode, - mode, wback, - opcode & 0x1f); - break; - case 0x08100000: - snprintf(instruction->text, 128, "0x%8.8" PRIx32 - "\t0x%8.8" PRIx32 - "\tRFE%s\tr%" PRIu32 "%s", - address, opcode, - mode, - (opcode >> 16) & 0xf, wback); - break; - default: - return evaluate_unknown(opcode, address, instruction); + case 0x08400000: + snprintf(instruction->text, 128, "0x%8.8" PRIx32 + "\t0x%8.8" PRIx32 + "\tSRS%s\tSP%s, #%" PRIu32, + address, opcode, + mode, wback, + opcode & 0x1f); + break; + case 0x08100000: + snprintf(instruction->text, 128, "0x%8.8" PRIx32 + "\t0x%8.8" PRIx32 + "\tRFE%s\tr%" PRIu32 "%s", + address, opcode, + mode, + (opcode >> 16) & 0xf, wback); + break; + default: + return evaluate_unknown(opcode, address, instruction); } return ERROR_OK; } @@ -631,21 +631,21 @@ static int evaluate_load_store(uint32_t opcode, snprintf(offset, 32, ", %sr%i", (u) ? "" : "-", rm); else { /* +-<Rm>, <Shift>, #<shift_imm> */ switch (shift) { - case 0x0: /* LSL */ - snprintf(offset, 32, ", %sr%i, LSL #0x%x", (u) ? "" : "-", rm, shift_imm); - break; - case 0x1: /* LSR */ - snprintf(offset, 32, ", %sr%i, LSR #0x%x", (u) ? "" : "-", rm, shift_imm); - break; - case 0x2: /* ASR */ - snprintf(offset, 32, ", %sr%i, ASR #0x%x", (u) ? "" : "-", rm, shift_imm); - break; - case 0x3: /* ROR */ - snprintf(offset, 32, ", %sr%i, ROR #0x%x", (u) ? "" : "-", rm, shift_imm); - break; - case 0x4: /* RRX */ - snprintf(offset, 32, ", %sr%i, RRX", (u) ? "" : "-", rm); - break; + case 0x0: /* LSL */ + snprintf(offset, 32, ", %sr%i, LSL #0x%x", (u) ? "" : "-", rm, shift_imm); + break; + case 0x1: /* LSR */ + snprintf(offset, 32, ", %sr%i, LSR #0x%x", (u) ? "" : "-", rm, shift_imm); + break; + case 0x2: /* ASR */ + snprintf(offset, 32, ", %sr%i, ASR #0x%x", (u) ? "" : "-", rm, shift_imm); + break; + case 0x3: /* ROR */ + snprintf(offset, 32, ", %sr%i, ROR #0x%x", (u) ? "" : "-", rm, shift_imm); + break; + case 0x4: /* RRX */ + snprintf(offset, 32, ", %sr%i, RRX", (u) ? "" : "-", rm); + break; } } } @@ -707,33 +707,33 @@ static int evaluate_extend(uint32_t opcode, uint32_t address, char *cp) char *type, *rot; switch ((opcode >> 24) & 0x3) { - case 0: - type = "B16"; - break; - case 1: - sprintf(cp, "UNDEFINED"); - return ARM_UNDEFINED_INSTRUCTION; - case 2: - type = "B"; - break; - default: - type = "H"; - break; + case 0: + type = "B16"; + break; + case 1: + sprintf(cp, "UNDEFINED"); + return ARM_UNDEFINED_INSTRUCTION; + case 2: + type = "B"; + break; + default: + type = "H"; + break; } switch ((opcode >> 10) & 0x3) { - case 0: - rot = ""; - break; - case 1: - rot = ", ROR #8"; - break; - case 2: - rot = ", ROR #16"; - break; - default: - rot = ", ROR #24"; - break; + case 0: + rot = ""; + break; + case 1: + rot = ", ROR #8"; + break; + case 2: + rot = ", ROR #16"; + break; + default: + rot = ", ROR #24"; + break; } if (rn == 0xf) { @@ -758,55 +758,55 @@ static int evaluate_p_add_sub(uint32_t opcode, uint32_t address, char *cp) int type; switch ((opcode >> 20) & 0x7) { - case 1: - prefix = "S"; - break; - case 2: - prefix = "Q"; - break; - case 3: - prefix = "SH"; - break; - case 5: - prefix = "U"; - break; - case 6: - prefix = "UQ"; - break; - case 7: - prefix = "UH"; - break; - default: - goto undef; + case 1: + prefix = "S"; + break; + case 2: + prefix = "Q"; + break; + case 3: + prefix = "SH"; + break; + case 5: + prefix = "U"; + break; + case 6: + prefix = "UQ"; + break; + case 7: + prefix = "UH"; + break; + default: + goto undef; } switch ((opcode >> 5) & 0x7) { - case 0: - op = "ADD16"; - type = ARM_ADD; - break; - case 1: - op = "ADDSUBX"; - type = ARM_ADD; - break; - case 2: - op = "SUBADDX"; - type = ARM_SUB; - break; - case 3: - op = "SUB16"; - type = ARM_SUB; - break; - case 4: - op = "ADD8"; - type = ARM_ADD; - break; - case 7: - op = "SUB8"; - type = ARM_SUB; - break; - default: - goto undef; + case 0: + op = "ADD16"; + type = ARM_ADD; + break; + case 1: + op = "ADDSUBX"; + type = ARM_ADD; + break; + case 2: + op = "SUBADDX"; + type = ARM_SUB; + break; + case 3: + op = "SUB16"; + type = ARM_SUB; + break; + case 4: + op = "ADD8"; + type = ARM_ADD; + break; + case 7: + op = "SUB8"; + type = ARM_SUB; + break; + default: + goto undef; } sprintf(cp, "%s%s%s\tr%d, r%d, r%d", prefix, op, COND(opcode), @@ -928,14 +928,14 @@ static int evaluate_media(uint32_t opcode, uint32_t address, unsigned int rn = (opcode >> 12) & 0xf; switch (opcode & 0xc0) { - case 3: - if (rn == 0xf) - goto undef; - /* FALL THROUGH */ - case 0: - break; - default: + case 3: + if (rn == 0xf) goto undef; + /* FALL THROUGH */ + case 0: + break; + default: + goto undef; } if (rn != 0xf) @@ -959,46 +959,46 @@ static int evaluate_media(uint32_t opcode, uint32_t address, /* simple matches against the remaining decode bits */ switch (opcode & 0x01f000f0) { - case 0x00a00030: - case 0x00e00030: - /* parallel halfword saturate */ - sprintf(cp, "%cSAT16%s\tr%d, #%d, r%d", - (opcode & (1 << 22)) ? 'U' : 'S', - COND(opcode), - (int) (opcode >> 12) & 0xf, - (int) (opcode >> 16) & 0xf, - (int) (opcode >> 0) & 0xf); - return ERROR_OK; - case 0x00b00030: - mnemonic = "REV"; - break; - case 0x00b000b0: - mnemonic = "REV16"; - break; - case 0x00f000b0: - mnemonic = "REVSH"; - break; - case 0x008000b0: - /* select bytes */ - sprintf(cp, "SEL%s\tr%d, r%d, r%d", COND(opcode), - (int) (opcode >> 12) & 0xf, - (int) (opcode >> 16) & 0xf, - (int) (opcode >> 0) & 0xf); - return ERROR_OK; - case 0x01800010: - /* unsigned sum of absolute differences */ - if (((opcode >> 12) & 0xf) == 0xf) - sprintf(cp, "USAD8%s\tr%d, r%d, r%d", COND(opcode), - (int) (opcode >> 16) & 0xf, - (int) (opcode >> 0) & 0xf, - (int) (opcode >> 8) & 0xf); - else - sprintf(cp, "USADA8%s\tr%d, r%d, r%d, r%d", COND(opcode), - (int) (opcode >> 16) & 0xf, - (int) (opcode >> 0) & 0xf, - (int) (opcode >> 8) & 0xf, - (int) (opcode >> 12) & 0xf); - return ERROR_OK; + case 0x00a00030: + case 0x00e00030: + /* parallel halfword saturate */ + sprintf(cp, "%cSAT16%s\tr%d, #%d, r%d", + (opcode & (1 << 22)) ? 'U' : 'S', + COND(opcode), + (int)(opcode >> 12) & 0xf, + (int)(opcode >> 16) & 0xf, + (int)(opcode >> 0) & 0xf); + return ERROR_OK; + case 0x00b00030: + mnemonic = "REV"; + break; + case 0x00b000b0: + mnemonic = "REV16"; + break; + case 0x00f000b0: + mnemonic = "REVSH"; + break; + case 0x008000b0: + /* select bytes */ + sprintf(cp, "SEL%s\tr%d, r%d, r%d", COND(opcode), + (int)(opcode >> 12) & 0xf, + (int)(opcode >> 16) & 0xf, + (int)(opcode >> 0) & 0xf); + return ERROR_OK; + case 0x01800010: + /* unsigned sum of absolute differences */ + if (((opcode >> 12) & 0xf) == 0xf) + sprintf(cp, "USAD8%s\tr%d, r%d, r%d", COND(opcode), + (int)(opcode >> 16) & 0xf, + (int)(opcode >> 0) & 0xf, + (int)(opcode >> 8) & 0xf); + else + sprintf(cp, "USADA8%s\tr%d, r%d, r%d, r%d", COND(opcode), + (int)(opcode >> 16) & 0xf, + (int)(opcode >> 0) & 0xf, + (int)(opcode >> 8) & 0xf, + (int)(opcode >> 12) & 0xf); + return ERROR_OK; } if (mnemonic) { unsigned int rm = (opcode >> 0) & 0xf; @@ -1280,22 +1280,22 @@ static int evaluate_mul_and_extra_ld_st(uint32_t opcode, s = (opcode & 0x00100000) >> 20; switch ((opcode & 0x00600000) >> 21) { - case 0x0: - instruction->type = ARM_UMULL; - mnemonic = "UMULL"; - break; - case 0x1: - instruction->type = ARM_UMLAL; - mnemonic = "UMLAL"; - break; - case 0x2: - instruction->type = ARM_SMULL; - mnemonic = "SMULL"; - break; - case 0x3: - instruction->type = ARM_SMLAL; - mnemonic = "SMLAL"; - break; + case 0x0: + instruction->type = ARM_UMULL; + mnemonic = "UMULL"; + break; + case 0x1: + instruction->type = ARM_UMLAL; + mnemonic = "UMLAL"; + break; + case 0x2: + instruction->type = ARM_SMULL; + mnemonic = "SMULL"; + break; + case 0x3: + instruction->type = ARM_SMLAL; + mnemonic = "SMLAL"; + break; } snprintf(instruction->text, @@ -1480,22 +1480,22 @@ static int evaluate_misc_instr(uint32_t opcode, rn = (opcode & 0xf0000) >> 16; switch ((opcode & 0x00600000) >> 21) { - case 0x0: - instruction->type = ARM_QADD; - mnemonic = "QADD"; - break; - case 0x1: - instruction->type = ARM_QSUB; - mnemonic = "QSUB"; - break; - case 0x2: - instruction->type = ARM_QDADD; - mnemonic = "QDADD"; - break; - case 0x3: - instruction->type = ARM_QDSUB; - mnemonic = "QDSUB"; - break; + case 0x0: + instruction->type = ARM_QADD; + mnemonic = "QADD"; + break; + case 0x1: + instruction->type = ARM_QSUB; + mnemonic = "QSUB"; + break; + case 0x2: + instruction->type = ARM_QDADD; + mnemonic = "QDADD"; + break; + case 0x3: + instruction->type = ARM_QDSUB; + mnemonic = "QDSUB"; + break; } snprintf(instruction->text, @@ -1527,21 +1527,21 @@ static int evaluate_misc_instr(uint32_t opcode, char *mnemonic = NULL; switch ((opcode & 0x600000) >> 21) { - case 0x1: - instruction->type = ARM_BKPT; - mnemonic = "BRKT"; - immediate = ((opcode & 0x000fff00) >> 4) | (opcode & 0xf); - break; - case 0x2: - instruction->type = ARM_HVC; - mnemonic = "HVC"; - immediate = ((opcode & 0x000fff00) >> 4) | (opcode & 0xf); - break; - case 0x3: - instruction->type = ARM_SMC; - mnemonic = "SMC"; - immediate = (opcode & 0xf); - break; + case 0x1: + instruction->type = ARM_BKPT; + mnemonic = "BRKT"; + immediate = ((opcode & 0x000fff00) >> 4) | (opcode & 0xf); + break; + case 0x2: + instruction->type = ARM_HVC; + mnemonic = "HVC"; + immediate = ((opcode & 0x000fff00) >> 4) | (opcode & 0xf); + break; + case 0x3: + instruction->type = ARM_SMC; + mnemonic = "SMC"; + immediate = (opcode & 0xf); + break; } snprintf(instruction->text, @@ -1717,70 +1717,70 @@ static int evaluate_data_proc(uint32_t opcode, instruction->info.data_proc.s = s; switch (op) { - case 0x0: - instruction->type = ARM_AND; - mnemonic = "AND"; - break; - case 0x1: - instruction->type = ARM_EOR; - mnemonic = "EOR"; - break; - case 0x2: - instruction->type = ARM_SUB; - mnemonic = "SUB"; - break; - case 0x3: - instruction->type = ARM_RSB; - mnemonic = "RSB"; - break; - case 0x4: - instruction->type = ARM_ADD; - mnemonic = "ADD"; - break; - case 0x5: - instruction->type = ARM_ADC; - mnemonic = "ADC"; - break; - case 0x6: - instruction->type = ARM_SBC; - mnemonic = "SBC"; - break; - case 0x7: - instruction->type = ARM_RSC; - mnemonic = "RSC"; - break; - case 0x8: - instruction->type = ARM_TST; - mnemonic = "TST"; - break; - case 0x9: - instruction->type = ARM_TEQ; - mnemonic = "TEQ"; - break; - case 0xa: - instruction->type = ARM_CMP; - mnemonic = "CMP"; - break; - case 0xb: - instruction->type = ARM_CMN; - mnemonic = "CMN"; - break; - case 0xc: - instruction->type = ARM_ORR; - mnemonic = "ORR"; - break; - case 0xd: - instruction->type = ARM_MOV; - mnemonic = "MOV"; - break; - case 0xe: - instruction->type = ARM_BIC; - mnemonic = "BIC"; - break; - case 0xf: - instruction->type = ARM_MVN; - mnemonic = "MVN"; - break; + case 0x0: + instruction->type = ARM_AND; + mnemonic = "AND"; + break; + case 0x1: + instruction->type = ARM_EOR; + mnemonic = "EOR"; + break; + case 0x2: + instruction->type = ARM_SUB; + mnemonic = "SUB"; + break; + case 0x3: + instruction->type = ARM_RSB; + mnemonic = "RSB"; + break; + case 0x4: + instruction->type = ARM_ADD; + mnemonic = "ADD"; + break; + case 0x5: + instruction->type = ARM_ADC; + mnemonic = "ADC"; + break; + case 0x6: + instruction->type = ARM_SBC; + mnemonic = "SBC"; + break; + case 0x7: + instruction->type = ARM_RSC; + mnemonic = "RSC"; + break; + case 0x8: + instruction->type = ARM_TST; + mnemonic = "TST"; + break; + case 0x9: + instruction->type = ARM_TEQ; + mnemonic = "TEQ"; + break; + case 0xa: + instruction->type = ARM_CMP; + mnemonic = "CMP"; + break; + case 0xb: + instruction->type = ARM_CMN; + mnemonic = "CMN"; + break; + case 0xc: + instruction->type = ARM_ORR; + mnemonic = "ORR"; + break; + case 0xd: + instruction->type = ARM_MOV; + mnemonic = "MOV"; + break; + case 0xe: + instruction->type = ARM_BIC; + mnemonic = "BIC"; + break; + case 0xf: + instruction->type = ARM_MVN; + mnemonic = "MVN"; + break; } if (i) {/* immediate shifter operand (#<immediate>)*/ @@ -2065,28 +2065,28 @@ static int evaluate_b_bl_blx_thumb(uint16_t opcode, target_address = address + 4 + (offset << 1); switch (opc) { - /* unconditional branch */ - case 0: - instruction->type = ARM_B; - mnemonic = "B"; - break; - /* BLX suffix */ - case 1: - instruction->type = ARM_BLX; - mnemonic = "BLX"; - target_address &= 0xfffffffc; - break; - /* BL/BLX prefix */ - case 2: - instruction->type = ARM_UNKNOWN_INSTRUCTION; - mnemonic = "prefix"; - target_address = offset << 12; - break; - /* BL suffix */ - case 3: - instruction->type = ARM_BL; - mnemonic = "BL"; - break; + /* unconditional branch */ + case 0: + instruction->type = ARM_B; + mnemonic = "B"; + break; + /* BLX suffix */ + case 1: + instruction->type = ARM_BLX; + mnemonic = "BLX"; + target_address &= 0xfffffffc; + break; + /* BL/BLX prefix */ + case 2: + instruction->type = ARM_UNKNOWN_INSTRUCTION; + mnemonic = "prefix"; + target_address = offset << 12; + break; + /* BL suffix */ + case 3: + instruction->type = ARM_BL; + mnemonic = "BL"; + break; } /* TODO: deal correctly with dual opcode (prefixed) BL/BLX; @@ -2158,21 +2158,21 @@ static int evaluate_shift_imm_thumb(uint16_t opcode, char *mnemonic = NULL; switch (opc) { - case 0: - instruction->type = ARM_MOV; - mnemonic = "LSLS"; - instruction->info.data_proc.shifter_operand.immediate_shift.shift = 0; - break; - case 1: - instruction->type = ARM_MOV; - mnemonic = "LSRS"; - instruction->info.data_proc.shifter_operand.immediate_shift.shift = 1; - break; - case 2: - instruction->type = ARM_MOV; - mnemonic = "ASRS"; - instruction->info.data_proc.shifter_operand.immediate_shift.shift = 2; - break; + case 0: + instruction->type = ARM_MOV; + mnemonic = "LSLS"; + instruction->info.data_proc.shifter_operand.immediate_shift.shift = 0; + break; + case 1: + instruction->type = ARM_MOV; + mnemonic = "LSRS"; + instruction->info.data_proc.shifter_operand.immediate_shift.shift = 1; + break; + case 2: + instruction->type = ARM_MOV; + mnemonic = "ASRS"; + instruction->info.data_proc.shifter_operand.immediate_shift.shift = 2; + break; } if ((imm == 0) && (opc != 0)) @@ -2208,24 +2208,24 @@ static int evaluate_data_proc_imm_thumb(uint16_t opcode, instruction->info.data_proc.shifter_operand.immediate.immediate = imm; switch (opc) { - case 0: - instruction->type = ARM_MOV; - mnemonic = "MOVS"; - instruction->info.data_proc.rn = -1; - break; - case 1: - instruction->type = ARM_CMP; - mnemonic = "CMP"; - instruction->info.data_proc.rd = -1; - break; - case 2: - instruction->type = ARM_ADD; - mnemonic = "ADDS"; - break; - case 3: - instruction->type = ARM_SUB; - mnemonic = "SUBS"; - break; + case 0: + instruction->type = ARM_MOV; + mnemonic = "MOVS"; + instruction->info.data_proc.rn = -1; + break; + case 1: + instruction->type = ARM_CMP; + mnemonic = "CMP"; + instruction->info.data_proc.rd = -1; + break; + case 2: + instruction->type = ARM_ADD; + mnemonic = "ADDS"; + break; + case 3: + instruction->type = ARM_SUB; + mnemonic = "SUBS"; + break; } snprintf(instruction->text, 128, @@ -2262,131 +2262,131 @@ static int evaluate_data_proc_thumb(uint16_t opcode, op >>= 2; switch (op) { - case 0x0: - instruction->type = ARM_ADD; - mnemonic = "ADD"; - break; - case 0x1: - instruction->type = ARM_CMP; - mnemonic = "CMP"; - break; - case 0x2: - instruction->type = ARM_MOV; - mnemonic = "MOV"; - if (rd == rm) - nop = true; - break; - case 0x3: - if ((opcode & 0x7) == 0x0) { - instruction->info.b_bl_bx_blx.reg_operand = rm; - if (h1) { - instruction->type = ARM_BLX; - snprintf(instruction->text, 128, - "0x%8.8" PRIx32 - " 0x%4.4x \tBLX\tr%i", - address, opcode, rm); - } else { - instruction->type = ARM_BX; - snprintf(instruction->text, 128, - "0x%8.8" PRIx32 - " 0x%4.4x \tBX\tr%i", - address, opcode, rm); - } + case 0x0: + instruction->type = ARM_ADD; + mnemonic = "ADD"; + break; + case 0x1: + instruction->type = ARM_CMP; + mnemonic = "CMP"; + break; + case 0x2: + instruction->type = ARM_MOV; + mnemonic = "MOV"; + if (rd == rm) + nop = true; + break; + case 0x3: + if ((opcode & 0x7) == 0x0) { + instruction->info.b_bl_bx_blx.reg_operand = rm; + if (h1) { + instruction->type = ARM_BLX; + snprintf(instruction->text, 128, + "0x%8.8" PRIx32 + " 0x%4.4x \tBLX\tr%i", + address, opcode, rm); } else { - instruction->type = ARM_UNDEFINED_INSTRUCTION; + instruction->type = ARM_BX; snprintf(instruction->text, 128, "0x%8.8" PRIx32 - " 0x%4.4x \t" - "UNDEFINED INSTRUCTION", - address, opcode); + " 0x%4.4x \tBX\tr%i", + address, opcode, rm); } - return ERROR_OK; + } else { + instruction->type = ARM_UNDEFINED_INSTRUCTION; + snprintf(instruction->text, 128, + "0x%8.8" PRIx32 + " 0x%4.4x \t" + "UNDEFINED INSTRUCTION", + address, opcode); + } + return ERROR_OK; } } else { switch (op) { - case 0x0: - instruction->type = ARM_AND; - mnemonic = "ANDS"; - break; - case 0x1: - instruction->type = ARM_EOR; - mnemonic = "EORS"; - break; - case 0x2: - instruction->type = ARM_MOV; - mnemonic = "LSLS"; - instruction->info.data_proc.variant = 2 /*register shift*/; - instruction->info.data_proc.shifter_operand.register_shift.shift = 0; - instruction->info.data_proc.shifter_operand.register_shift.rm = rd; - instruction->info.data_proc.shifter_operand.register_shift.rs = rm; - break; - case 0x3: - instruction->type = ARM_MOV; - mnemonic = "LSRS"; - instruction->info.data_proc.variant = 2 /*register shift*/; - instruction->info.data_proc.shifter_operand.register_shift.shift = 1; - instruction->info.data_proc.shifter_operand.register_shift.rm = rd; - instruction->info.data_proc.shifter_operand.register_shift.rs = rm; - break; - case 0x4: - instruction->type = ARM_MOV; - mnemonic = "ASRS"; - instruction->info.data_proc.variant = 2 /*register shift*/; - instruction->info.data_proc.shifter_operand.register_shift.shift = 2; - instruction->info.data_proc.shifter_operand.register_shift.rm = rd; - instruction->info.data_proc.shifter_operand.register_shift.rs = rm; - break; - case 0x5: - instruction->type = ARM_ADC; - mnemonic = "ADCS"; - break; - case 0x6: - instruction->type = ARM_SBC; - mnemonic = "SBCS"; - break; - case 0x7: - instruction->type = ARM_MOV; - mnemonic = "RORS"; - instruction->info.data_proc.variant = 2 /*register shift*/; - instruction->info.data_proc.shifter_operand.register_shift.shift = 3; - instruction->info.data_proc.shifter_operand.register_shift.rm = rd; - instruction->info.data_proc.shifter_operand.register_shift.rs = rm; - break; - case 0x8: - instruction->type = ARM_TST; - mnemonic = "TST"; - break; - case 0x9: - instruction->type = ARM_RSB; - mnemonic = "RSBS"; - instruction->info.data_proc.variant = 0 /*immediate*/; - instruction->info.data_proc.shifter_operand.immediate.immediate = 0; - instruction->info.data_proc.rn = rm; - break; - case 0xA: - instruction->type = ARM_CMP; - mnemonic = "CMP"; - break; - case 0xB: - instruction->type = ARM_CMN; - mnemonic = "CMN"; - break; - case 0xC: - instruction->type = ARM_ORR; - mnemonic = "ORRS"; - break; - case 0xD: - instruction->type = ARM_MUL; - mnemonic = "MULS"; - break; - case 0xE: - instruction->type = ARM_BIC; - mnemonic = "BICS"; - break; - case 0xF: - instruction->type = ARM_MVN; - mnemonic = "MVNS"; - break; + case 0x0: + instruction->type = ARM_AND; + mnemonic = "ANDS"; + break; + case 0x1: + instruction->type = ARM_EOR; + mnemonic = "EORS"; + break; + case 0x2: + instruction->type = ARM_MOV; + mnemonic = "LSLS"; + instruction->info.data_proc.variant = 2 /*register shift*/; + instruction->info.data_proc.shifter_operand.register_shift.shift = 0; + instruction->info.data_proc.shifter_operand.register_shift.rm = rd; + instruction->info.data_proc.shifter_operand.register_shift.rs = rm; + break; + case 0x3: + instruction->type = ARM_MOV; + mnemonic = "LSRS"; + instruction->info.data_proc.variant = 2 /*register shift*/; + instruction->info.data_proc.shifter_operand.register_shift.shift = 1; + instruction->info.data_proc.shifter_operand.register_shift.rm = rd; + instruction->info.data_proc.shifter_operand.register_shift.rs = rm; + break; + case 0x4: + instruction->type = ARM_MOV; + mnemonic = "ASRS"; + instruction->info.data_proc.variant = 2 /*register shift*/; + instruction->info.data_proc.shifter_operand.register_shift.shift = 2; + instruction->info.data_proc.shifter_operand.register_shift.rm = rd; + instruction->info.data_proc.shifter_operand.register_shift.rs = rm; + break; + case 0x5: + instruction->type = ARM_ADC; + mnemonic = "ADCS"; + break; + c... [truncated message content] |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:36:22
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 0cd8b6a9d950e7f5e1d83bb62ce98c71116aee70 (commit) from 867611d3e19502d3affa780a38de3b41201ee712 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0cd8b6a9d950e7f5e1d83bb62ce98c71116aee70 Author: Antonio Borneo <bor...@gm...> Date: Sat Jul 26 18:39:07 2025 +0200 jtag: drivers: ulink: special align switch and case statements The coding style requires the 'case' to be at the same indentation level of its 'switch' statement. Checkpatch is not able to detect numbers in exponential format, like 6E-5, and complains about missing space around the operator minus. To complete the alignment of switch and case statements in this file, use a separate commit with the special checkpatch ignore tag in the commit message. Align the code accordingly. No changes are reported by git log -p -w --ignore-blank-lines --patience Checkpatch-ignore: SPACING Change-Id: Ibe70c4a4d3f0bb44c03007103910b778944bb90e Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9056 Tested-by: jenkins Reviewed-by: zapb <de...@za...> diff --git a/src/jtag/drivers/ulink.c b/src/jtag/drivers/ulink.c index 93b862926..1f14b1a04 100644 --- a/src/jtag/drivers/ulink.c +++ b/src/jtag/drivers/ulink.c @@ -1285,24 +1285,24 @@ static int ulink_calculate_delay(enum ulink_delay_type type, long f, int *delay) t = 1.0 / (float)(f); switch (type) { - case DELAY_CLOCK_TCK: - x = (t - (float)(6E-6)) / (float)(4E-6); - break; - case DELAY_CLOCK_TMS: - x = (t - (float)(8.5E-6)) / (float)(4E-6); - break; - case DELAY_SCAN_IN: - x = (t - (float)(8.8308E-6)) / (float)(4E-6); - break; - case DELAY_SCAN_OUT: - x = (t - (float)(1.0527E-5)) / (float)(4E-6); - break; - case DELAY_SCAN_IO: - x = (t - (float)(1.3132E-5)) / (float)(4E-6); - break; - default: - return ERROR_FAIL; - break; + case DELAY_CLOCK_TCK: + x = (t - (float)(6E-6)) / (float)(4E-6); + break; + case DELAY_CLOCK_TMS: + x = (t - (float)(8.5E-6)) / (float)(4E-6); + break; + case DELAY_SCAN_IN: + x = (t - (float)(8.8308E-6)) / (float)(4E-6); + break; + case DELAY_SCAN_OUT: + x = (t - (float)(1.0527E-5)) / (float)(4E-6); + break; + case DELAY_SCAN_IO: + x = (t - (float)(1.3132E-5)) / (float)(4E-6); + break; + default: + return ERROR_FAIL; + break; } /* Check if the delay value is negative. This happens when a frequency is @@ -1345,38 +1345,38 @@ static long ulink_calculate_frequency(enum ulink_delay_type type, int delay) return 0; switch (type) { - case DELAY_CLOCK_TCK: - if (delay < 0) - t = (float)(2.666E-6); - else - t = (float)(4E-6) * (float)(delay) + (float)(6E-6); - break; - case DELAY_CLOCK_TMS: - if (delay < 0) - t = (float)(5.666E-6); - else - t = (float)(4E-6) * (float)(delay) + (float)(8.5E-6); - break; - case DELAY_SCAN_IN: - if (delay < 0) - t = (float)(5.5E-6); - else - t = (float)(4E-6) * (float)(delay) + (float)(8.8308E-6); - break; - case DELAY_SCAN_OUT: - if (delay < 0) - t = (float)(7.0E-6); - else - t = (float)(4E-6) * (float)(delay) + (float)(1.0527E-5); - break; - case DELAY_SCAN_IO: - if (delay < 0) - t = (float)(9.926E-6); - else - t = (float)(4E-6) * (float)(delay) + (float)(1.3132E-5); - break; - default: - return 0; + case DELAY_CLOCK_TCK: + if (delay < 0) + t = (float)(2.666E-6); + else + t = (float)(4E-6) * (float)(delay) + (float)(6E-6); + break; + case DELAY_CLOCK_TMS: + if (delay < 0) + t = (float)(5.666E-6); + else + t = (float)(4E-6) * (float)(delay) + (float)(8.5E-6); + break; + case DELAY_SCAN_IN: + if (delay < 0) + t = (float)(5.5E-6); + else + t = (float)(4E-6) * (float)(delay) + (float)(8.8308E-6); + break; + case DELAY_SCAN_OUT: + if (delay < 0) + t = (float)(7.0E-6); + else + t = (float)(4E-6) * (float)(delay) + (float)(1.0527E-5); + break; + case DELAY_SCAN_IO: + if (delay < 0) + t = (float)(9.926E-6); + else + t = (float)(4E-6) * (float)(delay) + (float)(1.3132E-5); + break; + default: + return 0; } f_float = 1.0 / t; ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/ulink.c | 100 +++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 50 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:35:52
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 867611d3e19502d3affa780a38de3b41201ee712 (commit) via 8b751e0d455b2e1d3867aec8aebdae4d9a2a9b65 (commit) from 8a504640d2bceaa938dca65e76c77ae844904df7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 867611d3e19502d3affa780a38de3b41201ee712 Author: Antonio Borneo <bor...@gm...> Date: Sat Jul 26 18:18:15 2025 +0200 jtag: drivers: align switch and case statements The coding style requires the 'case' to be at the same indentation level of its 'switch' statement. Align the code accordingly. Skip the driver angie that is going to be updated soon with a new commit and skip the folder OpenULINK that contains a firmware for the dongle. No changes are reported by git log -p -w --ignore-blank-lines --patience Change-Id: I960a89a45bc9956f98676a019f0d1a652601155f Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9055 Tested-by: jenkins Reviewed-by: zapb <de...@za...> diff --git a/src/jtag/drivers/amt_jtagaccel.c b/src/jtag/drivers/amt_jtagaccel.c index d3f8bb61e..6f1718896 100644 --- a/src/jtag/drivers/amt_jtagaccel.c +++ b/src/jtag/drivers/amt_jtagaccel.c @@ -332,43 +332,43 @@ static int amt_jtagaccel_execute_queue(struct jtag_command *cmd_queue) while (cmd) { switch (cmd->type) { - case JTAG_RESET: - LOG_DEBUG_IO("reset trst: %i srst %i", - cmd->cmd.reset->trst, - cmd->cmd.reset->srst); - if (cmd->cmd.reset->trst == 1) - tap_set_state(TAP_RESET); - amt_jtagaccel_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); - break; - case JTAG_RUNTEST: - LOG_DEBUG_IO("runtest %i cycles, end in %i", - cmd->cmd.runtest->num_cycles, - cmd->cmd.runtest->end_state); - amt_jtagaccel_end_state(cmd->cmd.runtest->end_state); - amt_jtagaccel_runtest(cmd->cmd.runtest->num_cycles); - break; - case JTAG_TLR_RESET: - LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state); - amt_jtagaccel_end_state(cmd->cmd.statemove->end_state); - amt_jtagaccel_state_move(); - break; - case JTAG_SCAN: - LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state); - amt_jtagaccel_end_state(cmd->cmd.scan->end_state); - scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); - type = jtag_scan_type(cmd->cmd.scan); - amt_jtagaccel_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size); - if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK) - retval = ERROR_JTAG_QUEUE_FAILED; - free(buffer); - break; - case JTAG_SLEEP: - LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); - jtag_sleep(cmd->cmd.sleep->us); - break; - default: - LOG_ERROR("BUG: unknown JTAG command type encountered"); - exit(-1); + case JTAG_RESET: + LOG_DEBUG_IO("reset trst: %i srst %i", + cmd->cmd.reset->trst, + cmd->cmd.reset->srst); + if (cmd->cmd.reset->trst == 1) + tap_set_state(TAP_RESET); + amt_jtagaccel_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); + break; + case JTAG_RUNTEST: + LOG_DEBUG_IO("runtest %i cycles, end in %i", + cmd->cmd.runtest->num_cycles, + cmd->cmd.runtest->end_state); + amt_jtagaccel_end_state(cmd->cmd.runtest->end_state); + amt_jtagaccel_runtest(cmd->cmd.runtest->num_cycles); + break; + case JTAG_TLR_RESET: + LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state); + amt_jtagaccel_end_state(cmd->cmd.statemove->end_state); + amt_jtagaccel_state_move(); + break; + case JTAG_SCAN: + LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state); + amt_jtagaccel_end_state(cmd->cmd.scan->end_state); + scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); + type = jtag_scan_type(cmd->cmd.scan); + amt_jtagaccel_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size); + if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK) + retval = ERROR_JTAG_QUEUE_FAILED; + free(buffer); + break; + case JTAG_SLEEP: + LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); + jtag_sleep(cmd->cmd.sleep->us); + break; + default: + LOG_ERROR("BUG: unknown JTAG command type encountered"); + exit(-1); } cmd = cmd->next; } diff --git a/src/jtag/drivers/arm-jtag-ew.c b/src/jtag/drivers/arm-jtag-ew.c index 9d8c592ed..5c0e2ea94 100644 --- a/src/jtag/drivers/arm-jtag-ew.c +++ b/src/jtag/drivers/arm-jtag-ew.c @@ -94,69 +94,69 @@ static int armjtagew_execute_queue(struct jtag_command *cmd_queue) while (cmd) { switch (cmd->type) { - case JTAG_RUNTEST: - LOG_DEBUG_IO("runtest %u cycles, end in %i", - cmd->cmd.runtest->num_cycles, - cmd->cmd.runtest->end_state); + case JTAG_RUNTEST: + LOG_DEBUG_IO("runtest %u cycles, end in %i", + cmd->cmd.runtest->num_cycles, + cmd->cmd.runtest->end_state); - armjtagew_end_state(cmd->cmd.runtest->end_state); - armjtagew_runtest(cmd->cmd.runtest->num_cycles); - break; + armjtagew_end_state(cmd->cmd.runtest->end_state); + armjtagew_runtest(cmd->cmd.runtest->num_cycles); + break; - case JTAG_TLR_RESET: - LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state); + case JTAG_TLR_RESET: + LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state); - armjtagew_end_state(cmd->cmd.statemove->end_state); - armjtagew_state_move(); - break; + armjtagew_end_state(cmd->cmd.statemove->end_state); + armjtagew_state_move(); + break; - case JTAG_PATHMOVE: - LOG_DEBUG_IO("pathmove: %u states, end in %i", - cmd->cmd.pathmove->num_states, - cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); + case JTAG_PATHMOVE: + LOG_DEBUG_IO("pathmove: %u states, end in %i", + cmd->cmd.pathmove->num_states, + cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); - armjtagew_path_move(cmd->cmd.pathmove->num_states, - cmd->cmd.pathmove->path); - break; + armjtagew_path_move(cmd->cmd.pathmove->num_states, + cmd->cmd.pathmove->path); + break; - case JTAG_SCAN: - LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state); + case JTAG_SCAN: + LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state); - armjtagew_end_state(cmd->cmd.scan->end_state); + armjtagew_end_state(cmd->cmd.scan->end_state); - scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); - LOG_DEBUG_IO("scan input, length = %d", scan_size); + scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); + LOG_DEBUG_IO("scan input, length = %d", scan_size); #ifdef _DEBUG_USB_COMMS_ - armjtagew_debug_buffer(buffer, (scan_size + 7) / 8); + armjtagew_debug_buffer(buffer, (scan_size + 7) / 8); #endif - type = jtag_scan_type(cmd->cmd.scan); - armjtagew_scan(cmd->cmd.scan->ir_scan, - type, buffer, - scan_size, cmd->cmd.scan); - break; - - case JTAG_RESET: - LOG_DEBUG_IO("reset trst: %i srst %i", - cmd->cmd.reset->trst, - cmd->cmd.reset->srst); - - armjtagew_tap_execute(); - - if (cmd->cmd.reset->trst == 1) - tap_set_state(TAP_RESET); - armjtagew_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); - break; - - case JTAG_SLEEP: - LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); - armjtagew_tap_execute(); - jtag_sleep(cmd->cmd.sleep->us); - break; - - default: - LOG_ERROR("BUG: unknown JTAG command type encountered"); - exit(-1); + type = jtag_scan_type(cmd->cmd.scan); + armjtagew_scan(cmd->cmd.scan->ir_scan, + type, buffer, + scan_size, cmd->cmd.scan); + break; + + case JTAG_RESET: + LOG_DEBUG_IO("reset trst: %i srst %i", + cmd->cmd.reset->trst, + cmd->cmd.reset->srst); + + armjtagew_tap_execute(); + + if (cmd->cmd.reset->trst == 1) + tap_set_state(TAP_RESET); + armjtagew_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); + break; + + case JTAG_SLEEP: + LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); + armjtagew_tap_execute(); + jtag_sleep(cmd->cmd.sleep->us); + break; + + default: + LOG_ERROR("BUG: unknown JTAG command type encountered"); + exit(-1); } cmd = cmd->next; } diff --git a/src/jtag/drivers/bitbang.c b/src/jtag/drivers/bitbang.c index c2e763ddb..ebf38c7fa 100644 --- a/src/jtag/drivers/bitbang.c +++ b/src/jtag/drivers/bitbang.c @@ -236,14 +236,14 @@ static int bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, buffered++; } else { switch (bitbang_interface->read()) { - case BB_LOW: - buffer[bytec] &= ~bcval; - break; - case BB_HIGH: - buffer[bytec] |= bcval; - break; - default: - return ERROR_FAIL; + case BB_LOW: + buffer[bytec] &= ~bcval; + break; + case BB_HIGH: + buffer[bytec] |= bcval; + break; + default: + return ERROR_FAIL; } } } @@ -256,14 +256,14 @@ static int bitbang_scan(bool ir_scan, enum scan_type type, uint8_t *buffer, bit_cnt == scan_size - 1)) { for (unsigned int i = bit_cnt + 1 - buffered; i <= bit_cnt; i++) { switch (bitbang_interface->read_sample()) { - case BB_LOW: - buffer[i/8] &= ~(1 << (i % 8)); - break; - case BB_HIGH: - buffer[i/8] |= 1 << (i % 8); - break; - default: - return ERROR_FAIL; + case BB_LOW: + buffer[i / 8] &= ~(1 << (i % 8)); + break; + case BB_HIGH: + buffer[i / 8] |= 1 << (i % 8); + break; + default: + return ERROR_FAIL; } } buffered = 0; @@ -315,64 +315,64 @@ int bitbang_execute_queue(struct jtag_command *cmd_queue) while (cmd) { switch (cmd->type) { - case JTAG_RUNTEST: - LOG_DEBUG_IO("runtest %u cycles, end in %s", - cmd->cmd.runtest->num_cycles, - tap_state_name(cmd->cmd.runtest->end_state)); - bitbang_end_state(cmd->cmd.runtest->end_state); - if (bitbang_runtest(cmd->cmd.runtest->num_cycles) != ERROR_OK) - return ERROR_FAIL; - break; - - case JTAG_STABLECLOCKS: - /* this is only allowed while in a stable state. A check for a stable - * state was done in jtag_add_clocks() - */ - if (bitbang_stableclocks(cmd->cmd.stableclocks->num_cycles) != ERROR_OK) - return ERROR_FAIL; - break; - - case JTAG_TLR_RESET: - LOG_DEBUG_IO("statemove end in %s", - tap_state_name(cmd->cmd.statemove->end_state)); - bitbang_end_state(cmd->cmd.statemove->end_state); - if (bitbang_state_move(0) != ERROR_OK) - return ERROR_FAIL; - break; - case JTAG_PATHMOVE: - LOG_DEBUG_IO("pathmove: %u states, end in %s", - cmd->cmd.pathmove->num_states, - tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1])); - if (bitbang_path_move(cmd->cmd.pathmove) != ERROR_OK) - return ERROR_FAIL; - break; - case JTAG_SCAN: - bitbang_end_state(cmd->cmd.scan->end_state); - scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); - LOG_DEBUG_IO("%s scan %d bits; end in %s", - (cmd->cmd.scan->ir_scan) ? "IR" : "DR", - scan_size, - tap_state_name(cmd->cmd.scan->end_state)); - type = jtag_scan_type(cmd->cmd.scan); - if (bitbang_scan(cmd->cmd.scan->ir_scan, type, buffer, - scan_size) != ERROR_OK) - return ERROR_FAIL; - if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK) - retval = ERROR_JTAG_QUEUE_FAILED; - free(buffer); - break; - case JTAG_SLEEP: - LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); - if (bitbang_interface->flush && (bitbang_interface->flush() != ERROR_OK)) - return ERROR_FAIL; - bitbang_sleep(cmd->cmd.sleep->us); - break; - case JTAG_TMS: - retval = bitbang_execute_tms(cmd); - break; - default: - LOG_ERROR("BUG: unknown JTAG command type encountered"); - exit(-1); + case JTAG_RUNTEST: + LOG_DEBUG_IO("runtest %u cycles, end in %s", + cmd->cmd.runtest->num_cycles, + tap_state_name(cmd->cmd.runtest->end_state)); + bitbang_end_state(cmd->cmd.runtest->end_state); + if (bitbang_runtest(cmd->cmd.runtest->num_cycles) != ERROR_OK) + return ERROR_FAIL; + break; + + case JTAG_STABLECLOCKS: + /* this is only allowed while in a stable state. A check for a stable + * state was done in jtag_add_clocks() + */ + if (bitbang_stableclocks(cmd->cmd.stableclocks->num_cycles) != ERROR_OK) + return ERROR_FAIL; + break; + + case JTAG_TLR_RESET: + LOG_DEBUG_IO("statemove end in %s", + tap_state_name(cmd->cmd.statemove->end_state)); + bitbang_end_state(cmd->cmd.statemove->end_state); + if (bitbang_state_move(0) != ERROR_OK) + return ERROR_FAIL; + break; + case JTAG_PATHMOVE: + LOG_DEBUG_IO("pathmove: %u states, end in %s", + cmd->cmd.pathmove->num_states, + tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1])); + if (bitbang_path_move(cmd->cmd.pathmove) != ERROR_OK) + return ERROR_FAIL; + break; + case JTAG_SCAN: + bitbang_end_state(cmd->cmd.scan->end_state); + scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); + LOG_DEBUG_IO("%s scan %d bits; end in %s", + (cmd->cmd.scan->ir_scan) ? "IR" : "DR", + scan_size, + tap_state_name(cmd->cmd.scan->end_state)); + type = jtag_scan_type(cmd->cmd.scan); + if (bitbang_scan(cmd->cmd.scan->ir_scan, type, buffer, + scan_size) != ERROR_OK) + return ERROR_FAIL; + if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK) + retval = ERROR_JTAG_QUEUE_FAILED; + free(buffer); + break; + case JTAG_SLEEP: + LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); + if (bitbang_interface->flush && (bitbang_interface->flush() != ERROR_OK)) + return ERROR_FAIL; + bitbang_sleep(cmd->cmd.sleep->us); + break; + case JTAG_TMS: + retval = bitbang_execute_tms(cmd); + break; + default: + LOG_ERROR("BUG: unknown JTAG command type encountered"); + exit(-1); } cmd = cmd->next; } diff --git a/src/jtag/drivers/buspirate.c b/src/jtag/drivers/buspirate.c index 4283616ad..7eab94bd0 100644 --- a/src/jtag/drivers/buspirate.c +++ b/src/jtag/drivers/buspirate.c @@ -941,24 +941,24 @@ static void buspirate_swd_set_feature(int fd, char feat, char action) uint8_t tmp[1]; switch (feat) { - case FEATURE_TRST: - LOG_DEBUG("Buspirate TRST feature not available in SWD mode"); - return; - case FEATURE_LED: - LOG_ERROR("Buspirate LED feature not available in SWD mode"); - return; - case FEATURE_SRST: - swd_features = (action == ACTION_ENABLE) ? swd_features | 0x02 : swd_features & 0x0D; - break; - case FEATURE_PULLUP: - swd_features = (action == ACTION_ENABLE) ? swd_features | 0x04 : swd_features & 0x0B; - break; - case FEATURE_VREG: - swd_features = (action == ACTION_ENABLE) ? swd_features | 0x08 : swd_features & 0x07; - break; - default: - LOG_DEBUG("Buspirate unknown feature %d", feat); - return; + case FEATURE_TRST: + LOG_DEBUG("Buspirate TRST feature not available in SWD mode"); + return; + case FEATURE_LED: + LOG_ERROR("Buspirate LED feature not available in SWD mode"); + return; + case FEATURE_SRST: + swd_features = (action == ACTION_ENABLE) ? swd_features | 0x02 : swd_features & 0x0D; + break; + case FEATURE_PULLUP: + swd_features = (action == ACTION_ENABLE) ? swd_features | 0x04 : swd_features & 0x0B; + break; + case FEATURE_VREG: + swd_features = (action == ACTION_ENABLE) ? swd_features | 0x08 : swd_features & 0x07; + break; + default: + LOG_DEBUG("Buspirate unknown feature %d", feat); + return; } tmp[0] = CMD_RAW_PERIPH | swd_features; diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index 3e1a3c5f0..e5e82d13d 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -1566,38 +1566,38 @@ static void debug_parse_cmsis_buf(const uint8_t *cmd, int cmdlen) printf(" %02x", cmd[i]); printf("\n"); switch (cmd[0]) { - case CMD_DAP_JTAG_SEQ: { - printf("cmsis-dap jtag sequence command %02x (n=%d)\n", cmd[0], cmd[1]); - /* - * #1 = number of sequences - * #2 = sequence info 1 - * #3...4+n_bytes-1 = sequence 1 - * #4+n_bytes = sequence info 2 - * #5+n_bytes = sequence 2 (single bit) - */ - int pos = 2; - for (int seq = 0; seq < cmd[1]; ++seq) { - uint8_t info = cmd[pos++]; - int len = info & DAP_JTAG_SEQ_TCK; - if (len == 0) - len = 64; - printf(" sequence %d starting %d: info %02x (len=%d tms=%d read_tdo=%d): ", - seq, pos, info, len, info & DAP_JTAG_SEQ_TMS, info & DAP_JTAG_SEQ_TDO); - for (int i = 0; i < DIV_ROUND_UP(len, 8); ++i) - printf(" %02x", cmd[pos+i]); - pos += DIV_ROUND_UP(len, 8); - printf("\n"); - } - if (pos != cmdlen) { - printf("BUFFER LENGTH MISMATCH looks like %d but %d specified", pos, cmdlen); - exit(-1); - } - - break; + case CMD_DAP_JTAG_SEQ: { + printf("cmsis-dap jtag sequence command %02x (n=%d)\n", cmd[0], cmd[1]); + /* + * #1 = number of sequences + * #2 = sequence info 1 + * #3...4+n_bytes-1 = sequence 1 + * #4+n_bytes = sequence info 2 + * #5+n_bytes = sequence 2 (single bit) + */ + int pos = 2; + for (int seq = 0; seq < cmd[1]; ++seq) { + uint8_t info = cmd[pos++]; + int len = info & DAP_JTAG_SEQ_TCK; + if (len == 0) + len = 64; + printf(" sequence %d starting %d: info %02x (len=%d tms=%d read_tdo=%d): ", + seq, pos, info, len, info & DAP_JTAG_SEQ_TMS, info & DAP_JTAG_SEQ_TDO); + for (int i = 0; i < DIV_ROUND_UP(len, 8); ++i) + printf(" %02x", cmd[pos + i]); + pos += DIV_ROUND_UP(len, 8); + printf("\n"); } - default: - LOG_DEBUG("unknown cmsis-dap command %02x", cmd[1]); - break; + if (pos != cmdlen) { + printf("BUFFER LENGTH MISMATCH looks like %d but %d specified", pos, cmdlen); + exit(-1); + } + + break; + } + default: + LOG_DEBUG("unknown cmsis-dap command %02x", cmd[1]); + break; } } #endif @@ -1938,32 +1938,32 @@ static void cmsis_dap_execute_tms(struct jtag_command *cmd) static void cmsis_dap_execute_command(struct jtag_command *cmd) { switch (cmd->type) { - case JTAG_SLEEP: - cmsis_dap_flush(); - cmsis_dap_execute_sleep(cmd); - break; - case JTAG_TLR_RESET: - cmsis_dap_flush(); - cmsis_dap_execute_tlr_reset(cmd); - break; - case JTAG_SCAN: - cmsis_dap_execute_scan(cmd); - break; - case JTAG_PATHMOVE: - cmsis_dap_execute_pathmove(cmd); - break; - case JTAG_RUNTEST: - cmsis_dap_execute_runtest(cmd); - break; - case JTAG_STABLECLOCKS: - cmsis_dap_execute_stableclocks(cmd); - break; - case JTAG_TMS: - cmsis_dap_execute_tms(cmd); - break; - default: - LOG_ERROR("BUG: unknown JTAG command type 0x%X encountered", cmd->type); - exit(-1); + case JTAG_SLEEP: + cmsis_dap_flush(); + cmsis_dap_execute_sleep(cmd); + break; + case JTAG_TLR_RESET: + cmsis_dap_flush(); + cmsis_dap_execute_tlr_reset(cmd); + break; + case JTAG_SCAN: + cmsis_dap_execute_scan(cmd); + break; + case JTAG_PATHMOVE: + cmsis_dap_execute_pathmove(cmd); + break; + case JTAG_RUNTEST: + cmsis_dap_execute_runtest(cmd); + break; + case JTAG_STABLECLOCKS: + cmsis_dap_execute_stableclocks(cmd); + break; + case JTAG_TMS: + cmsis_dap_execute_tms(cmd); + break; + default: + LOG_ERROR("BUG: unknown JTAG command type 0x%X encountered", cmd->type); + exit(-1); } } diff --git a/src/jtag/drivers/dmem.c b/src/jtag/drivers/dmem.c index c1eb5b80d..0f1b58299 100644 --- a/src/jtag/drivers/dmem.c +++ b/src/jtag/drivers/dmem.c @@ -118,41 +118,41 @@ static int dmem_emu_ap_q_read(unsigned int ap_idx, unsigned int reg, uint32_t *d struct dmem_emu_ap_info *ap_info = &dmem_emu_ap_list[ap_idx]; switch (reg) { - case ADIV5_MEM_AP_REG_CSW: - *data = ap_info->apbap_csw; - break; - case ADIV5_MEM_AP_REG_TAR: - *data = ap_info->apbap_tar; - break; - case ADIV5_MEM_AP_REG_CFG: - *data = 0; - break; - case ADIV5_MEM_AP_REG_BASE: - *data = 0; - break; - case ADIV5_AP_REG_IDR: - *data = 0; - break; - case ADIV5_MEM_AP_REG_BD0: - case ADIV5_MEM_AP_REG_BD1: - case ADIV5_MEM_AP_REG_BD2: - case ADIV5_MEM_AP_REG_BD3: - addr = (ap_info->apbap_tar & ~0xf) + (reg & 0x0C); - - *data = dmem_emu_get_ap_reg(addr); - - break; - case ADIV5_MEM_AP_REG_DRW: - addr = ap_info->apbap_tar; - - *data = dmem_emu_get_ap_reg(addr); - - ap_info->apbap_tar += dmem_memap_tar_inc(ap_info->apbap_csw); - break; - default: - LOG_INFO("%s: Unknown reg: 0x%02x", __func__, reg); - ret = ERROR_FAIL; - break; + case ADIV5_MEM_AP_REG_CSW: + *data = ap_info->apbap_csw; + break; + case ADIV5_MEM_AP_REG_TAR: + *data = ap_info->apbap_tar; + break; + case ADIV5_MEM_AP_REG_CFG: + *data = 0; + break; + case ADIV5_MEM_AP_REG_BASE: + *data = 0; + break; + case ADIV5_AP_REG_IDR: + *data = 0; + break; + case ADIV5_MEM_AP_REG_BD0: + case ADIV5_MEM_AP_REG_BD1: + case ADIV5_MEM_AP_REG_BD2: + case ADIV5_MEM_AP_REG_BD3: + addr = (ap_info->apbap_tar & ~0xf) + (reg & 0x0C); + + *data = dmem_emu_get_ap_reg(addr); + + break; + case ADIV5_MEM_AP_REG_DRW: + addr = ap_info->apbap_tar; + + *data = dmem_emu_get_ap_reg(addr); + + ap_info->apbap_tar += dmem_memap_tar_inc(ap_info->apbap_csw); + break; + default: + LOG_INFO("%s: Unknown reg: 0x%02x", __func__, reg); + ret = ERROR_FAIL; + break; } /* Track the last error code. */ @@ -169,46 +169,46 @@ static int dmem_emu_ap_q_write(unsigned int ap_idx, unsigned int reg, uint32_t d struct dmem_emu_ap_info *ap_info = &dmem_emu_ap_list[ap_idx]; switch (reg) { - case ADIV5_MEM_AP_REG_CSW: - /* - * This implementation only supports 32-bit accesses. - * Force this by ensuring CSW_SIZE field indicates 32-BIT. - */ - ap_info->apbap_csw = ((data & ~CSW_SIZE_MASK) | CSW_32BIT); - break; - case ADIV5_MEM_AP_REG_TAR: - /* - * This implementation only supports 32-bit accesses. - * Force LS 2-bits of TAR to 00b - */ - ap_info->apbap_tar = (data & ~0x3); - break; - - case ADIV5_MEM_AP_REG_CFG: - case ADIV5_MEM_AP_REG_BASE: - case ADIV5_AP_REG_IDR: - /* We don't use this, so we don't need to store */ - break; - - case ADIV5_MEM_AP_REG_BD0: - case ADIV5_MEM_AP_REG_BD1: - case ADIV5_MEM_AP_REG_BD2: - case ADIV5_MEM_AP_REG_BD3: - addr = (ap_info->apbap_tar & ~0xf) + (reg & 0x0C); - - dmem_emu_set_ap_reg(addr, data); - - break; - case ADIV5_MEM_AP_REG_DRW: - addr = ap_info->apbap_tar; - dmem_emu_set_ap_reg(addr, data); - - ap_info->apbap_tar += dmem_memap_tar_inc(ap_info->apbap_csw); - break; - default: - LOG_INFO("%s: Unknown reg: 0x%02x", __func__, reg); - ret = EINVAL; - break; + case ADIV5_MEM_AP_REG_CSW: + /* + * This implementation only supports 32-bit accesses. + * Force this by ensuring CSW_SIZE field indicates 32-BIT. + */ + ap_info->apbap_csw = ((data & ~CSW_SIZE_MASK) | CSW_32BIT); + break; + case ADIV5_MEM_AP_REG_TAR: + /* + * This implementation only supports 32-bit accesses. + * Force LS 2-bits of TAR to 00b + */ + ap_info->apbap_tar = (data & ~0x3); + break; + + case ADIV5_MEM_AP_REG_CFG: + case ADIV5_MEM_AP_REG_BASE: + case ADIV5_AP_REG_IDR: + /* We don't use this, so we don't need to store */ + break; + + case ADIV5_MEM_AP_REG_BD0: + case ADIV5_MEM_AP_REG_BD1: + case ADIV5_MEM_AP_REG_BD2: + case ADIV5_MEM_AP_REG_BD3: + addr = (ap_info->apbap_tar & ~0xf) + (reg & 0x0C); + + dmem_emu_set_ap_reg(addr, data); + + break; + case ADIV5_MEM_AP_REG_DRW: + addr = ap_info->apbap_tar; + dmem_emu_set_ap_reg(addr, data); + + ap_info->apbap_tar += dmem_memap_tar_inc(ap_info->apbap_csw); + break; + default: + LOG_INFO("%s: Unknown reg: 0x%02x", __func__, reg); + ret = EINVAL; + break; } /* Track the last error code. */ @@ -242,13 +242,13 @@ static int dmem_dp_q_read(struct adiv5_dap *dap, unsigned int reg, uint32_t *dat return ERROR_OK; switch (reg) { - case DP_CTRL_STAT: - *data = CDBGPWRUPACK | CSYSPWRUPACK; - break; + case DP_CTRL_STAT: + *data = CDBGPWRUPACK | CSYSPWRUPACK; + break; - default: - *data = 0; - break; + default: + *data = 0; + break; } return ERROR_OK; diff --git a/src/jtag/drivers/ft232r.c b/src/jtag/drivers/ft232r.c index 8f7ae13d6..5bd934c38 100644 --- a/src/jtag/drivers/ft232r.c +++ b/src/jtag/drivers/ft232r.c @@ -818,71 +818,71 @@ static int syncbb_execute_queue(struct jtag_command *cmd_queue) while (cmd) { switch (cmd->type) { - case JTAG_RESET: - LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); - - if (cmd->cmd.reset->trst == 1 || - (cmd->cmd.reset->srst && - (jtag_get_reset_config() & RESET_SRST_PULLS_TRST))) - tap_set_state(TAP_RESET); - - ft232r_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); - break; - - case JTAG_RUNTEST: - LOG_DEBUG_IO("runtest %u cycles, end in %s", cmd->cmd.runtest->num_cycles, - tap_state_name(cmd->cmd.runtest->end_state)); - - syncbb_end_state(cmd->cmd.runtest->end_state); - syncbb_runtest(cmd->cmd.runtest->num_cycles); - break; - - case JTAG_STABLECLOCKS: - /* this is only allowed while in a stable state. A check for a stable - * state was done in jtag_add_clocks() - */ - syncbb_stableclocks(cmd->cmd.stableclocks->num_cycles); - break; - - case JTAG_TLR_RESET: /* renamed from JTAG_STATEMOVE */ - LOG_DEBUG_IO("statemove end in %s", tap_state_name(cmd->cmd.statemove->end_state)); - - syncbb_end_state(cmd->cmd.statemove->end_state); - syncbb_state_move(0); - break; - - case JTAG_PATHMOVE: - LOG_DEBUG_IO("pathmove: %u states, end in %s", cmd->cmd.pathmove->num_states, - tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1])); - - syncbb_path_move(cmd->cmd.pathmove); - break; - - case JTAG_SCAN: - LOG_DEBUG_IO("%s scan end in %s", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", - tap_state_name(cmd->cmd.scan->end_state)); - - syncbb_end_state(cmd->cmd.scan->end_state); - scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); - type = jtag_scan_type(cmd->cmd.scan); - syncbb_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size); - if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK) - retval = ERROR_JTAG_QUEUE_FAILED; - free(buffer); - break; - - case JTAG_SLEEP: - LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); - - jtag_sleep(cmd->cmd.sleep->us); - break; - - case JTAG_TMS: - retval = syncbb_execute_tms(cmd); - break; - default: - LOG_ERROR("BUG: unknown JTAG command type encountered"); - exit(-1); + case JTAG_RESET: + LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); + + if (cmd->cmd.reset->trst == 1 || + (cmd->cmd.reset->srst && + (jtag_get_reset_config() & RESET_SRST_PULLS_TRST))) + tap_set_state(TAP_RESET); + + ft232r_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); + break; + + case JTAG_RUNTEST: + LOG_DEBUG_IO("runtest %u cycles, end in %s", cmd->cmd.runtest->num_cycles, + tap_state_name(cmd->cmd.runtest->end_state)); + + syncbb_end_state(cmd->cmd.runtest->end_state); + syncbb_runtest(cmd->cmd.runtest->num_cycles); + break; + + case JTAG_STABLECLOCKS: + /* this is only allowed while in a stable state. A check for a stable + * state was done in jtag_add_clocks() + */ + syncbb_stableclocks(cmd->cmd.stableclocks->num_cycles); + break; + + case JTAG_TLR_RESET: /* renamed from JTAG_STATEMOVE */ + LOG_DEBUG_IO("statemove end in %s", tap_state_name(cmd->cmd.statemove->end_state)); + + syncbb_end_state(cmd->cmd.statemove->end_state); + syncbb_state_move(0); + break; + + case JTAG_PATHMOVE: + LOG_DEBUG_IO("pathmove: %u states, end in %s", cmd->cmd.pathmove->num_states, + tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1])); + + syncbb_path_move(cmd->cmd.pathmove); + break; + + case JTAG_SCAN: + LOG_DEBUG_IO("%s scan end in %s", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", + tap_state_name(cmd->cmd.scan->end_state)); + + syncbb_end_state(cmd->cmd.scan->end_state); + scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); + type = jtag_scan_type(cmd->cmd.scan); + syncbb_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size); + if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK) + retval = ERROR_JTAG_QUEUE_FAILED; + free(buffer); + break; + + case JTAG_SLEEP: + LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); + + jtag_sleep(cmd->cmd.sleep->us); + break; + + case JTAG_TMS: + retval = syncbb_execute_tms(cmd); + break; + default: + LOG_ERROR("BUG: unknown JTAG command type encountered"); + exit(-1); } if (ft232r_output_len > 0) ft232r_send_recv(); diff --git a/src/jtag/drivers/ftdi.c b/src/jtag/drivers/ftdi.c index a8f6f6015..00b3d198b 100644 --- a/src/jtag/drivers/ftdi.c +++ b/src/jtag/drivers/ftdi.c @@ -597,30 +597,30 @@ static void ftdi_execute_stableclocks(struct jtag_command *cmd) static void ftdi_execute_command(struct jtag_command *cmd) { switch (cmd->type) { - case JTAG_RUNTEST: - ftdi_execute_runtest(cmd); - break; - case JTAG_TLR_RESET: - ftdi_execute_statemove(cmd); - break; - case JTAG_PATHMOVE: - ftdi_execute_pathmove(cmd); - break; - case JTAG_SCAN: - ftdi_execute_scan(cmd); - break; - case JTAG_SLEEP: - ftdi_execute_sleep(cmd); - break; - case JTAG_STABLECLOCKS: - ftdi_execute_stableclocks(cmd); - break; - case JTAG_TMS: - ftdi_execute_tms(cmd); - break; - default: - LOG_ERROR("BUG: unknown JTAG command type encountered: %d", cmd->type); - break; + case JTAG_RUNTEST: + ftdi_execute_runtest(cmd); + break; + case JTAG_TLR_RESET: + ftdi_execute_statemove(cmd); + break; + case JTAG_PATHMOVE: + ftdi_execute_pathmove(cmd); + break; + case JTAG_SCAN: + ftdi_execute_scan(cmd); + break; + case JTAG_SLEEP: + ftdi_execute_sleep(cmd); + break; + case JTAG_STABLECLOCKS: + ftdi_execute_stableclocks(cmd); + break; + case JTAG_TMS: + ftdi_execute_tms(cmd); + break; + default: + LOG_ERROR("BUG: unknown JTAG command type encountered: %d", cmd->type); + break; } } diff --git a/src/jtag/drivers/gw16012.c b/src/jtag/drivers/gw16012.c index 98f775422..f6ae684f7 100644 --- a/src/jtag/drivers/gw16012.c +++ b/src/jtag/drivers/gw16012.c @@ -284,46 +284,46 @@ static int gw16012_execute_queue(struct jtag_command *cmd_queue) while (cmd) { switch (cmd->type) { - case JTAG_RESET: - LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); - if (cmd->cmd.reset->trst == 1) - tap_set_state(TAP_RESET); - gw16012_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); - break; - case JTAG_RUNTEST: - LOG_DEBUG_IO("runtest %u cycles, end in %i", cmd->cmd.runtest->num_cycles, - cmd->cmd.runtest->end_state); - gw16012_end_state(cmd->cmd.runtest->end_state); - gw16012_runtest(cmd->cmd.runtest->num_cycles); - break; - case JTAG_TLR_RESET: - LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state); - gw16012_end_state(cmd->cmd.statemove->end_state); - gw16012_state_move(); - break; - case JTAG_PATHMOVE: - LOG_DEBUG_IO("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, - cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); - gw16012_path_move(cmd->cmd.pathmove); - break; - case JTAG_SCAN: - gw16012_end_state(cmd->cmd.scan->end_state); - scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); - type = jtag_scan_type(cmd->cmd.scan); - LOG_DEBUG_IO("%s scan (%i) %i bit end in %i", (cmd->cmd.scan->ir_scan) ? "ir" : "dr", - type, scan_size, cmd->cmd.scan->end_state); - gw16012_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size); - if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK) - retval = ERROR_JTAG_QUEUE_FAILED; - free(buffer); - break; - case JTAG_SLEEP: - LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); - jtag_sleep(cmd->cmd.sleep->us); - break; - default: - LOG_ERROR("BUG: unknown JTAG command type encountered"); - exit(-1); + case JTAG_RESET: + LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); + if (cmd->cmd.reset->trst == 1) + tap_set_state(TAP_RESET); + gw16012_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); + break; + case JTAG_RUNTEST: + LOG_DEBUG_IO("runtest %u cycles, end in %i", cmd->cmd.runtest->num_cycles, + cmd->cmd.runtest->end_state); + gw16012_end_state(cmd->cmd.runtest->end_state); + gw16012_runtest(cmd->cmd.runtest->num_cycles); + break; + case JTAG_TLR_RESET: + LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state); + gw16012_end_state(cmd->cmd.statemove->end_state); + gw16012_state_move(); + break; + case JTAG_PATHMOVE: + LOG_DEBUG_IO("pathmove: %i states, end in %i", cmd->cmd.pathmove->num_states, + cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); + gw16012_path_move(cmd->cmd.pathmove); + break; + case JTAG_SCAN: + gw16012_end_state(cmd->cmd.scan->end_state); + scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); + type = jtag_scan_type(cmd->cmd.scan); + LOG_DEBUG_IO("%s scan (%i) %i bit end in %i", (cmd->cmd.scan->ir_scan) ? "ir" : "dr", + type, scan_size, cmd->cmd.scan->end_state); + gw16012_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size); + if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK) + retval = ERROR_JTAG_QUEUE_FAILED; + free(buffer); + break; + case JTAG_SLEEP: + LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); + jtag_sleep(cmd->cmd.sleep->us); + break; + default: + LOG_ERROR("BUG: unknown JTAG command type encountered"); + exit(-1); } cmd = cmd->next; } diff --git a/src/jtag/drivers/jlink.c b/src/jtag/drivers/jlink.c index b8716fa9a..46afa862d 100644 --- a/src/jtag/drivers/jlink.c +++ b/src/jtag/drivers/jlink.c @@ -249,27 +249,27 @@ static void jlink_execute_sleep(struct jtag_command *cmd) static int jlink_execute_command(struct jtag_command *cmd) { switch (cmd->type) { - case JTAG_STABLECLOCKS: - jlink_execute_stableclocks(cmd); - break; - case JTAG_RUNTEST: - jlink_execute_runtest(cmd); - break; - case JTAG_TLR_RESET: - jlink_execute_statemove(cmd); - break; - case JTAG_PATHMOVE: - jlink_execute_pathmove(cmd); - break; - case JTAG_SCAN: - jlink_execute_scan(cmd); - break; - case JTAG_SLEEP: - jlink_execute_sleep(cmd); - break; - default: - LOG_ERROR("BUG: Unknown JTAG command type encountered"); - return ERROR_JTAG_QUEUE_FAILED; + case JTAG_STABLECLOCKS: + jlink_execute_stableclocks(cmd); + break; + case JTAG_RUNTEST: + jlink_execute_runtest(cmd); + break; + case JTAG_TLR_RESET: + jlink_execute_statemove(cmd); + break; + case JTAG_PATHMOVE: + jlink_execute_pathmove(cmd); + break; + case JTAG_SCAN: + jlink_execute_scan(cmd); + break; + case JTAG_SLEEP: + jlink_execute_sleep(cmd); + break; + default: + LOG_ERROR("BUG: Unknown JTAG command type encountered"); + return ERROR_JTAG_QUEUE_FAILED; } return ERROR_OK; @@ -2118,44 +2118,44 @@ static int jlink_swd_switch_seq(enum swd_special_seq seq) unsigned int s_len; switch (seq) { - case LINE_RESET: - LOG_DEBUG_IO("SWD line reset"); - s = swd_seq_line_reset; - s_len = swd_seq_line_reset_len; - break; - case JTAG_TO_SWD: - LOG_DEBUG("JTAG-to-SWD"); - s = swd_seq_jtag_to_swd; - s_len = swd_seq_jtag_to_swd_len; - break; - case JTAG_TO_DORMANT: - LOG_DEBUG("JTAG-to-DORMANT"); - s = swd_seq_jtag_to_dormant; - s_len = swd_seq_jtag_to_dormant_len; - break; - case SWD_TO_JTAG: - LOG_DEBUG("SWD-to-JTAG"); - s = swd_seq_swd_to_jtag; - s_len = swd_seq_swd_to_jtag_len; - break; - case SWD_TO_DORMANT: - LOG_DEBUG("SWD-to-DORMANT"); - s = swd_seq_swd_to_dormant; - s_len = swd_seq_swd_to_dormant_len; - break; - case DORMANT_TO_SWD: - LOG_DEBUG("DORMANT-to-SWD"); - s = swd_seq_dormant_to_swd; - s_len = swd_seq_dormant_to_swd_len; - break; - case DORMANT_TO_JTAG: - LOG_DEBUG("DORMANT-to-JTAG"); - s = swd_seq_dormant_to_jtag; - s_len = swd_seq_dormant_to_jtag_len; - break; - default: - LOG_ERROR("Sequence %d not supported", seq); - return ERROR_FAIL; + case LINE_RESET: + LOG_DEBUG_IO("SWD line reset"); + s = swd_seq_line_reset; + s_len = swd_seq_line_reset_len; + break; + case JTAG_TO_SWD: + LOG_DEBUG("JTAG-to-SWD"); + s = swd_seq_jtag_to_swd; + s_len = swd_seq_jtag_to_swd_len; + break; + case JTAG_TO_DORMANT: + LOG_DEBUG("JTAG-to-DORMANT"); + s = swd_seq_jtag_to_dormant; + s_len = swd_seq_jtag_to_dormant_len; + break; + case SWD_TO_JTAG: + LOG_DEBUG("SWD-to-JTAG"); + s = swd_seq_swd_to_jtag; + s_len = swd_seq_swd_to_jtag_len; + break; + case SWD_TO_DORMANT: + LOG_DEBUG("SWD-to-DORMANT"); + s = swd_seq_swd_to_dormant; + s_len = swd_seq_swd_to_dormant_len; + break; + case DORMANT_TO_SWD: + LOG_DEBUG("DORMANT-to-SWD"); + s = swd_seq_dormant_to_swd; + s_len = swd_seq_dormant_to_swd_len; + break; + case DORMANT_TO_JTAG: + LOG_DEBUG("DORMANT-to-JTAG"); + s = swd_seq_dormant_to_jtag; + s_len = swd_seq_dormant_to_jtag_len; + break; + default: + LOG_ERROR("Sequence %d not supported", seq); + return ERROR_FAIL; } jlink_queue_data_out(s, s_len); diff --git a/src/jtag/drivers/kitprog.c b/src/jtag/drivers/kitprog.c index 2bb4d17da..f79e2dca7 100644 --- a/src/jtag/drivers/kitprog.c +++ b/src/jtag/drivers/kitprog.c @@ -646,24 +646,24 @@ static void kitprog_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay static int kitprog_swd_switch_seq(enum swd_special_seq seq) { switch (seq) { - case JTAG_TO_SWD: - if (kitprog_handle->supports_jtag_to_swd) { - LOG_DEBUG("JTAG to SWD"); - if (kitprog_swd_seq(SEQUENCE_JTAG_TO_SWD) != ERROR_OK) - return ERROR_FAIL; - break; - } - LOG_DEBUG("JTAG to SWD not supported"); - /* Fall through to fix target reset issue */ - /* fallthrough */ - case LINE_RESET: - LOG_DEBUG("SWD line reset"); - if (kitprog_swd_seq(SEQUENCE_LINE_RESET) != ERROR_OK) + case JTAG_TO_SWD: + if (kitprog_handle->supports_jtag_to_swd) { + LOG_DEBUG("JTAG to SWD"); + if (kitprog_swd_seq(SEQUENCE_JTAG_TO_SWD) != ERROR_OK) return ERROR_FAIL; break; - default: - LOG_ERROR("Sequence %d not supported.", seq); + } + LOG_DEBUG("JTAG to SWD not supported"); + /* Fall through to fix target reset issue */ + /* fallthrough */ + case LINE_RESET: + LOG_DEBUG("SWD line reset"); + if (kitprog_swd_seq(SEQUENCE_LINE_RESET) != ERROR_OK) return ERROR_FAIL; + break; + default: + LOG_ERROR("Sequence %d not supported.", seq); + return ERROR_FAIL; } return ERROR_OK; diff --git a/src/jtag/drivers/opendous.c b/src/jtag/drivers/opendous.c index 04626cb1e..4b5981ab5 100644 --- a/src/jtag/drivers/opendous.c +++ b/src/jtag/drivers/opendous.c @@ -173,26 +173,26 @@ COMMAND_HANDLER(opendous_handle_opendous_info_command) COMMAND_HANDLER(opendous_handle_opendous_hw_jtag_command) { switch (CMD_ARGC) { - case 0: - command_print(CMD, "opendous hw jtag %i", opendous_hw_jtag_version); + case 0: + command_print(CMD, "opendous hw jtag %i", opendous_hw_jtag_version); + break; + + case 1: { + int request_version = atoi(CMD_ARGV[0]); + switch (request_version) { + case 2: + case 3: + opendous_hw_jtag_version = request_version; break; - case 1: { - int request_version = atoi(CMD_ARGV[0]); - switch (request_version) { - case 2: - case 3: - opendous_hw_jtag_version = request_version; - break; - - default: - return ERROR_COMMAND_SYNTAX_ERROR; - } - break; - } - default: return ERROR_COMMAND_SYNTAX_ERROR; + } + break; + } + + default: + return ERROR_COMMAND_SYNTAX_ERROR; } return ERROR_OK; @@ -248,66 +248,66 @@ static int opendous_execute_queue(struct jtag_command *cmd_queue) while (cmd) { switch (cmd->type) { - case JTAG_RUNTEST: - LOG_DEBUG_IO("runtest %u cycles, end in %i", cmd->cmd.runtest->num_cycles, - cmd->cmd.runtest->end_state); + case JTAG_RUNTEST: + LOG_DEBUG_IO("runtest %u cycles, end in %i", cmd->cmd.runtest->num_cycles, + cmd->cmd.runtest->end_state); - if (cmd->cmd.runtest->end_state != -1) - opendous_end_state(cmd->cmd.runtest->end_state); - opendous_runtest(cmd->cmd.runtest->num_cycles); - break; + if (cmd->cmd.runtest->end_state != -1) + opendous_end_state(cmd->cmd.runtest->end_state); + opendous_runtest(cmd->cmd.runtest->num_cycles); + break; - case JTAG_TLR_RESET: - LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state); + case JTAG_TLR_RESET: + LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state); - if (cmd->cmd.statemove->end_state != -1) - opendous_end_state(cmd->cmd.statemove->end_state); - opendous_state_move(); - break; + if (cmd->cmd.statemove->end_state != -1) + opendous_end_state(cmd->cmd.statemove->end_state); + opendous_state_move(); + break; - case JTAG_PATHMOVE: - LOG_DEBUG_IO("pathmove: %u states, end in %i", - cmd->cmd.pathmove->num_states, - cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); + case JTAG_PATHMOVE: + LOG_DEBUG_IO("pathmove: %u states, end in %i", + cmd->cmd.pathmove->num_states, + cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); - opendous_path_move(cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path); - break; + opendous_path_move(cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path); + break; - case JTAG_SCAN: - LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state); + case JTAG_SCAN: + LOG_DEBUG_IO("scan end in %i", cmd->cmd.scan->end_state); - if (cmd->cmd.scan->end_state != -1) - opendous_end_state(cmd->cmd.scan->end_state); + if (cmd->cmd.scan->end_state != -1) + opendous_end_state(cmd->cmd.scan->end_state); - scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); - LOG_DEBUG_IO("scan input, length = %d", scan_size); + scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); + LOG_DEBUG_IO("scan input, length = %d", scan_size); #ifdef _DEBUG_USB_COMMS_ - opendous_debug_buffer(buffer, (scan_size + 7) / 8); + opendous_debug_buffer(buffer, (scan_size + 7) / 8); #endif - type = jtag_scan_type(cmd->cmd.scan); - opendous_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size, cmd->cmd.scan); - break; + type = jtag_scan_type(cmd->cmd.scan); + opendous_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size, cmd->cmd.scan); + break; - case JTAG_RESET: - LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); + case JTAG_RESET: + LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); - opendous_tap_execute(); + opendous_tap_execute(); - if (cmd->cmd.reset->trst == 1) - tap_set_state(TAP_RESET); - opendous_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); - break; + if (cmd->cmd.reset->trst == 1) + tap_set_state(TAP_RESET); + opendous_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); + break; - case JTAG_SLEEP: - LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); - opendous_tap_execute(); - jtag_sleep(cmd->cmd.sleep->us); - break; + case JTAG_SLEEP: + LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); + opendous_tap_execute(); + jtag_sleep(cmd->cmd.sleep->us); + break; - default: - LOG_ERROR("BUG: unknown JTAG command type encountered"); - exit(-1); + default: + LOG_ERROR("BUG: unknown JTAG command type encountered"); + exit(-1); } cmd = cmd->next; } diff --git a/src/jtag/drivers/openjtag.c b/src/jtag/drivers/openjtag.c index 943ad854e..d45a1c6a9 100644 --- a/src/jtag/drivers/openjtag.c +++ b/src/jtag/drivers/openjtag.c @@ -135,36 +135,36 @@ static void openjtag_debug_buffer(uint8_t *buffer, int length, uint8_t type) int j; switch (type) { + case DEBUG_TYPE_READ: + sprintf(line, "USB READ %d bytes", length); + break; + case DEBUG_TYPE_WRITE: + sprintf(line, "USB WRITE %d bytes", length); + break; + case DEBUG_TYPE_OCD_READ: + sprintf(line, "TO OpenOCD %d bytes", length); + break; + case DEBUG_TYPE_BUFFER: + sprintf(line, "Buffer %d bytes", length); + break; + } + + LOG_DEBUG("%s", line); + + for (i = 0; i < length; i += LINE_LEN) { + switch (type) { case DEBUG_TYPE_READ: - sprintf(line, "USB READ %d bytes", length); + sprintf(line, "USB READ: %04x", i); break; case DEBUG_TYPE_WRITE: - sprintf(line, "USB WRITE %d bytes", length); + sprintf(line, "USB WRITE: %04x", i); break; case DEBUG_TYPE_OCD_READ: - sprintf(line, "TO OpenOCD %d bytes", length); + sprintf(line, "TO OpenOCD: %04x", i); break; case DEBUG_TYPE_BUFFER: - sprintf(line, "Buffer %d bytes", length); + sprintf(line, "BUFFER: %04x", i); break; - } - - LOG_DEBUG("%s", line); - - for (i = 0; i < length; i += LINE_LEN) { - switch (type) { - case DEBUG_TYPE_READ: - sprintf(line, "USB READ: %04x", i); - break; - case DEBUG_TYPE_WRITE: - sprintf(line, "USB WRITE: %04x", i); - break; - case DEBUG_TYPE_OCD_READ: - sprintf(line, "TO OpenOCD: %04x", i); - break; - case DEBUG_TYPE_BUFFER: - sprintf(line, "BUFFER: %04x", i); - break; } for (j = i; j < i + LINE_LEN && j < length; j++) { @@ -182,24 +182,24 @@ static int8_t openjtag_get_tap_state(int8_t state) { switch (state) { - case TAP_DREXIT2: return OPENJTAG_TAP_EXIT2_DR; - case TAP_DREXIT1: return OPENJTAG_TAP_EXIT1_DR; - case TAP_DRSHIFT: return OPENJTAG_TAP_SHIFT_DR; - case TAP_DRPAUSE: return OPENJTAG_TAP_PAUSE_DR; - case TAP_IRSELECT: return OPENJTAG_TAP_SELECT_IR; - case TAP_DRUPDATE: return OPENJTAG_TAP_UPDATE_DR; - case TAP_DRCAPTURE: return OPENJTAG_TAP_CAPTURE_DR; - case TAP_DRSELECT: return OPENJTAG_TAP_SELECT_DR; - case TAP_IREXIT2: return OPENJTAG_TAP_EXIT2_IR; - case TAP_IREXIT1: return OPENJTAG_TAP_EXIT1_IR; - case TAP_IRSHIFT: return OPENJTAG_TAP_SHIFT_IR; - case TAP_IRPAUSE: return OPENJTAG_TAP_PAUSE_IR; - case TAP_IDLE: return OPENJTAG_TAP_IDLE; - case TAP_IRUPDATE: return OPENJTAG_TAP_UPDATE_IR; - case TAP_IRCAPTURE: return OPENJTAG_TAP_CAPURE_IR; - case TAP_RESET: return OPENJTAG_TAP_RESET; - case TAP_INVALID: - default: return OPENJTAG_TAP_INVALID; + case TAP_DREXIT2: return OPENJTAG_TAP_EXIT2_DR; + case TAP_DREXIT1: return OPENJTAG_TAP_EXIT1_DR; + case TAP_DRSHIFT: return OPENJTAG_TAP_SHIFT_DR; + case TAP_DRPAUSE: return OPENJTAG_TAP_PAUSE_DR; + case TAP_IRSELECT: return OPENJTAG_TAP_SELECT_IR; + case TAP_DRUPDATE: return OPENJTAG_TAP_UPDATE_DR; + case TAP_DRCAPTURE: return OPENJTAG_TAP_CAPTURE_DR; + case TAP_DRSELECT: return OPENJTAG_TAP_SELECT_DR; + case TAP_IREXIT2: return OPENJTAG_TAP_EXIT2_IR; + case TAP_IREXIT1: return OPENJTAG_TAP_EXIT1_IR; + case TAP_IRSHIFT: return OPENJTAG_TAP_SHIFT_IR; + case TAP_IRPAUSE: return OPENJTAG_TAP_PAUSE_IR; + case TAP_IDLE: return OPENJTAG_TAP_IDLE; + case TAP_IRUPDATE: return OPENJTAG_TAP_UPDATE_IR; + case TAP_IRCAPTURE: return OPENJTAG_TAP_CAPURE_IR; + case TAP_RESET: return OPENJTAG_TAP_RESET; + case TAP_INVALID: + default: return OPENJTAG_TAP_INVALID; } } @@ -347,34 +347,34 @@ static int openjtag_speed(int speed) { int clockcmd; switch (speed) { - case 48000: - clockcmd = 0x00; - break; - case 24000: - clockcmd = 0x20; - break; - case 12000: - clockcmd = 0x40; - break; - case 6000: - clockcmd = 0x60; - break; - case 3000: - clockcmd = 0x80; - break; - case 1500: - clockcmd = 0xA0; - break; - case 750: - clockcmd = 0xC0; - break; - case 375: - clockcmd = 0xE0; - break; - default: - clockcmd = 0xE0; - LOG_WARNING("adapter speed not recognized, reverting to 375 kHz"); - break; + case 48000: + clockcmd = 0x00; + break; + case 24000: + clockcmd = 0x20; + break; + case 12000: + clockcmd = 0x40; + break; + case 6000: + clockcmd = 0x60; + break; + case 3000: + clockcmd = 0x80; + break; + case 1500: + clockcmd = 0xA0; + break; + case 750: + clockcmd = 0xC0; + break; + case 375: + clockcmd = 0xE0; + break; + default: + clockcmd = 0xE0; + LOG_WARNING("adapter speed not recognized, reverting to 375 kHz"); + break; } openjtag_sendcommand(clockcmd); diff --git a/src/jtag/drivers/remote_bitbang.c b/src/jtag/drivers/remote_bitbang.c index 449c61654..71ec572b3 100644 --- a/src/jtag/drivers/remote_bitbang.c +++ b/src/jtag/drivers/remote_bitbang.c @@ -179,14 +179,14 @@ static int remote_bitbang_quit(void) static enum bb_value char_to_int(int c) { switch (c) { - case '0': - return BB_LOW; - case '1': - return BB_HIGH; - default: - remote_bitbang_quit(); - LOG_ERROR("remote_bitbang: invalid read response: %c(%i)", c, c); - return BB_ERROR; + case '0': + return BB_LOW; + case '1': + return BB_HIGH; + default: + remote_bitbang_quit(); + LOG_ERROR("remote_bitbang: invalid read response: %c(%i)", c, c); + return BB_ERROR; } } diff --git a/src/jtag/drivers/rlink.c b/src/jtag/drivers/rlink.c index 9622740c6..83c6d6853 100644 --- a/src/jtag/drivers/rlink.c +++ b/src/jtag/drivers/rlink.c @@ -321,53 +321,53 @@ static int dtc_load_from_buffer(struct libusb_device_handle *hdev_param, const u } switch (header->type) { - case DTCLOAD_COMMENT: - break; - - case DTCLOAD_ENTRY: - /* store entry addresses somewhere */ - if (!strncmp("download", (char *)buffer + 1, 8)) - dtc_entry_download = buffer[0]; - break; - - case DTCLOAD_LOAD: - /* Send the DTC program to ST7 RAM. */ - usb_err = ep1_memory_write(hdev_param, DTC_LOAD_BUFFER, - header->length + 1, buffer); - if (usb_err < 0) - return usb_err; - - /* Load it into the DTC. */ - usb_err = ep1_generic_commandl(hdev_param, 3, EP1_CMD_DTC_LOAD, - (DTC_LOAD_BUFFER >> 8), DTC_LOAD_BUFFER); - if (usb_err < 0) - return usb_err; - - break; - - case DTCLOAD_RUN: - usb_err = ep1_generic_commandl(hdev_param, 3, EP1_CMD_DTC_CALL, - buffer[0], EP1_CMD_DTC_WAIT); - if (usb_err < 0) - return usb_err; - - break; - - case DTCLOAD_LUT_START: - lut_start = buffer[0]; - break; - - case DTCLOAD_LUT: - usb_err = ep1_memory_write(hdev_param, - ST7_USB_BUF_EP0OUT + lut_start, header->length + 1, buffer); - if (usb_err < 0) - return usb_err; - break; - - default: - LOG_ERROR("Invalid DTC image record type: 0x%02x", header->type); - exit(1); - break; + case DTCLOAD_COMMENT: + break; + + case DTCLOAD_ENTRY: + /* store entry addresses somewhere */ + if (!strncmp("download", (char *)buffer + 1, 8)) + dtc_entry_download = buffer[0]; + break; + + case DTCLOAD_LOAD: + /* Send the DTC program to ST7 RAM. */ + usb_err = ep1_memory_write(hdev_param, DTC_LOAD_BUFFER, + header->length + 1, buffer); + if (usb_err < 0) + return usb_err; + + /* Load it into the DTC. */ + usb_err = ep1_generic_commandl(hdev_param, 3, EP1_CMD_DTC_LOAD, + (DTC_LOAD_BUFFER >> 8), DTC_LOAD_BUFFER); + if (usb_err < 0) + return usb_err; + + break; + + case DTCLOAD_RUN: + usb_err = ep1_generic_commandl(hdev_param, 3, EP1_CMD_DTC_CALL, + buffer[0], EP1_CMD_DTC_WAIT); + if (usb_err < 0) + return usb_err; + + break; + + case DTCLOAD_LUT_START: + lut_start = buffer[0]; + break; + + case DTCLOAD_LUT: + usb_err = ep1_memory_write(hdev_param, + ST7_USB_BUF_EP0OUT + lut_start, header->length + 1, buffer); + if (usb_err < 0) + return usb_err; + break; + + default: + LOG_ERROR("Invalid DTC image record type: 0x%02x", header->type); + exit(1); + break; } buffer += (header->length + 1); @@ -1133,15 +1133,15 @@ static int rlink_scan(struct jtag_command *cmd, enum scan_type type, chunk_bytes = chunk_bits / 8; switch (type) { - case SCAN_IN: - x = DTC_CMD_SHIFT_TDO_BYTES(chunk_bytes); - break; - case SCAN_OUT: - x = DTC_CMD_SHIFT_TDI_BYTES(chunk_bytes); - break; - default: - x = DTC_CMD_SHIFT_TDIO_BYTES(chunk_bytes); - break; + case SCAN_IN: + x = DTC_CMD_SHIFT_TDO_BYTES(chunk_bytes); + break; + case SCAN_OUT: + x = DTC_CMD_SHIFT_TDI_BYTES(chunk_bytes); + break; + default: + x = DTC_CMD_SHIFT_TDIO_BYTES(chunk_bytes); + break; } dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = x; @@ -1267,69 +1267,69 @@ static int rlink_execute_queue(struct jtag_command *cmd_queue) while (cmd) { switch (cmd->type) { - case JTAG_RUNTEST: - case JTAG_TLR_RESET: - case JTAG_PATHMOVE: - case JTAG_SCAN: - break; - - default: - /* some events, such as resets, need a queue flush to ensure - *consistency */ - tap_state_queue_run(); - dtc_queue_run(); - break; + case JTAG_RUNTEST: + case JTAG_TLR_RESET: + case JTAG_PATHMOVE: + case JTAG_SCAN: + break; + + default: + /* some events, such as resets, need a queue flush to ensure + *consistency */ + tap_state_queue_run(); + dtc_queue_run(); + break; } switch (cmd->type) { - case JTAG_RESET: - LOG_DEBUG_IO("reset trst: %i srst %i", - cmd->cmd.reset->trst, - cmd->cmd.reset->srst); - if (cmd->cmd.reset->trst == 1 || - (cmd->cmd.reset->srst && - (jtag_get_reset_config() & RESET_SRST_PULLS_TRST))) - tap_set_state(TAP_RESET); - rlink_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); - break; - case JTAG_RUNTEST: - LOG_DEBUG_IO("runtest %i cycles, end in %i", - cmd->cmd.runtest->num_cycles, - cmd->cmd.runtest->end_state); - if (cmd->cmd.runtest->end_state != -1) - rlink_end_state(cmd->cmd.runtest->end_state); - rlink_runtest(cmd->cmd.runtest->num_cycles); - break; - case JTAG_TLR_RESET: - LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state); - if (cmd->cmd.statemove->end_state != -1) - rlink_end_state(cmd->cmd.statemove->end_state); - rlink_state_move(); - break; - case JTAG_PATHMOVE: - LOG_DEBUG_IO("pathmove: %u states, end in %i", - cmd->cmd.pathmove->num_states, - cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); - rlink_path_move(cmd->cmd.pathmove); - break; - case JTAG_SCAN: - LOG_DEBUG_IO("%s scan end in %i", - (cmd->cmd.scan->ir_scan) ? "IR" : "DR", - cmd->cmd.scan->end_state); - if (cmd->cmd.scan->end_state != -1) - rlink_end_state(cmd->cmd.scan->end_state); - scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); - type = jtag_scan_type(cmd->cmd.scan); - if (rlink_scan(cmd, type, buffer, scan_size) != ERROR_OK) - retval = ERROR_FAIL; - break; - case JTAG_SLEEP: - LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); - jtag_sleep(cmd->cmd.sleep->us); - break; - default: - LOG_ERROR("BUG: unknown JTAG command type encountered"); - exit(-1); + case JTAG_RESET: + LOG_DEBUG_IO("reset trst: %i srst %i", + cmd->cmd.reset->trst, + cmd->cmd.reset->srst); + if (cmd->cmd.reset->trst == 1 || + (cmd->cmd.reset->srst && + (jtag_get_reset_config() & RESET_SRST_PULLS_TRST))) + tap_set_state(TAP_RESET); + rlink_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); + break; + case JTAG_RUNTEST: + LOG_DEBUG_IO("runtest %i cycles, end in %i", + cmd->cmd.runtest->num_cycles, + cmd->cmd.runtest->end_state); + if (cmd->cmd.runtest->end_state != -1) + rlink_end_state(cmd->cmd.runtest->end_state); + rlink_runtest(cmd->cmd.runtest->num_cycles); + break; + case JTAG_TLR_RESET: + LOG_DEBUG_IO("statemove end in %i", cmd->cmd.statemove->end_state); + if (cmd->cmd.statemove->end_state != -1) + rlink_end_state(cmd->cmd.statemove->end_state); + rlink_state_move(); + break; + case JTAG_PATHMOVE: + LOG_DEBUG_IO("pathmove: %u states, end in %i", + cmd->cmd.pathmove->num_states, + cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1]); + rlink_path_move(cmd->cmd.pathmove); + break; + case JTAG_SCAN: + LOG_DEBUG_IO("%s scan end in %i", + (cmd->cmd.scan->ir_scan) ? "IR" : "DR", + cmd->cmd.scan->end_state); + if (cmd->cmd.scan->end_state != -1) + rlink_end_state(cmd->cmd.scan->end_state); + scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); + type = jtag_scan_type(cmd->cmd.scan); + if (rlink_scan(cmd, type, buffer, scan_size) != ERROR_OK) + retval = ERROR_FAIL; + break; + case JTAG_SLEEP: + LOG_DEBUG_IO("sleep %" PRIu32, cmd->cmd.sleep->us); + jtag_sleep(cmd->cmd.sleep->us); + break; + default: + LOG_ERROR("BUG: unknown JTAG command type encountered"); + exit(-1); } cmd = cmd->next; } diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c index 70a73eeb9..b4d21100c 100644 --- a/src/jtag/drivers/stlink_usb.c +++ b/src/jtag/drivers/stlink_usb.c @@ -608,28 +608,28 @@ static int transfer_error_status(const struct libusb_transfer *transfer) int r = 0; switch (transfer->status) { - case LIBUSB_TRANSFER_COMPLETED: - r = 0; - break; - case LIBUSB_TRANSFER_TIMED_OUT: - r = LIBUSB_ERROR_TIMEOUT; - break; - case LIBUSB_TRANSFER_STALL: - r = LIBUSB_ERROR_PIPE; - break; - case LIBUSB_TRANSFER_OVERFLOW: - r = LIBUSB_ERROR_OVERFLOW; - break; - case LIBUSB_TRANSFER_NO_DEVICE: - r = LIBUSB_ERROR_NO_DEVICE; - break; - case LIBUSB_TRANSFER_ERROR: - case LIBUSB_TRANSFER_CANCELLED: - r = LIBUSB_ERROR_IO; - break; - default: - r = LIBUSB_ERROR_OTHER; - break; + case LIBUSB_TRANSFER_COMPLETED: + r = 0; + break; + case LIBUSB_TRANSFER_TIMED_OUT: + r = LIBUSB_ERROR_TIMEOUT; + break; + case LIBUSB_TRANSFER_STALL: + r = LIBUSB_ERROR_PIPE; + break; + case LIBUSB_TRANSFER_OVERFLOW: + r = LIBUSB_ERROR_OVERFLOW; + break; + case LIBUSB_TRANSFER_NO_DEVICE: + r = LIBUSB_ERROR_NO_DEVICE; + break; + case LIBUSB_TRANSFER_ERROR: + case LIBUSB_TRANSFER_CANCELLED: + r = LIBUSB_ERROR_IO; + break; + default: + r = LIBUSB_ERROR_OTHER; + break; } return r; @@ -1058,13 +1058,13 @@ static int stlink_usb_error_check(void *handle) if (h->st_mode == STLINK_MODE_DEBUG_SWIM) { switch (h->databuf[0]) { - case STLINK_SWIM_ERR_OK: - return ERROR_OK; - case STLINK_SWIM_BUSY: - return ERROR_WAIT; - default: - LOG_DEBUG("unknown/unexpected STLINK status code 0x%x", h->databuf[0]); - return ERROR_FAIL; + case STLINK_SWIM_ERR_OK: + return ERROR_OK; + case STLINK_SWIM_BUSY: + return ERROR_WAIT; + default: + LOG_DEBUG("unknown/unexpected STLINK status code 0x%x", h->databuf[0]); + return ERROR_FAIL; } } @@ -1073,64 +1073,64 @@ static int stlink_usb_error_check(void *handle) h->databuf[0] = STLINK_DEBUG_ERR_OK; switch (h->databuf[0]) { - case STLINK_DEBUG_ERR_OK: - return ERROR_OK; - case STLINK_DEBUG_ERR_FAULT: - LOG_DEBUG("SWD fault response (0x%x)", STLINK_DEBUG_ERR_FAULT); - return ERROR_FAIL; - case STLINK_SWD_AP_WAIT: - LOG_DEBUG("wait status SWD_AP_WAIT (0x%x)", STLINK_SWD_AP_WAIT); - return ERROR_WAIT; - case STLINK_SWD_DP_WAIT: - LOG_DEBUG("wait status SWD_DP_WAIT (0x%x)", STLINK_SWD_DP_WAIT); - return ERROR_WAIT; - case STLINK_JTAG_GET_IDCODE_ERROR: - LOG_DEBUG("STLINK_JTAG_GET_IDCODE_ERROR"); - return ERROR_FAIL; - case STLINK_JTAG_WRITE_ERROR: - LOG_DEBUG("Write error"); - return ERROR_FAIL; - case STLINK_JTAG_WRITE_VERIF_ERROR: - LOG_DEBUG("Write verify error, ignoring"); - return ERROR_OK; - case STLINK_SWD_AP_FAULT: - /* git://git.ac6.fr/openocd commit 657e3e885b9ee10 - * returns ERROR_OK with the comment: - * Change in error status when reading outside RAM. - * This fix allows CDT plugin to visualize memory. - */ - LOG_DEBUG("STLINK_SWD_AP_FAULT"); - return ERROR_FAIL; - case STLINK_SWD_AP_ERROR: - LOG_DEBUG("STLINK_SWD_AP_ERROR"); - return ERROR_FAIL; - case STLINK_SWD_AP_PARITY_ERROR: - LOG_DEBUG("STLINK_SWD_AP_PARITY_ERROR"); - return ERROR_FAIL; - case STLINK_SWD_DP_FAULT: - LOG_DEBUG("STLINK_SWD_DP_FAULT"); - return ERROR_FAIL; - case STLINK_SWD_DP_ERROR: - LOG_DEBUG("STLINK_SWD_DP_ERROR"); - return ERROR_FAIL; - case STLINK_SWD_DP_PARITY_ERROR: - LOG_DEBUG("STLINK_SWD_DP_PARITY_ERROR"); - return ERROR_FAIL; - case STLINK_SWD_AP_WDATA_ERROR: - LOG_DEBUG("STLINK_SWD_AP_WDATA_ERROR"); - return ERROR_FAIL; - case STLINK_SWD_AP_STICKY_ERROR: - LOG_DEBUG("STLINK_SWD_AP_STICKY_ERROR"); - return ERROR_FAIL; - case STLINK_SWD_AP_STICKYORUN_ERROR: - LOG_DEBUG("STLINK_SWD_AP_STICKYORUN_ERROR"); - return ERROR_FAIL; - case STLINK... [truncated message content] |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:35:33
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 8a504640d2bceaa938dca65e76c77ae844904df7 (commit) from 9bc4873a716d46608bc300571cef8caca3dfad8d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8a504640d2bceaa938dca65e76c77ae844904df7 Author: Antonio Borneo <bor...@gm...> Date: Sat Jul 26 18:00:20 2025 +0200 jtag: align switch and case statements The coding style requires the 'case' to be at the same indentation level of its 'switch' statement. Align the code accordingly. No changes are reported by git log -p -w --ignore-blank-lines --patience Change-Id: Iaf368b0bdd7c797b0e4cfb91e838696d706fdcce Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9053 Tested-by: jenkins Reviewed-by: zapb <de...@za...> diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index 87c65719c..c30a26c87 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -271,15 +271,15 @@ int adapter_config_rclk(unsigned int fallback_speed_khz) int adapter_get_speed(int *speed) { switch (adapter_config.clock_mode) { - case CLOCK_MODE_KHZ: - adapter_khz_to_speed(adapter_get_speed_khz(), speed); - break; - case CLOCK_MODE_RCLK: - adapter_rclk_to_speed(adapter_config.rclk_fallback_speed_khz, speed); - break; - default: - LOG_ERROR("BUG: unknown adapter clock mode"); - return ERROR_FAIL; + case CLOCK_MODE_KHZ: + adapter_khz_to_speed(adapter_get_speed_khz(), speed); + break; + case CLOCK_MODE_RCLK: + adapter_rclk_to_speed(adapter_config.rclk_fallback_speed_khz, speed); + break; + default: + LOG_ERROR("BUG: unknown adapter clock mode"); + return ERROR_FAIL; } return ERROR_OK; } @@ -615,34 +615,34 @@ next: /* minimal JTAG has neither SRST nor TRST (so that's the default) */ switch (new_cfg & (RESET_HAS_TRST | RESET_HAS_SRST)) { - case RESET_HAS_SRST: - modes[0] = "srst_only"; - break; - case RESET_HAS_TRST: - modes[0] = "trst_only"; - break; - case RESET_TRST_AND_SRST: - modes[0] = "trst_and_srst"; - break; - default: - modes[0] = "none"; - break; + case RESET_HAS_SRST: + modes[0] = "srst_only"; + break; + case RESET_HAS_TRST: + modes[0] = "trst_only"; + break; + case RESET_TRST_AND_SRST: + modes[0] = "trst_and_srst"; + break; + default: + modes[0] = "none"; + break; } /* normally SRST and TRST are decoupled; but bugs happen ... */ switch (new_cfg & (RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST)) { - case RESET_SRST_PULLS_TRST: - modes[1] = "srst_pulls_trst"; - break; - case RESET_TRST_PULLS_SRST: - modes[1] = "trst_pulls_srst"; - break; - case RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST: - modes[1] = "combined"; - break; - default: - modes[1] = "separate"; - break; + case RESET_SRST_PULLS_TRST: + modes[1] = "srst_pulls_trst"; + break; + case RESET_TRST_PULLS_SRST: + modes[1] = "trst_pulls_srst"; + break; + case RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST: + modes[1] = "combined"; + break; + default: + modes[1] = "separate"; + break; } /* TRST-less connectors include Altera, Xilinx, and minimal JTAG */ diff --git a/src/jtag/core.c b/src/jtag/core.c index 6dd2144c6..479d2efe5 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -969,58 +969,58 @@ int default_interface_jtag_execute_queue(void) while (debug_level >= LOG_LVL_DEBUG_IO && cmd) { switch (cmd->type) { - case JTAG_SCAN: - LOG_DEBUG_IO("JTAG %s SCAN to %s", - cmd->cmd.scan->ir_scan ? "IR" : "DR", - tap_state_name(cmd->cmd.scan->end_state)); - for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++) { - struct scan_field *field = cmd->cmd.scan->fields + i; - if (field->out_value) { - char *str = buf_to_hex_str(field->out_value, field->num_bits); - LOG_DEBUG_IO(" %ub out: %s", field->num_bits, str); - free(str); - } - if (field->in_value) { - char *str = buf_to_hex_str(field->in_value, field->num_bits); - LOG_DEBUG_IO(" %ub in: %s", field->num_bits, str); - free(str); - } + case JTAG_SCAN: + LOG_DEBUG_IO("JTAG %s SCAN to %s", + cmd->cmd.scan->ir_scan ? "IR" : "DR", + tap_state_name(cmd->cmd.scan->end_state)); + for (unsigned int i = 0; i < cmd->cmd.scan->num_fields; i++) { + struct scan_field *field = cmd->cmd.scan->fields + i; + if (field->out_value) { + char *str = buf_to_hex_str(field->out_value, field->num_bits); + LOG_DEBUG_IO(" %ub out: %s", field->num_bits, str); + free(str); } - break; - case JTAG_TLR_RESET: - LOG_DEBUG_IO("JTAG TLR RESET to %s", - tap_state_name(cmd->cmd.statemove->end_state)); - break; - case JTAG_RUNTEST: - LOG_DEBUG_IO("JTAG RUNTEST %d cycles to %s", - cmd->cmd.runtest->num_cycles, - tap_state_name(cmd->cmd.runtest->end_state)); - break; - case JTAG_RESET: - { - const char *reset_str[3] = { - "leave", "deassert", "assert" - }; - LOG_DEBUG_IO("JTAG RESET %s TRST, %s SRST", - reset_str[cmd->cmd.reset->trst + 1], - reset_str[cmd->cmd.reset->srst + 1]); + if (field->in_value) { + char *str = buf_to_hex_str(field->in_value, field->num_bits); + LOG_DEBUG_IO(" %ub in: %s", field->num_bits, str); + free(str); } - break; - case JTAG_PATHMOVE: - LOG_DEBUG_IO("JTAG PATHMOVE (TODO)"); - break; - case JTAG_SLEEP: - LOG_DEBUG_IO("JTAG SLEEP (TODO)"); - break; - case JTAG_STABLECLOCKS: - LOG_DEBUG_IO("JTAG STABLECLOCKS (TODO)"); - break; - case JTAG_TMS: - LOG_DEBUG_IO("JTAG TMS (TODO)"); - break; - default: - LOG_ERROR("Unknown JTAG command: %d", cmd->type); - break; + } + break; + case JTAG_TLR_RESET: + LOG_DEBUG_IO("JTAG TLR RESET to %s", + tap_state_name(cmd->cmd.statemove->end_state)); + break; + case JTAG_RUNTEST: + LOG_DEBUG_IO("JTAG RUNTEST %d cycles to %s", + cmd->cmd.runtest->num_cycles, + tap_state_name(cmd->cmd.runtest->end_state)); + break; + case JTAG_RESET: + { + const char *reset_str[3] = { + "leave", "deassert", "assert" + }; + LOG_DEBUG_IO("JTAG RESET %s TRST, %s SRST", + reset_str[cmd->cmd.reset->trst + 1], + reset_str[cmd->cmd.reset->srst + 1]); + } + break; + case JTAG_PATHMOVE: + LOG_DEBUG_IO("JTAG PATHMOVE (TODO)"); + break; + case JTAG_SLEEP: + LOG_DEBUG_IO("JTAG SLEEP (TODO)"); + break; + case JTAG_STABLECLOCKS: + LOG_DEBUG_IO("JTAG STABLECLOCKS (TODO)"); + break; + case JTAG_TMS: + LOG_DEBUG_IO("JTAG TMS (TODO)"); + break; + default: + LOG_ERROR("Unknown JTAG command: %d", cmd->type); + break; } cmd = cmd->next; } @@ -1551,22 +1551,22 @@ int jtag_init_inner(struct command_context *cmd_ctx) */ retval = jtag_examine_chain(); switch (retval) { - case ERROR_OK: - /* complete success */ - break; - default: - /* For backward compatibility reasons, try coping with - * configuration errors involving only ID mismatches. - * We might be able to talk to the devices. - * - * Also the device might be powered down during startup. - * - * After OpenOCD starts, we can try to power on the device - * and run a reset. - */ - LOG_ERROR("Trying to use configured scan chain anyway..."); - issue_setup = false; - break; + case ERROR_OK: + /* complete success */ + break; + default: + /* For backward compatibility reasons, try coping with + * configuration errors involving only ID mismatches. + * We might be able to talk to the devices. + * + * Also the device might be powered down during startup. + * + * After OpenOCD starts, we can try to power on the device + * and run a reset. + */ + LOG_ERROR("Trying to use configured scan chain anyway..."); + issue_setup = false; + break; } /* Now look at IR values. Problems here will prevent real diff --git a/src/jtag/interface.c b/src/jtag/interface.c index 0473a8753..23b5bcf4f 100644 --- a/src/jtag/interface.c +++ b/src/jtag/interface.c @@ -67,28 +67,28 @@ int tap_move_ndx(enum tap_state astate) int ndx; switch (astate) { - case TAP_RESET: - ndx = 0; - break; - case TAP_IDLE: - ndx = 1; - break; - case TAP_DRSHIFT: - ndx = 2; - break; - case TAP_DRPAUSE: - ndx = 3; - break; - case TAP_IRSHIFT: - ndx = 4; - break; - case TAP_IRPAUSE: - ndx = 5; - break; - default: - LOG_ERROR("FATAL: unstable state \"%s\" in %s()", - tap_state_name(astate), __func__); - exit(1); + case TAP_RESET: + ndx = 0; + break; + case TAP_IDLE: + ndx = 1; + break; + case TAP_DRSHIFT: + ndx = 2; + break; + case TAP_DRPAUSE: + ndx = 3; + break; + case TAP_IRSHIFT: + ndx = 4; + break; + case TAP_IRPAUSE: + ndx = 5; + break; + default: + LOG_ERROR("FATAL: unstable state \"%s\" in %s()", + tap_state_name(astate), __func__); + exit(1); } return ndx; @@ -205,16 +205,16 @@ bool tap_is_state_stable(enum tap_state astate) * (not value dependent like an array), and can also check bounds. */ switch (astate) { - case TAP_RESET: - case TAP_IDLE: - case TAP_DRSHIFT: - case TAP_DRPAUSE: - case TAP_IRSHIFT: - case TAP_IRPAUSE: - is_stable = true; - break; - default: - is_stable = false; + case TAP_RESET: + case TAP_IDLE: + case TAP_DRSHIFT: + case TAP_DRPAUSE: + case TAP_IRSHIFT: + case TAP_IRPAUSE: + is_stable = true; + break; + default: + is_stable = false; } return is_stable; @@ -230,83 +230,83 @@ enum tap_state tap_state_transition(enum tap_state cur_state, bool tms) if (tms) { switch (cur_state) { - case TAP_RESET: - new_state = cur_state; - break; - case TAP_IDLE: - case TAP_DRUPDATE: - case TAP_IRUPDATE: - new_state = TAP_DRSELECT; - break; - case TAP_DRSELECT: - new_state = TAP_IRSELECT; - break; - case TAP_DRCAPTURE: - case TAP_DRSHIFT: - new_state = TAP_DREXIT1; - break; - case TAP_DREXIT1: - case TAP_DREXIT2: - new_state = TAP_DRUPDATE; - break; - case TAP_DRPAUSE: - new_state = TAP_DREXIT2; - break; - case TAP_IRSELECT: - new_state = TAP_RESET; - break; - case TAP_IRCAPTURE: - case TAP_IRSHIFT: - new_state = TAP_IREXIT1; - break; - case TAP_IREXIT1: - case TAP_IREXIT2: - new_state = TAP_IRUPDATE; - break; - case TAP_IRPAUSE: - new_state = TAP_IREXIT2; - break; - default: - LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state); - exit(1); - break; + case TAP_RESET: + new_state = cur_state; + break; + case TAP_IDLE: + case TAP_DRUPDATE: + case TAP_IRUPDATE: + new_state = TAP_DRSELECT; + break; + case TAP_DRSELECT: + new_state = TAP_IRSELECT; + break; + case TAP_DRCAPTURE: + case TAP_DRSHIFT: + new_state = TAP_DREXIT1; + break; + case TAP_DREXIT1: + case TAP_DREXIT2: + new_state = TAP_DRUPDATE; + break; + case TAP_DRPAUSE: + new_state = TAP_DREXIT2; + break; + case TAP_IRSELECT: + new_state = TAP_RESET; + break; + case TAP_IRCAPTURE: + case TAP_IRSHIFT: + new_state = TAP_IREXIT1; + break; + case TAP_IREXIT1: + case TAP_IREXIT2: + new_state = TAP_IRUPDATE; + break; + case TAP_IRPAUSE: + new_state = TAP_IREXIT2; + break; + default: + LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state); + exit(1); + break; } } else { switch (cur_state) { - case TAP_RESET: - case TAP_IDLE: - case TAP_DRUPDATE: - case TAP_IRUPDATE: - new_state = TAP_IDLE; - break; - case TAP_DRSELECT: - new_state = TAP_DRCAPTURE; - break; - case TAP_DRCAPTURE: - case TAP_DRSHIFT: - case TAP_DREXIT2: - new_state = TAP_DRSHIFT; - break; - case TAP_DREXIT1: - case TAP_DRPAUSE: - new_state = TAP_DRPAUSE; - break; - case TAP_IRSELECT: - new_state = TAP_IRCAPTURE; - break; - case TAP_IRCAPTURE: - case TAP_IRSHIFT: - case TAP_IREXIT2: - new_state = TAP_IRSHIFT; - break; - case TAP_IREXIT1: - case TAP_IRPAUSE: - new_state = TAP_IRPAUSE; - break; - default: - LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state); - exit(1); - break; + case TAP_RESET: + case TAP_IDLE: + case TAP_DRUPDATE: + case TAP_IRUPDATE: + new_state = TAP_IDLE; + break; + case TAP_DRSELECT: + new_state = TAP_DRCAPTURE; + break; + case TAP_DRCAPTURE: + case TAP_DRSHIFT: + case TAP_DREXIT2: + new_state = TAP_DRSHIFT; + break; + case TAP_DREXIT1: + case TAP_DRPAUSE: + new_state = TAP_DRPAUSE; + break; + case TAP_IRSELECT: + new_state = TAP_IRCAPTURE; + break; + case TAP_IRCAPTURE: + case TAP_IRSHIFT: + case TAP_IREXIT2: + new_state = TAP_IRSHIFT; + break; + case TAP_IREXIT1: + case TAP_IRPAUSE: + new_state = TAP_IRPAUSE; + break; + default: + LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state); + exit(1); + break; } } diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index 8b0bc7aff..9cffd6b5d 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -64,13 +64,13 @@ struct jtag_tap *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o) static bool scan_is_safe(enum tap_state state) { switch (state) { - case TAP_RESET: - case TAP_IDLE: - case TAP_DRPAUSE: - case TAP_IRPAUSE: - return true; - default: - return false; + case TAP_RESET: + case TAP_IDLE: + case TAP_DRPAUSE: + case TAP_IRPAUSE: + return true; + default: + return false; } } @@ -558,18 +558,18 @@ static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e) } switch (e) { - case JTAG_TAP_EVENT_ENABLE: - case JTAG_TAP_EVENT_DISABLE: - /* NOTE: we currently assume the handlers - * can't fail. Right here is where we should - * really be verifying the scan chains ... - */ - tap->enabled = (e == JTAG_TAP_EVENT_ENABLE); - LOG_INFO("JTAG tap: %s %s", tap->dotted_name, + case JTAG_TAP_EVENT_ENABLE: + case JTAG_TAP_EVENT_DISABLE: + /* NOTE: we currently assume the handlers + * can't fail. Right here is where we should + * really be verifying the scan chains ... + */ + tap->enabled = (e == JTAG_TAP_EVENT_ENABLE); + LOG_INFO("JTAG tap: %s %s", tap->dotted_name, tap->enabled ? "enabled" : "disabled"); - break; - default: - break; + break; + default: + break; } } } ----------------------------------------------------------------------- Summary of changes: src/jtag/adapter.c | 66 ++++++++-------- src/jtag/core.c | 132 ++++++++++++++++---------------- src/jtag/interface.c | 212 +++++++++++++++++++++++++-------------------------- src/jtag/tcl.c | 36 ++++----- 4 files changed, 223 insertions(+), 223 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:35:14
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 9bc4873a716d46608bc300571cef8caca3dfad8d (commit) from e9561c4af5f01f0fe7a088b1725b915e8d43127f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 9bc4873a716d46608bc300571cef8caca3dfad8d Author: Antonio Borneo <bor...@gm...> Date: Sat Jul 26 18:01:41 2025 +0200 jtag: prepare for aligning switch and case statements To prepare for aligning switch and case statements, fix in advance some checkpatch error due to existing code: - use '__func__' in place of hardcoded function name. Change-Id: Ib90811c7fffa15702fb710345c5ca3c7331d5ad6 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9052 Reviewed-by: zapb <de...@za...> Tested-by: jenkins diff --git a/src/jtag/interface.c b/src/jtag/interface.c index 92c88ca93..0473a8753 100644 --- a/src/jtag/interface.c +++ b/src/jtag/interface.c @@ -86,8 +86,8 @@ int tap_move_ndx(enum tap_state astate) ndx = 5; break; default: - LOG_ERROR("FATAL: unstable state \"%s\" in tap_move_ndx()", - tap_state_name(astate)); + LOG_ERROR("FATAL: unstable state \"%s\" in %s()", + tap_state_name(astate), __func__); exit(1); } ----------------------------------------------------------------------- Summary of changes: src/jtag/interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:34:19
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via e9561c4af5f01f0fe7a088b1725b915e8d43127f (commit) from 6b7cc918f03fd913272ab912fb40f84909d62e74 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e9561c4af5f01f0fe7a088b1725b915e8d43127f Author: Antonio Borneo <bor...@gm...> Date: Sat Jul 26 13:41:04 2025 +0200 target: prepare for aligning switch and case statements To prepare for aligning switch and case statements, fix in advance some checkpatch error due to existing code: - remove useless parenthesis; - remove useless 'break'; - join spit lines; - add space around operators; - remove 'else' after exit() and return. Change-Id: I8a87a0ea104205d087dcb8cbf4c67ff13a47742f Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9050 Tested-by: jenkins Reviewed-by: zapb <de...@za...> diff --git a/src/target/arm11.c b/src/target/arm11.c index f5331408b..a3e3ef843 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -838,7 +838,6 @@ static int arm11_read_memory_inner(struct target *target, break; case 2: - { arm11->arm.core_cache->reg_list[1].dirty = true; for (size_t i = 0; i < count; i++) { @@ -856,7 +855,6 @@ static int arm11_read_memory_inner(struct target *target, } break; - } case 4: { @@ -928,7 +926,6 @@ static int arm11_write_memory_inner(struct target *target, switch (size) { case 1: - { arm11->arm.core_cache->reg_list[1].dirty = true; for (size_t i = 0; i < count; i++) { @@ -948,10 +945,8 @@ static int arm11_write_memory_inner(struct target *target, } break; - } case 2: - { arm11->arm.core_cache->reg_list[1].dirty = true; for (size_t i = 0; i < count; i++) { @@ -974,9 +969,9 @@ static int arm11_write_memory_inner(struct target *target, } break; - } - case 4: { + case 4: + { /* stream word data through DCC directly to memory */ /* increment: STC p14,c5,[R0],#4 */ /* no increment: STC p14,c5,[R0]*/ diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index 5392b6450..3a066e07d 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -2329,9 +2329,9 @@ int arm7_9_write_memory(struct target *target, /* fast memory writes are only safe when the target is running * from a sufficiently high clock (32 kHz is usually too slow) */ - if (arm7_9->fast_memory_access) + if (arm7_9->fast_memory_access) { retval = arm7_9_execute_fast_sys_speed(target); - else { + } else { retval = arm7_9_execute_sys_speed(target); /* @@ -2373,9 +2373,9 @@ int arm7_9_write_memory(struct target *target, /* fast memory writes are only safe when the target is running * from a sufficiently high clock (32 kHz is usually too slow) */ - if (arm7_9->fast_memory_access) + if (arm7_9->fast_memory_access) { retval = arm7_9_execute_fast_sys_speed(target); - else { + } else { retval = arm7_9_execute_sys_speed(target); /* @@ -2416,9 +2416,9 @@ int arm7_9_write_memory(struct target *target, /* fast memory writes are only safe when the target is running * from a sufficiently high clock (32 kHz is usually too slow) */ - if (arm7_9->fast_memory_access) + if (arm7_9->fast_memory_access) { retval = arm7_9_execute_fast_sys_speed(target); - else { + } else { retval = arm7_9_execute_sys_speed(target); /* diff --git a/src/target/dsp563xx.c b/src/target/dsp563xx.c index 9f9953a56..b44be1340 100644 --- a/src/target/dsp563xx.c +++ b/src/target/dsp563xx.c @@ -816,11 +816,9 @@ static int dsp563xx_write_register(struct target *target, int num, int force) arch_info->instr_mask, dsp563xx->core_regs[num]); - if ((err == ERROR_OK) && (arch_info->num == DSP563XX_REG_IDX_SP)) { - dsp563xx->core_cache->reg_list[DSP563XX_REG_IDX_SSH].valid = - 0; - dsp563xx->core_cache->reg_list[DSP563XX_REG_IDX_SSL].valid = - 0; + if (err == ERROR_OK && arch_info->num == DSP563XX_REG_IDX_SP) { + dsp563xx->core_cache->reg_list[DSP563XX_REG_IDX_SSH].valid = 0; + dsp563xx->core_cache->reg_list[DSP563XX_REG_IDX_SSL].valid = 0; } break; diff --git a/src/target/etm.c b/src/target/etm.c index 9e5814e34..90fa3fc6d 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -933,7 +933,6 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_invocatio ctx->current_pc = ctx->last_branch; ctx->pipe_index++; continue; - break; case 0x2: /* trace restarted after FIFO overflow */ command_print(cmd, "--- trace restarted after FIFO overflow at 0x%8.8" PRIx32 " ---", @@ -941,7 +940,6 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_invocatio ctx->current_pc = ctx->last_branch; ctx->pipe_index++; continue; - break; case 0x3: /* exit from debug state */ command_print(cmd, "--- exit from debug state at 0x%8.8" PRIx32 " ---", @@ -949,7 +947,6 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_invocatio ctx->current_pc = ctx->last_branch; ctx->pipe_index++; continue; - break; case 0x4: /* periodic synchronization point */ next_pc = ctx->last_branch; /* if we had no valid PC prior to this synchronization point, @@ -965,8 +962,7 @@ static int etmv1_analyze_trace(struct etm_context *ctx, struct command_invocatio } break; default: /* reserved */ - LOG_ERROR( - "BUG: branch reason code 0x%" PRIx32 " is reserved", + LOG_ERROR("BUG: branch reason code 0x%" PRIx32 " is reserved", ctx->last_branch_reason); return ERROR_FAIL; } diff --git a/src/target/openrisc/jsp_server.c b/src/target/openrisc/jsp_server.c index 185a506c4..917b87200 100644 --- a/src/target/openrisc/jsp_server.c +++ b/src/target/openrisc/jsp_server.c @@ -119,9 +119,9 @@ static int jsp_input(struct connection *connection) while (bytes_read) { switch (t_con->state) { case TELNET_STATE_DATA: - if (*buf_p == 0xff) + if (*buf_p == 0xff) { t_con->state = TELNET_STATE_IAC; - else { + } else { int out_len = 1; int in_len; unsigned char in_buffer[10]; @@ -129,8 +129,7 @@ static int jsp_input(struct connection *connection) &out_len, buf_p, &in_len, in_buffer); if (in_len) - telnet_write(connection, - in_buffer, in_len); + telnet_write(connection, in_buffer, in_len); } break; case TELNET_STATE_IAC: diff --git a/src/target/semihosting_common.c b/src/target/semihosting_common.c index ffcd3aafd..93016c66f 100644 --- a/src/target/semihosting_common.c +++ b/src/target/semihosting_common.c @@ -452,7 +452,8 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 1, fields); if (retval != ERROR_OK) return retval; - else { + + { int fd = semihosting_get_field(target, 0, fields); /* Do not allow to close OpenOCD's own standard streams */ if (fd == 0 || fd == 1 || fd == 2) { @@ -554,49 +555,43 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 2, fields); if (retval != ERROR_OK) return retval; - else { - int type = semihosting_get_field(target, 0, fields); - int code = semihosting_get_field(target, 1, fields); - - if (type == ADP_STOPPED_APPLICATION_EXIT) { - if (!gdb_get_actual_connections()) - exit(code); - else { - fprintf(stderr, - "semihosting: *** application exited with %d ***\n", - code); - } - } else { - fprintf(stderr, - "semihosting: application exception %#x\n", - type); - } + + int type = semihosting_get_field(target, 0, fields); + int code = semihosting_get_field(target, 1, fields); + + if (type == ADP_STOPPED_APPLICATION_EXIT) { + if (!gdb_get_actual_connections()) + exit(code); + + fprintf(stderr, + "semihosting: *** application exited with %d ***\n", + code); + } else { + fprintf(stderr, + "semihosting: application exception %#x\n", type); } } else { if (semihosting->param == ADP_STOPPED_APPLICATION_EXIT) { if (!gdb_get_actual_connections()) exit(0); - else { - fprintf(stderr, - "semihosting: *** application exited normally ***\n"); - } + + fprintf(stderr, + "semihosting: *** application exited normally ***\n"); } else if (semihosting->param == ADP_STOPPED_RUN_TIME_ERROR) { /* Chosen more or less arbitrarily to have a nicer message, * otherwise all other return the same exit code 1. */ if (!gdb_get_actual_connections()) exit(1); - else { - fprintf(stderr, - "semihosting: *** application exited with error ***\n"); - } + + fprintf(stderr, + "semihosting: *** application exited with error ***\n"); } else { if (!gdb_get_actual_connections()) exit(1); - else { - fprintf(stderr, - "semihosting: application exception %#x\n", - (unsigned) semihosting->param); - } + + fprintf(stderr, + "semihosting: application exception %#x\n", + (unsigned int)semihosting->param); } } if (!semihosting->has_resumable_exit) { @@ -645,21 +640,20 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 2, fields); if (retval != ERROR_OK) return retval; - else { + + { int type = semihosting_get_field(target, 0, fields); int code = semihosting_get_field(target, 1, fields); if (type == ADP_STOPPED_APPLICATION_EXIT) { if (!gdb_get_actual_connections()) exit(code); - else { - fprintf(stderr, - "semihosting: *** application exited with %d ***\n", - code); - } + + fprintf(stderr, + "semihosting: *** application exited with %d ***\n", + code); } else { - fprintf(stderr, "semihosting: exception %#x\n", - type); + fprintf(stderr, "semihosting: exception %#x\n", type); } } if (!semihosting->has_resumable_exit) { @@ -691,7 +685,8 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 1, fields); if (retval != ERROR_OK) return retval; - else { + + { int fd = semihosting_get_field(target, 0, fields); struct stat buf; semihosting->result = fstat(fd, &buf); @@ -736,16 +731,16 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 2, fields); if (retval != ERROR_OK) return retval; - else { + + { uint64_t addr = semihosting_get_field(target, 0, fields); size_t size = semihosting_get_field(target, 1, fields); - char *arg = semihosting->cmdline ? - semihosting->cmdline : ""; + char *arg = semihosting->cmdline ? semihosting->cmdline : ""; uint32_t len = strlen(arg) + 1; - if (len > size) + if (len > size) { semihosting->result = -1; - else { + } else { semihosting_set_field(target, len, 1, fields); retval = target_write_buffer(target, addr, len, (uint8_t *)arg); @@ -784,7 +779,8 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 1, fields); if (retval != ERROR_OK) return retval; - else { + + { uint64_t addr = semihosting_get_field(target, 0, fields); /* tell the remote we have no idea */ memset(fields, 0, 4 * semihosting->word_size_bytes); @@ -908,7 +904,8 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 3, fields); if (retval != ERROR_OK) return retval; - else { + + { uint64_t addr = semihosting_get_field(target, 0, fields); uint32_t mode = semihosting_get_field(target, 1, fields); size_t len = semihosting_get_field(target, 2, fields); @@ -1038,7 +1035,8 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 3, fields); if (retval != ERROR_OK) return retval; - else { + + { int fd = semihosting_get_field(target, 0, fields); uint64_t addr = semihosting_get_field(target, 1, fields); size_t len = semihosting_get_field(target, 2, fields); @@ -1117,7 +1115,8 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 2, fields); if (retval != ERROR_OK) return retval; - else { + + { uint64_t addr = semihosting_get_field(target, 0, fields); size_t len = semihosting_get_field(target, 1, fields); if (semihosting->is_fileio) { @@ -1131,9 +1130,7 @@ int semihosting_common(struct target *target) semihosting->result = -1; semihosting->sys_errno = ENOMEM; } else { - retval = - target_read_memory(target, addr, 1, len, - fn); + retval = target_read_memory(target, addr, 1, len, fn); if (retval != ERROR_OK) { free(fn); return retval; @@ -1171,7 +1168,8 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 4, fields); if (retval != ERROR_OK) return retval; - else { + + { uint64_t addr1 = semihosting_get_field(target, 0, fields); size_t len1 = semihosting_get_field(target, 1, fields); uint64_t addr2 = semihosting_get_field(target, 2, fields); @@ -1192,15 +1190,13 @@ int semihosting_common(struct target *target) semihosting->result = -1; semihosting->sys_errno = ENOMEM; } else { - retval = target_read_memory(target, addr1, 1, len1, - fn1); + retval = target_read_memory(target, addr1, 1, len1, fn1); if (retval != ERROR_OK) { free(fn1); free(fn2); return retval; } - retval = target_read_memory(target, addr2, 1, len2, - fn2); + retval = target_read_memory(target, addr2, 1, len2, fn2); if (retval != ERROR_OK) { free(fn1); free(fn2); @@ -1208,8 +1204,7 @@ int semihosting_common(struct target *target) } fn1[len1] = 0; fn2[len2] = 0; - semihosting->result = rename((char *)fn1, - (char *)fn2); + semihosting->result = rename((char *)fn1, (char *)fn2); // rename() on Windows returns nonzero on error if (semihosting->result != 0) semihosting->sys_errno = errno; @@ -1246,7 +1241,8 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 2, fields); if (retval != ERROR_OK) return retval; - else { + + { int fd = semihosting_get_field(target, 0, fields); off_t pos = semihosting_get_field(target, 1, fields); if (semihosting->is_fileio) { @@ -1292,7 +1288,8 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 2, fields); if (retval != ERROR_OK) return retval; - else { + + { uint64_t addr = semihosting_get_field(target, 0, fields); size_t len = semihosting_get_field(target, 1, fields); if (semihosting->is_fileio) { @@ -1314,12 +1311,10 @@ int semihosting_common(struct target *target) if (retval != ERROR_OK) { free(cmd); return retval; - } else { - cmd[len] = 0; - semihosting->result = system( - (const char *)cmd); - LOG_DEBUG("system('%s')=%" PRId64, cmd, semihosting->result); } + cmd[len] = 0; + semihosting->result = system((const char *)cmd); + LOG_DEBUG("system('%s')=%" PRId64, cmd, semihosting->result); free(cmd); } @@ -1374,7 +1369,8 @@ int semihosting_common(struct target *target) retval = semihosting_read_fields(target, 3, fields); if (retval != ERROR_OK) return retval; - else { + + { int fd = semihosting_get_field(target, 0, fields); uint64_t addr = semihosting_get_field(target, 1, fields); size_t len = semihosting_get_field(target, 2, fields); @@ -1634,7 +1630,7 @@ int semihosting_common(struct target *target) default: fprintf(stderr, "semihosting: unsupported call %#x\n", - (unsigned) semihosting->op); + (unsigned int)semihosting->op); semihosting->result = -1; semihosting->sys_errno = ENOTSUP; } diff --git a/src/target/x86_32_common.c b/src/target/x86_32_common.c index 858315b7a..a5df8b9e9 100644 --- a/src/target/x86_32_common.c +++ b/src/target/x86_32_common.c @@ -1208,15 +1208,13 @@ static int set_watchpoint(struct target *t, struct watchpoint *wp) switch (wp->rw) { case WPT_WRITE: if (set_debug_regs(t, wp->address, wp_num, - DR7_BP_WRITE, wp->length) != ERROR_OK) { + DR7_BP_WRITE, wp->length) != ERROR_OK) return ERROR_FAIL; - } break; case WPT_ACCESS: if (set_debug_regs(t, wp->address, wp_num, DR7_BP_READWRITE, - wp->length) != ERROR_OK) { + wp->length) != ERROR_OK) return ERROR_FAIL; - } break; default: LOG_ERROR("%s only 'access' or 'write' watchpoints are supported", __func__); diff --git a/src/target/xscale.c b/src/target/xscale.c index 1f7b346a9..a6ee7a234 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -2708,7 +2708,7 @@ static int xscale_analyze_trace(struct target *target, struct command_invocation case 13: /* Checkpointed Indirect Branch */ xscale_branch_address(trace_data, i, &branch_target); - if ((trace_data->num_checkpoints == 2) && (chkpt == 0)) + if (trace_data->num_checkpoints == 2 && chkpt == 0) chkpt_reg = trace_data->chkpt1; /* 2 chkpts, this is *oldest */ else @@ -2719,7 +2719,7 @@ static int xscale_analyze_trace(struct target *target, struct command_invocation break; case 12: /* Checkpointed Direct Branch */ - if ((trace_data->num_checkpoints == 2) && (chkpt == 0)) + if (trace_data->num_checkpoints == 2 && chkpt == 0) chkpt_reg = trace_data->chkpt1; /* 2 chkpts, this is *oldest */ else ----------------------------------------------------------------------- Summary of changes: src/target/arm11.c | 9 +-- src/target/arm7_9_common.c | 12 ++-- src/target/dsp563xx.c | 8 +-- src/target/etm.c | 6 +- src/target/openrisc/jsp_server.c | 7 +-- src/target/semihosting_common.c | 132 +++++++++++++++++++-------------------- src/target/x86_32_common.c | 6 +- src/target/xscale.c | 4 +- 8 files changed, 83 insertions(+), 101 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:33:57
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 6b7cc918f03fd913272ab912fb40f84909d62e74 (commit) via cb526f065903701ac94311f5506f5db23cb1d8ce (commit) from ce3fa4ac088214e10321eb39b0ecdf96d7ef78e6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6b7cc918f03fd913272ab912fb40f84909d62e74 Author: Antonio Borneo <bor...@gm...> Date: Sat Jul 26 17:44:30 2025 +0200 target: cortex_a: add break in switch/case The code falls-through in the default case, making it not easy to read. Add the explicit break to improve the readability. Change-Id: I4784b883e0e82258de17018dfdfb59b4042ac743 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9049 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c index 9e1aa4416..60527c7da 100644 --- a/src/target/cortex_a.c +++ b/src/target/cortex_a.c @@ -2360,6 +2360,7 @@ static int cortex_a_write_cpu_memory(struct target *target, count *= 2; size = 2; } + break; case 0: default: break; commit cb526f065903701ac94311f5506f5db23cb1d8ce Author: Antonio Borneo <bor...@gm...> Date: Sat Jul 26 13:13:32 2025 +0200 xsvf: align switch and case statements The coding style requires the 'case' to be at the same indentation level of its 'switch' statement. Align the code accordingly. No changes are reported by git log -p -w --ignore-blank-lines --patience Change-Id: I24762505cdac22058e0a2a1f4e9235c9006e543d Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9048 Tested-by: jenkins Reviewed-by: zapb <de...@za...> diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c index e1cbca41e..5f5bf8d09 100644 --- a/src/xsvf/xsvf.c +++ b/src/xsvf/xsvf.c @@ -117,57 +117,57 @@ static enum tap_state xsvf_to_tap(int xsvf_state) enum tap_state ret; switch (xsvf_state) { - case XSV_RESET: - ret = TAP_RESET; - break; - case XSV_IDLE: - ret = TAP_IDLE; - break; - case XSV_DRSELECT: - ret = TAP_DRSELECT; - break; - case XSV_DRCAPTURE: - ret = TAP_DRCAPTURE; - break; - case XSV_DRSHIFT: - ret = TAP_DRSHIFT; - break; - case XSV_DREXIT1: - ret = TAP_DREXIT1; - break; - case XSV_DRPAUSE: - ret = TAP_DRPAUSE; - break; - case XSV_DREXIT2: - ret = TAP_DREXIT2; - break; - case XSV_DRUPDATE: - ret = TAP_DRUPDATE; - break; - case XSV_IRSELECT: - ret = TAP_IRSELECT; - break; - case XSV_IRCAPTURE: - ret = TAP_IRCAPTURE; - break; - case XSV_IRSHIFT: - ret = TAP_IRSHIFT; - break; - case XSV_IREXIT1: - ret = TAP_IREXIT1; - break; - case XSV_IRPAUSE: - ret = TAP_IRPAUSE; - break; - case XSV_IREXIT2: - ret = TAP_IREXIT2; - break; - case XSV_IRUPDATE: - ret = TAP_IRUPDATE; - break; - default: - LOG_ERROR("UNKNOWN XSVF STATE 0x%02X", xsvf_state); - exit(1); + case XSV_RESET: + ret = TAP_RESET; + break; + case XSV_IDLE: + ret = TAP_IDLE; + break; + case XSV_DRSELECT: + ret = TAP_DRSELECT; + break; + case XSV_DRCAPTURE: + ret = TAP_DRCAPTURE; + break; + case XSV_DRSHIFT: + ret = TAP_DRSHIFT; + break; + case XSV_DREXIT1: + ret = TAP_DREXIT1; + break; + case XSV_DRPAUSE: + ret = TAP_DRPAUSE; + break; + case XSV_DREXIT2: + ret = TAP_DREXIT2; + break; + case XSV_DRUPDATE: + ret = TAP_DRUPDATE; + break; + case XSV_IRSELECT: + ret = TAP_IRSELECT; + break; + case XSV_IRCAPTURE: + ret = TAP_IRCAPTURE; + break; + case XSV_IRSHIFT: + ret = TAP_IRSHIFT; + break; + case XSV_IREXIT1: + ret = TAP_IREXIT1; + break; + case XSV_IRPAUSE: + ret = TAP_IRPAUSE; + break; + case XSV_IREXIT2: + ret = TAP_IREXIT2; + break; + case XSV_IRUPDATE: + ret = TAP_IRUPDATE; + break; + default: + LOG_ERROR("UNKNOWN XSVF STATE 0x%02X", xsvf_state); + exit(1); } return ret; @@ -275,92 +275,91 @@ COMMAND_HANDLER(handle_xsvf_command) enum tap_state mystate; switch (opcode) { - case XCOMMENT: - /* ignore/show comments between XSTATE ops */ + case XCOMMENT: + /* ignore/show comments between XSTATE ops */ + break; + case XSTATE: + /* try to collect another transition */ + if (pathlen == XSTATE_MAX_PATH) { + LOG_ERROR("XSVF: path too long"); + do_abort = 1; break; - case XSTATE: - /* try to collect another transition */ - if (pathlen == XSTATE_MAX_PATH) { - LOG_ERROR("XSVF: path too long"); - do_abort = 1; - break; - } - - if (read(xsvf_fd, &uc, 1) < 0) { - do_abort = 1; - break; - } + } - mystate = xsvf_to_tap(uc); - path[pathlen++] = mystate; - - LOG_DEBUG("XSTATE 0x%02X %s", uc, - tap_state_name(mystate)); - - /* If path is incomplete, collect more */ - if (!svf_tap_state_is_stable(mystate)) - continue; - - /* Else execute the path transitions we've - * collected so far. - * - * NOTE: Punting on the saved path is not - * strictly correct, but we must to do this - * unless jtag_add_pathmove() stops rejecting - * paths containing RESET. This is probably - * harmless, since there aren't many options - * for going from a stable state to reset; - * at the worst, we may issue extra clocks - * once we get to RESET. - */ - if (mystate == TAP_RESET) { - LOG_WARNING("XSVF: dodgey RESET"); - path[0] = mystate; - } + if (read(xsvf_fd, &uc, 1) < 0) { + do_abort = 1; + break; + } - /* FALL THROUGH */ - default: - /* Execute the path we collected - * - * NOTE: OpenOCD requires something that XSVF - * doesn't: the last TAP state in the path - * must be stable. In practice, tools that - * create XSVF seem to follow that rule too. - */ - collecting_path = false; + mystate = xsvf_to_tap(uc); + path[pathlen++] = mystate; - if (path[0] == TAP_RESET) - jtag_add_tlr(); - else - jtag_add_pathmove(pathlen, path); + LOG_DEBUG("XSTATE 0x%02X %s", uc, + tap_state_name(mystate)); - result = jtag_execute_queue(); - if (result != ERROR_OK) { - LOG_ERROR("XSVF: pathmove error %d", result); - do_abort = 1; - break; - } + /* If path is incomplete, collect more */ + if (!svf_tap_state_is_stable(mystate)) continue; + + /* Else execute the path transitions we've + * collected so far. + * + * NOTE: Punting on the saved path is not + * strictly correct, but we must to do this + * unless jtag_add_pathmove() stops rejecting + * paths containing RESET. This is probably + * harmless, since there aren't many options + * for going from a stable state to reset; + * at the worst, we may issue extra clocks + * once we get to RESET. + */ + if (mystate == TAP_RESET) { + LOG_WARNING("XSVF: dodgey RESET"); + path[0] = mystate; + } + + /* FALL THROUGH */ + default: + /* Execute the path we collected + * + * NOTE: OpenOCD requires something that XSVF + * doesn't: the last TAP state in the path + * must be stable. In practice, tools that + * create XSVF seem to follow that rule too. + */ + collecting_path = false; + + if (path[0] == TAP_RESET) + jtag_add_tlr(); + else + jtag_add_pathmove(pathlen, path); + + result = jtag_execute_queue(); + if (result != ERROR_OK) { + LOG_ERROR("XSVF: pathmove error %d", result); + do_abort = 1; + break; + } + continue; } } switch (opcode) { - case XCOMPLETE: - LOG_DEBUG("XCOMPLETE"); - - result = jtag_execute_queue(); - if (result != ERROR_OK) - tdo_mismatch = 1; - break; + case XCOMPLETE: + LOG_DEBUG("XCOMPLETE"); + result = jtag_execute_queue(); + if (result != ERROR_OK) + tdo_mismatch = 1; + break; - case XTDOMASK: - LOG_DEBUG("XTDOMASK"); - if (dr_in_mask && - (xsvf_read_buffer(xsdrsize, xsvf_fd, dr_in_mask) != ERROR_OK)) - do_abort = 1; - break; + case XTDOMASK: + LOG_DEBUG("XTDOMASK"); + if (dr_in_mask && + (xsvf_read_buffer(xsdrsize, xsvf_fd, dr_in_mask) != ERROR_OK)) + do_abort = 1; + break; - case XRUNTEST: + case XRUNTEST: { uint8_t xruntest_buf[4]; @@ -374,7 +373,7 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - case XREPEAT: + case XREPEAT: { uint8_t myrepeat; @@ -387,7 +386,7 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - case XSDRSIZE: + case XSDRSIZE: { uint8_t xsdrsize_buf[4]; @@ -409,8 +408,8 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - case XSDR: /* these two are identical except for the dr_in_buf */ - case XSDRTDO: + case XSDR: /* these two are identical except for the dr_in_buf */ + case XSDRTDO: { int limit = xrepeat; int matched = 0; @@ -519,47 +518,47 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - case XSETSDRMASKS: - LOG_ERROR("unsupported XSETSDRMASKS"); - unsupported = 1; - break; + case XSETSDRMASKS: + LOG_ERROR("unsupported XSETSDRMASKS"); + unsupported = 1; + break; - case XSDRINC: - LOG_ERROR("unsupported XSDRINC"); - unsupported = 1; - break; + case XSDRINC: + LOG_ERROR("unsupported XSDRINC"); + unsupported = 1; + break; - case XSDRB: - LOG_ERROR("unsupported XSDRB"); - unsupported = 1; - break; + case XSDRB: + LOG_ERROR("unsupported XSDRB"); + unsupported = 1; + break; - case XSDRC: - LOG_ERROR("unsupported XSDRC"); - unsupported = 1; - break; + case XSDRC: + LOG_ERROR("unsupported XSDRC"); + unsupported = 1; + break; - case XSDRE: - LOG_ERROR("unsupported XSDRE"); - unsupported = 1; - break; + case XSDRE: + LOG_ERROR("unsupported XSDRE"); + unsupported = 1; + break; - case XSDRTDOB: - LOG_ERROR("unsupported XSDRTDOB"); - unsupported = 1; - break; + case XSDRTDOB: + LOG_ERROR("unsupported XSDRTDOB"); + unsupported = 1; + break; - case XSDRTDOC: - LOG_ERROR("unsupported XSDRTDOC"); - unsupported = 1; - break; + case XSDRTDOC: + LOG_ERROR("unsupported XSDRTDOC"); + unsupported = 1; + break; - case XSDRTDOE: - LOG_ERROR("unsupported XSDRTDOE"); - unsupported = 1; - break; + case XSDRTDOE: + LOG_ERROR("unsupported XSDRTDOE"); + unsupported = 1; + break; - case XSTATE: + case XSTATE: { enum tap_state mystate; @@ -604,50 +603,48 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - case XENDIR: - - if (read(xsvf_fd, &uc, 1) < 0) { - do_abort = 1; - break; - } - - /* see page 22 of XSVF spec */ - if (uc == 0) { - xendir = TAP_IDLE; - } else if (uc == 1) { - xendir = TAP_IRPAUSE; - } else { - LOG_ERROR("illegial XENDIR argument: 0x%02X", uc); - unsupported = 1; - break; - } - - LOG_DEBUG("XENDIR 0x%02X %s", uc, tap_state_name(xendir)); + case XENDIR: + if (read(xsvf_fd, &uc, 1) < 0) { + do_abort = 1; break; + } - case XENDDR: + /* see page 22 of XSVF spec */ + if (uc == 0) { + xendir = TAP_IDLE; + } else if (uc == 1) { + xendir = TAP_IRPAUSE; + } else { + LOG_ERROR("illegial XENDIR argument: 0x%02X", uc); + unsupported = 1; + break; + } - if (read(xsvf_fd, &uc, 1) < 0) { - do_abort = 1; - break; - } + LOG_DEBUG("XENDIR 0x%02X %s", uc, tap_state_name(xendir)); + break; - /* see page 22 of XSVF spec */ - if (uc == 0) { - xenddr = TAP_IDLE; - } else if (uc == 1) { - xenddr = TAP_DRPAUSE; - } else { - LOG_ERROR("illegial XENDDR argument: 0x%02X", uc); - unsupported = 1; - break; - } + case XENDDR: + if (read(xsvf_fd, &uc, 1) < 0) { + do_abort = 1; + break; + } - LOG_DEBUG("XENDDR %02X %s", uc, tap_state_name(xenddr)); + /* see page 22 of XSVF spec */ + if (uc == 0) { + xenddr = TAP_IDLE; + } else if (uc == 1) { + xenddr = TAP_DRPAUSE; + } else { + LOG_ERROR("illegial XENDDR argument: 0x%02X", uc); + unsupported = 1; break; + } + + LOG_DEBUG("XENDDR %02X %s", uc, tap_state_name(xenddr)); + break; - case XSIR: - case XSIR2: + case XSIR: + case XSIR2: { uint8_t short_buf[2]; uint8_t *ir_buf; @@ -710,7 +707,7 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - case XCOMMENT: + case XCOMMENT: { unsigned int ndx = 0; char comment[128]; @@ -732,7 +729,7 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - case XWAIT: + case XWAIT: { /* expected in stream: XWAIT <uint8_t wait_state> <uint8_t end_state> <uint32_t usecs> @@ -775,7 +772,7 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - case XWAITSTATE: + case XWAITSTATE: { /* expected in stream: * XWAITSTATE <uint8_t wait_state> <uint8_t end_state> <uint32_t clock_count> @@ -836,7 +833,7 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - case LCOUNT: + case LCOUNT: { /* expected in stream: * LCOUNT <uint32_t loop_count> @@ -853,7 +850,7 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - case LDELAY: + case LDELAY: { /* expected in stream: * LDELAY <uint8_t wait_state> <uint32_t clock_count> <uint32_t usecs_to_sleep> @@ -879,10 +876,10 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - /* LSDR is more like XSDRTDO than it is like XSDR. It uses LDELAY which - * comes with clocks !AND! sleep requirements. - */ - case LSDR: + /* LSDR is more like XSDRTDO than it is like XSDR. It uses LDELAY which + * comes with clocks !AND! sleep requirements. + */ + case LSDR: { int limit = loop_count; int matched = 0; @@ -946,7 +943,7 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - case XTRST: + case XTRST: { uint8_t trst_mode; @@ -972,9 +969,9 @@ COMMAND_HANDLER(handle_xsvf_command) } break; - default: - LOG_ERROR("unknown xsvf command (0x%02X)", uc); - unsupported = 1; + default: + LOG_ERROR("unknown xsvf command (0x%02X)", uc); + unsupported = 1; } if (do_abort || unsupported || tdo_mismatch) { ----------------------------------------------------------------------- Summary of changes: src/target/cortex_a.c | 1 + src/xsvf/xsvf.c | 421 +++++++++++++++++++++++++------------------------- 2 files changed, 210 insertions(+), 212 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:33:47
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via ce3fa4ac088214e10321eb39b0ecdf96d7ef78e6 (commit) from 83b92bc6347aeea0da487a37c9c333717ef818e4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ce3fa4ac088214e10321eb39b0ecdf96d7ef78e6 Author: Antonio Borneo <bor...@gm...> Date: Sat Jul 26 13:21:52 2025 +0200 xsvf: prepare for aligning switch and case statements To prepare for aligning switch and case statements, fix in advance some checkpatch error due to existing code: - uniform braces around if/else statements. While there: - drop useless break. Change-Id: Ic0ce0a9877dbf17c625cf80009a52922176a162d Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9047 Reviewed-by: zapb <de...@za...> Tested-by: jenkins diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c index 617c2f423..e1cbca41e 100644 --- a/src/xsvf/xsvf.c +++ b/src/xsvf/xsvf.c @@ -349,10 +349,8 @@ COMMAND_HANDLER(handle_xsvf_command) LOG_DEBUG("XCOMPLETE"); result = jtag_execute_queue(); - if (result != ERROR_OK) { + if (result != ERROR_OK) tdo_mismatch = 1; - break; - } break; case XTDOMASK: @@ -380,9 +378,9 @@ COMMAND_HANDLER(handle_xsvf_command) { uint8_t myrepeat; - if (read(xsvf_fd, &myrepeat, 1) < 0) + if (read(xsvf_fd, &myrepeat, 1) < 0) { do_abort = 1; - else { + } else { xrepeat = myrepeat; LOG_DEBUG("XREPEAT %d", xrepeat); } @@ -614,11 +612,11 @@ COMMAND_HANDLER(handle_xsvf_command) } /* see page 22 of XSVF spec */ - if (uc == 0) + if (uc == 0) { xendir = TAP_IDLE; - else if (uc == 1) + } else if (uc == 1) { xendir = TAP_IRPAUSE; - else { + } else { LOG_ERROR("illegial XENDIR argument: 0x%02X", uc); unsupported = 1; break; @@ -635,11 +633,11 @@ COMMAND_HANDLER(handle_xsvf_command) } /* see page 22 of XSVF spec */ - if (uc == 0) + if (uc == 0) { xenddr = TAP_IDLE; - else if (uc == 1) + } else if (uc == 1) { xenddr = TAP_DRPAUSE; - else { + } else { LOG_ERROR("illegial XENDDR argument: 0x%02X", uc); unsupported = 1; break; @@ -675,9 +673,9 @@ COMMAND_HANDLER(handle_xsvf_command) ir_buf = malloc((bitcount + 7) / 8); - if (xsvf_read_buffer(bitcount, xsvf_fd, ir_buf) != ERROR_OK) + if (xsvf_read_buffer(bitcount, xsvf_fd, ir_buf) != ERROR_OK) { do_abort = 1; - else { + } else { struct scan_field field; field.num_bits = bitcount; @@ -762,9 +760,9 @@ COMMAND_HANDLER(handle_xsvf_command) LOG_DEBUG("XWAIT %s %s usecs:%d", tap_state_name( wait_state), tap_state_name(end_state), delay); - if (runtest_requires_tck && wait_state == TAP_IDLE) + if (runtest_requires_tck && wait_state == TAP_IDLE) { jtag_add_runtest(delay, end_state); - else { + } else { /* FIXME handle statemove errors ... */ result = svf_add_statemove(wait_state); if (result != ERROR_OK) ----------------------------------------------------------------------- Summary of changes: src/xsvf/xsvf.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) hooks/post-receive -- Main OpenOCD repository |