aboutsummaryrefslogtreecommitdiff
path: root/src/jtag
AgeCommit message (Collapse)AuthorFilesLines
2023-05-24jtag/drivers/bcm2835gpio: add peripheral_mem_dev config commandTomas Vanek1-8/+37
The bcm2835gpio driver preferred /dev/gpiomem for access to memory mapped GPIO control and used /dev/mem as a fallback only if it couldn't open /dev/gpiomem. /dev/mem usually requires elevated rights or specific capabilities of the opening process, so the fallback failed anyway. Although /dev/gpiomem is the strongly preferred option with respect to security, there could be also use cases which require /dev/mem even if /dev/gpiomem is available (e.g. changing the GPIO pad settings is necessary or testing/debugging OpenOCD). It was difficult to handle such cases because they required to block globally the system device /dev/gpiomem (remove, rename or chmod). Drop the fallback feature and select the memory device by 'bcm2835gpio peripheral_mem_dev' configuration command. Use /dev/gpiomem as a default. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I60e427bda795d7a13d55d61443590dd31d694832 Reviewed-on: https://review.openocd.org/c/openocd/+/7350 Tested-by: jenkins Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com>
2023-05-24jtag/drivers/bcm2835gpio: extend peripheral_base to off_tTomas Vanek1-6/+10
Raspberry Pi 4 with 64-bit kernel and arm_peri_high=1 config.txt parameter needs peripheral_base 0x47e000000, uint32_t is not enough. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: Icedd084e2916657fa4478d452a5eb1e84a45c281 Reviewed-on: https://review.openocd.org/c/openocd/+/7685 Tested-by: jenkins Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-05-24jtag/drivers/bcm2835gpio: don't touch pad setting on /dev/gpiomemTomas Vanek1-11/+23
The pads were configured at a wrong memory address if /dev/gpiomem was mapped. The pad setting registers are not accessible in mapped /dev/gpiomem, disable the pads setting if the driver doesn't open /dev/mem. While on it, do not fail the driver initialization if pad mapping fails - just emit a warning and work with unchanged pad setting. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I0bce76cade8f7efd75efd9087a7d9ba6511a6239 Reviewed-on: https://review.openocd.org/c/openocd/+/7684 Tested-by: jenkins Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-05-18jtag: move declaration outside functionAntonio Borneo2-5/+3
The function jtag_debug_state_machine_() is only used by a static inline function and declared inside it as private. The static analyser 'sparse' complains that the function is defined as global but not cross checked against a prototype in an include file. Move the declaration outside the inline function so it get visible by interface.c, which already includes interface.h While there, change the argument type from 'unsigned' to 'unsigned int' to pass checkpatch check. Change-Id: Ia5dfb92dc4bc6d52ead4f0cb8c68319c83ff85b0 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7672 Tested-by: jenkins
2023-05-18jtag: move in interface.h the adapter_driver's declarationAntonio Borneo2-114/+40
The static analyser 'sparse' complains, while compiling a jtag driver, that the struct adapter_driver is declared in the file as non static, but it is not exposed through an include file. The message is: warning: symbol 'XXX' was not declared. Should it be static? Move the list of adapter_driver's declaration in interface.h Drop the preprocessor #ifdef/#endif around the declaration, as it has no effect when the declaration is not used and/or the symbol does not exist. Change-Id: I5b8f5fe48a89ff0ffce38d547c551cd196379fbf Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7665 Tested-by: jenkins
2023-05-13jtag: tcl: show error message when attempting manual "drscan" on a bypassed tapPaul Fertser1-0/+5
To perform any meaningful manipulations with DR the corresponding IR should be set to a relevant instruction, not BYPASS, so warn the user accordingly. Signed-off-by: Paul Fertser <fercerpav@gmail.com> Change-Id: I42580ecd75ae824a4145f6f17f0df9bcf825b50f Reviewed-on: https://review.openocd.org/c/openocd/+/7654 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2023-05-13jtag: tcl: change drscan usage to show at least one value is requiredPaul Fertser1-1/+1
It's customary to use [] brackets to mean the argument is optional, but drscan requires at least one pair of "num_bits value" so change it to (). In common regular expressions * means 0 or more, and + means 1 or more, so change that too. Signed-off-by: Paul Fertser <fercerpav@gmail.com> Change-Id: Ib15d833bda2aa398ad1345a042f97d91c98dbf66 Reviewed-on: https://review.openocd.org/c/openocd/+/7653 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-05-13jtag: rewrite command 'pathmove' as COMMAND_HANDLERAntonio Borneo1-23/+20
Change-Id: I1f8c6722021f392b1f065484b63a19964db69ad5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7556 Tested-by: jenkins
2023-05-13jtag: rewrite command 'drscan' as COMMAND_HANDLERAntonio Borneo1-114/+65
Reorganize the code to parse the command line only once. Add check for successful memory allocation. Change-Id: Ibf6068e177c09e93150d11aecfcf079348c47c21 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7555 Tested-by: jenkins
2023-05-13openocd: trivial replace of jim-nvp with new nvpAntonio Borneo1-4/+5
For some trivial case only, replace calls to jim-nvp with calls to the new OpenOCD nvp. Change-Id: Ifd9aff32b67748af8ab808e6a6b6e64f5271b888 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7553 Tested-by: jenkins
2023-05-06jtag: xds110: fix check on malloc() returned pointerAntonio Borneo1-1/+1
Commit 07e1ebcc12cd ("jtag: drivers: with pointers, use NULL instead of 0") incorrectly inverts the check, making the driver's pathmove operation not functional and triggering two clang errors. Fix the check on malloc() returned pointer. Change-Id: If1f220aca67452adbcd3a1c9cf691fc984b16b27 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: 07e1ebcc12cd ("jtag: drivers: with pointers, use NULL instead of 0") Reviewed-on: https://review.openocd.org/c/openocd/+/7656 Tested-by: jenkins
2023-05-05jtag: drivers: with pointers, use NULL instead of 0Antonio Borneo14-32/+40
Don't compare pointers with 0, use NULL when needed. Don't assign pointer to 0, use NULL. Don't pass 0 ad pointer argument, pass NULL. While there, check for return value from malloc(), replace an assert() with a LOG_ERROR(), drop a useless cast. Detected through 'sparse' tool. Change-Id: Ia7cf52221b12198aba1a07ebdfaf57ce341d5699 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7592 Tested-by: jenkins
2023-05-05jtag: drivers: add static to local symbolsAntonio Borneo3-4/+4
Add static type to symbols that are not used elsewhere. Detected through 'sparse' tool. Change-Id: I00e151d2466868a5dce028444d326defb80d4826 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7591 Tested-by: jenkins
2023-03-25jtag: rewrite command 'flush_count' as COMMAND_HANDLERAntonio Borneo1-5/+9
While there: - check the number of command parameters; - add the mandatory 'usage' field. Change-Id: I7cd16f049753caedf19f313f7dc84be98efdba42 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7497 Tested-by: jenkins
2023-03-25jtag: rewrite command 'jtag arp_init-reset' as COMMAND_HANDLERAntonio Borneo1-20/+12
While there add the mandatory 'usage' field. Change-Id: I316fb31e24e94985dcc724e428b0384be7ef5bdd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7496 Tested-by: jenkins
2023-03-25jtag: rewrite command 'jtag arp_init' as COMMAND_HANDLERAntonio Borneo1-16/+7
While there add the mandatory 'usage' field. Change-Id: I3491ed79d11c5a3e81cc9afd2423da14b8df72ff Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7495 Tested-by: jenkins
2023-03-25jtag: rewrite command 'jtag names' as COMMAND_HANDLERAntonio Borneo1-17/+9
While there: - format in a human readable way the output list by using one line per tap name; - add the mandatory 'usage' field. Change-Id: I295449220c78fac8973478b265413342ea832f61 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7494 Tested-by: jenkins
2023-03-25jtag: rewrite command 'adapter name' as COMMAND_HANDLERAntonio Borneo1-12/+10
Trivial change. Add the mandatory 'usage' field. Change-Id: Id92af5cd873fb86f5de79f785f156d1ef734b005 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7493 Tested-by: jenkins
2023-03-18drivers/ftdi: prevent misleading error msg when more vid/pids configuredTomas Vanek2-19/+8
The driver tries to open mpsse engine for each vid pid pair in sequence. If more vid/pid pairs are configured and the USB device does not correspond to the first pair, the driver shows 'unable to open ftdi device ...' error. Match vid pid with the whole list as used in jtag_libusb_open() instead of multiple mpsse_open() in for loop over vid/pid pairs. Change-Id: I8ef55205be221c727607fe25b81ae21de0d96f02 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7529 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Wolfram Sang <wsa@kernel.org>
2023-03-18drivers/libusb_helper: allow external use of jtag_libusb_match_ids()Tomas Vanek2-1/+3
Can be employed by a driver with custom libusb open. Change-Id: I00c8a01df8780891a8b7c30e2e34ab191acdf9a8 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7528 Tested-by: jenkins Reviewed-by: Wolfram Sang <wsa@kernel.org> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-02-26jtag/drivers/cmsis_dap: run queue on reaching transaction limitPeter Collingbourne1-1/+3
We currently fail the transfer when issuing more than 255 transactions at once, e.g. > read_memory 0x10000000 32 256 CMSIS-DAP transfer count mismatch: expected 257, got 1 This is because the protocol only supports 255 transactions per packet (65535 for block transactions), and as a result we truncate the transaction count when assembling the packet. Fix it by running the queue when we hit the limit. Change-Id: Ia9e01e3af5ad035f2cf2a32292c9d66e57eafae9 Signed-off-by: Peter Collingbourne <pcc@google.com> Fixes: 40bac8e8c4e5 ("jtag/drivers/cmsis_dap: improve USB packets filling") Reviewed-on: https://review.openocd.org/c/openocd/+/7483 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2023-01-28jtag/drivers/jlink: allow SWD multidropTomas Vanek1-3/+7
SW-DPv2 and SWJ-DPv2 devices do not reply to DP_TARGETSEL write cmd. Ignore the received ACK after TARGETSEL write. While on it, use swd_ack_to_error_code() for unified error code translation of the received ACK value for all other commands. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: If978c88c8496e31581175385e59c32faebfd20aa Reviewed-on: https://review.openocd.org/c/openocd/+/7383 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: zapb <dev@zapb.de>
2023-01-28jtag/drivers/bcm2835gpio: refactor delays to inline functionTomas Vanek1-6/+9
No functional change, the delay is unchanged. Change-Id: I5b5e837d741ac01fc573657357c5fe61ad901319 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7262 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-28jtag/drivers/bcm2835gpio: use rounding in delay mathTomas Vanek1-2/+5
After setting adapter speed to some values, the driver shows the real speed little bit higher. Although it does not impose a problem from technical point of view because the difference is smaller than usual speed error, it looks at least strange to the user. The documentation reads that real frequency should be same or lower than requested. Use proper rounding in speed -> delay and delay -> speed conversions. Change-Id: I1831112cc58681875548d2aeb688391fb79fa37f Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7261 Tested-by: jenkins Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-28jtag/drivers/bitbang: avoid mostly harmless glitch on SWDIOTomas Vanek1-1/+13
bitbang_swd_exchange(rnw=true,...) calls bitbang_interface->swd_write() with swdio clamped to 0. bitbang_swd_write_reg() reads 1 turnaround bit, 3 ack bits and 1 turnaround by one call to bitbang_swd_exchange() and then switches SWDIO to output. AFAIK all bitbang interfaces switch SWDIO GPIO direction immediately in bitbang_interface->swdio_drive(). The GPIO now drives SWDIO line to the value stored in the output register which is always zero from previous bitbang_swd_exchange(rnw=true,...). In case the following data bit (bit 0) is 1 we can observe a glitch on SWDIO: _____ out 1 ____ HiZ/pull-up ----\ / \ / \______ out 0 ______/ swdio_drive(true) swd_write(0,1) The glitch fortunately takes place far enough from SWCLK rising edge where SWDIO is sampled by the target, so I believe it is harmless except some corner cases where the reflected wave is delayed on long line. Anyway keeping electrical signals glitch free is a good practice. To keep performance penalty minimal, pre-write the first data bit to SWDIO GPIO output buffer while clocking the turnaround bit. Following swdio_drive(true) outputs the pre-written value and the same value is rewritten by the next swd_write() instead of glitching SWDIO. Change-Id: I72ea9c0b2fae57e8ff5aa616859182c67abc924f Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7260 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-28jtag/drivers/openjtag: fix annoying num_cycles > 16 warningN S1-6/+8
The OpenJTAG driver logs "num_cycles > 16 on run test" warning whenever the JTAG_RUNTEST operation cycle count is larger than 16. Instead of logging the warning and only running the first 16 TCLK cycles, remove the warning and queue up multiple operations of up to 16 cycles each. Signed-off-by: N S <nlshipp@yahoo.com> Change-Id: Id405fa802ff1cf3db7a21e76bd6df0c2d3a0fe61 Reviewed-on: https://review.openocd.org/c/openocd/+/7420 Tested-by: jenkins Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-15jtag: hla: use generic helper for commands 'jtag newtap' 'swd newdap'Antonio Borneo6-168/+3
The commands 'jtag newtap' and 'swd newdap' have to work either on HLA transport and on standard JTAG/SWD. Having a dedicated implementation for HLA is a non-sense. Reuse the generic code jim_jtag_newtap() and drop the files hla_tcl.[ch] as they are now empty. Change-Id: I9dabbdc2a6f338f23b2fd3ed1a4dc3da0200c080 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7428 Tested-by: jenkins
2023-01-15jtag: parse command options in 'swd newdap'Antonio Borneo1-8/+1
The same code is currently used for commands 'jtag newtap' and 'swd newdap' (plus dapdirect versions), but for SWD case the code skips the parsing of the command line as not every flag is used. This has the drawback that syntax errors get unchecked. Move the check about the transport so the command line get always parsed even when the corresponding flags are not useful. Change-Id: I596c3beb04e9e8a9ebe6ee68a61395b679d43b3e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7427 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2023-01-15jtag/drivers/cmsis_dap: prevent conn/discon workaround before line resetTomas Vanek1-1/+3
The line reset SWD sequence is used quite often in SWD multidrop mode. Prevent the ugly connect/disconnect adapter firmware bug workaround to be called before each line reset. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: Id85bff075dba9077e4e501e2cdcfd64d5d9d0531 Reviewed-on: https://review.openocd.org/c/openocd/+/7381 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-15jtag/drivers/cmsis_dap: speed up long transfers using DAP_TransferBlockTomas Vanek2-22/+83
DAP_TransferBlock command saves n - 3 bytes in comparison to DAP_Transfer, where n is number of transfers. Use DAP_TransferBlock optionaly to save some USB bandwidth. The change increases the speed of the write transfer from 40 KiB/s to 42 KiB/s @ USB FS, adapter speed 1000. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: Ifde0159cfd44481d2b81b90daa088e731c03e26d Reviewed-on: https://review.openocd.org/c/openocd/+/7372 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-15jtag/drivers/cmsis_dap: improve USB packets fillingTomas Vanek2-8/+62
DAP write transaction occupies 5 bytes of a command packet. DAP read transaction needs just one byte in a command packet and expect 4 bytes in a response. The fixed maximal number of transactions in a packet caused packet filling less than optimal. Compute both command and expected response sizes based on read or write direction of each transaction. Run the queue if one of sizes does not fit into a packet. The change increases the speed of the mostly read transfer from 36 KiB/s to almost 40 KiB/s @ USB FS, adapter speed 1000 due to reduction of adapter inserted RDBUFF reads. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: Ib70812600eaae0403b8ee8673b6f897348496569 Reviewed-on: https://review.openocd.org/c/openocd/+/7364 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-15jtag/drivers/cmsis_dap: introduce packet_usable_sizeTomas Vanek4-12/+8
USB bulk backend needs to avoid zero sized USB packets sent after each full sized packed for performance reasons. HID backend uses fixed size HID reports so the full size of the report can be utilized. Introduce packet_usable_size to reflect it. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I34094c9edac5730624480711cbd6aa65883c47c7 Reviewed-on: https://review.openocd.org/c/openocd/+/7363 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-15jtag/drivers/cmsis_dap: use unsigned typesTomas Vanek2-23/+24
Not all variables converted, JTAG part is left as is. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: Ie9cc890769a2f53cb3a07fd457030e1b98910d44 Reviewed-on: https://review.openocd.org/c/openocd/+/7362 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-15jtag/drivers/cmsis_dap: use dap parameter instead of cmsis_dap_handleTomas Vanek1-6/+7
Replace the direct dereference of cmsis_dap_handle by dereference of the dap function parameter wherever possible. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I32601dbe0270267642720a8524706aa76d187c3b Reviewed-on: https://review.openocd.org/c/openocd/+/7361 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-15jtag/drivers/cmsis_dap: move pending request FIFOTomas Vanek2-56/+59
Move all pending request FIFO related variables to the struct cmsis_dap Pure refactoring, no functional changes. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I2cea9c1e265ac102ec0f314767b8b9afdcda9ee9 Reviewed-on: https://review.openocd.org/c/openocd/+/7360 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-15adapter: Improve three adapter-related printsJan Matyas1-3/+5
- Do not warn the user about adapter speed not being set if the selected adapter does not support configurable speed. This would be confusing to users. - Minor reword in the "adapter speed is not selected" warning. - Print the adapter name in the "adapter doesn't support configurable speed" log entry - Another minor reword: autoselect --> autoselecting Signed-off-by: Jan Matyas <matyas@codasip.com> Change-Id: I4c198b547544fd8199921f092153562c5f159134 Reviewed-on: https://review.openocd.org/c/openocd/+/7269 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-15nds32: drop it, together with aice adapter driverAntonio Borneo14-6382/+0
The target nds32 and its companion adapter aice have not received any real improvement since 2013. It has been hard to keep them aligned during the evolution of OpenOCD code, with no way for maintainers to really check if they are still working. No real documentation is present for them in OpenOCD. The nds32 code triggers ~50 errors/warnings with scan-build. The arch nds32 has been dropped from Linux kernel v5.18-rc1. For all the reasons above, this code has been deprecated with commit 2e5df83de7f2 ("nds32: deprecate it, together with aice adapter driver") and tagged to be dropped before v0.13.0. Let it r.i.p. in OpenOCD git history. While there, drop from checkpatch list the camelcase symbols that where only used in this code. Change-Id: Ide52a217f2228e9da2f1cc5036c48f3536f26952 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7382 Tested-by: jenkins
2023-01-11jtag: esp_usb_jtag: remove macro __packedAntonio Borneo1-5/+3
In FreeBSB 13.0 the build fails due to redefined macro __packed. src/jtag/drivers/esp_usb_jtag.c:19:9: error: '__packed' macro redefined [-Werror,-Wmacro-redefined] #define __packed __attribute__((packed)) ^ /usr/include/sys/cdefs.h:223:9: note: previous definition is here #define __packed __attribute__((__packed__)) ^ 1 error generated. Drop the macro and align the code with the other files in OpenOCD project, where the attribute is directly applied without using a macro. Change-Id: I89ae943e77036206d40d4d54172cd4a73e76e5c5 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Wojciech Puchar <wojtek@puchar.net> Reviewed-on: https://review.openocd.org/c/openocd/+/7435 Tested-by: jenkins Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
2022-12-18jtag: fix build with configure --enable-verboseAntonio Borneo2-20/+10
With flag --enable-verbose, configure enables compiling some conditional code that with new gcc triggers an error: error: '%04x' directive output may be truncated writing between 4 and 8 bytes into a region of size 5 [-Werror=format-truncation=] Extend the buffer to contain the full 8 bytes of %04x on a 'int' and change the limit in snprintf. Skip the intermediate buffer 's[4]'. Align the code to the coding style. Change-Id: Ifc8a6e4686555578a7355a1f6049471fd5e31913 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Karl Hammar <karl@aspodata.se> Reported-by: Tommy Murphy <tommy_murphy@hotmail.com> Fixes: https://sourceforge.net/p/openocd/tickets/376/ Reviewed-on: https://review.openocd.org/c/openocd/+/7403 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2022-12-17driver: vdebug: fix mode of cmd 'vdebug mem_path'Antonio Borneo1-1/+1
The command 'vdebug mem_path' is reported in the documentation as '{Config Command}', but the code sets mode = COMMAND_ANY. The code of the commands sets some value that is only used during the init phase, so the documentation is correct. Change mode of command 'vdebug mem_path' to COMMAND_CONFIG. Change-Id: Icb940fe382cbc75015273b35dcc8a88fc2a7d0ac Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7395 Tested-by: jenkins Reviewed-by: Jacek Wuwer <jacekmw8@gmail.com>
2022-12-03jtag: xds110: fix clang error core.StackAddressEscapeAntonio Borneo1-0/+2
Clang ignores that xds110_swd_write_reg() is always called with bit SWD_CMD_RNW in 'cmd' set to zero. It then complains that the local variable 'value' gets passed by address to xds110_swd_queue_cmd() and in case of 'read request' such stack address get stored for later use: src/jtag/drivers/xds110.c:1363:1: warning: Address of stack memory associated with local variable 'value' is still referred to by the global variable 'xds110' upon returning to the caller. This will be a dangling reference [core.StackAddressEscape] To both xds110_swd_write_reg() and xds110_swd_read_reg(), add an assert() to inform Clang about the state of bit SWD_CMD_RNW. Change-Id: I7687c055ec71424b642e152f478723a930966e3a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7380 Tested-by: jenkins
2022-11-28jtag/drivers/cmsis_dap.c: Fix Length of SWO Baudrate CommandNick Kraus1-1/+1
The command should now send the full 5 byte command length, which includes the command tag (0x19) and the 4-byte baudrate word, instead of only the last 3 bytes of the baudrate. Signed-off-by: Nick Kraus <nick@nckraus.com> Change-Id: Idd6e084efd7492489aa900cdbf08f540944041cb Reviewed-on: https://review.openocd.org/c/openocd/+/7370 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-11-11jtag/drivers/cmsis_dap: prevent CDC missdetect as CMSIS-DAP bulkTomas Vanek1-1/+3
The autodetection of CMSIS-DAP v2 bulk interface is tricky as not all adapters conform CMSIS-DAP specs. If an interface has a string descriptor containing CMSIS-DAP, then OpenOCD did not insisted on the correct interface class LIBUSB_CLASS_VENDOR_SPEC. However the relaxed test caused false autodetection of v2 bulk interface on some CMSIS-DAP v1 adapters with an additional serial interface with the string descriptor stupidly containing CMSIS-DAP text. Make the test less relaxed, refuse autodetection of the interfaces with the class number of well known functions including CDC and MSC. Link: https://sourceforge.net/p/openocd/tickets/368/ Change-Id: I917cb257eb42aab93560cc39c61ec35a60ce52e3 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7279 Tested-by: jenkins Reviewed-by: SilverFox <yyjdelete@126.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-21jtag/drivers: bcm2835gpio: implement memory barriers when bitbashingJonathan Bell1-0/+15
This GPIO driver is common to SoCs that have in-order ARM cores (BCM2835) as well as superscalar (BCM2836-7) and speculative out-of-order cores (BCM2711). For BCM2837 and BCM2711, the processor can dual-issue stores and is free to merge writes to peripheral memory for pages mapped MT_NORMAL_NC, which is the default provided by /dev/[gpio]mem. This can cause glitches (or missing edges) on GPIO pins when toggled with no delay, as pipelined writes to the same address can get arbitrarily squelched. To prevent this happening, make sure the preceding write ops are flushed outside the shareable domain by using a memory barrier. Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com> Change-Id: I8805cc0911667bcb9b7f4ca340d7f4f1cb25d096 Reviewed-on: https://review.openocd.org/c/openocd/+/7258 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-10-08jtag/drivers/bitbang: reduce debug verbosityTomas Vanek1-11/+4
The bitbang driver floods the log by many messages with very little informational value. Remove some LOG_DEBUGs, convert some others to LOG_DEBUG_IO. Change-Id: I0c7539467b45543e12932c67dc71e86d58c8c6cd Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7220 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com> Tested-by: jenkins
2022-10-08jtag/drivers/cmsis_dap: add LOG_DEBUG_IO to cmsis_dap_metacmd_targetselTomas Vanek1-2/+4
Make write to DP_TARGETSEL is logged the similar way as other DP register read/writes. While on it fix checkpatch message 'Concatenated strings should use spaces between elements' Change-Id: I98f724c984e8c4610cc461340f4c4a7cc9627ed9 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7219 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Jonathan Bell <jonathan@raspberrypi.com> Tested-by: jenkins
2022-09-23jtag/adapter: fix doxygen warningAntonio Borneo1-1/+1
Doxygen complains about: adapter.h:120: warning: Unsupported xml/html tag <signal_name> found Move the text in double quote to remove the warning. Change-Id: Ia4ead5caa83c84e10ee2b2359048c282892170b0 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: 82fd4005427b ("jtag/adapter: Add command 'adapter gpio'") Reviewed-on: https://review.openocd.org/c/openocd/+/7202 Tested-by: jenkins
2022-09-18openocd: fix SPDX tag format for files .cAntonio Borneo74-74/+74
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
2022-09-13drivers/bcm2835gpio: Fully restore GPIOs after useSteve Marple1-5/+21
Restore outputs to their initial output level. Signed-off-by: Steve Marple <stevemarple@googlemail.com> Change-Id: I82402fd7b59d944f81c0ea7859ac499943901f82 Reviewed-on: https://review.openocd.org/c/openocd/+/7125 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2022-09-13drivers/bcm2835gpio: Add support for activity LEDSteve Marple1-1/+11
Signed-off-by: Steve Marple <stevemarple@googlemail.com> Change-Id: I472385753507167c93328b9b4dc62d5d61c86f74 Reviewed-on: https://review.openocd.org/c/openocd/+/7124 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>