Abdellazizhammami / arduino

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

ArduinoISP sketch should only respond to first sync request (not all of them) #730

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Upload ArduinoISP to Arduino Uno
2. Try to upload a blink example to an ATTiny85

What is the expected output? What do you see instead?
It should upload. 
Got the following errors.

Error1:
Binary sketch size: 688 bytes (of a 8192 byte maximum)

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

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x01
avrdude: stk500_initialize(): (a) protocol error, expect=0x14, resp=0x10
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): unknown response=0x12

Solution1:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286589145
"I think I found one myself.
the problem is that the init request is sent 3 times but only one answer is 
expected, the following patch should fix":

bilibao@nbarizzi2:~/ELE/arduino-0022$ diff -u 
examples/ArduinoISP/ArduinoISP.pde /home/bilibao/sketchbook/fixed/fixed.pde
--- examples/ArduinoISP/ArduinoISP.pde  2010-12-24 23:12:25.000000000 +0100
+++ /home/bilibao/sketchbook/fixed/fixed.pde    2011-01-12 01:10:41.373212997 
+0100
@@ -54,7 +54,7 @@
  pinMode(9, OUTPUT);
  pulse(9, 2);
}
-
+int initSent=0;
int error=0;
int pmode=0;
// address for reading and writing, set by 'U' command
@@ -399,7 +399,8 @@
  uint8_t ch = getch();
  switch (ch) {
  case '0': // signon
-    empty_reply();
+    if(! initSent) empty_reply();
+    initSent = 1;
    break;
  case '1':
    if (getch() == CRC_EOP) {
I applied the patch above manually and hurray I got a different error!

Error2:
Binary sketch size: 688 bytes (of a 8192 byte maximum)
avrdude: stk500_getsync(): not in sync: resp=0x15
avrdude: please define PAGEL and BS2 signals in the configuration file for part 
ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part 
ATtiny85

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x11
avrdude: stk500_cmd(): programmer is out of sync

Solution2:
Get the following version of the ArduinoISP and apply the patch from solution 1 
again.
http://mega-isp.googlecode.com/files/ArduinoISP.04.zip
(found the solution here: http://forums.adafruit.com/viewtopic.php?f=25&t=20290 
) 

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?
ArduinoUno
Arduino IDE: 0022ubuntu0.1
OS: Ubuntu 11.10 oneiric 64bit

Please provide any additional information below.
I thought I'll let you guys know what fixed it for me, and hopefully get a fix 
in.
http://amanica.blogspot.com/2011/11/my-quest-to-program-attiny85-with-my.html

Original issue reported on code.google.com by ama...@gmail.com on 28 Nov 2011 at 1:02

GoogleCodeExporter commented 8 years ago
Is this an avrdude issue? If avrdude sends 'sign on' three times it should 
handle three responses. Maybe it's a timing issue.

The 'initSent' flag should be cleared when the session is complete. Not all 
Arduino board reset each time you connect, and you might want to run a second 
session.

Original comment by rsb...@gmail.com on 7 Dec 2011 at 12:37

GoogleCodeExporter commented 8 years ago
> Is this an avrdude issue?

I don't think so because it only required me to hack ArduinoISP to make things 
work.

> The 'initSent' flag should be cleared when the session is complete. Not all 
Arduino board reset each time you connect, and you might want to run a second 
session.

Well with the changes I noted in the initial post things *are* working for me.

From online sources I saw that you have to somehow pull the reset up or down (I 
can't remember) using a resistor or capacitor, but all my attempts to do that 
made that my programmer will not work. Because mine worked without that I just 
left that out, maybe I somehow have a software fix for that. 

Original comment by ama...@gmail.com on 7 Dec 2011 at 12:47

GoogleCodeExporter commented 8 years ago
I am using Audunio 1.0 with an SMD edition Uno trying to upload to ATtiny85.
Also using ATtiny definitions from: "damellis-attiny-6bff522.zip"
Initially I received similar error messages during upload to ATtiny85.
I followed Solution 2 above using "ArduinoISP.04.zip" - note I had to add the 
line "#include "pins_arduino.h" " to solve a compile error. So now the ISP 
compiles and loads into the Uno OK. When i try to upload blink to the ATtiny85 
i now get a single line error message: avrdude: stk500_getsync(): not in sync: 
resp=0x15
Any ideas? I've also tried 100 ohm pull-up on Uno reste line and seperately no 
pull-up and then the 10uF capacitor that has worked for others but make no 
difference to my outcomes.

Original comment by gjkend...@gmail.com on 26 Dec 2011 at 4:47

GoogleCodeExporter commented 8 years ago
OK got it working now and here are the details to help others:
1. Went back to Arduino 22 IDE (running on a separate laptop)and uploaded the 
Ardunio ISP sketch to my Uno with no mods. Close IDE.
2. Used ATtiny definition file from 
http://hlt.media.mit.edu/wp-content/uploads/2011/06/attiny45_85.zip. 
3. Open IDE and select board in Tools as "ATtiny85 with Arduino as ISP".
4. Upload Blink sketch modified to pin 0 and it works (with just the two known 
errors).
5. Then went back to Arduino 1.0 IDE which still has ATtiny definitions from 
https://github.com/damellis/attiny/tree/Arduino1 and uploaded blink to target 
OK also able to change the tiny85 to 8MHz using the "Burn Bootloader" tool all 
as described on the http://hlt.media.mit.edu/?p=1695 web-page.
Notes: I tried definitions attiny45-85.zip on Ardunio 1.0 IDE but it causes 
compile errors so reverted to "damellis-attiny-6bff522.zip". The key to my 
success is using the Ardunio ISP sketch example from the 22 IDE.  There must be 
some fundemental bugs in the Ardunio ISP sketch bundled with Ardunio 1.0

Original comment by gjkend...@gmail.com on 27 Dec 2011 at 7:04

GoogleCodeExporter commented 8 years ago
Using the Ardunio ISP from Arduino IDE V0.22 also worked for me where the V1.0 
version did not work.

Original comment by mch...@gmail.com on 27 Dec 2011 at 9:54

GoogleCodeExporter commented 8 years ago
You're right, the ArduinoISP sketch doesn't work in Arduino 1.0.  This is issue 
#661.  The initial bug report / fix here was different though, so I'm leaving 
this issue open too.

Original comment by dmel...@gmail.com on 27 Dec 2011 at 4:06

GoogleCodeExporter commented 8 years ago

Original comment by dmel...@gmail.com on 29 Dec 2011 at 8:27

GoogleCodeExporter commented 8 years ago
I can use the Arduino 1.0 with ArduinoISP plus the "ATtiny.zip" from github and 
the Arduino 0022 with the ArduinoISP with attiny45_85.zip. Other mixtures fail 
Read both the ATtiny45-85 writeup and the ATtiny writeups on MIT page. 
AtTiny45-85 only works with ARduino 0022. I've used it with Tiny84 (change 
blink pin to 1) and Tiny85 (change blink pin to 0. It took two weeks to sort 
this all out. Quick test - select Burn Bootloader. Should work error free.

Jim

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

GoogleCodeExporter commented 8 years ago
I reviewed the avrdude source code 
http://svn.savannah.nongnu.org/viewvc/RELEASE_5_11_0/stk500.c?revision=996&root=
avrdude&view=markup

-It does send Cmnd_GET_SYNC three times
-It ignores the first two replies (stk500_drain())

It will read and process the third reply. The following configuration is 
expected to work:
-Arduino UNO
-Arduino IDE 1.0
--In programmers.txt set arduinoisp.speed=9600
--In the ArduinoISP sketch use Serial.begin(9600);
-A resistor to tie the reset line HIGH is considered unnecessary.
-A capacitor to defeat auto-reset is considered unnecessary.

Original comment by rsb...@gmail.com on 18 Feb 2012 at 3:20

GoogleCodeExporter commented 8 years ago
I were able to program an atTiny45 using the following approach:
- Arduino R2
- Arduino IDE 1.0
- ArduinoISP bundled with Arduino-1.0,
  plus the two modifications described in comment #9
- A 10µF capacitor between reset and GND.

Without the capacitor, avrdude returns a few errors, as shown in the attached 
.txt.

Original comment by chrte...@gmail.com on 18 Feb 2012 at 6:34

Attachments:

GoogleCodeExporter commented 8 years ago
After tearing my hair out for a week trying to program my Attiny85, the fix in 
comment #9 did the trick.  I was worried I had fried the 85, but it turns out 
ArduinoISP was just talking too fast.  Thank you, rsb...!

Attiny85
Arduino Uno R3
Arduino IDE 1.0
ArduinoISP from IDE 1.0, modified to run at 9600 baud
I did use a capacitor to defeat auto reset.  May not be necessary, but it 
worked.  :)

Original comment by MechaTam...@gmail.com on 8 Mar 2012 at 5:06

GoogleCodeExporter commented 8 years ago
I had similar problems using my SB-Freeduino and Arduino 1.0: I kept getting

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x11
avrdude: stk500_cmd(): programmer is out of sync

Arduino 1.0.1 has a new version of ArduinoISP. So I took the sketch from there, 
renamed .ino into .pde, and now everything works. (I don't need the capacitor.) 
Probably upgrading everything to Arduino 1.0.1 would work, too.

Original comment by wullschl...@gmail.com on 27 May 2012 at 2:31

GoogleCodeExporter commented 8 years ago
#12 
program seems to be rite and even the arduino software is configured for 
ArduinoMega2560. Can you plz help us wit this error..

avrdude: stk500v2_getsync(): not in sync: resp=0x01

Original comment by anamikam...@gmail.com on 6 Apr 2013 at 1:10

GoogleCodeExporter commented 8 years ago
I found a similar issue running the command
avrdude -b 9600 -c arduino -p m644p -t -vvvv -P /dev/ttyACM0

and provided a fix in both avrdude (see 
https://savannah.nongnu.org/bugs/index.php?39526) and mega-isp (see 
http://code.google.com/p/mega-isp/issues/detail?id=30).  The discussion for 
that fix is at http://forum.arduino.cc/index.php?topic=174857.0 and perhaps, 
over time, in those bug reports.

The best solution would be to implement a three way handshake to correctly 
start the communication with the mega-isp.  Its an issue with both avrdude and 
mega-isp.  But at least the fix provided helped me get going.  Now all I need 
is openocd to support atmega644 chips!

Original comment by pete...@gmail.com on 19 Jul 2013 at 1:59