From 080d18c6d2b2ec7c0ee8cad53226b5131a9e45dc Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 6 Sep 2008 22:17:58 +0000 Subject: Incorporating ladyada's watchdog timer changes into the bootloader source, but only compiling them in for the Pro and Pro Mini (since Nathan includes them in the bootloader he burns to the board). Added a WATCHDOG_MODS flag to the Makefile to specify that they should be included. Recompiled the pro .hex file to include them. --- bootloaders/atmega168/ATmegaBOOT_168.c | 17 +++ bootloaders/atmega168/ATmegaBOOT_168_pro_8MHz.hex | 158 +++++++++++----------- bootloaders/atmega168/Makefile | 6 +- 3 files changed, 100 insertions(+), 81 deletions(-) (limited to 'bootloaders') diff --git a/bootloaders/atmega168/ATmegaBOOT_168.c b/bootloaders/atmega168/ATmegaBOOT_168.c index c542af1..7bbf24e 100755 --- a/bootloaders/atmega168/ATmegaBOOT_168.c +++ b/bootloaders/atmega168/ATmegaBOOT_168.c @@ -251,7 +251,19 @@ int main(void) uint8_t ch,ch2; uint16_t w; +#ifdef WATCHDOG_MODS + ch = MCUSR; + MCUSR = 0; + + WDTCSR |= _BV(WDCE) | _BV(WDE); + WDTCSR = 0; + + // Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot. + if (! (ch & _BV(EXTRF))) // if its a not an external reset... + app_start(); // skip bootloader +#else asm volatile("nop\n\t"); +#endif /* set pin direction for bootloader pin and enable pullup */ /* for ATmega128, two pins need to be initialized */ @@ -445,6 +457,11 @@ int main(void) /* Leave programming mode */ else if(ch=='Q') { nothing_response(); +#ifdef WATCHDOG_MODS + // autoreset via watchdog (sneaky!) + WDTCSR = _BV(WDE); + while (1); // 16 ms +#endif } diff --git a/bootloaders/atmega168/ATmegaBOOT_168_pro_8MHz.hex b/bootloaders/atmega168/ATmegaBOOT_168_pro_8MHz.hex index f1d4fb0..03ff00c 100644 --- a/bootloaders/atmega168/ATmegaBOOT_168_pro_8MHz.hex +++ b/bootloaders/atmega168/ATmegaBOOT_168_pro_8MHz.hex @@ -5,7 +5,7 @@ :103840000C944F1C0C944F1C0C944F1C0C944F1C4C :103850000C944F1C0C944F1C0C944F1C0C944F1C3C :103860000C944F1C0C944F1C11241FBECFEFD4E0BE -:10387000DEBFCDBF11E0A0E0B1E0E8E1FFE302C0B0 +:10387000DEBFCDBF11E0A0E0B1E0ECE3FFE302C0AA :1038800005900D92A230B107D9F712E0A2E0B1E0A5 :1038900001C01D92AD30B107E1F70C94311D0C94BD :1038A000001CCF93DF93CDB7DEB724970FB6F89403 @@ -36,82 +36,84 @@ :103A300084E10E94E41C812F0E94E41C80E10E942A :103A4000E41C1F910895282F882351F090E0809165 :103A5000C00087FFFCCF8091C6009F5F2917B9F790 -:103A60000895CFEFD4E0DEBFCDBF000089E18093A1 -:103A7000C4001092C50088E18093C10086E0809365 -:103A8000C2005098589A259A81E00E94511C0E94C9 -:103A9000B81C8033B1F18133B9F1803409F454C0DA -:103AA000813409F45AC0823409F469C0853409F4B8 -:103AB0006CC0803531F1813521F1823511F18535C8 -:103AC00009F4B2C0863509F4BAC0843609F463C07B -:103AD000843709F4BBC0853709F40EC1863709F471 -:103AE0004AC0809104018F5F80930401853079F68C -:103AF000E0910201F091030109950E94B81C803306 -:103B000051F60E94EC1CC3CF0E94B81C803249F7CA -:103B100084E10E94E41C81E40E94E41C86E50E948A -:103B2000E41C82E50E94E41C80E20E94E41C89E41B -:103B30000E94E41C83E50E94E41C80E50E94E41CD2 -:103B400080E10E94E41CA3CF0E94B81C8638C8F212 -:103B50000E94B81C0E94EC1C9ACF0E94B81C8038AE -:103B600009F4F7C0813809F4F8C0823809F4F9C0C3 -:103B7000883909F4BDC080E00E94051D88CF84E12A -:103B80000E94231D0E94EC1C82CF85E00E94231D11 -:103B90000E94EC1C7CCF0E94B81C809309020E94FA -:103BA000B81C8093080280910C028E7F80930C02D7 -:103BB0000E94B81C853409F4C6C080910802909117 -:103BC0000902892B09F0ADC00E94B81C803209F0AF -:103BD00088CF80910C0280FFC8C08091080290912C -:103BE00009020097D1F02091060130910701E8E029 -:103BF000F1E0AC014E0F5F1FF999FECF32BD21BD40 -:103C0000819180BDFA9AF99A2F5F3F4F4E175F0757 -:103C100099F7309307012093060184E10E94E41C88 -:103C200080E10E94E41C33CF0E94B81C80930601FF -:103C30000E94B81C809307010E94EC1C28CF84E0EE -:103C40000E94231D80E00E94051D21CF0E94B81C08 -:103C5000809309020E94B81C809308020E94B81C3D -:103C6000853409F4F4C080910C028E7F80930C029D -:103C70008091060190910701880F991F9093070189 -:103C8000809306010E94B81C803209F000CF84E1C5 -:103C90000E94E41C2091080230910902211531058F -:103CA00019F1C0E0D0E0E0910601F09107018091A8 -:103CB0000C0280FFC4C0F999FECFF2BDE1BDF89AB5 -:103CC00080B50E94E41CE0910601F0910701319655 -:103CD000F0930701E0930601209108023091090258 -:103CE0002196C217D30718F380E10E94E41CCFCEBF -:103CF00083E00E94051DCBCE0E94B81C803209F0E3 -:103D0000F0CE84E10E94E41C8EE10E94E41C84E970 -:103D10000E94E41C86E00E94E41C80E10E94E41CF6 -:103D2000B6CEC0E0D0E008E011E00E94B81CF80177 -:103D300081938F0121968091080290910902C81702 -:103D4000D90798F341CF80910C02816080930C02D7 -:103D500034CF82E00E94051D9ACE81E00E94051DAD -:103D600096CE80E10E94051D92CE8091070187FDCD -:103D700080C010920B028091060190910701880F7C -:103D8000991F90930701809306018091080280FF9C -:103D900009C080910802909109020196909309024E -:103DA00080930802F894F999FECF1127E09106015B -:103DB000F0910701C8E0D1E08091080290910902DA -:103DC000103091F40091570001700130D9F303E0F5 -:103DD00000935700E8950091570001700130D9F326 -:103DE00001E100935700E895099019900091570060 -:103DF00001700130D9F301E000935700E895139565 -:103E0000103498F011270091570001700130D9F358 -:103E100005E000935700E8950091570001700130CC -:103E2000D9F301E100935700E8953296029709F023 -:103E3000C7CF103011F00296E5CF1124EECE81FFEE -:103E40000CC03196F0930701E093060149CF8091B1 -:103E50000C02816080930C0215CF84910E94E41CB7 -:103E60002091080230910902E0910601F0910701CA -:103E7000E8CF81E080930B027ECF0F931F930E94C7 -:103E8000B81C182F0E94E41C0E94B81C082F0E9426 -:103E9000E41C11362CF0175501363CF0075508C0CC -:103EA0001033D4F310530136CCF700330CF0005329 -:103EB0001295107F100F812F992787FD90951F91E4 -:103EC0000F9108951F93282F992787FD9095807F44 -:103ED00090709595879595958795959587959595E6 -:103EE00087958A304CF0982F995A822F8F708A309C -:103EF0004CF0182F195A08C0982F905D822F8F70A0 -:103F00008A30BCF7182F105D892F0E94E41C812F86 -:083F10000E94E41C1F910895BA -:023F1800800027 +:103A60000895CFEFD4E0DEBFCDBF94B714BE8091F0 +:103A700060008861809360001092600091FFEFC148 +:103A800089E18093C4001092C50088E18093C10051 +:103A900086E08093C2005098589A259A81E00E944F +:103AA000511C0E94B81C8033B9F18133C1F18034BC +:103AB00009F455C0813409F45BC0823409F46AC04A +:103AC000853409F46DC0803539F1813509F404C1BC +:103AD000823511F1853509F4BDC0863509F4B3C0CE +:103AE000843609F463C0843709F4FCC0853709F4CF +:103AF000CEC0863709F44AC0809104018F5F80935D +:103B00000401853071F6E0910201F09103010995FD +:103B10000E94B81C803349F60E94EC1CC2CF0E9460 +:103B2000B81C803249F784E10E94E41C81E40E94C1 +:103B3000E41C86E50E94E41C82E50E94E41C80E20D +:103B40000E94E41C89E40E94E41C83E50E94E41CBA +:103B500080E50E94E41C80E10E94E41CA2CF0E9448 +:103B6000B81C8638C8F20E94B81C0E94EC1C99CF81 +:103B70000E94B81C803809F4ABC0813809F4A4C095 +:103B8000823809F49DC0883909F496C080E00E940B +:103B9000051D87CF84E10E94231D0E94EC1C81CF6C +:103BA00085E00E94231D0E94EC1C7BCF0E94B81C64 +:103BB000809309020E94B81C8093080280910C0235 +:103BC0008E7F80930C020E94B81C853429F480916A +:103BD0000C02816080930C0280910802909109028E +:103BE000892B09F042C00E94B81C803209F084CFB2 +:103BF00080910C0280FFC5C080910802909109025B +:103C00000097D1F02091060130910701E8E0F1E042 +:103C1000AC014E0F5F1FF999FECF32BD21BD8191DE +:103C200080BDFA9AF99A2F5F3F4FE417F50799F78D +:103C3000309307012093060184E10E94E41C80E197 +:103C40000E94E41C2ECF84E00E94231D80E00E948D +:103C5000051D27CF0E94B81C809306010E94B81C46 +:103C6000809307010E94EC1C1CCFC0E0D0E008E06C +:103C700011E00E94B81CF80181938F012196809178 +:103C8000080290910902C817D90798F3ACCF0E9497 +:103C9000B81C803209F030CF84E10E94E41C8EE130 +:103CA0000E94E41C84E90E94E41C86E00E94E41C5B +:103CB00080E10E94E41CF5CE83E00E94051DF1CE58 +:103CC00080E10E94051DEDCE81E00E94051DE9CE38 +:103CD00082E00E94051DE5CE0E94EC1C88E08093E6 +:103CE0006000FFCF0E94B81C809309020E94B81C9C +:103CF000809308020E94B81C853409F4BEC08091EC +:103D00000C028E7F80930C02809106019091070136 +:103D1000880F991F90930701809306010E94B81C99 +:103D2000803209F0BECE84E10E94E41C809108023A +:103D300090910902009709F4BBCFC0E0D0E0E09178 +:103D40000601F091070120910C0220FF8EC0F99925 +:103D5000FECFF2BDE1BDF89A80B50E94E41CE0916F +:103D60000601F09107013196F0930701E0930601F7 +:103D700080910802909109022196C817D90718F37B +:103D800097CF8091070187FD66C010920B0280914A +:103D9000060190910701880F991F90930701809366 +:103DA00006018091080280FF09C08091080290916D +:103DB000090201969093090280930802F894F999F8 +:103DC000FECF1127E0910601F0910701C8E0D1E094 +:103DD0008091080290910902103091F400915700EF +:103DE00001700130D9F303E000935700E89500918A +:103DF000570001700130D9F301E100935700E895B5 +:103E0000099019900091570001700130D9F301E039 +:103E100000935700E8951395103498F011270091FE +:103E2000570001700130D9F305E000935700E89581 +:103E30000091570001700130D9F301E10093570060 +:103E4000E8953296029709F0C7CF103011F002962C +:103E5000E5CF1124F1CE81E080930B0298CFE09161 +:103E60000201F091030109950BCE21FF0CC03196A0 +:103E7000F0930701E09306017FCF80910C028160EF +:103E800080930C024BCF84910E94E41C8091080225 +:103E900090910902E0910601F0910701E8CF0F939C +:103EA0001F930E94B81C182F0E94E41C0E94B81C8B +:103EB000082F0E94E41C11362CF0175501363CF0F7 +:103EC000075508C01033D4F310530136CCF7003334 +:103ED0000CF000531295107F100F812F992787FD4A +:103EE00090951F910F9108951F93282F992787FD73 +:103EF0009095807F907095958795959587959595E8 +:103F00008795959587958A304CF0982F995A822FEE +:103F10008F708A304CF0182F195A08C0982F905D76 +:103F2000822F8F708A30BCF7182F105D892F0E9466 +:0C3F3000E41C812F0E94E41C1F910895E6 +:023F3C00800003 :0400000300003800C1 :00000001FF diff --git a/bootloaders/atmega168/Makefile b/bootloaders/atmega168/Makefile index 6be8dbe..c55cfc9 100755 --- a/bootloaders/atmega168/Makefile +++ b/bootloaders/atmega168/Makefile @@ -81,21 +81,21 @@ lilypad_resonator: HFUSE = DD lilypad_resonator: LFUSE = C6 pro8: TARGET = pro_8MHz -pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' +pro8: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS' pro8: $(PROGRAM)_pro_8MHz.hex pro8: AVR_FREQ = 8000000L pro8: HFUSE = DD pro8: LFUSE = C6 pro16: TARGET = pro_16MHz -pro16: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' +pro16: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS' pro16: $(PROGRAM)_pro_16MHz.hex pro16: AVR_FREQ = 16000000L pro16: HFUSE = DD pro16: LFUSE = C6 pro20: TARGET = pro_20mhz -pro20: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' +pro20: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' '-DWATCHDOG_MODS' pro20: $(PROGRAM)_pro_20mhz.hex pro20: AVR_FREQ = 20000000L pro20: HFUSE = DD -- cgit v1.2.3-18-g5258