Monday 28 November 2011

My quest to program a ATTiny85 with my Arduinon UNO using ISP

While doing the Arduino advanced course at house4hack a while ago, the Ubuntu 11.10 (oneric) guys could not manage to program their ATTiny85 chips although the windows and Ubuntu 10.04 (Lucid) guys managed fine. Today I spent a lot of time trying to get it to work and FINALLY did. Below is the main errors I saw and how to fix it.

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)

My tiny is now happily blinking away, at last.
I sommer reported this as a bug too, so it may stand a chance of getting fixed.

4 comments:

  1. Hi,

    How do I use the Arduino ISP patch? I also got that particular error message.

    May Christ guide you

    ReplyDelete
    Replies
    1. Well I manually applied, i.e. remove the lines indicated with a starting -, and add the lines indicated with a starting + (but don't leave the + in the file).

      Delete
  2. Hey,

    Thanks for the tutorial; I've been working on programming an AtTiny45 for a while using the MIT media labs site that has something similiar. I was having problems, and downloaded the new version of the Arduino ISP and applied your solution number 2 patch; I get less errors, but now I get avrdude: stk500_getsync(): not in sync: resp=0x15. My atTiny45 says it's a 20 MHz chip; do I need to find a 20Mhz AtTiny support file? Everything seems to either be 1 MHz or 8. Any advice? Thanks!

    ReplyDelete
    Replies
    1. I don't actually know. I'm not an expert, just somebody that battled for a day or so and with a lot of googling and experimentation got mine to work. Hope you come right, sorry that I can't be of more help.

      Delete