aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Schodet2021-09-29 19:53:54 +0200
committerNicolas Schodet2021-09-29 19:53:54 +0200
commit582238fde1bce551e1c8bf6a0cc95b830bf08bbe (patch)
treed8556467333c3460c39e109bdebe82c2194b7a4f
parent3e3709885a3627c9dec1414b505e76252256ec68 (diff)
Detach the kernel driver
On Linux, the SAM-BA bootloader is claimed by the cdc_acm driver, preventing libnxt to access it. Try to detach the kernel driver, if it fails, try to use the device anyway. The usb_detach_kernel_driver_np function is only implemented on Linux, it will return an error on other system, just ignore it. Fix issue reported at: https://code.google.com/archive/p/libnxt/issues/2
-rw-r--r--lowlevel.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lowlevel.c b/lowlevel.c
index 7b3bec6..3779af7 100644
--- a/lowlevel.c
+++ b/lowlevel.c
@@ -96,6 +96,9 @@ nxt_open(nxt_t *nxt, int interface)
nxt->hdl = usb_open(nxt->dev);
+ // Try to detach driver, but ignore errors, only implemented on Linux
+ usb_detach_kernel_driver_np(nxt->hdl, interface);
+
ret = usb_set_configuration(nxt->hdl, 1);
if (ret < 0)
{