Hi all,
I have custom built board on ATMega328AU that I am trying to upload bootloader with AVRISPmkII. It powered with 3v3 and has 8Mhz external crystal. It is similar to the "Arduino Fio" board except it uses ATMega328AU instead of ATMega328P that I believe differs only in pico-power and signature. I went ahead and created record in avrdude.conf for "atmega328au" by copying completely ATmega328P section and changing signature "0x1e 0x95 0x0F" => "0x1e 0x95 0x14" and id to "atmega328au".
Steps:
- Verified with avrdude that default fuses per datasheet are set. efuse = 7; hfuse = D9; lfuse = 62;
- Set unlock bits and wrote efuse.
avrdude -v -v -v -v -patmega328au -cavrispmkII -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m
........
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK
avrdude: Sent: . [11] . [01] . [01]
avrdude: Recv: . [11] . [00]
avrdude done. Thank you.
- Played with device by uploading various sketches directly with programmer. Everything worked just fine. Except the fact that timing was wrong (attributed to CKDIV8 fuse that divided internal RC Oscillator @ 8MHz by 8).
- Decided to update all the fuses to bring them to the "Arduino FIO" state: efuse=0x05; hfuse=0xDA; lfuse=0xFF.
avrdude -v -v -v -v -patmega328au -cstk500v2 -Pusb -t -U efuse:w:0x05:m -U hfuse:w:0xDA:m -U lfuse:w:0xFF:m
………
avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
……..
avrdude: 1 bytes of efuse verified
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDA:
………..
avrdude: 1 bytes of hfuse verified
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
……………
avrdude: 1 bytes of lfuse verified
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [00] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] P [50] . [00] ? [ff] . [00]
avrdude: safemode read 1, lfuse value: ff
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [00] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] P [50] . [00] ? [ff] . [00]
avrdude: safemode read 2, lfuse value: ff
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [00] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] P [50] . [00] ? [ff] . [00]
avrdude: safemode read 3, lfuse value: ff
avrdude: safemode: lfuse reads as FF
avrdude: Sent: . [1d] . [04] . [04] . [00] X [58] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] X [58] . [08] ? [ff] . [00]
avrdude: safemode read 1, hfuse value: ff
avrdude: Sent: . [1d] . [04] . [04] . [00] X [58] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] X [58] . [08] ? [ff] . [00]
avrdude: safemode read 2, hfuse value: ff
avrdude: Sent: . [1d] . [04] . [04] . [00] X [58] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] X [58] . [08] ? [da] . [00]
avrdude: safemode read 3, hfuse value: da
avrdude: safemode: Verify error - unable to read hfuse properly. Programmer may not be reliable.
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [00] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] P [50] . [00] ? [ff] . [00]
avrdude: safemode read 1, lfuse value: ff
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [00] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] P [50] . [00] ? [ff] . [00]
avrdude: safemode read 2, lfuse value: ff
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [00] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] P [50] . [00] ? [ff] . [00]
avrdude: safemode read 3, lfuse value: ff
avrdude: safemode: lfuse reads as FF
avrdude: Sent: . [1d] . [04] . [04] . [00] X [58] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] X [58] . [08] ? [da] . [00]
avrdude: safemode read 1, hfuse value: da
avrdude: Sent: . [1d] . [04] . [04] . [00] X [58] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] X [58] . [08] ? [da] . [00]
avrdude: safemode read 2, hfuse value: da
avrdude: Sent: . [1d] . [04] . [04] . [00] X [58] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] X [58] . [08] ? [da] . [00]
avrdude: safemode read 3, hfuse value: da
avrdude: safemode: hfuse reads as DA
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] P [50] . [08] ? [fd] . [00]
avrdude: safemode read 1, efuse value: 5
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] P [50] . [08] ? [fd] . [00]
avrdude: safemode read 2, efuse value: 5
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] P [50] . [08] ? [fd] . [00]
avrdude: safemode read 3, efuse value: 5
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK
avrdude: Sent: . [11] . [01] . [01]
avrdude: Recv: . [11] . [00]
avrdude done. Thank you.
Command executed successfully. However this output makes me suspicious.
avrdude: safemode read 1, hfuse value: ff
avrdude: Sent: . [1d] . [04] . [04] . [00] X [58] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] X [58] . [08] ? [ff] . [00]
avrdude: safemode read 2, hfuse value: ff
avrdude: Sent: . [1d] . [04] . [04] . [00] X [58] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] X [58] . [08] ? [da] . [00]
avrdude: safemode read 3, hfuse value: da
avrdude: safemode: Verify error - unable to read hfuse properly. Programmer may not be reliable.
- However, when I run avrdude again it bombs
avrdude: Sent: . [10] . [c8] d [64] . [19] [20] . [00] S [53] . [03] . [ac] S [53] . [00] . [00]
avrdude: Recv: . [10] . [c0]
avrdude: stk500v2_command(): command failed
avrdude: Sent: . [03] . [a1]
avrdude: Recv: . [03] . [00] . [00]
avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Unknown status 0x00
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATMEGA328AU is 1E 95 14
I am able to read fuses and lock bits only in terminal mode with -F flag. Fuses suddenly became :
efuse=0x05; hfuse=0xFF; lfuse=0xFF and disabled SPIEN fuse bit. Write operations on fuses and lock bits fail now.
avrdude -v -v -v -v -patmega328au -cavrispmkII -Pusb -tF
..........
>>> d lock
avrdude: Sent: . [1d] . [04] . [04] . [00] X [58] . [00] . [00] . [00]
avrdude: Recv: . [1d] . [00] ? [ff] ? [ff] ? [ff] ? [ff] . [00]
0000 3f |? |
avrdude> d efuse
>>> d efuse
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] ? [ff] ? [ff] ? [ff] ? [ff] . [00]
0000 07 |. |
avrdude> d hfuse
>>> d hfuse
avrdude: Sent: . [1d] . [04] . [04] . [00] X [58] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] ? [ff] ? [ff] ? [ff] ? [ff] . [00]
0000 ff |. |
avrdude> d lfuse
>>> d lfuse
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [00] . [00] . [00]
avrdude: Recv: . [1d] . [00] ? [ff] ? [ff] ? [ff] ? [ff] . [00]
0000 ff
avrdude> w lfuse 0 0x62
>>> w lfuse 0 0x62
......
avrdude (write): error writing 0x62 at 0x00000, rc=-6
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [00] . [00] . [00]
avrdude: Recv: . [1d] . [00] ? [ff] ? [ff] ? [ff] ? [ff] . [00]
avrdude (write): error writing 0x62 at 0x00000 cell=0xff
Is there anything obvious that I am doing wrong? I already locked several microprocessors this way.
Any suggestions and recommendations are helpful.
Regards, Denys