Verification errors with TPI and PDI programming

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Verification errors with TPI and PDI programming

Joakim Lubeck
Hello,

I heve been using the svn-version of avrdude for a while now, and it
works well most of the time. But there are some combinations that
doesn't work for me.

When I use usbasp (latest firmware) with TPI (tested tiny10, 20, 40) it
gives me verification errors, like

---
  $ avrdude -p attiny10 -P usb -c usbasp -e   -U flash:w:main.hex

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9003
avrdude: erasing chip
avrdude: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (330 bytes):

Writing | ################################################## | 100% 1.71s

avrdude: 330 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex auto detected as Intel Hex
avrdude: input file main.hex contains 330 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.21s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0010
          0xff != 0x20
avrdude: verification error; content mismatch

avrdude done.  Thank you.
---

But it works without problems if I use the version RELEASE_5_11_1.

I see the same problems with both Ubuntu 10.04 and Ubuntu 12.10.


Now I bought an AVRISPmkII yesterday (updated the firmware with Atmel
Studio 6.1sp1). And it gives me the same problem when I program an
XMega128a1, but works without problems with avrdude 5.11.1.

---
$ avrdude -p atxmega128a1 -P usb -c avrispmkii -U flash:w:main.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e974c
avrdude: NOTE: Programmer supports page erase for Xmega devices.
          Each page will be erased before programming it, but no chip
erase is performed.
          To disable page erases, specify the -D option; for a
chip-erase, use the -e option.
avrdude: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (43140 bytes):

Writing | ################################################## | 100% 2.34s

avrdude: 43140 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex auto detected as Intel Hex
avrdude: input file main.hex contains 43140 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.53s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0006
          0x04 != 0x06
avrdude: verification error; content mismatch

avrdude done.  Thank you.
---

Any idea what's going on here? Please ask for more specific information
if needed.

/Joakim

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Verification errors with TPI and PDI programming

Joerg Wunsch
As Joakim Lubeck wrote:

> But it works without problems if I use the version RELEASE_5_11_1.

Well, the USBasp code doesn't offer much debugging output.

The AVRISPmkII code does, can you please try running with -vvvv, and
compare the logs between both version in order to try finding a
difference?  (Better use a short hexfile, the output is noisy.)
--
cheers, Joerg               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Verification errors with TPI and PDI programming

Joakim Lubeck
On 08/29/2013 11:30 AM, Joerg Wunsch wrote:
> As Joakim Lubeck wrote:
>
>> But it works without problems if I use the version RELEASE_5_11_1.
> Well, the USBasp code doesn't offer much debugging output.
>
> The AVRISPmkII code does, can you please try running with -vvvv, and
> compare the logs between both version in order to try finding a
> difference?  (Better use a short hexfile, the output is noisy.)

I found that it works if I do an explicit flash erase before writing the
flash with avrispmkii/XMega128a1. I did not have to do that with the
JTAGICE3.

But that does not help with usbasp/tiny10 combination. And as you say,
it's very little debug information with the usbasp. I don't think it's
anything usefull from the -vvvv output.

/Joakim

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Verification errors with TPI and PDI programming

Joerg Wunsch
As Joakim Lubeck wrote:

> I found that it works if I do an explicit flash erase before writing
> the flash with avrispmkii/XMega128a1. I did not have to do that with
> the JTAGICE3.

Hmm, I switched Xmegas to use page erase (rather than chip erase) by
default when reprogramming application flash.  Perhaps there's still a
bug in that ...
--
cheers, Joerg               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Verification errors with TPI and PDI programming

Joerg Wunsch
In reply to this post by Joakim Lubeck
As Joakim Lubeck wrote:

> When I use usbasp (latest firmware) with TPI (tested tiny10, 20, 40)
> it gives me verification errors, like

...

> But it works without problems if I use the version RELEASE_5_11_1.

This is kind of strange.

I just compared the USBasp code in AVRDUDE between RELEASE_5_11_1 and
trunk.

Most of the differences relate to a modified USB search algorithm, so
that's completely unrelated.

Two further changes are in the (non-TPI) paged load and paged write
routines, adding the current (page) address to the buffer pointer in
order to obtain the data.  These changes became necessary since the
paged load and write routines are now called from the upper layer once
per page, while they have been called once per memory region in the
past (so the bug always existed, but did not have any effect prior).

No changes have been applied at all to the TPI-related code.

So it's really not quite clear to me why the TPI programming behaviour
would have changed between both versions.

Perhaps I'll add some debugging code to usbasp.c in order to have the
-vvvv option provide a communication trace.  Maybe we can find a
difference between both versions that way.
--
cheers, Joerg               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Verification errors with TPI and PDI programming

Joakim Lubeck
> As Joakim Lubeck wrote:
>
>> When I use usbasp (latest firmware) with TPI (tested tiny10, 20, 40)
>> it gives me verification errors, like
>
> ...
>
>> But it works without problems if I use the version RELEASE_5_11_1.
>
> This is kind of strange.

Yes, I also (with my limited knowledge of the inner workings of avrdude)
see some strange things.

If I build in tags/RELEASE_5_11_1/avrdude I get a working version. If I
"svn log" in that directory then this is the last entry
---
r1016 | joerg_wunsch | 2011-09-16 13:27:20 +0200 (Fri, 16 Sep 2011) | 3 lines

5.11.1 has been released.
---

If I checkout r1016 in trunc I get a non working version(?).


So I did some brute-force testing with a lot of different versions.

First working release is r961 where tpi support was added to usbasp.

962 - 975 - also working.
976 - 977 - can't compile, tpi.h missing
With 978 - 980, 990, 995, 996, 997, 998, 999, 1000, 1005, 1007 I get
---
avrdude: AVR device initialized and ready to accept instructions

Reading |                                                    | 0%
0.00savrdude: Error: usbasp programmer does not support TPI
avrdude: error reading signature data for part "ATtiny10", rc=-1
avrdude: error reading signature data, rc=-1
---

and from 1008 and a couple of tested releases after that I get
verification error.

/Joakim


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Verification errors with TPI and PDI programming

Joerg Wunsch
As [hidden email] wrote:

> So I did some brute-force testing with a lot of different versions.

Thanks, Joakim.

> 962 - 975 - also working.

I just committed a change to SVN trunk that enables a communications
trace for USBasp with -vvvv.  If you rebuild trunk, this should get
you a trace for the non-working version.

If you apply the attached patch to RELEASE_5_11_1 (or to one of the
revisions above which are also working), you can also trace these
old versions.  (The patch applies cleanly to 5.11.1, with just some
offset.)

Maybe the traces got us further.

Sorry, I don't have my ATtiny10 setup around here right now, so I
cannot test myself.
--
cheers, Joerg               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Verification errors with TPI and PDI programming

Joakim Lubeck
Joerg wrote:
> I just committed a change to SVN trunk that enables a communications
> trace for USBasp with -vvvv.  If you rebuild trunk, this should get
> you a trace for the non-working version.

Ok. I attached a trace from a failing session.

> If you apply the attached patch to RELEASE_5_11_1 (or to one of the
> revisions above which are also working), you can also trace these
> old versions.  (The patch applies cleanly to 5.11.1, with just some
> offset.)

Did you forget the attachment?

/Joakim

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev

fail.txt (20K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Verification errors with TPI and PDI programming

Joerg Wunsch
As [hidden email] wrote:

> > I just committed a change to SVN trunk that enables a communications
> > trace for USBasp with -vvvv.  If you rebuild trunk, this should get
> > you a trace for the non-working version.
>
> Ok. I attached a trace from a failing session.

I think I found and fixed all problems now.  In particular, there have
been two major bugs:

. the paged_load and paged_write methods didn't use the current page
  address as offset into m->buf

. each paged_write invocation issued a SECTION_ERASE command before;
  as we now call the paged_write() method once per page (as opposed to
  once per memory region previously), this caused all of the flash to
  be erased on each new page write; a SECTION_ERASE is not needed at
  all since (by default) everything is preceded by a CHIP_ERASE anyway.

I also added some more trace code for -vvv, but only for the TPI
portion of usbasp.c by now.

Joakim, thanks for reporting this!

To anyone else, please test if you can.
--
cheers, Joerg               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Verification errors with TPI and PDI programming

Joakim Lubeck
On 09/01/2013 11:01 PM, Joerg Wunsch wrote:.
> I think I found and fixed all problems now.
Nice. It seems to work!

Thank you very much Jörg!

/Joakim

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: USBasp tracing (Was: Verification errors with TPI and PDI programming)

Joerg Wunsch
In reply to this post by Joerg Wunsch
As Joerg Wunsch wrote:

> I also added some more trace code for -vvv, but only for the TPI
> portion of usbasp.c by now.

I also added it for the non-TPI functions now.  Thus, USBasp can be
traced with a detailed log with -vvv, and including the low-level
device communication with -vvvv.  Hopefully, this will make debugging
any issues easier in the future.
--
cheers, Joerg               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Verification errors with TPI and PDI programming

Joerg Wunsch
In reply to this post by Joakim Lubeck
As Joakim Lubeck wrote:

> On 09/01/2013 11:01 PM, Joerg Wunsch wrote:.
> >I think I found and fixed all problems now.
> Nice. It seems to work!
>
> Thank you very much Jörg!

Varsågod!  I'm glad you found it before 6.0 was released.
--
cheers, Joerg               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Verification errors with TPI and PDI programming

Daniel Rozsnyó

On 09/02/2013 09:39 AM, Joerg Wunsch wrote:

> As Joakim Lubeck wrote:
>
>> On 09/01/2013 11:01 PM, Joerg Wunsch wrote:.
>>> I think I found and fixed all problems now.
>> Nice. It seems to work!
>>
>> Thank you very much Jörg!
>
> Varsågod!  I'm glad you found it before 6.0 was released.
>

Not all is fixed.. few days ago in SVN verson the xmega fuses were still
wrongly programmed - all io went to fuse0 in hardware (jtagice3/pdi with
x32a4u).

There was a patch for it - but why it is not applied for trunk?

Daniel


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Verification errors with TPI and PDI programming

Joerg Wunsch
As "Ing. Daniel Rozsnyó" wrote:

> Not all is fixed..

Nobody claimed it were.  It was just the two specific bugs Joakim
mentioned are assumed to be fixed now.

> few days ago in SVN verson the xmega fuses were
> still wrongly programmed - all io went to fuse0 in hardware
> (jtagice3/pdi with x32a4u).

Yes, I'm aware of it.

> There was a patch for it - but why it is not applied for trunk?

Because my time budget is finite only, and nobody else (of those with
commit privs) stepped forward to apply it.

It's not only to apply the patch, but it also needs testing.  The last
thing we'd like to have is introducing new bugs by a bugfix.

Before polishing up for a release, I'll certainly walk again through
the bug list, and try closing everything that appears to be a fatal
bug (the wrong fuse writes fall into that category, for sure).
--
cheers, Joerg               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: USBasp tracing (Was: Verification errors with TPI and PDI programming)

Joakim Lubeck
In reply to this post by Joerg Wunsch
On 09/02/2013 08:46 AM, Joerg Wunsch wrote:
> I also added it for the non-TPI functions now. Thus, USBasp can be
> traced with a detailed log with -vvv, and including the low-level
> device communication with -vvvv. Hopefully, this will make debugging
> any issues easier in the future.

I think it sneeked in a bug there, it's verbose even if I not tell it to
be. After a quick lock in usbasp.c I think it's at the end of
usbasp_spi_cmd:
---
   if (verbose > 2)
     if (verbose > 3)
       fprintf(stderr, "%s: usbasp_cpi_cmd()", progname);
     fprintf(stderr, " => 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
         res[0], res[1], res[2], res[3]);
---

The missing {}'s make the last printf always print the debug message.
Example:

---
$ avrdude -c usbasp -p t85 -B5

avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions

Reading |                                                    | 0% 0.00s
=> 0x00, 0x30, 0x00, 0x1e
  => 0x00, 0x30, 0x00, 0x93
Reading | #################                                  | 33% 0.00s
=> 0x00, 0x30, 0x00, 0x0b
Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e930b
  => 0x00, 0x50, 0x00, 0x62
  => 0x00, 0x50, 0x00, 0x62
  => 0x00, 0x50, 0x00, 0x62
  => 0x00, 0x58, 0x08, 0xdf
  => 0x00, 0x58, 0x08, 0xdf
  => 0x00, 0x58, 0x08, 0xdf
  => 0x00, 0x50, 0x08, 0xff
  => 0x00, 0x50, 0x08, 0xff
  => 0x00, 0x50, 0x08, 0xff

  => 0x00, 0x50, 0x00, 0x62
  => 0x00, 0x50, 0x00, 0x62
  => 0x00, 0x50, 0x00, 0x62
  => 0x00, 0x58, 0x08, 0xdf
  => 0x00, 0x58, 0x08, 0xdf
  => 0x00, 0x58, 0x08, 0xdf
  => 0x00, 0x50, 0x08, 0xff
  => 0x00, 0x50, 0x08, 0xff
  => 0x00, 0x50, 0x08, 0xff
avrdude: safemode: Fuses OK

avrdude done.  Thank you.
---

/Joakim

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: USBasp tracing (Was: Verification errors with TPI and PDI programming)

Joerg Wunsch
As Joakim Lubeck wrote:

> I think it sneeked in a bug there, it's verbose even if I not tell
> it to be.

You're right, thanks for spotting it.

Fixed.
--
cheers, Joerg               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/
Never trust an operating system you don't have sources for. ;-)

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev