diff options
author | WestfW <westfw@gmail.com> | 2011-06-13 19:07:07 -0700 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2011-10-10 12:11:16 -0400 |
commit | 0d9377c729d3dfe4719bab1631587bfc5d444b60 (patch) | |
tree | fdf18f6c101c39d58d9936e38a415fe28053d7d9 /bootloaders/optiboot/optiboot.c | |
parent | e74e76ce14724fc3ea0a49e291de9b707825a576 (diff) |
http://code.google.com/p/arduino/issues/detail?id=368
Optiboot does not support ArduinoasISP programmer.
When avrdude runs and talks to an arduino running ArduinoISP,
it needs the optiboot (entered due to auto-reset) to abort and
start the ArduinoISP "application" when it sees communications
at the wrong serial speed. Unfortunately, optiboot treats all
unrecognized command characters as "no-ops" and responds/loops
for more commands, leading to a nice loop that never gets to
the sketch. This patch causes characters received with Framing
errors (the most likely error for speed mis-matches) to NOT
reset the watchdog timer (normally done in getch()), which will
cause the application to start if it continues for "a while."
(tested. Works! Running ArduinoISP at speeds as high as 57600
still causes the bootloader to start the sketch (although it fails
later on for other reasons.))
(cherry picked from commit e81c1123b624b6cac7da018c9c786700f3152bc9)
Diffstat (limited to 'bootloaders/optiboot/optiboot.c')
-rw-r--r-- | bootloaders/optiboot/optiboot.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/bootloaders/optiboot/optiboot.c b/bootloaders/optiboot/optiboot.c index 8dbe1bf..3f4404d 100644 --- a/bootloaders/optiboot/optiboot.c +++ b/bootloaders/optiboot/optiboot.c @@ -132,13 +132,16 @@ /**********************************************************/ /* Edit History: */ /* */ +/* 4.3 WestfW: catch framing errors in getch(), so that */ +/* AVRISP works without HW kludges. */ +/* http://code.google.com/p/arduino/issues/detail?id=368n*/ /* 4.2 WestfW: reduce code size, fix timeouts, change */ /* verifySpace to use WDT instead of appstart */ /* 4.1 WestfW: put version number in binary. */ /**********************************************************/ #define OPTIBOOT_MAJVER 4 -#define OPTIBOOT_MINVER 2 +#define OPTIBOOT_MINVER 3 #define MAKESTR(a) #a #define MAKEVER(a, b) MAKESTR(a*256+b) @@ -512,8 +515,6 @@ void putch(char ch) { uint8_t getch(void) { uint8_t ch; - watchdogReset(); - #ifdef LED_DATA_FLASH #ifdef __AVR_ATmega8__ LED_PORT ^= _BV(LED); @@ -547,7 +548,20 @@ uint8_t getch(void) { "r25" ); #else - while(!(UCSR0A & _BV(RXC0))); + while(!(UCSR0A & _BV(RXC0))) + ; + if (!(UCSR0A & _BV(FE0))) { + /* + * A Framing Error indicates (probably) that something is talking + * to us at the wrong bit rate. Assume that this is because it + * expects to be talking to the application, and DON'T reset the + * watchdog. This should cause the bootloader to abort and run + * the application "soon", if it keeps happening. (Note that we + * don't care that an invalid char is returned...) + */ + watchdogReset(); + } + ch = UDR0; #endif |