kinect_upload_fw: fix setting configuration for some devices On some Kinect devices where the desired configuration is already the currently active one libusb_set_configuration() fails in some way causing the subsequent bulk transfer to fail, and the program to exit, with this message: libusbx: error [op_set_configuration] failed, error -1 errno 110 About to send: 09 20 02 06 01 00 00 00 60 00 00 00 00 00 00 00 15 00 00 00 00 00 00 00 libusbx: error [submit_bulk_transfer] submiturb failed error -1 errno=2 Error: res: -1 transferred: 0 (expected 24) Only set the desired configuration if it hasn't been set already. This prevents the problems from above. Do the configuration check as illustrated in http://libusbx.sourceforge.net/api-1.0/caveats.html that is by checking that the current configuration is still the desired one after claiming the device.
kinect_upload_fw/endian.c: fix warning and rename a function Remove the bigend() function, it is never used and causes a compiler warning: endian.c:10:12: warning: ‘bigend’ defined but not used [-Wunused-function] static int bigend(void) { Also rename the litend() function to little_endian(), there is no need to use a short name in this case.
kinect_upload_fw: specify libraries after objects in the linking command When some options, like -Wl,--as-needed, are passed to the compiler (and then to the liker) the order of linking options becomes important: libraries must be specified after the objects in the linking command. The implicit rule used was more or less: kinect_upload_fw: kinect_upload_fw.o $(CC) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ with LDFLAGS expanded before $^ (the objects); use LDLIBS to specify the libraries instead, which is expanded after $^. More details in http://ao2.it/it/blog/2011/11/27/dont-mix-ldflags-and-ldlibs
kinect_upload_fw: fix reading the firmware file on Windows In MS Windows fread() behaves differently than on UNIX systems when reading binary files if we do not specify "b" in the mode when opening the file. Quoting FOPEN(3) man page: ... the 'b' is ignored on all POSIX conforming systems, including Linux. (Other systems may treat text files and binary files differently, and adding the 'b' may be a good idea if you do I/O to a binary file and expect that your program may be ported to non-UNIX environments.)