From 7b6c8b9897b43c8c8d920850fce9fde9d96d9485 Mon Sep 17 00:00:00 2001 From: Malaclypse The Younger Date: Tue, 19 Feb 2013 14:01:36 -0500 Subject: Tests on all Linux machines available led to errors such as: Erasing the memory ... erasing: 66% complete Error erasing: -84>> Abort mission! error has occured ... Please unplug the device and restart the program. Whereas Windows can recover from this condition with Eep! Connection to device lost during erase! Not to worry This happens on some computers - reconnecting... the Linux version could not correctly interpret the -84 error code returned by the USBDEVFS_CONTROL call. This modification fixes this, re-interpreting the -84 code to -2 and allowing the program to reconnect and succesfully upload the firmware. --- commandline/library/micronucleus_lib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/commandline/library/micronucleus_lib.c b/commandline/library/micronucleus_lib.c index 6f1ac8d..462190b 100644 --- a/commandline/library/micronucleus_lib.c +++ b/commandline/library/micronucleus_lib.c @@ -89,7 +89,15 @@ int micronucleus_eraseFlash(micronucleus* deviceHandle, micronucleus_callback pr i += 0.01; } - if (res == -5) + /* Under Linux, the erase process is often aborted with errors such as: + usbfs: USBDEVFS_CONTROL failed cmd micronucleus rqt 192 rq 2 len 0 ret -84 + This seems to be because the erase is taking long enough that the device + is disconnecting and reconnecting. Under Windows, micronucleus can see this + and automatically reconnects prior to uploading the program. To get the + the same functionality, we must flag this state (the "-84" error result) by + converting the return to -2 for the upper layer. + */ + if (res == -5 || res == -84) return -2; if (res != 0) return -1; -- cgit v1.2.3