aboutsummaryrefslogtreecommitdiff
path: root/src/jtag/drivers/cmsis_dap_usb_hid.c
AgeCommit message (Collapse)AuthorFilesLines
2023-01-15jtag/drivers/cmsis_dap: introduce packet_usable_sizeTomas Vanek1-0/+1
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>
2022-09-18openocd: fix SPDX tag format for files .cAntonio Borneo1-1/+1
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-07-23openocd: src/jtag: replace the GPL-2.0-or-later license tagAntonio Borneo1-13/+2
Replace the FSF boilerplate with the SPDX tag. The SPDX tag on files *.c is incorrect, as it should use the C99 single line comment using '//'. But current checkpatch doesn't allow C99 comments, so keep using standard C comments, by now. Change-Id: Ie873d12bb0fb838d0d6252e6b9ca3c2118853e9a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7069 Tested-by: jenkins
2021-11-28jtag/cmsis_dap: switch to command 'adapter serial'Antonio Borneo1-1/+1
The driver cmsis_dap defines the command 'cmsis_dap_serial' to specify the serial string of the adapter. Remove and deprecate the driver command, and use 'adapter serial'. Change-Id: I88e2d4de360a6c6f23529bb18494962a267250df Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6649 Tested-by: jenkins
2021-07-24openocd: fix Yoda conditions with checkpatchAntonio Borneo1-1/+1
The new checkpatch can automatically fix the code, but this feature is still error prone and not complete. Patch generated automatically through the new checkpatch with flags "--types CONSTANT_COMPARISON --fix-inplace". Some Yoda condition is detected by checkpatch but not fixed; it will be fixed manually in a following commit. Change-Id: Ifaaa1159e63dbd1db6aa3c017125df9874fa9703 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6355 Tested-by: jenkins
2021-07-24openocd: fix simple cases of NULL comparisonAntonio Borneo1-8/+8
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
2021-05-01Cleanup of config/includes.Tim Newsome1-0/+1
Remove a use of AH_BOTTOM from configure.ac. This macro is used by autoheader to add '#include' of some include file to the end of config.h.in and then to config.h. OpenOCD can be built with a custom config.h, so it's preferable to move these '#include' statement directly in the C files that need them dropping this unneeded dependency. It also causes problems when I want to use the gnulib library (which comes with its own Makefile, and does not have the same include path as the top-level Makefile). So this change touches a lot of files, but is actually really simple. It does not affect functionality at all. Change-Id: I52c70bf15eb2edc1dd10e0fde23b2bcd4caec000 Signed-off-by: Tim Newsome <tim@sifive.com> Reviewed-on: http://openocd.zylin.com/6171 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-04-10drivers/cmsis-dap: tidy up buffer accessTomas Vanek1-1/+8
Each one of CMSIS-DAP command handlers was responsible for setting HID report number, which in case of USB bulk transport was not used at all. The command had to be filled with 1 byte offset whereas the response was read without an offset. Introduce 'command' and 'response' pointers into struct cmsis_dap. Use them for filling the command and read the response respectively. CMSIS-DAP command parameter are now at positions as documented in https://arm-software.github.io/CMSIS_5/DAP/html/group__DAP__Commands__gr.html Adjust buffer allocation for HID and USB bulk transports. While on it, use h_u32_to_le() and h_u16_to_le() instead of per-byte writes. Change-Id: Ib0808d6826ba0e254c1007ace8b743405536332a Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/6120 Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com> Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2021-04-10cmsis-dap: don't update the packet size across backends.Adrian Negreanu1-7/+33
The hidapi cmsis-dap backend is using a packet_size of 64+1: 64 is the bMaxPacketSize0 and 1 is the hid Report-Id. In hidapi::hid_write(), the packet_size is decremented by 1 and stored for the next transfer. The packet_size is now valid bMaxPacketSize0=64, so when hid_read() is called, libusb_bulk_transfer() finishes w/o timeout. For the libusb bulk backend, the same packet_size of 64+1 is used, but there's no hid_write() to decrement and store it for the next read. So the next time a read is done, it will try to read 64+1 bytes. Fix this by putting the packet logic within each backend. Use calloc() to allocate the struct cmsis_dap to be on safer side. Change-Id: I0c450adbc7674d5fcd8208dd23062d5cdd209efd Signed-off-by: Adrian Negreanu <adrian.negreanu@nxp.com> Reviewed-on: http://openocd.zylin.com/5920 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2020-11-15Add CMSIS-DAP v2 supportMickaël Thomas1-0/+208
This change implements CMSIS-DAP v2 which works with raw USB bulk transfers. The old driver is now split into a generic CMSIS part and a HID backend, with a new raw USB backend for CMSIS-DAP v2. New commands: - cmsis_dap_backend (usb_bulk | hid | auto) - cmsis_dap_usb interface <interface number> Change-Id: I4218477b12ccbfe19c9b332321cd21394bf44e30 Signed-off-by: Mickaël Thomas <mickael9@gmail.com> Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4831 Tested-by: jenkins