microtherion / ScratchMonkey

Arduino software programmer sketch, supporting ISP, HVSP, and HVPP
67 stars 25 forks source link

Problem in HVPP mode with atmega8 #5

Open PASAf opened 7 years ago

PASAf commented 7 years ago

Hello, I've compiled sketch of ScratchMonkey with latest Arduino IDE (1.8.3) and loaded up it to Arduino Mega 2560 R3 (original, not chinese version). Connected all like in Target Connection Diagram from https://microtherion.github.io/ScratchMonkey/Connection.html (used ATmega328 diagram, mine is ATmega8, but pins match). 12V source is 12V 1.5A power unite of TP-LINK router connected to external power connector of Arduino. Vin connected as in High Voltage Programming diagram (https://microtherion.github.io/ScratchMonkey/img/external.png) through BC547C transistor. Command line of avrdude is: -c stk500pp -p m8 -P COM9 Output:

avrdude.exe: AVR device initialized and ready to accept instructions

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

avrdude.exe: Device signature = 0x000102
avrdude.exe: Expected signature for ATmega8 is 1E 93 07

All fuses reads as 0x04:

Fuses

If I add force (-F) key and do dump - it looks normal (although I don't remember what where on that mega8, but it looks normal at least at start, at end it goes like repeated sequence 00 FF 01 FF 02 FF 03 FF 04 FF 05 FF 06 FF 07 FF till the F8 FF F9 FF FA FF FB FF FC FF FD FF FE FF FF FF) I can't erase and write to flash. avrdude reports that write or erase is OK, but during verification it throws error and when I read flash after that - it has same contents.

What does it mean? What could be wrong? P.S. If I compile ScratchMonkey with Arduino IDE 1.0.5 it doesn't respond to avrdude at all and continuously output some trash to COM port (TX led blinking all time).

PASAf commented 7 years ago

OK, I've managed out it to work. I've enabled HVPP Debug in SMoConfig.h like: #undef DEBUG_HVPP -> #define DEBUG_HVPP (uploaded with Arduino IDE 1.8.3) And this allowed me to correctly identify chip and write correct fuses. Perhaps, debug slowed down something a bit and that was enough to identify chip and read fuses. Altough wires were short (about 5cm max) and soldered directly to Arduino pins. However I was not able to do dump of flash, output was:

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.19s

avrdude.exe: Device signature = 0x1e9307
avrdude.exe: reading flash memory:

Reading | avrdude.exe: stk500v2_ReceiveMessage(): timeout
avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
avrdude.exe: stk500v2_ReceiveMessage(): timeout
#avrdude.exe: stk500v2_ReceiveMessage(): timeout
(continiously)

But this doesn't matter as now with correct fuse bits I'm able to read and write flash with usual ISP.