Export to GitHub

arduino - issue #661

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


Posted on Sep 30, 2011 by Happy Rhino

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/Blink.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.

Comment #1

Posted on Nov 7, 2011 by Happy Rhino

(No comment was entered for this change.)

Comment #2

Posted on Dec 16, 2011 by Happy Rhino

(No comment was entered for this change.)

Comment #3

Posted on Dec 28, 2011 by Happy Rhino

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/80a2154279a02fd69f995ef6ff9eb889363c73ca

Comment #4

Posted on Jan 18, 2012 by Happy Elephant

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!

Comment #5

Posted on Jan 30, 2012 by Happy Rhino

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.

Comment #6

Posted on Feb 8, 2012 by Happy Hippo

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

Comment #7

Posted on Feb 17, 2012 by Massive Rhino

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.

Status: Fixed

Labels:
Type-Defect Priority-Medium Component-Examples Milestone-1.0.1