diff options
author | WestfW <westfw@gmail.com> | 2011-06-13 19:07:07 -0700 |
---|---|---|
committer | WestfW <westfw@gmail.com> | 2011-06-13 19:07:07 -0700 |
commit | a0d00b4d86cfbd5cb508eda69997175fab39e725 (patch) | |
tree | 2f8874a64eb917eecf6e8c92da5d2b9b05fbb0cb /bootloaders/optiboot/optiboot.c | |
parent | 5c27dd97a0df974fa7f42b08d8eba6bf1fd50cb8 (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.))
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 |