Skip to content

Commit

Permalink
usb: Replace USBDEVFS interface with libusb
Browse files Browse the repository at this point in the history
In order to support selecting board based on serial number the iProduct
field needs to be inspected, with the hand-rolled parsing of the USB
descriptors this becomes cumbersome.

Furthermore the direct use of Linux's USBDEVFS creats an unnecessary
dependency on the host OS being Linux.

It's unclear why libusb wasn't choosen in the first place, perhaps it
relates to the faint memory of 0.1 vs 1.0 packaging issues?

Move to libusb-1.0 in order to resolve these issues, as well as clean up
the code a bit.

Signed-off-by: Bjorn Andersson <[email protected]>
  • Loading branch information
quic-bjorande committed May 8, 2024
1 parent 5f2f82a commit 399b3fd
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 198 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ QDL := qdl
RAMDUMP := qdl-ramdump

CFLAGS := -O2 -Wall -g `pkg-config --cflags libxml-2.0`
LDFLAGS := `pkg-config --libs libxml-2.0 libudev`
LDFLAGS := `pkg-config --libs libxml-2.0` -lusb-1.0
prefix := /usr/local

QDL_SRCS := firehose.c qdl.c sahara.c util.c patch.c program.c ufs.c usb.c
Expand Down
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Usage:

Building
========
In order to build the project you need libxml2 and libudev headers
and libraries, found in e.g. the libxml2-dev and libudev-dev packages
In order to build the project you need libxml2 and libusb-1.0 headers
and libraries, found in e.g. the libxml2-dev and libusb-1.0.0-dev packages

With these installed run:
make
3 changes: 3 additions & 0 deletions qdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

#define MAPPING_SZ 64

struct libusb_device_handle;

struct qdl_device {
struct libusb_device_handle *usb_handle;
int fd;

int in_ep;
Expand Down
Loading

0 comments on commit 399b3fd

Please sign in to comment.