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>
openocd: fix SPDX tag format for files .c With the old checkpatch we cannot use the correct format for the SPDX tags in the file .c, in fact the C99 comments are not allowed and we had to use the block comment. With the new checkpatch, let's switch to the correct SPDX format. Change created automatically through the command: sed -i \ 's,^/\* *\(SPDX-License-Identifier: .*[^ ]\) *\*/$,// \1,' \ $(find src/ contrib/ -name \*.c) Change-Id: I6da16506baa7af718947562505dd49606d124171 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7153 Tested-by: jenkins
jtag: make local symbols static Symbols that are not exported should be declared as static. Change-Id: I6224ae89ebda3230dfee2413e3823be9b8716bba Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7165 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
drivers/linuxgpiod: Migrate to adapter gpio commands Use the new "adapter gpio" commands to configure the GPIOs used by the linuxgpiod driver. Adds support for drive mode and resistor pull options on all signals. Change-Id: Ic90cb4f06db82435294228b6793330107a9f3606 Signed-off-by: Steve Marple <stevemarple@googlemail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7048 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
drivers/linuxgpiod: simplify gpio release We already have a helper to release the gpio. Extend it to also release its corresponding gpio chip. As side effect, remove comparison with NULL. Change-Id: I47cd446edfaead662d63c3330f25a791b747e882 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7033 Tested-by: jenkins Reviewed-by: Steve Marple <stevemarple@googlemail.com>
drivers/linuxgpiod: release gpio at exit Commit 20adf85f3484 ("linuxgpiod: add SWDIO buffer") introduces an additional gpio for SWDIO direction, but does not release it at driver's exit. Release the gpio at exit. Change-Id: If7ea31f79ffed04af585864e49bcf1f35e118bdd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7032 Tested-by: jenkins Reviewed-by: Steve Marple <stevemarple@googlemail.com>
linuxgpiod: add SWDIO buffer The SWDIO buffer requires a direction pin to select input or output direction. Output is selected by a high logic level (matches bcm2835gpio driver). Change-Id: I240cb99a5dfea08121bb33d4b5e2108ce7597468 Signed-off-by: Steve Marple <stevemarple@googlemail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6936 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
linuxgpiod: Allow using multiple GPIO chips. Allow passing optional gpiochip number before gpio number. If no optional chip number is passed, the one from the 'gpiochip' configuration directive is used. Change-Id: I16933d81581d9af4d1600c5f9fdbc832ef3fda94 Signed-off-by: Laszlo Sitzer <dlsitzer@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6742 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
drivers/linuxgpiod: add support for opendrain trst This is a follow-up to 2f424b7eb, which added support for opendrain srst, finishing up support for opendrain reset signals. Signed-off-by: Alex Crawford <openocd@code.acrawford.com> Change-Id: Ib79b2e12f2a9469fd6c53bb839c0d2e8e46103a4 Reviewed-on: https://review.openocd.org/c/openocd/+/6598 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
driver/linuxgpiod: add support for opendrain srst Some MCUs (e.g. the STM32F3) directly expose the internal reset line to an external pin. When this signal is driven by a push/pull line, it can actually be inhibited by the external driver. This results in a setup where the MCU cannot reset itself, for example, by a watchdog timeout or a sysreset request. To fix this condition, support for open drain output on the SRST line is required. Note that because `reset_config srst_open_drain` is the default, all users of this adapter will switch over to an open drain output unless explicitly configured otherwise. Signed-off-by: Alex Crawford <openocd@code.acrawford.com> Change-Id: I89b39b03aa03f826ed3c45793412780448940bcc Reviewed-on: https://review.openocd.org/c/openocd/+/6559 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
drivers/linuxgpiod: Group adapter commands Use a command group 'linuxgpiod' with subcommands instead of individual commands with 'linuxgpiod_' prefix. The old commands are still available for backward compatibility but marked as deprecated. Change-Id: Iad9b330363f81128ab1ec1cbc498df28ba2ca152 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/6400 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
openocd: fix simple cases of NULL comparison There are more than 1000 NULL comparisons to be aligned to the coding style. For recurrent NULL comparison it's preferable using trivial scripts in order to minimize the review effort. Patch generated automatically with the command: sed -i PATTERN $(find src/ -type f) where PATTERN is in the list: 's/(\([a-z][a-z0-9_]*\) == NULL)/(!\1)/g' 's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) == NULL)/(!\1)/g' 's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) == NULL)/(!\1)/g' 's/(\([a-z][a-z0-9_]*\) != NULL)/(\1)/g' 's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) != NULL)/(\1)/g' 's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) != NULL)/(\1)/g' 's/(NULL == \([a-z][a-z0-9_]*\))/(!\1)/g' 's/(NULL == \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(!\1)/g' 's/(NULL == \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(!\1)/g' 's/(NULL != \([a-z][a-z0-9_]*\))/(\1)/g' 's/(NULL != \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(\1)/g' 's/(NULL != \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(\1)/g' Change-Id: Ida103e325d6d0600fb69c0b7a1557ee969db4417 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6350 Tested-by: jenkins
drivers/linuxgpiod: add led Bitbang interface allows having a LED on one of the GPIO. Let also linuxgpiod driver to specify and use the LED connection. Change-Id: Id3d8772ee1808b92354fd073ba3947bacd8253ef Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5770 Tested-by: jenkins
jtag/drivers: add linuxgpiod driver New adapter driver for GPIO bitbanging over Linux GPIO descriptors through the library libgpiod. On Debian based distribution, the package libgpiod-dev is required for build. Change-Id: I1ce1a4f1ca79096d6d476b01b523c8c10f2cac07 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5559 Tested-by: jenkins