Hi guys,
@mon2 -- awesome story about HP, thanks for sharing.. entertained angels unawares!
Just as a note, we had a co-op student compile the xmosdfu.cpp for Windows (VS Express 2017) with just a few changes, and he confirmed it works. Just so you can avoid interacting with the "kind" folks at Thesycon.
You need to use the DLL release of libusb-1.0 from the Windows binaries at
https://libusb.info/ ... I think we built a 32 bit binary so we used the 32 bit dll (I always tend to build 32 bit Windows applications for some reason, not that many people run 32 bit Windows anymore but there's some old Win 7 32 bit installs hanging around I suppose). And you need the WinUSB driver installed for libusb-1.0 to work I believe.
Here is the patch we did to the xmosdfu.cpp
Code: Select all
@@ -112,19 +112,19 @@
}
int xmos_dfu_resetdevice(void) {
- libusb_control_transfer(devh, DFU_REQUEST_TO_DEV, XMOS_DFU_RESETDEVICE, 0, 0, NULL, 0, 0);
+ return libusb_control_transfer(devh, DFU_REQUEST_TO_DEV, XMOS_DFU_RESETDEVICE, 0, 0, NULL, 0, 0);
}
int xmos_dfu_revertfactory(void) {
- libusb_control_transfer(devh, DFU_REQUEST_TO_DEV, XMOS_DFU_REVERTFACTORY, 0, 0, NULL, 0, 0);
+ return libusb_control_transfer(devh, DFU_REQUEST_TO_DEV, XMOS_DFU_REVERTFACTORY, 0, 0, NULL, 0, 0);
}
int xmos_dfu_resetintodfu(unsigned int interface) {
- libusb_control_transfer(devh, DFU_REQUEST_TO_DEV, XMOS_DFU_RESETINTODFU, 0, interface, NULL, 0, 0);
+ return libusb_control_transfer(devh, DFU_REQUEST_TO_DEV, XMOS_DFU_RESETINTODFU, 0, interface, NULL, 0, 0);
}
int xmos_dfu_resetfromdfu(unsigned int interface) {
- libusb_control_transfer(devh, DFU_REQUEST_TO_DEV, XMOS_DFU_RESETFROMDFU, 0, interface, NULL, 0, 0);
+ return libusb_control_transfer(devh, DFU_REQUEST_TO_DEV, XMOS_DFU_RESETFROMDFU, 0, interface, NULL, 0, 0);
}
int dfu_detach(unsigned int interface, unsigned int timeout) {
@@ -199,7 +199,13 @@
unsigned char strIndex = 0;
unsigned int dfuBlockCount = 0;
- inFile = fopen( file, "rb" );
+ errno_t err = fopen_s(&inFile, file, "rb");
+ if (0 != err)
+ {
+ fprintf(stderr, "Error: Failed to open input data file with error %lu.\n", (unsigned long)err);
+ return -1;
+ }
+
if( inFile == NULL ) {
fprintf(stderr,"Error: Failed to open input data file.\n");
return -1;
@@ -255,7 +261,13 @@
unsigned int block_size = 64;
unsigned char block_data[64];
- outFile = fopen( file, "wb" );
+ errno_t err = fopen_s( &outFile, file, "wb" );
+ if (0 != err)
+ {
+ fprintf(stderr, "Error: Failed to open output data file with error %lu.\n", (unsigned long)err);
+ return -1;
+ }
+
if( outFile == NULL ) {
fprintf(stderr,"Error: Failed to open output data file.\n");
return -1;
@@ -273,6 +285,7 @@
}
fclose(outFile);
+ return 0;
}
int main(int argc, char **argv) {
@@ -380,7 +393,7 @@
printf("Waiting for device to restart and enter DFU mode...\n");
// Wait for device to enter dfu mode and restart
- system("sleep 20");
+ system("timeout 20 /nobreak");
// NOW IN DFU APPLICATION MODE
@@ -429,7 +442,7 @@
printf("... Reverting device to factory image\n");
xmos_dfu_revertfactory();
// Give device time to revert firmware
- system("sleep 2");
+ system("timeout 2 /nobreak");
xmos_dfu_resetfromdfu(XMOS_DFU_IF);
}
else{
cheers!