From 75da79ad7602d1a73e46155a5630f41d91f9bd83 Mon Sep 17 00:00:00 2001 From: Zach Eveland Date: Thu, 8 Mar 2012 14:20:12 -0500 Subject: give Leonardo bootloader 250 ms to finish housekeeping before leaving self-programming mode Earlier approach had bootloader end as soon as it was told to. On Linux this caused problems with avrdude because the microcontroller never had a chance to send an acknowledgement. --- bootloaders/caterina/Caterina.c | 11 +- bootloaders/caterina/Caterina.hex | 266 +++++++++++++++++++------------------- 2 files changed, 142 insertions(+), 135 deletions(-) (limited to 'bootloaders/caterina') diff --git a/bootloaders/caterina/Caterina.c b/bootloaders/caterina/Caterina.c index c8e82a9..2b50636 100755 --- a/bootloaders/caterina/Caterina.c +++ b/bootloaders/caterina/Caterina.c @@ -62,6 +62,7 @@ uint16_t TxLEDPulse = 0; // time remaining for Tx LED pulse uint16_t RxLEDPulse = 0; // time remaining for Rx LED pulse /* Bootloader timeout timer */ +#define TIMEOUT_PERIOD 8000 uint16_t Timeout = 0; uint16_t bootKey = 0x7777; @@ -133,12 +134,14 @@ int main(void) /* Enable global interrupts so that the USB stack can function */ sei(); + Timeout = 0; + while (RunBootloader) { CDC_Task(); USB_USBTask(); /* Time out and start the sketch if one is present */ - if (Timeout > 8000) + if (Timeout > TIMEOUT_PERIOD) RunBootloader = false; LEDPulse(); @@ -475,7 +478,11 @@ void CDC_Task(void) if (Command == 'E') { - RunBootloader = false; + /* We nearly run out the bootloader timeout clock, + * leaving just a few hundred milliseconds so the + * bootloder has time to respond and service any + * subsequent requests */ + Timeout = TIMEOUT_PERIOD - 250; // Send confirmation byte back to the host WriteNextResponseByte('\r'); diff --git a/bootloaders/caterina/Caterina.hex b/bootloaders/caterina/Caterina.hex index 98cf01a..0975ace 100644 --- a/bootloaders/caterina/Caterina.hex +++ b/bootloaders/caterina/Caterina.hex @@ -1,6 +1,6 @@ :1070000055C000006EC000006CC000006AC00000E7 :1070100068C0000066C0000064C0000062C00000DC -:1070200060C000005EC00000ECC400005AC0000058 +:1070200060C000005EC00000F0C400005AC0000054 :1070300058C0000056C0000054C0000052C00000FC :1070400050C0000078C000004CC000004AC00000E2 :1070500048C0000046C0000044C0000042C000001C @@ -9,10 +9,10 @@ :1070800030C000002EC000002CC000002AC000004C :1070900028C0000026C0000024C0000022C000005C :1070A00020C000001EC000001CC0000011241FBE34 -:1070B000CFEFDAE0DEBFCDBF11E0A0E0B1E0E6E265 +:1070B000CFEFDAE0DEBFCDBF11E0A0E0B1E0EEE25D :1070C000FFE702C005900D92A83AB107D9F711E089 :1070D000A8EAB1E001C01D92AE3BB107E1F78ED343 -:1070E00020C78ECFF89410926F00109281001092FA +:1070E00024C78ECFF89410926F00109281001092F6 :1070F00085001092840081E085BF15BE47985D9A97 :10710000289A0C94000008952091B2013091B301A7 :107110002F5F3F4F3093B3012093B201932F37FF7E @@ -66,7 +66,7 @@ :10741000FF29E4918E2FEBDEDD2081F082E090E009 :10742000A0E0B0E0E80EF91E0A1F1B1FE092AE01BB :10743000F092AF010093B0011093B101DC2418C0A9 -:10744000D801C701B695A7959795879554D5CFDEF6 +:10744000D801C701B695A7959795879558D5CFDEF2 :1074500082E090E0A0E0B0E0E80EF91E0A1F1B1FDA :10746000E092AE01F092AF010093B0011093B10130 :107470002197209709F0BECF7DC08090AE019090FB @@ -80,7 +80,7 @@ :1074F0000093B0011093B10102C061DE582E7424D4 :1075000023C0E090AE01F090AF010091B001109166 :10751000B10116950795F794E79451DE682FC701DE -:10752000F2D48091AE019091AF01A091B001B091E1 +:10752000F6D48091AE019091AF01A091B001B091DD :10753000B1010296A11DB11D8093AE019093AF01E0 :10754000A093B001B093B101219704C055247724D2 :1075500044244394209709F0A5CF96E4691641F49A @@ -97,12 +97,12 @@ :107600003DCE823551F4E091AE01F091AF0105918C :107610001491812FECDD802F4CC0843421F5E09053 :10762000AE01F090AF010091B0011091B10116953B -:107630000795F794E794C3DD682FC70164D4809160 +:107630000795F794E794C3DD682FC70168D480915C :10764000AE019091AF01A091B001B091B10102964D :10765000A11DB11D8093AE019093AF01A093B00125 :10766000B093B1010BCE843609F5E090AE01F090F5 :10767000AF010091B0011091B101D801C701B695D9 -:10768000A7959795879537D4B2DD82E090E0A0E08A +:10768000A795979587953BD4B2DD82E090E0A0E086 :10769000B0E0E80EF91E0A1F1B1FE092AE01F09247 :1076A000AF010093B0011093B10104C08B3111F010 :1076B0008FE39DDD83E08093E9009091E800809165 @@ -115,142 +115,142 @@ :107720006F905F904F9008959091B601892F8F7759 :10773000813249F58091B7018032A1F0813219F58B :10774000913A09F58091E800877F8093E8008EE008 -:1077500091E067E070E006D28091E8008B7780933B +:1077500091E067E070E00AD28091E8008B77809337 :10776000E8000895913279F48091E800877F809352 -:10777000E8008EE091E067E070E058D28091E80088 -:107780008E778093E800089582E061EC42E0B0D00B -:1077900083E061E842E1ACD084E060E842E1A8C067 +:10777000E8008EE091E067E070E05CD28091E80084 +:107780008E778093E800089582E061EC42E0B4D007 +:1077900083E061E842E1B0D084E060E842E1ACC05F :1077A00084B7877F84BF88E10FB6F8948093600028 :1077B000109260000FBE20E880E090E00FB6F894D1 :1077C00020936100809361000FBE81E085BF92E04D :1077D00095BF3F9A209A559AE1E6F0E02083108207 :1077E00047985D9A289A109289008AEF80938800C2 -:1077F00090936F0083E080938100EBC01F9388E13A +:1077F00090936F0083E080938100EFC01F9388E136 :107800000FB6F89480936000109260000FBE84B7AA :1078100014BE182F10FF08C0E0E0F0E085919491AD :107820008F5F9F4F09F05EDC2091000A3091010AC2 :107830001092010A1092000A13FF0FC080910901F3 :1078400090910A012817390741F0E0E0F0E08591B6 -:1078500094918F5F9F4F09F045DCA2DF78940CC0B4 -:10786000E5DC37D38091AC019091AD0181549F410B -:1078700010F010920D0148DC80910D01882381F7F2 -:107880008091E00081608093E0002CDC80E090E05B -:107890001F910895FA01923049F0933061F09130D0 -:1078A000F9F485E191E022E130E01EC087E291E049 -:1078B0002EE330E019C0882329F485E691E024E026 -:1078C00030E012C0813029F489E691E022E230E014 -:1078D0000BC0823029F48DE891E028E130E004C04B -:1078E00080E090E020E030E091838083C90108953A -:1078F0008093E9008091EB0081608093EB0010920F -:10790000ED006093EC004093ED008091EE00881F45 -:107910008827881F08958091B60188238CF403C0BE -:107920008EB38823B1F08091E80082FFF9CF809177 -:10793000E8008B778093E80008958EB3882349F0A0 -:107940008091E80080FFF9CF8091E8008E778093E6 -:10795000E8000895EF92FF920F931F9345D04CD00B -:1079600008ED10E0F80180818F7780838081806846 -:10797000808380818F7D808319BC1EBA1092B401F0 -:1079800080EEE82EF12CF70180818B7F8083F80157 -:1079900080818160808380E060E042E0A9DFE1EEE9 -:1079A000F0E080818E7F8083E2EEF0E08081816074 -:1079B0008083808188608083F70180818E7F8083CF -:1079C000F8018081806180831F910F91FF90EF907B -:1079D0000895E7EDF0E08081816080838AE482BFD2 -:1079E00081E08093B501B6CFE8EDF0E080818E7F35 -:1079F00080831092E20008951092DA001092E10064 -:107A000008951F920F920FB60F9211242F933F9358 -:107A10004F935F936F937F938F939F93AF93BF9396 -:107A2000EF93FF938091DA0080FF1BC08091D80014 -:107A300080FF17C08091DA008E7F8093DA008091FA -:107A4000D90080FF0BC080E189BD82E189BD09B406 -:107A500000FEFDCF81E08EBB3BD203C019BC1EBA35 -:107A600037D28091E10080FF17C08091E20080FF53 -:107A700013C08091E2008E7F8093E2008091E2004B -:107A800080618093E2008091D80080628093D8006A -:107A900019BC85E08EBB1CD28091E10084FF2CC014 -:107AA0008091E20084FF28C080E189BD82E189BD28 -:107AB00009B400FEFDCF8091D8008F7D8093D8005F -:107AC0008091E1008F7E8093E1008091E2008F7EC3 -:107AD0008093E2008091E20081608093E2008091D7 -:107AE000B401882331F48091E30087FD02C081E076 -:107AF00001C084E08EBBECD18091E10083FF21C006 -:107B00008091E20083FF1DC08091E100877F809318 -:107B1000E10082E08EBB1092B4018091E1008E7F83 -:107B20008093E1008091E2008E7F8093E20080915B -:107B3000E20080618093E20080E060E042E0D8DE15 -:107B4000C7D1FF91EF91BF91AF919F918F917F919D -:107B50006F915F914F913F912F910F900FBE0F90BA -:107B60001F9018959C014091BC015091BD01461792 -:107B7000570718F4F90190E044C06115710511F040 -:107B8000AB01F8CF8091E8008E778093E80040E069 -:107B900050E0F0CF8EB3882309F444C0853009F457 -:107BA00043C08091E80083FF02C081E00895809186 -:107BB000E80082FD31C08091E80080FF22C0809102 -:107BC000F3009091F200782F60E0292F30E0262B0F -:107BD000372B07C081918093F100415050402F5FB7 -:107BE0003F4F4115510519F02830310598F390E0C9 -:107BF0002830310509F491E08091E8008E77809378 -:107C0000E8004115510531F6992321F605C08EB3E0 -:107C1000882341F0853041F08091E80082FFF7CF62 -:107C200080E0089582E0089583E008959C01611545 -:107C3000710529F48091E8008B778093E800F901C1 -:107C400026C08EB3882391F1853091F18091E800B0 -:107C500083FF02C081E008958091E80082FFF1CFA8 -:107C600006C08091F10081936150704059F02091DD -:107C7000F3008091F200322F20E090E0822B932BD2 -:107C8000892B79F78091E8008B778093E800611564 -:107C90007105B9F605C08EB3882341F0853041F0F7 -:107CA0008091E80080FFF7CF80E0089582E008959A -:107CB00083E008950F931F93DF93CF9300D0CDB748 -:107CC000DEB7E6EBF1E08091F100819381E0EE3BDD -:107CD000F807C9F729DD8091E80083FFE4C08091AF -:107CE000B6019091B701953009F46DC0963040F41B -:107CF000913081F1913070F0933009F0D4C02AC0F6 -:107D0000983009F4A3C0993009F4B2C0963009F054 -:107D1000CAC07CC0803809F4C6C0823809F0C3C02C -:107D20008091BA0187708093E9008091EB001092F6 -:107D3000E9002091E800277F2093E80090E025E00B -:107D4000969587952A95E1F781708093F1001092BE -:107D5000F10087C0882319F0823009F0A4C08F7128 -:107D6000823009F0A0C08091B801882331F52091BC -:107D7000BA01277009F497C02093E9008091EB00C5 -:107D800080FF1BC0933021F48091EB00806213C010 -:107D90008091EB0080618093EB0081E090E002C075 -:107DA000880F991F2A95E2F78093EA001092EA0063 -:107DB0008091EB0088608093EB001092E900809145 -:107DC000E800877F51C0882309F06DC01091B80189 -:107DD0001F770FB7F8948091E800877F8093E800C1 -:107DE0009ADD8091E80080FFFCCF8091E3008078ED -:107DF000812B8093E30080688093E300112311F4CA -:107E000082E001C083E08EBB0FBF4DC0805882303E -:107E100008F049C08091B8019091B9016091BA0110 -:107E2000AE014F5F5F4F36DDBC01009709F43BC0E8 -:107E30008091E800877F8093E80089819A8192DEB3 -:107E40008091E8008B778093E8002DC0803859F549 -:107E50008091E800877F8093E8008091B40180934F -:107E6000F1008091E8008E778093E80054DD1BC01C -:107E70008823C9F49091B8019230A8F48091E80069 -:107E8000877F8093E8009093B40145DD8091B40131 -:107E9000882331F48091E30087FD02C081E001C0B6 -:107EA00084E08EBB71DC8091E80083FF0AC0809182 -:107EB000EB0080628093EB008091E800877F8093E5 -:107EC000E8000F900F90CF91DF911F910F910895CF -:107ED00008951F938EB3882361F01091E9001092EA -:107EE000E9008091E80083FF01C0E4DE1770109381 -:107EF000E9001F910895F999FECF92BD81BDF89ACE -:107F0000992780B50895262FF999FECF1FBA92BD03 -:107F100081BD20BD0FB6F894FA9AF99A0FBE01966A -:067F20000895F894FFCF64 -:107F26004341544552494E41007777000A0100000B -:107F360000000000081201100102000008412301A0 -:107F46000701000201000109023E00020100803221 -:107F560009040000010202010005240010010424A6 -:107F660002040524060001070582030800FF090430 -:107F76000100020A000000070504021000010705BF -:107F86008302100001040309042203410072006405 -:107F960000750069006E006F0020004C0065006FE0 -:107FA600006E006100720064006F0000001803415B -:107FB6000072006400750069006E006F0020004CBE -:087FC600004C00430000000024 +:1078500094918F5F9F4F09F045DCA2DF78941092DE +:10786000AD011092AC010CC0E1DC37D38091AC01CA +:107870009091AD0181549F4110F010920D0144DCB4 +:1078800080910D01882381F78091E00081608093D1 +:10789000E00028DC80E090E01F910895FA0192302A +:1078A00049F0933061F09130F9F485E191E022E103 +:1078B00030E01EC087E291E02EE330E019C088235B +:1078C00029F485E691E024E030E012C0813029F40B +:1078D00089E691E022E230E00BC0823029F48DE8A5 +:1078E00091E028E130E004C080E090E020E030E06A +:1078F00091838083C90108958093E9008091EB0012 +:1079000081608093EB001092ED006093EC00409357 +:10791000ED008091EE00881F8827881F08958091D0 +:10792000B60188238CF403C08EB38823B1F0809114 +:10793000E80082FFF9CF8091E8008B778093E80020 +:1079400008958EB3882349F08091E80080FFF9CF35 +:107950008091E8008E778093E8000895EF92FF927F +:107960000F931F9345D04CD008ED10E0F8018081B3 +:107970008F77808380818068808380818F7D808302 +:1079800019BC1EBA1092B40180EEE82EF12CF7015A +:1079900080818B7F8083F80180818160808380E09B +:1079A00060E042E0A9DFE1EEF0E080818E7F80833D +:1079B000E2EEF0E080818160808380818860808356 +:1079C000F70180818E7F8083F801808180618083D0 +:1079D0001F910F91FF90EF900895E7EDF0E0808107 +:1079E000816080838AE482BF81E08093B501B6CF55 +:1079F000E8EDF0E080818E7F80831092E2000895B0 +:107A00001092DA001092E10008951F920F920FB6C3 +:107A10000F9211242F933F934F935F936F937F9314 +:107A20008F939F93AF93BF93EF93FF938091DA006F +:107A300080FF1BC08091D80080FF17C08091DA00C2 +:107A40008E7F8093DA008091D90080FF0BC080E1A7 +:107A500089BD82E189BD09B400FEFDCF81E08EBB06 +:107A60003BD203C019BC1EBA37D28091E10080FF1F +:107A700017C08091E20080FF13C08091E2008E7FEA +:107A80008093E2008091E20080618093E200809127 +:107A9000D80080628093D80019BC85E08EBB1CD2D0 +:107AA0008091E10084FF2CC08091E20084FF28C017 +:107AB00080E189BD82E189BD09B400FEFDCF8091DE +:107AC000D8008F7D8093D8008091E1008F7E8093D5 +:107AD000E1008091E2008F7E8093E2008091E200DD +:107AE00081608093E2008091B401882331F4809119 +:107AF000E30087FD02C081E001C084E08EBBECD1D1 +:107B00008091E10083FF21C08091E20083FF1DC0CE +:107B10008091E100877F8093E10082E08EBB10922C +:107B2000B4018091E1008E7F8093E1008091E200BA +:107B30008E7F8093E2008091E20080618093E2007A +:107B400080E060E042E0D8DEC7D1FF91EF91BF91C5 +:107B5000AF919F918F917F916F915F914F913F91E5 +:107B60002F910F900FBE0F901F9018959C01409180 +:107B7000BC015091BD014617570718F4F90190E078 +:107B800044C06115710511F0AB01F8CF8091E80098 +:107B90008E778093E80040E050E0F0CF8EB38823EA +:107BA00009F444C0853009F443C08091E80083FFA4 +:107BB00002C081E008958091E80082FD31C080918B +:107BC000E80080FF22C08091F3009091F200782FAE +:107BD00060E0292F30E0262B372B07C0819180935E +:107BE000F100415050402F5F3F4F4115510519F0B2 +:107BF0002830310598F390E02830310509F491E000 +:107C00008091E8008E778093E8004115510531F6A8 +:107C1000992321F605C08EB3882341F0853041F0C9 +:107C20008091E80082FFF7CF80E0089582E0089518 +:107C300083E008959C016115710529F48091E800A5 +:107C40008B778093E800F90126C08EB3882391F1E9 +:107C5000853091F18091E80083FF02C081E00895B2 +:107C60008091E80082FFF1CF06C08091F1008193FE +:107C70006150704059F02091F3008091F200322F52 +:107C800020E090E0822B932B892B79F78091E800FC +:107C90008B778093E80061157105B9F605C08EB346 +:107CA000882341F0853041F08091E80080FFF7CFD4 +:107CB00080E0089582E0089583E008950F931F9374 +:107CC000DF93CF9300D0CDB7DEB7E6EBF1E0809144 +:107CD000F100819381E0EE3BF807C9F725DD809143 +:107CE000E80083FFE4C08091B6019091B701953020 +:107CF00009F46DC0963040F4913081F1913070F00C +:107D0000933009F0D4C02AC0983009F4A3C0993048 +:107D100009F4B2C0963009F0CAC07CC0803809F4BA +:107D2000C6C0823809F0C3C08091BA0187708093C1 +:107D3000E9008091EB001092E9002091E800277F94 +:107D40002093E80090E025E0969587952A95E1F745 +:107D500081708093F1001092F10087C0882319F0A0 +:107D6000823009F0A4C08F71823009F0A0C08091E8 +:107D7000B801882331F52091BA01277009F497C022 +:107D80002093E9008091EB0080FF1BC0933021F429 +:107D90008091EB00806213C08091EB008061809342 +:107DA000EB0081E090E002C0880F991F2A95E2F76E +:107DB0008093EA001092EA008091EB008860809343 +:107DC000EB001092E9008091E800877F51C0882382 +:107DD00009F06DC01091B8011F770FB7F89480912A +:107DE000E800877F8093E8009ADD8091E80080FFBB +:107DF000FCCF8091E3008078812B8093E300806842 +:107E00008093E300112311F482E001C083E08EBB74 +:107E10000FBF4DC08058823008F049C08091B80132 +:107E20009091B9016091BA01AE014F5F5F4F36DDAD +:107E3000BC01009709F43BC08091E800877F8093E4 +:107E4000E80089819A8192DE8091E8008B778093A7 +:107E5000E8002DC0803859F58091E800877F809335 +:107E6000E8008091B4018093F1008091E8008E7762 +:107E70008093E80054DD1BC08823C9F49091B801B9 +:107E80009230A8F48091E800877F8093E800909377 +:107E9000B40145DD8091B401882331F48091E30081 +:107EA00087FD02C081E001C084E08EBB6DDC809163 +:107EB000E80083FF0AC08091EB0080628093EB00B2 +:107EC0008091E800877F8093E8000F900F90CF911A +:107ED000DF911F910F91089508951F938EB388230A +:107EE00061F01091E9001092E9008091E80083FFB1 +:107EF00001C0E4DE17701093E9001F910895F9990D +:107F0000FECF92BD81BDF89A992780B50895262F9E +:107F1000F999FECF1FBA92BD81BD20BD0FB6F8946E +:0E7F2000FA9AF99A0FBE01960895F894FFCFD1 +:107F2E004341544552494E41007777000A01000003 +:107F3E000000000008120110010200000841230198 +:107F4E000701000201000109023E00020100803219 +:107F5E00090400000102020100052400100104249E +:107F6E0002040524060001070582030800FF090428 +:107F7E000100020A000000070504021000010705B7 +:107F8E0083021000010403090422034100720064FD +:107F9E0000750069006E006F0020004C0065006FD8 +:107FAE00006E006100720064006F00000018034153 +:107FBE000072006400750069006E006F0020004CB6 +:087FCE00004C0043000000001C :040000030000700089 :00000001FF -- cgit v1.2.3-18-g5258