Skip to content

Commit 3fd9759

Browse files
zapb-0tom-van
authored andcommitted
adapters/cmsis-dap: Fix build without libusb
The cmsis-dap core driver depends on libusb-related code which breaks the build when libusb is not available. Remove libusb dependency of the core driver to fix the build issue. For now, use an own timeout #define with the value of LIBUSB_TIMEOUT_MS but timeout handling should be better moved to the backends. However, this should be addressed in a dedicated patch. Change-Id: Ic5da392f8ab26b47466be199432432cdc08712ab Signed-off-by: Marc Schink <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/9161 Reviewed-by: Tomas Vanek <[email protected]> Reviewed-by: <[email protected]> Tested-by: jenkins
1 parent 1f5da25 commit 3fd9759

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/jtag/drivers/cmsis_dap.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
#include <target/cortex_m.h>
3838

3939
#include "cmsis_dap.h"
40-
#include "libusb_helper.h"
40+
41+
#define TIMEOUT_MS 6000
4142

4243
/* Create a dummy backend for 'backend' command if real one does not build */
4344
#if BUILD_CMSIS_DAP_USB == 0
@@ -363,12 +364,12 @@ static int cmsis_dap_xfer(struct cmsis_dap *dap, int txlen)
363364
}
364365

365366
uint8_t current_cmd = dap->command[0];
366-
int retval = dap->backend->write(dap, txlen, LIBUSB_TIMEOUT_MS);
367+
int retval = dap->backend->write(dap, txlen, TIMEOUT_MS);
367368
if (retval < 0)
368369
return retval;
369370

370371
/* get reply */
371-
retval = dap->backend->read(dap, LIBUSB_TIMEOUT_MS, CMSIS_DAP_BLOCKING);
372+
retval = dap->backend->read(dap, TIMEOUT_MS, CMSIS_DAP_BLOCKING);
372373
if (retval < 0)
373374
return retval;
374375

@@ -872,7 +873,7 @@ static void cmsis_dap_swd_write_from_queue(struct cmsis_dap *dap)
872873
}
873874
}
874875

875-
int retval = dap->backend->write(dap, idx, LIBUSB_TIMEOUT_MS);
876+
int retval = dap->backend->write(dap, idx, TIMEOUT_MS);
876877
if (retval < 0) {
877878
queued_retval = retval;
878879
goto skip;
@@ -913,7 +914,7 @@ static void cmsis_dap_swd_read_process(struct cmsis_dap *dap, enum cmsis_dap_blo
913914
}
914915

915916
/* get reply */
916-
retval = dap->backend->read(dap, LIBUSB_TIMEOUT_MS, blocking);
917+
retval = dap->backend->read(dap, TIMEOUT_MS, blocking);
917918
bool timeout = (retval == ERROR_TIMEOUT_REACHED || retval == 0);
918919
if (timeout && blocking == CMSIS_DAP_NON_BLOCKING)
919920
return;

0 commit comments

Comments
 (0)