diff options
author | Bluebie <a@creativepony.com> | 2012-11-30 10:30:45 +1100 |
---|---|---|
committer | Bluebie <a@creativepony.com> | 2012-11-30 10:30:45 +1100 |
commit | 80e2501285bb6535cb65cf4712ba1d0c540d6f41 (patch) | |
tree | f9af094da1cf2c8b6773b786cd03a8618ec9cafa /commandline/examples | |
parent | 51e671761935daf08fdd3881d13dd342e0263677 (diff) | |
download | micronucleus-80e2501285bb6535cb65cf4712ba1d0c540d6f41.tar.gz micronucleus-80e2501285bb6535cb65cf4712ba1d0c540d6f41.tar.bz2 micronucleus-80e2501285bb6535cb65cf4712ba1d0c540d6f41.zip |
commandline: pspgeek's usb fail workaround
Diffstat (limited to 'commandline/examples')
-rw-r--r-- | commandline/examples/micronucleus.c | 28 |
1 files changed, 24 insertions, 4 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; } |