ipdbg: split ipdbg command into multiple commands To simplify the ipdbg start/stop command and be able to add additional commands in the future, we introduce the concept of a hub which has to be created before a ipdbg server can be started. The hub was created on the fly in previous versions. Change-Id: I55f317542d01a7324990b2cacd496a41fa5ff875 Signed-off-by: Daniel Anselmi <danselmi@gmx.ch> Reviewed-on: https://review.openocd.org/c/openocd/+/7979 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
jtag/drivers/bitbang: limit SWD WAIT retries by timeout The bitbang driver kept retrying a SWD command as long as the debugged device had been responding by SWD WAIT. If the DP stalled in WAIT permanently, OpenOCD hanged. Check 0.5 sec timeout in WAIT retry loop. While on it insert a short alive_sleep() if the command is retried 20 or more times. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I744e56e21a5a2dc2c4494cc0d7bbcb4be14ddb23 Reviewed-on: https://review.openocd.org/c/openocd/+/8153 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
jtag/drivers/bitbang: use LOG_CUSTOM_LEVEL() macro for SWD Log SWD commands with not OK response but WAIT retries at debug level. For commands responded OK and WAIT retries use debug io level not to flood the log. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: Idf658e82ed970061c155945df55d06908ed25e09 Reviewed-on: https://review.openocd.org/c/openocd/+/8152 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
helper/log: add LOG_CUSTOM_LEVEL() macro Allow logging at a changeable level. Add an example of usage in ftdi driver. Log SWD commands with not OK response at debug level (3). For commands which responded OK use debug io level (4) not to flood the log. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I67a472b293f7ed9ee84cadb7c081803e9eeb1ad0 Reviewed-on: https://review.openocd.org/c/openocd/+/8151 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
drivers/cmsis_dap, kitprog: use helper to derive err code from ack Unify the error codes returned by adapter drivers in the case of the received SWD ACK field differs from OK. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I29e478390b4b30408054a090ac6a7fac3415ae71 Reviewed-on: https://review.openocd.org/c/openocd/+/8137 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
src/jtag/drivers/mpsse: Add support for new FTDI chip types. The new FTDI ICs with USB-C Support have different bcdDevice identifiers. The added bcdDevice identifiers are taken from the chips datasheet, respectively. The patch was tested with a FT4232HP IC. The used bcdDevice IDs can be found in Section 8.1 of the respective Datasheets: https://ftdichip.com/wp-content/uploads/2023/09/DS_FT233HP-v1.4.pdf https://ftdichip.com/wp-content/uploads/2023/09/DS_FT2233HP-v1.4.pdf https://ftdichip.com/wp-content/uploads/2023/09/DS_FT4233HP-v1.5.pdf Change-Id: I701083cb72030e398ce1c74310676e13895a77ff Signed-off-by: Luca Rufer <lucarufer333@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8134 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
jtag/commands: fixed buffer overflow When performing a command queue allocation larger than the default page size of 1MiB any subsequent allocations will run into an integer under- flow when checking for the remaining memory left in the current page. Causing the function returning a pointer past the end of the buffer and thus creating a buffer overflow. This has been observed to cause some transfers to Efinix FPGAs to fail, because another buffer can get corrupted in the process, causing its respective free() to fail. Change-Id: Ic5a0e1774e2dbd58f1a05127f14816c8251a7d9c Signed-off-by: SydMontague <sydmontague@phoenix-staffel.de> Reviewed-on: https://review.openocd.org/c/openocd/+/8126 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
driver: Add additional check for count of BYPASS devices At least one TAP shouldn't be in BYPASS mode Change-Id: Ic882acbfc9b6a9f4b0c3bb4741a49f3981503c8c Signed-off-by: Kirill Radkin <kirill.radkin@syntacore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7741 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
jtag interfaces: Reduce usage of global for jtag queue Makes driver interface slightly more flexible. Change-Id: I2c7f5cb6d014e94a0e6122cbe2f4002c77fbabb9 Signed-off-by: Evan Hunter <ehunter@broadcom.com> Signed-off-by: David Ryskalczyk <david.rysk@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/945 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
jtag/drivers: fix reset logic handling in OpenJTAG The OpenJTAG driver behaviour always forces a system reset on jtag_init. The driver was incorrectly assuming that when execute_reset is called with trst set to 1 - perform a software TAP reset, otherwise perform a system reset when trst is 0. The set_state call assumes the that OpenJTAG hardware will perform a software TLR reset if the target state is TAP_RESET. This is not the case: the published VHDL will simply find the shortest path to TLR and not perform a fixed 5 cycle operation with TMS held high. Fix the code to only perform system resets when srst is 1 in execute_reset and to force a software TAP reset operation in set_state when the target state is TAP_RESET. Change-Id: I7e0f76f8491efefff1ccaeb4b1ae16e722d76df4 Signed-off-by: N S <nlshipp@yahoo.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8121 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
jtag/drivers: OpenJTAG standard variant perf improvement Calculate exact size of response expected from OpenJTAG device so that openjtag_buf_read_standard doesn't spend 5 retry cycles waiting for data that isn't coming. Change-Id: Icd010d1fa4453d6592a1f9aed93fb1f01e0a19da Signed-off-by: N S <nlshipp@yahoo.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8101 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
jtag: fix jtag configure command containing events Commit ea2e26f7d521 ("jtag: rewrite jim_jtag_configure() as COMMAND_HANDLER") breaks the option -event if it is the last of the command line. This can be tested, even without any device connected, through: #> openocd -f board/ti_cc26x0_launchpad.cfg wrong # args: should be "-event <event-name> <event-body>" Fix the check on available arguments after -event. Change-Id: Iec1522238f906d61a888a09a7685acd9ac6442a7 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Lorenz Brun <lorenz@brun.one> Fixes: ea2e26f7d521 ("jtag: rewrite jim_jtag_configure() as COMMAND_HANDLER") Reviewed-on: https://review.openocd.org/c/openocd/+/8125 Tested-by: jenkins Reviewed-by: Lorenz Brun <lorenz@brun.one>
jtag/mpsse: mpsse_flush should not treat LIBUSB_ERROR_INTERRUPTED as an error LIBUSB_ERROR_INTERRUPTED can happen when (among other things) OpenOCD process receives a signal like SIGHUP or SIGINT during a call to libusb. Such situations are expected and should not be treated as an error - the affected request should just be restarted. Without this patch applied if a signal arrives during FTDI initialization procedure we can easily end up (if JTAG speed is low) in situations like https://review.openocd.org/c/openocd/+/4767. This happens because fpsse_flush fails due to LIBUSB_ERROR_INTERRUPTED . It should be noted that the current usage of mpsse_flush should be revised since it seems that we don't always process error codes returned by the function. Change-Id: Ifa063ce828068f8d0371e1c2a864bb6174649848 Signed-off-by: Parshintsev Anatoly <anatoly.parshintsev@syntacore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7769 Reviewed-by: Tim Newsome <tim@sifive.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
jtag/drivers: Add vid_pid command to OpenJTAG Enable support for USB vid and pid combinations other than 0x0403/0x6001 on OpenJTAG adapters. Change-Id: Ibb5fb14a6f33abbc011dbf3179df20d79ed74a7a Signed-off-by: N S <nlshipp@yahoo.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8100 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
jtag/adapter: retype adapter_gpio_config.{gpio,chip}_num Previously, the gpio_num and chip_num members of adapter_gpio_config were typed as 'int' and a sentinel value of -1 was used to denote unconfigured values. Now, these members are typed as 'unsigned int' to better reflect their expected value range. The sentinel value now maps to UINT_MAX as all adapters either define an upper bound for these members or, in the case of bcm2835gpio, only operate on a specific chip, in which case the value doesn't matter. Format specifiers have been left as %d since, when configured, valid values are within the positive range of 'int'. This allows unconfigured values to display as a more readable value of -1 instead of UINT_MAX. Change-Id: Ieb20e5327b2e2e443a8e43d8689cb29538a5c9c1 Signed-off-by: Vincent Fazio <vfazio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8124 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
jtag/drivers/jlink: make jlink quiet polling target in -d 3 Jlink driver floods the debug log by a message per one poll interval. Avoid annoying messages, change their logging level to LOG_DEBUG_IO Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I84ea6aa9cdfd44b5985c5393519d1efb7de9530a Reviewed-on: https://review.openocd.org/c/openocd/+/8116 Reviewed-by: zapb <dev@zapb.de> Tested-by: jenkins
jtag/vdebug: add support for DAP6 This change implements the support for the ARM Debug Interface v6. The DAP-level interface properly selects the DP Banks and AP address. Sample ARM configuration DAP and JTAG scripts have been updated. Change-Id: I7df87ef764bca587697c778810443649a7f46c2b Signed-off-by: Jacek Wuwer <jacekmw8@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8067 Tested-by: jenkins Reviewed-by: Ian Thompson <ianst@cadence.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
jtag/vdebug: fix socket options on CYGWIN the socket option RCVLOWAT is not supported on CYGWIN. implemented ifdef __CYGWIN not to set this option. Change-Id: I9f6e81fa98ecf5261ea286deb4675658aae59b8e Signed-off-by: Jacek Wuwer <jacekmw8@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8066 Tested-by: jenkins Reviewed-by: Ian Thompson <ianst@cadence.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
jtag/drivers: Correct ANGIE driver and GPIO Extender configuration Correct GPIO Extender configuration, after reconsideration, we need to configure the IO extender 0x23 pins as all inputs. Add more LOG_ERRORs to the code to better track bugs. Re-organize angie_init function Change-Id: I1fcf4919ba9ea95576803dd35cce7dafa26853b4 Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8079 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
jtag/drivers/cmsis_dap_usb_bulk: fix clang warning Clang static analyzer warnings "1st function call argument is an uninitialized value" on the first libusb_free_transfer() parameter (lines 423, 424) could turn into a real problem in a corner case: If allocation of a libusb transfer struct fails, the pointers of not yet allocated transfers remain uninitialized. Use calloc() to zero whole struct cmsis_dap_backend_data. Fixes: fd75e9e54270 (jtag/drivers/cmsis_dap_bulk: use asynchronous libusb transfer) Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I0e489757d82d10ed7416c5e8c215e1facc7f8093 Reviewed-on: https://review.openocd.org/c/openocd/+/8045 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>