itsanjan / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

ArduinoISP sketch doesn't work in Arduino 1.0 (serial buffer overflow)? #661

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Upload the Arduino ISP sketch to an Uno w/ optiboot 4.4 (or Duemilanove w/ 
ATmega328)
2. Wire the Arduino to an ATtiny84 microcontroller.
3. Install this core (https://github.com/damellis/attiny/tree/Arduino1).
4. Select ATtiny84 from boards menu and Arduino as ISP sketch from programmer 
menu.
5. Try to upload a simple sketch.

What is the expected output? What do you see instead?
The upload hangs in the middle of trying to write the first page:

avrdude: reading input file 
"/var/folders/v6/4xtyhj9r8xl785006s6n6dkh0000gp/T/build259072443118035160.tmp/Bl
ink.cpp.hex"
avrdude: writing flash (838 bytes):

Writing | avrdude: Send: U [55] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
avrdude: Send: d [64] . [00] @ [40] F [46] * [2a] . [c0] D [44] . [c0] C [43] . 
[c0] B [42] . [c0] A [41] . [c0] @ [40] . [c0] ? [3f] . [c0] > [3e] . [c0] = 
[3d] . [c0] < [3c] . [c0] ; [3b] . [c0] S [53] . [c0] 9 [39] . [c0] 8 [38] . 
[c0] 7 [37] . [c0] 6 [36] . [c0] 5 [35] . [c0] . [00] . [00] : [3a] . [00] 7 
[37] . [00] . [00] . [00] ; [3b] . [00] 8 [38] . [00] . [00] . [00] 9 [39] . 
[00] 6 [36] . [00] . [02] . [02] . [02] . [01] . [01] . [01] . [01] . [01] . 
[01] . [01] . [01] . [01]   [20] 
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

This seems to be because the serial receive buffer is overflowing.  If I change 
it from 64 to 128 bytes (in HardwareSerial.cpp) and reupload the ArduinoISP 
sketch, it works.

Original issue reported on code.google.com by dmel...@gmail.com on 30 Sep 2011 at 3:32

GoogleCodeExporter commented 8 years ago

Original comment by dmel...@gmail.com on 7 Nov 2011 at 10:58

GoogleCodeExporter commented 8 years ago

Original comment by dmel...@gmail.com on 16 Dec 2011 at 10:08

GoogleCodeExporter commented 8 years ago
I fixed this by lowering the baud rate to 9600.  Not the most elegant solution, 
but it seems to work.

https://github.com/arduino/Arduino/commit/80a2154279a02fd69f995ef6ff9eb889363c73
ca

Original comment by dmel...@gmail.com on 28 Dec 2011 at 11:45

GoogleCodeExporter commented 8 years ago
I also had this issue, and I resolved it using the serial buffer fix (THANK 
YOU!!)  I was also able to get the baud rate fix working, which of course 
required me to change the avrdude command line.

It occurred to me that all of the documentation I had found on the web (for 
example http://www.arduino.cc/playground/Code/MegaISP, 
http://www.ladyada.net/library/arduino/bootloader.html) indicated a baud rate 
of 19200 and not everyone using this may understand how to modify the command 
line.  Speaking for myself, I started with Arduino and later learned to program 
an AVR directly by using this sketch, and a mismatch on the command line would 
have been very hard for me to figure out at first.

It's definitely better to have something that works than something that 
doesn't, but consider that this change might "break" the documentation.  Is 
there any way to use the HardwareSerial fix instead?  Maybe it could prevent a 
buffer overrun somewhere else in the code.

Thank you so much for this fix!

Original comment by dch...@gmail.com on 18 Jan 2012 at 5:56

GoogleCodeExporter commented 8 years ago
I'd love a fix that didn't require changing the baud rate (for compatibility 
but also just for speed), but increasing the size of the serial buffer affects 
all sketches.  This seemed like too much just for the ArduinoISP sketch.  

On the other hand, if you use the ArduinoISP sketch with the "Arduino as ISP" 
programmer option in the Arduino 1.0.1 IDE, the baud rates will match up.

Original comment by dmel...@gmail.com on 30 Jan 2012 at 9:20

GoogleCodeExporter commented 8 years ago
I've been going a bit nuts with ArduinoISP and ATTiny chips (84 and 85). I was 
using the MIT Arduino writeups, plus reading a lot on the net. The first 
writeup works great - but only if you use Arduino-0022. The second writeup uses 
Arduino 1.0 but not if you download the tiny45-85 files first. Arduino 1.0 will 
not properly use tiny45-85 and Arduino 0022 will not properly use the tiny 
files for Arduino 1.0

Typical response is:

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64

Original comment by jimgr...@earthlink.net on 8 Feb 2012 at 6:06

GoogleCodeExporter commented 8 years ago
Bit of a hack but...
In the ArduinoISP sketch I #defined a ARDUINOISPMODE then in HardwareSerial.cpp 
I used a #ifdef to change the buffer size.
That way the buffer should only change if I've loaded the ArduinoISP sketch.  
Will get blown away any time the Arduino environment needs to be reinstalled 
though.

Original comment by dhewg...@gmail.com on 17 Feb 2012 at 6:26