bperrybap / usbasp

My repo for experimenting with the usbasp firmware from www.fischl.de
34 stars 12 forks source link

TPI Fails #2

Open sleemanj opened 7 years ago

sleemanj commented 7 years ago

Short story, I have not investigated far, ATTiny5

Writing flash with TPI on 1.06a firmware (prebuilt binary) doesn't actually appear to modify the flash,

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e8f09 (probably t5)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
        To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "/tmp/arduino_build_514273/Blink.ino.hex"
avrdude: writing flash (242 bytes):

Writing | ################################################## | 100% 0.32s

avrdude: 242 bytes of flash written
avrdude: verifying flash memory against /tmp/arduino_build_514273/Blink.ino.hex:
avrdude: load data flash data from input file /tmp/arduino_build_514273/Blink.ino.hex:
avrdude: input file /tmp/arduino_build_514273/Blink.ino.hex contains 242 bytes
avrdude: reading on-chip flash data:

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

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x00ba
        0x43 != 0x47
avrdude: verification error; content mismatch

avrdude done.  Thank you.

The existing firmware on the target is unmodified (evidenced by the behaviour of the target being that specified by the previous flash contents) indicating that even though it said it wrote flash, it didn't, and hence the verification error.

Usnig the current fischl firmware it works fine.

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e8f09 (probably t5)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
        To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "/tmp/arduino_build_514273/Blink.ino.hex"
avrdude: writing flash (242 bytes):

Writing | ################################################## | 100% 0.91s

avrdude: 242 bytes of flash written
avrdude: verifying flash memory against /tmp/arduino_build_514273/Blink.ino.hex:
avrdude: load data flash data from input file /tmp/arduino_build_514273/Blink.ino.hex:
avrdude: input file /tmp/arduino_build_514273/Blink.ino.hex contains 242 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.10s

avrdude: verifying ...
avrdude: 242 bytes of flash verified

Now, beware when testing, the verification in 1.06a firmware DOES work, so if you successfully write the flash with the fischl firmware, then try to write the same flash contents using the 1.06a firmware, it will look like it all worked fine, but it didn't, it still didn't write the flash it just passes verification because it was already written previously. So in other words, every time you do a test, make sure your flash content you are testing with is unique.

bperrybap commented 7 years ago

What processor is on USBasp device? Many of the USBasp devices have atmega48 processors. The atmega48 only has 4k of flash and so on that part the TPI code is removed. But averdude should report an error if TPI mode is attempted.

sleemanj commented 7 years ago

Both are ATMega8A

The output indicates that TPI is working but it's not actually writing anything - it reads stuff out fine it seems (signature and verification of existing contents).

I also tried forcing the bitclock slower (notice the writing time for the fischl is 3x the (non-)writing time for 1.06a), makes no difference.

sleemanj commented 7 years ago

I should have RTF Datasheet!

The ATTiny 4/5/9/10 require 5v to program them.

I had the USBasp with the 1.06a firmware set to 3v3 output, so it was able to read but not enough juice to actually flip any bits.

Maybe a note in the README.md, I see somebody else was having similar problems in the Arduino forums a year or so back, I bet it was the same.