summaryrefslogtreecommitdiffstats
path: root/commandline
diff options
context:
space:
mode:
authorBluebie <a@creativepony.com>2012-11-30 10:30:45 +1100
committerBluebie <a@creativepony.com>2012-11-30 10:30:45 +1100
commit80e2501285bb6535cb65cf4712ba1d0c540d6f41 (patch)
treef9af094da1cf2c8b6773b786cd03a8618ec9cafa /commandline
parent51e671761935daf08fdd3881d13dd342e0263677 (diff)
downloadmicronucleus-80e2501285bb6535cb65cf4712ba1d0c540d6f41.tar.gz
micronucleus-80e2501285bb6535cb65cf4712ba1d0c540d6f41.tar.bz2
micronucleus-80e2501285bb6535cb65cf4712ba1d0c540d6f41.zip
commandline: pspgeek's usb fail workaround
Diffstat (limited to 'commandline')
-rw-r--r--commandline/examples/micronucleus.c28
-rw-r--r--commandline/library/micronucleus_lib.c4
2 files changed, 27 insertions, 5 deletions
diff --git a/commandline/examples/micronucleus.c b/commandline/examples/micronucleus.c
index af62494..4cab97a 100644
--- a/commandline/examples/micronucleus.c
+++ b/commandline/examples/micronucleus.c
@@ -179,9 +179,29 @@ int main(int argc, char **argv) {
setProgressData("erasing", 4);
printf("> Erasing the memory ...\n");
res = micronucleus_eraseFlash(my_device, printProgress);
- if (res != 0) {
- printf(">> Abort mission! An error has occured ...\n");
- printf(">> Please unplug the device and restart the program. \n");
+
+ if (res == -2) { // erase disconnection bug workaround
+ printf(">> Eep! Connection to device lost during erase! Not to worry\n");
+ printf(">> This happens on some computers - reconnecting...\n");
+ my_device = NULL;
+
+ int deciseconds_till_reconnect_notice = 50; // notice after 5 seconds
+ while (my_device == NULL) {
+ delay(100);
+ my_device = micronucleus_connect();
+ deciseconds_till_reconnect_notice -= 1;
+
+ if (deciseconds_till_reconnect_notice == 0) {
+ printf(">> (!) Automatic reconnection not working. Unplug and reconnect\n");
+ printf(" device usb connector, or reset it some other way to continue.\n");
+ }
+ }
+
+ printf(">> Reconnected! Continuing upload sequence...\n");
+
+ } else if (res != 0) {
+ printf(">> Abort mission! %d error has occured ...\n", res);
+ printf(">> Please unplug the device and restart the program.\n");
return EXIT_FAILURE;
}
printProgress(1.0);
@@ -191,7 +211,7 @@ int main(int argc, char **argv) {
res = micronucleus_writeFlash(my_device, endAddress, dataBuffer, printProgress);
if (res != 0) {
printf(">> Abort mission! An error has occured ...\n");
- printf(">> Please unplug the device and restart the program. \n");
+ printf(">> Please unplug the device and restart the program.\n");
return EXIT_FAILURE;
}
diff --git a/commandline/library/micronucleus_lib.c b/commandline/library/micronucleus_lib.c
index 561ddce..6f1ac8d 100644
--- a/commandline/library/micronucleus_lib.c
+++ b/commandline/library/micronucleus_lib.c
@@ -89,7 +89,9 @@ int micronucleus_eraseFlash(micronucleus* deviceHandle, micronucleus_callback pr
i += 0.01;
}
- if(res!=0)
+ if (res == -5)
+ return -2;
+ if (res != 0)
return -1;
else
return 0;