Skip to content

avrdude 6.3-20171130 fails with attiny13a #8198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bratoff opened this issue Nov 15, 2018 · 15 comments
Closed

avrdude 6.3-20171130 fails with attiny13a #8198

bratoff opened this issue Nov 15, 2018 · 15 comments
Labels
Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Component: Uploading Uploading programs to an Arduino board Type: Bug Upstream notified Related to a software component maintained by someone else. They have been notified of it

Comments

@bratoff
Copy link

bratoff commented Nov 15, 2018

I receive the following error output when attempting to program an attiny13a using avrdude 6.3-20171130, which is installed by Arduino 1.8.7. If I revert to the previous version of avrdude (by installing version 1.6.21 of Arduino AVR Boards), everything works normally.

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\\.\libusb0-0001--0x1781-0x0c9f
         AVR Part                      : ATtiny13
         Chip Erase delay              : 4000 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no         64    4      0  4000  4000 0xff 0xff
           flash         65     6    32    0 yes      1024   32     32  4500  4500 0xff 0xff
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          2    0      0     0     0 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, https://learn.adafruit.com/usbtinyisp
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0xffffff (probably .avr8x_mega) (retrying)

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0xffffff (probably .avr8x_mega) (retrying)

An error occurred while uploading the sketch
Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0xffffff (probably .avr8x_mega)
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

I can reproduce the exact same behavior by running avrdude from a command prompt, completely outside of the Arduino IDE, using the same configuration file, command parameters and programmer. IMO, this isolates the issue to the 20171130 release of avrdude.

I have tried several other AVR family chips, and of those I've tried only the attiny13a appears to have this problem.

I have also tried several different versions of avrdude.conf, and that made no difference.

I do not have any other type of programmer than the usbtiny, so I cannot determine if that is a factor.

@per1234 per1234 added Component: Uploading Uploading programs to an Arduino board Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) labels Nov 15, 2018
@facchinm
Copy link
Member

The first signal that something is going wrong seems avrdude: programmer operation not supported that comes from here, so it looks like the programmer is not being recognized.
Can you share the commandline you are using?

@facchinm facchinm added the Waiting for feedback More information must be provided before we can proceed label Nov 15, 2018
@matthijskooijman
Copy link
Collaborator

@facchinm, sounds like the programmer is supported, but doesn't implement everything that is being used (e.g. perhaps not block writes, no chipe erase or no voltage control, stuff like that). Still, if some operation that is expected is not executed, that could cause a problem. Pity the error message doesn't say what operation exactly.

@bratoff
Copy link
Author

bratoff commented Nov 15, 2018

Here is the command line being issued by the Arduino IDE.

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -pattiny13 -cusbtiny -Uflash:w:C:\Users\bruce\AppData\Local\Temp\arduino_build_545146/Simon_attiny.ino.hex:i

@facchinm please also keep in mind that this command worked perfectly with the avrdude 6.3 that came with version 1.8.5 of the Arduino IDE. The only thing that has changed is the version of avrdude.

Also, it has been my experience that all "usbtiny" class programmers produce the "operation not supported" error for certain chips, but seem to have no problem programming these chips anyway.

Again, my original post is a new problem that only appeared with avrdude 6.3-20171130. Does anybody know why the Arduino team switched versions or what is different about this version of avrdude?

@facchinm
Copy link
Member

@bratoff we switched version to support new Microchip AVR chips with UPDI programming interface. The change should not affect older chips/programmers so I'll double check your commandline.
If you need the old avrdude back, either downgrade avr core to 1.6.21 (last version with old avrdude) or replace the binary with this one http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino9-i686-w64-mingw32.zip

@bratoff
Copy link
Author

bratoff commented Nov 16, 2018

I have both versions of avrdude on my machine. Rather than downgrade my Arduino configuration, I am now programming the atttiny13a from the command line so that I can force the older version of avrdude.
It would be a far cleaner and more convenient solution if there were a single version of avrdude that supported both the attiny13a and the newer UPDI chips. Is it possible that whatever was done in avrdude to detect the new chips affected the older chips somehow? Could there possibly be a change in avrdude.conf that would work around the problem?

@per1234 per1234 removed the Waiting for feedback More information must be provided before we can proceed label Nov 18, 2018
@facchinm
Copy link
Member

@bratoff the best way would be to bisect the avrdude history until we find the root cause, but unfortunately I don't have an usbtiny programmer to test it. Could you send both the successful output and the broken one launched with -vvv (superverbose) command line switch? Probably there's a hint on what is going on. Thanks!

@bratoff
Copy link
Author

bratoff commented Nov 20, 2018

@facchinm Here are the console outputs from the two runs. The two versions are definitely issuing different commands to initialize the chip and read the signature.

This is the successful run using the avrdude from the 1.6.21 AVR core:
Test1.txt

And this is the broken run using the avrdude from the latest AVR core:
Test2.txt

From what I can see in the successful run the chip does not respond to the first Programming Enable command, avrdude retries and is successful on the second attempt. Everything else then works after that.

In the broken run, avrdude apparently does not detect that the first Programming Enable command did not get a valid response and does not retry. That easily explains why nothing works after that - the chip was never put in programming mode.

Thank you very much for your follow-up. I hope this helps track down the issue.

@facchinm
Copy link
Member

The only commit regarding usbtiny alone in the period between the two builds of avrdude is facchinm/avrdude@5beac69 . I'm attaching a build with that commit reverted, if you can test it it would help a lot!
avrdude-6.3.0-arduino14-i686-w64-mingw32.zip

@bratoff
Copy link
Author

bratoff commented Nov 20, 2018

@facchinm The reverted build works correctly! Here's the console output:

Test3.txt

@facchinm
Copy link
Member

Great to hear that! I think the patch can be further reduced into changing this line; I'm sending you another binary for testing and if it works I'll file a PR for mainline avrdude.

diff --git a/usbtiny.c b/usbtiny.c
index 1f86b1d..8c303de 100644
--- a/usbtiny.c
+++ b/usbtiny.c
@@ -503,7 +503,7 @@ static int usbtiny_initialize (PROGRAMMER *pgm, AVRPART *p )
   }
 
   for (tries = 0; tries < 4; ++tries) {
-    if (pgm->program_enable(pgm, p) >= 0)
+    if (pgm->program_enable(pgm, p) == 0)
       break;
     // no response, RESET and try again
     if (usb_control(pgm, USBTINY_POWERUP,
-- 

avrdude-6.3.0-arduino14-i686-w64-mingw32.zip

@bratoff
Copy link
Author

bratoff commented Nov 21, 2018

@facchinm Success! Looks like that's the fix. Here's the console output:
Test4.txt

Thanks again for your help.

@facchinm
Copy link
Member

Reported mainline at https://savannah.nongnu.org/patch/index.php?9728

@facchinm facchinm added the Upstream notified Related to a software component maintained by someone else. They have been notified of it label Nov 22, 2018
@matthijskooijman
Copy link
Collaborator

@facchinm, Nice fix, some good digging there :-)

facchinm added a commit to facchinm/avrdude that referenced this issue Apr 5, 2019
As reported on arduino/Arduino#8198 ,
`patch #8924: Enable TPI for usbtiny` broke the functionality of such programmer for non TPI targets.
The refactor included reworking `usbtiny_initialize`, which used to call `pgm->program_enable` once and, in case of failure, reset the programmer and call it again.
The new code considers the return code successful if >=0, so the first failure is not reported and the programmer is not being reset.
The attached patch restores the previous behaviour by checking if `pgm->program_enable() == 0`

Cross reference: https://savannah.nongnu.org/patch/index.php?9728
@bratoff bratoff closed this as completed May 21, 2019
@bratoff bratoff reopened this May 21, 2019
@bratoff
Copy link
Author

bratoff commented May 21, 2019

The avrdude team accepted the patch in January, but it has not been included in the 1.8.9 release.

@facchinm
Copy link
Member

The patch has been merged in facchinm/avrdude@a45d203 and is available on megaAVR core since 1.8.1 (on AVR it will arrive soon).
Closing the issue as fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Component: Uploading Uploading programs to an Arduino board Type: Bug Upstream notified Related to a software component maintained by someone else. They have been notified of it
Projects
None yet
Development

No branches or pull requests

4 participants