From 874cacf143330bf156d44102faba83ade270029d Mon Sep 17 00:00:00 2001 From: Zach Eveland Date: Thu, 8 Sep 2011 16:23:29 -0400 Subject: misc. bootloader fixes: increased wait time after receiving avrdude 'Q', increased bootloader timeout, and fixed LED one-shot timing --- bootloaders/diskloader/DiskLoader.hex | 171 +++++++++++++++--------------- bootloaders/diskloader/src/DiskLoader.cpp | 5 +- bootloaders/diskloader/src/USBCore.cpp | 31 +++--- 3 files changed, 110 insertions(+), 97 deletions(-) (limited to 'bootloaders/diskloader') diff --git a/bootloaders/diskloader/DiskLoader.hex b/bootloaders/diskloader/DiskLoader.hex index 7ca0c74..811efed 100644 --- a/bootloaders/diskloader/DiskLoader.hex +++ b/bootloaders/diskloader/DiskLoader.hex @@ -1,4 +1,4 @@ -:1078000011241FBECFEFDAE0DEBFCDBFC3C0410100 +:1078000011241FBECFEFDAE0DEBFCDBFC5C04101FE :1078100042144505560455026403740300001E9586 :1078200087020110030000C18081C106C0FF0A0069 :107830000CA10185037508150026FF00954009017C @@ -14,87 +14,92 @@ :1078D00084034000400020918A0130918B012F5F8A :1078E0003F4F30938B0120938A01832F9927982F44 :1078F00087FD9095990F921710F447980895479A2D -:10790000089581E08093E0001092E200EE27FF27C7 -:10791000099408950F931F93CF93DF93982FEB0152 -:10792000042F10E088E76030780730F411E083E03E -:10793000FB0180935700E895892F68E071E0402FA4 -:10794000E2D0112311F107B600FCFDCF402F469580 -:10795000FE01A8E0B1E020E031E009C08D919D91E9 -:107960000C0130935700E895112432962F5F2417AD -:10797000A8F385E0FE0180935700E89507B600FC68 -:10798000FDCF81E180935700E895DF91CF911F9162 -:107990000F910895769A289A47983F9A209A6E9A5E -:1079A00090E8909361001092610081E885BF95BFD7 -:1079B00091D084E18093880180E180938901E0E0A7 -:1079C000F0E0859194918F5F9F4F19F081E0809353 -:1079D0008D01EE24FF24BB24B39421E0C22ED12CD0 -:1079E000DBD1082F8EE098E7FC01249131960296B6 -:1079F0004491201711F02223B9F710928F011092B1 -:107A00008E0182E068E071E07ED0013479F460910B -:107A100008016058633028F0683111F064E001C05B -:107A200063E0C62FD0E0CF5DD7480EC0063571F4B5 -:107A300080910801803311F011E022C080910A0189 -:107A4000C82FD0E0C25ED74811E022C0053721F42C -:107A500013E0CEE1D8E71CC0053539F4E090080109 -:107A6000F0900901EE0CFF1C0AC0043631F482E0EC -:107A7000B701409109014EDF02C0043721F010E048 -:107A8000C5E2D8E705C010910901E701E10EF11C3C -:107A900083D18097B1F483E068E871E041E050E081 -:107AA00049D0112329F0412F50E083E8BE0142D094 -:107AB00083E469E871E041E050E03CD0013509F031 -:107AC0008FCFD0928F01C0928E01B0928D01EE24A3 -:107AD000FF2486CF10928F0110928E0110928C019C -:107AE00010928D0181E08093D70080EA8093D800C6 -:107AF00082E189BD09B400FEFDCF80E98093D80002 -:107B00001092E0000895FB018093E9009BE60FC00E -:107B10008091E80085FFFCCF28988091F100819347 -:107B20008091E80085FD02C09093E8004150442315 -:107B300079F70895982FFB01282F20728770809382 -:107B4000E9003AE315C08091E80085FFFCCF97FF7C -:107B500002C0849101C080813196211180E0769825 -:107B60008093F1008091E80085FD02C03093E80029 -:107B7000415050408FEF4F3F580729F796FF03C001 -:107B80008AE38093E800089580919101813281F425 -:107B9000769820E030E003C080818093F100F90105 -:107BA000E050FF4F2F5F3F4F28303105A9F71FC02E -:107BB0008032B9F48091E80082FFFCCF289820E061 -:107BC00030E003C08091F1008083F901E050FF4F65 -:107BD0002F5F3F4F28303105A9F78BEF8093E800E6 -:107BE00006C0823221F4809192018093070181E0E6 -:107BF000089520919301223201F1213079F480918E -:107C0000960190919701089711F420939801809123 -:107C100098018823B1F5EFE5F8E735C0223021F46B -:107C200084E6E1E7F8E70CC0233049F58091920142 -:107C3000882329F5E9E4F8E726C081E0EBE2F8E7DC -:107C400090919601282F981708F4292F90E03EEF85 -:107C50008091E8008570E1F38091E80082FD0FC01B -:107C60009F5F849176988093F100892F8F7311F430 -:107C70003093E8003196921758F381E0089580E040 -:107C80000895EDE4F8E78491DBCF1092E90080914C -:107C9000E80083FF62C02898E0E9F1E003C080912A -:107CA000F100819381E0E839F807C9F782EF80930A -:107CB000E8008091900187FF05C08091E80080FF77 -:107CC000FCCF03C08EEF8093E80080919101853056 -:107CD00051F48091E80080FFFCCF80919201806890 -:107CE0008093E30033C08930E1F480919201809366 -:107CF0008C01E7E2F8E791E031E026E39093E900B8 -:107D00003093EB0084918093EC002093ED009F5F13 -:107D10003196953099F78EE78093EA001092EA0049 -:107D200015C0883031F480918C0176988093F100F1 -:107D30000DC0882321F476981092F10007C0863098 -:107D400011F457DF01C020DF882321F08EEF8093EC -:107D5000E800089581E28093EB0008958091E100AE -:107D60001092E100282F83FF0CC01092E90081E0FF -:107D70008093EB001092EC0082E38093ED00109270 -:107D80008C0122FF08C080918D01882321F410927C -:107D90008F0110928E0108951F9312E076DFDEDFCF -:107DA0001093E9008091E80085FF0EC0289890911B -:107DB000F1008091E80085FD03C08BE68093E80028 -:107DC000892F90E01F91089584E6000000000000D4 -:107DD00000008150D1F7289A769A80918E01909177 -:107DE0008F01019790938F0180938E0180918E0176 -:107DF00090918F01892B19F4769A289A82DD6BDD98 -:027E0000CDCFE4 -:087E020000E100000000000097 +:107900000895769A289A81E08093E0001092E20030 +:10791000EE27FF27099408950F931F93CF93DF93CA +:10792000982FEB01042F10E088E76030780730F4DF +:1079300011E083E0FB0180935700E895892F68E010 +:1079400071E0402FF0D0112311F107B600FCFDCFFC +:10795000402F4695FE01A8E0B1E020E031E009C0EB +:107960008D919D910C0130935700E895112432962A +:107970002F5F2417A8F385E0FE0180935700E89558 +:1079800007B600FCFDCF81E180935700E895DF91B9 +:10799000CF911F910F910895769A289A47983F9A10 +:1079A000209A6E9A90E8909361001092610081E8AD +:1079B00085BF95BF9FD084E18093880180E180934B +:1079C0008901E0E0F0E0859194918F5F9F4F19F07D +:1079D00081E080938F01EE24FF24BB24B39428EE32 +:1079E000C22E23E0D22E03D2082F8EE098E7FC01AE +:1079F0002491319602964491201711F02223B9F771 +:107A0000109291011092900182E068E071E08BD0B9 +:107A1000013479F4609108016058633028F06831CE +:107A200011F064E001C063E0C62FD0E0CF5DD7481D +:107A30000EC0063571F480910801803311F011E019 +:107A400022C080910A01C82FD0E0C25ED74811E061 +:107A500022C0053721F413E0CEE1D8E71CC005357C +:107A600039F4E0900801F0900901EE0CFF1C0AC007 +:107A7000043631F482E0B701409109014DDF02C0C4 +:107A8000043721F010E0C5E2D8E705C010910901E4 +:107A9000E701E10EF11CABD18097B1F483E068E817 +:107AA00071E041E050E059D0112329F0412F50E01E +:107AB00083E8BE0152D083E469E871E041E050E020 +:107AC0004CD0013509F08FCFD0929101C092900136 +:107AD000B0928F01EE24FF2486CFFC01289884E623 +:107AE00080938D0104C08091F100819361506623E1 +:107AF000D1F70895109291011092900110928E0189 +:107B000010928F0181E08093D70080EA8093D800A3 +:107B100082E189BD09B400FEFDCF80E98093D800E1 +:107B20001092E0000895FB018093E90024E69BE6B3 +:107B300011C08091E80085FFFCCF289820938D012B +:107B40008091F10081938091E80085FD02C09093BF +:107B5000E8004150442369F70895982FFB01282F2E +:107B6000207287708093E90064E63AE317C0809141 +:107B7000E80085FFFCCF97FF02C0849101C080819F +:107B80003196211180E0769860938C018093F1000A +:107B90008091E80085FD02C03093E80041505040DC +:107BA0008FEF4F3F580719F796FF03C08AE3809382 +:107BB000E800089580919301813299F4769884E6E3 +:107BC00080938C0120E030E003C080818093F1003D +:107BD000F901E050FF4F2F5F3F4F28303105A9F7E3 +:107BE00014C0803261F48091E80082FFFCCF80E015 +:107BF00091E067E072DF8BEF8093E80006C082328D +:107C000021F4809194018093070181E008952091EF +:107C10009501223209F1213081F4809198019091EF +:107C20009901089711F420939A0180919A01882371 +:107C300009F03FC0EFE5F8E73EC0223021F484E6CA +:107C4000E1E7F8E70CC0233091F580919401882397 +:107C500071F5E9E4F8E72FC081E0EBE2F8E79091F5 +:107C60009801382F981708F4392F90918C0120E053 +:107C70004EEF8091E8008570E1F38091E80082FD8D +:107C800012C02F5F849176988093F100822F8F73BA +:107C900011F44093E800319694E6231750F3909343 +:107CA0008C0181E0089590938C0180E0089580E03C +:107CB0000895EDE4F8E78491D2CF1092E900809125 +:107CC000E80083FF61C082E991E068E006DF82EFAF +:107CD0008093E8008091920187FF05C08091E800C1 +:107CE00080FFFCCF03C08EEF8093E800809193016A +:107CF000853051F48091E80080FFFCCF80919401A1 +:107D000080688093E30039C08930E1F48091940168 +:107D100080938E01E7E2F8E791E031E026E390936B +:107D2000E9003093EB0084918093EC002093ED0008 +:107D30009F5F3196953099F78EE78093EA00109215 +:107D4000EA001BC0883049F490918E01769884E651 +:107D500080938C019093F10010C0882339F47698B9 +:107D600084E680938C011092F10007C0863011F4F4 +:107D70004EDF01C01FDF882321F08EEF8093E800E3 +:107D8000089581E28093EB0008958091E1001092C4 +:107D9000E100282F83FF0CC01092E90081E080935E +:107DA000EB001092EC0082E38093ED0010928E01C4 +:107DB00022FF1CC080918C01882331F08150809378 +:107DC0008C01882309F4769A80918D01882331F003 +:107DD000815080938D01882309F4289A80918F0126 +:107DE000882321F4109291011092900108951F931D +:107DF000CF93DF9312E0C0E9D1E05FDFC6DF1093DD +:107E0000E9008091E80085FF13C0289884E68093FC +:107E10008D019091F1008091E80085FD03C08BE613 +:107E20008093E800892F90E0DF91CF911F91089512 +:107E3000809190019091910101979093910180938D +:107E400090018091900190919101892B09F459DD65 +:0A7E5000CE010197F1F73FDDD0CF1E +:087E5A0000E10000000000003F :040000030000780081 :00000001FF diff --git a/bootloaders/diskloader/src/DiskLoader.cpp b/bootloaders/diskloader/src/DiskLoader.cpp index 34a9c94..da57e75 100644 --- a/bootloaders/diskloader/src/DiskLoader.cpp +++ b/bootloaders/diskloader/src/DiskLoader.cpp @@ -210,7 +210,7 @@ int main() if (cmd == 'Q') break; } - _timeout = 1; // signal to exit the bootloader + _timeout = 1000; // wait a moment before exiting the bootloader - may need to finish responding to 'Q' for example _ejected = 1; } } @@ -232,7 +232,8 @@ void LEDPulse() void Reboot() { - /* TODO - ZE - this should probably be a WDT reset instead, right? */ + TXLED0; // switch off the RX and TX LEDs before starting the user sketch + RXLED0; UDCON = 1; // Detatch USB UDIEN = 0; asm volatile ( // Reset vector to run firmware diff --git a/bootloaders/diskloader/src/USBCore.cpp b/bootloaders/diskloader/src/USBCore.cpp index 142fc79..1a8f2d0 100644 --- a/bootloaders/diskloader/src/USBCore.cpp +++ b/bootloaders/diskloader/src/USBCore.cpp @@ -29,6 +29,11 @@ #define EP_TYPE_ISOCHRONOUS_IN 0x41 #define EP_TYPE_ISOCHRONOUS_OUT 0x40 +/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */ +#define TX_RX_LED_PULSE_MS 100 +u8 TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */ +u8 RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */ + void Reboot(); //================================================================== @@ -85,6 +90,7 @@ static void Send(volatile const u8* data, u8 count) { TXLED1; // light the TX LED + TxLEDPulse = TX_RX_LED_PULSE_MS; while (count--) UEDATX = *data++; } @@ -92,6 +98,7 @@ void Send(volatile const u8* data, u8 count) void Recv(volatile u8* data, u8 count) { RXLED1; // light the RX LED + RxLEDPulse = TX_RX_LED_PULSE_MS; while (count--) *data++ = UEDATX; } @@ -99,12 +106,14 @@ void Recv(volatile u8* data, u8 count) static inline u8 Recv8() { RXLED1; // light the RX LED + RxLEDPulse = TX_RX_LED_PULSE_MS; return UEDATX; } static inline void Send8(u8 d) { TXLED1; // light the TX LED + TxLEDPulse = TX_RX_LED_PULSE_MS; UEDATX = d; } @@ -451,12 +460,17 @@ void USBGeneralInterrupt() { InitEP(0,EP_TYPE_CONTROL,EP_SINGLE_64); // init ep0 _usbConfiguration = 0; // not configured yet - //UEIENX = 1 << RXSTPE; } - // Start of Frame + // Start of Frame - happens every millisecond so we use it for TX and RX LED one-shot timing, too if (udint & (1<