I am working on some PCB with an ATmega328P on it. I use a Pogo connector because we have to program and test the PCB outside.
I program with usbTiny
, (mosi/miso/rest/clk/power
)
Anyway, many times during programming I move a little bit which disturbs the Pogo pin contacts and get a verification error. Then I start again and flash it successfully.
But sometimes, after a movement and a mismatch on verification, I can not flash it any more, like now.
I get :
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
An error occurred while uploading the sketch
I got extremely tired from manufacturing again and again 🙁 and I am sure the chip is still OK. This will probably happen again.
I have read that there are ways to save it, like serial programming or oscillator.
How exactly can I do this with serial?
VERBOS:
Using Port : usb
Using Programmer : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: 020:013
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
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 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
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
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : USBtiny
Description : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported
avrdude: Using SCK period of 10 usec
avrdude: initialization failed, rc=-1
Best Answer
It seems likely that you have inadvertently changes the fuses to one of:
To recover this you need to use a "high-voltage" programmer that involves holding /RESET at +12V whilst specific sequences of commands are sent through most of the other pins. This may be difficult with your "pogo pin" arrangement.
It may even be impossible if putting 12V into /RESET damages other circuitry (eg. if you have a pull-up resistor that would bleed 12V into the 5V line).
I have a post about using another Arduino to do high-voltage programming here.
You can see that there are a lot of wires, and it may not be practical to do what with pogo pins.
You can also use an AVR Dragon board to provide the necessary signals and pin-outs.
However this would require that you either remove the chip and place it inside the programmer, or run something like 18 wires to the board, similar to the earlier solution.
I suggest, whilst testing, that you solder on a 6-pin header suitable for doing your SPI programming. That will eliminate the pogo pins, and give you a reliable contact for programming. Once you have debugged it the production models won't need that.
You could use my chip detector sketch which would help show if the chip is unresponsive, or has merely had some fuses changed (eg. clock source).
Example output from the sketch:
Source for sketch on GitHub - in "Atmega_Board_Detector" folder.