avrdudes / avrdude

AVRDUDE is a utility to program AVR microcontrollers
GNU General Public License v2.0
667 stars 131 forks source link

[bug #41631] TPI bitbang for preprogrammed ATtinys can fail (Patch attached) #331

Closed avrs-admin closed 1 year ago

avrs-admin commented 2 years ago

Matthias Neeracher Tue 18 Feb 2014 01:13:56 PM UTC

If an ATtiny4/5/9/10 has been programmed with software that sets PB0 (a.k.a TPIDATA) as an output, this will interfere with the MOSI -> MISO connectivity test when avrdude tries to reprogram the MCU.

The simplest solution, it seems to me, is to hold RESET low during the MOSI->MISO test. I’ve attached a patch implementing this, which works for me (Using a Buspirate as the programmer).

file #30594: bitbang,patch

This issue was migrated from https://savannah.nongnu.org/bugs/?41631

mcuee commented 2 years ago

Can this be made generic? What does the official Atmel programmers do in this case?

BTW, STM32 Cube Programmer has an option to ask the user to try to enter programming mode while holding the chip under reset. Maybe a document enhancement can be done to provide information for such siutation and potential workaround (if possible).

mcuee commented 2 years ago

Somehow I can not download the patch now, I will try later.

mcuee commented 2 years ago

Somehow I can not download the patch now, I will try later.

Looks like the patch is gone.

MCUdude commented 2 years ago

I was able to download it!

Index: bitbang.c
===================================================================
--- bitbang.c   (revision 1275)
+++ bitbang.c   (working copy)
@@ -548,8 +548,8 @@
       return -1;
     }

-   /* bring RESET high first */
-    pgm->setpin(pgm, PIN_AVR_RESET, 1);
+   /* bring RESET low first */
+    pgm->setpin(pgm, PIN_AVR_RESET, 0);
    usleep(1000);

     if (verbose >= 2)
@@ -571,6 +571,8 @@
   }

   pgm->setpin(pgm, PIN_AVR_SCK, 0);
+  pgm->setpin(pgm, PIN_AVR_RESET, 1);
+  usleep(1000);
   pgm->setpin(pgm, PIN_AVR_RESET, 0);
   usleep(20000);
mcuee commented 1 year ago

I do not have TPI parts for testing as of now. Just wondering if this is still applicable or not.

mcuee commented 1 year ago

@MCUdude

I do not have good testing facility for TPI parts. Just wondering if you can check if this is still an issue or not. Thanks.

mcuee commented 1 year ago

Nobody has complained for so long, so I guess this is no longer an issue. I will close this for now. We can re-open this if there are new reports.