Firmware flash - device not recognised. :(

oh hai olivier!

build looks fine, but having some firmware flash woes.

any ideas about the below?

C:\\midipal>avrdude -B 100 -V -p m328p -c usbtiny -P usb -e -u -U efuse:w:0xfd:m -U hfuse:w:0xd4:m -U lfuse:w:0xff:m -U lock:w:0x2f:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x000102
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
Double check chip, or use -F to override this check.

Is the USBtiny providing 3.3V to the chip? If not, make sure that the power supply is running.

hmm. got a bit further, but crashed out on this:

Writing | ################################################ | 96% 46.42s *****failed;
*****failed;
*****failed;
*****failed;
*****failed;
*****failed;
*****failed;
Writing | ################################################# | 97% 46.84s *****failed;
*****failed;
*****failed;
*****failed;
Writing | ################################################## | 99% 47.17s *****failed;
*****failed;
*****failed;
*****failed;
*****failed;
*****failed;
Writing | ################################################## | 100% 47.56s

avrdude: 1024 bytes of eeprom written
avrdude: reading input file "0x2f"
avrdude: writing lock (1 bytes):

Writing | | 0% 0.00s *****failed;
Writing | ################################################## | 100% 0.11s

avrdude: 1 bytes of lock written

avrdude: safemode: Verify error - unable to read hfuse properly. Programmer may not be reliable.
avrdude: safemode: Verify error - unable to read lfuse properly. Programmer may not be reliable.
avrdude: safemode: Sorry, reading back fuses was unreliable. I have given up and exited programming mode

avrdude done. Thank you.

fuses not set? i hope i haven’t blown anything…

wow, quick reply! power supply is on. and lcd is bright, etc. 3.3v on test points…

What did you do to go to this step further? Have you checked for solder blobs causing bridges between the lines of the ISP socket?

There’s not much risk of bricking things - except by writing the fuses to use an external crystal oscillator while the crystal is not there ; but it doesn’t seem to be your problem here.

I’ll also check for flaky ISP cable - once in a while I see things like your first message (failure very early in the process, not recognizing the chips) - it’s just the cable.

I thought the first command completed sucessfully but I wasn’t sure so I went ahead and tried the next one, which seemed to progress but failed eventually. I’ll keep poking. Thanks for the quick reply.

ok i’m guessing it’s a dodgy programmer. shame, cos it worked on lots of other stuff.

can you tell from the below if the fuses were set properly?

C:\\midipal>avrdude -B 100 -V -p m328p -c usbtiny -F -P usb -e -u -U efuse:w:0xfd:m -U hfuse:w:0xd4:m -U lfuse:w:0xff:m -U lock:w:0x2f:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e950f
avrdude: erasing chip
avrdude: reading input file "0xfd"
avrdude: writing efuse (1 bytes):

Writing | | 0% 0.00s *****failed;
Writing | ################################################## | 100% 0.11s

avrdude: 1 bytes of efuse written
avrdude: reading input file "0xd4"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of hfuse written
avrdude: reading input file "0xff"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lfuse written
avrdude: reading input file "0x2f"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lock written

avrdude done. Thank you.

C:\\midipal>avrdude -B 100 -V -p m328p -c usbtiny -P usb -e -u -U efuse:w:0xfd:m -U hfuse:w:0xd4:m -U lfuse:w:0xff:m -U lock:w:0x2f:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e950f
avrdude: erasing chip
avrdude: reading input file "0xfd"
avrdude: writing efuse (1 bytes):

Writing | | 0% 0.00s *****failed;
Writing | ################################################## | 100% 0.11s

avrdude: 1 bytes of efuse written
avrdude: reading input file "0xd4"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of hfuse written
avrdude: reading input file "0xff"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lfuse written
avrdude: reading input file "0x2f"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lock written

avrdude done. Thank you.

C:\\midipal>avrdude -B 1 -V -p m328p -c usbtiny -P usb -U flash:w:midipal_flash_golden.hex:i -U eeprom:w:midipal_eeprom_golden.hex:i -U lock:w:0
x2f:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e950f
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 "midipal_flash_golden.hex"
avrdude: writing flash (32614 bytes):

Writing | ################################################## | 100% 7.48s

avrdude: 32614 bytes of flash written
avrdude: reading input file "midipal_eeprom_golden.hex"
avrdude: writing eeprom (1024 bytes):

Writing | | 0% 0.00s
avrdude: error: usbtiny_send: usb_control_msg: sending control message failed, win error: The I/O operation has been aborted because of either
a thread exit or an application request.
(expected 128, got -116)
avrdude: 8 retries during SPI command
Writing | ################################################## | 100% 5.70s

avrdude: 1024 bytes of eeprom written
avrdude: reading input file "0x2f"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lock written

avrdude: safemode: Fuses OK

avrdude done. Thank you.

C:\\midipal>

Yes, the fuses are read back correctly.

fuck it. i’ve ordered an avrisp mkii…

Have you tested another -B value, perhaps slower does it?

Can you elaborate? Do you mean the number 1 directly after the -b? What would you recommend?

Use -B 100 when writing fuses and -B 10 when writing the main firmware + eeprom. The number after -B is the divider of the ISP programmer clock frequency. The bigger, the slower.

cool. will try again later. thanks you two!

so i was getting the following on the avrisp mkII:

Avrdude: usbdev_open() did not find any USB device “usb”

i did some searchnig and updated the libusb-win32 libusb0.dll as described here:

http://www.mail-archive.com/avr-chat@nongnu.org/msg01217.html

not sure if that worked but it made some kind of difference, does this look like the programmer is recognised ok?

C:\\midipal>avrdude -B 10 -V -p m328p -c avrispmkII -P usb -U flash:w:midipal_flash_golden.hex:i -U eeprom:w:midipal_eeprom_golden.hex:i -U lock
:w:0x2f:m

avrdude: stk500v2_command(): command failed
avrdude: stk500v2_command(): unknown status 0xc9
avrdude: stk500v2_program_enable(): cannot get connection status
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude done. Thank you.

The programmer appears to be recognized correctly by the OS. This error indicates that communication with the MCU could not be established. Check that the MIDIpal board is powered, and that the connector is correctly oriented.

ok cool. midipal is powered, and programmer is correctly connected (pin 1 indicated by the bar over pin 1 on the board, and the down arrow on the programmer header).

just to confirm: the ISP header should be connected facing down onto the board, not from underneath?

at this point, i suppose it must be a dodgy connection somewhere on my board. i’ll go over everything again when i get a chance. it’s strange though, because i was able to flash the fuses at one point.

thanks again for your help olivier, i appreciate it. this must be the worst part of being mutable instruments - trouble shooting twats!

Like this:

hmm, no all connected fine.

fine tooth comb on the board later on i guess.

one final thing:

is it really neccessary to do the following: " alter command as follows: change avrdude to C:\\WinAVR\\bin\\avrdude (or wherever avrdude is on windows)"?

Depends on where avrdude is set up and your PATH.