From: OpenOCD-Gerrit <ope...@us...> - 2021-11-20 14:45:05
|
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 872682345af6e26af145c76d5a4373b16d815b7e (commit) via 3eef83e4bd2b112b98d73f8b0947af93c193e0ef (commit) from 08dac883a14aab398922a4e61d55204d7cef644f (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 872682345af6e26af145c76d5a4373b16d815b7e Author: Tomas Vanek <va...@fb...> Date: Fri Nov 12 09:49:01 2021 +0100 drivers/swd: add support for SWD multidrop According to ARM IHI0031C+ chapter 2.3.11 "TARGETSEL, Target Selection register" multidrop capable DPv2 must not drive SWDIO line during the response phase of a write to TARGETSEL register. Introduce helper functions swd_cmd_returns_ack() and swd_ack_to_error_code() to centralize these tests from all drivers to one place. Introduce distinct error codes for SWD protocol. Partly inspired by Graham Sanderson's http://review.openocd.org/4935 Change-Id: Ie5f9edb22e066a933a534bf2b29e7e1d3087dad1 Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/6699 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/src/jtag/swd.h b/src/jtag/swd.h index fe28667c6..8a436d0c6 100644 --- a/src/jtag/swd.h +++ b/src/jtag/swd.h @@ -18,6 +18,7 @@ #ifndef OPENOCD_JTAG_SWD_H #define OPENOCD_JTAG_SWD_H +#include <helper/log.h> #include <target/arm_adi_v5.h> /* Bits in SWD command packets, written from host to target @@ -32,6 +33,12 @@ #define SWD_CMD_PARK (1 << 7) /* driven high by host */ /* followed by TRN, 3-bits of ACK, TRN */ +/* + * The SWD subsystem error codes + */ +#define ERROR_SWD_FAIL (-400) /** protocol or parity error */ +#define ERROR_SWD_FAULT (-401) /** device returned FAULT in ACK field */ + /** * Construct a "cmd" byte, in lSB bit order, which swd_driver.read_reg() * and swd_driver.write_reg() methods will use directly. @@ -53,6 +60,40 @@ static inline uint8_t swd_cmd(bool is_read, bool is_ap, uint8_t regnum) /* SWD_ACK_* bits are defined in <target/arm_adi_v5.h> */ +/** + * Test if we can rely on ACK returned by SWD command + * + * @param cmd Byte constructed by swd_cmd(), START, STOP and TRN are filtered off + * @returns true if ACK should be checked, false if should be ignored + */ +static inline bool swd_cmd_returns_ack(uint8_t cmd) +{ + uint8_t base_cmd = cmd & (SWD_CMD_APNDP | SWD_CMD_RNW | SWD_CMD_A32); + + /* DPv2 does not reply to DP_TARGETSEL write cmd */ + return base_cmd != swd_cmd(false, false, DP_TARGETSEL); +} + +/** + * Convert SWD ACK value returned from DP to OpenOCD error code + * + * @param ack + * @returns error code + */ +static inline int swd_ack_to_error_code(uint8_t ack) +{ + switch (ack) { + case SWD_ACK_OK: + return ERROR_OK; + case SWD_ACK_WAIT: + return ERROR_WAIT; + case SWD_ACK_FAULT: + return ERROR_SWD_FAULT; + default: + return ERROR_SWD_FAIL; + } +} + /* * The following sequences are updated to * ARM(tm) Debug Interface v5 Architecture Specification ARM IHI 0031E commit 3eef83e4bd2b112b98d73f8b0947af93c193e0ef Author: Tomas Vanek <va...@fb...> Date: Wed Nov 10 12:46:42 2021 +0100 target/arm_dap: fix memory leak in error path of dap_create() Change-Id: I91fa5910670161b62a76fc834b6394c5a6c05395 Suggested-by: Antonio Borneo <bor...@gm...> Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/6685 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/target/arm_dap.c b/src/target/arm_dap.c index 94edfc09d..18e77b50f 100644 --- a/src/target/arm_dap.c +++ b/src/target/arm_dap.c @@ -267,8 +267,11 @@ static int dap_create(struct jim_getopt_info *goi) dap_commands[0].chain = NULL; e = register_commands_with_data(cmd_ctx, NULL, dap_commands, dap); - if (e != ERROR_OK) + if (e != ERROR_OK) { + free(dap->name); + free(dap); return JIM_ERR; + } list_add_tail(&dap->lh, &all_dap); ----------------------------------------------------------------------- Summary of changes: src/jtag/swd.h | 41 +++++++++++++++++++++++++++++++++++++++++ src/target/arm_dap.c | 5 ++++- 2 files changed, 45 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |