Hi!
I have a few Xplained boards with onboard mEDBG chips (ATmega32u4). I recently found out that these mEDBG chips are completely open in terms of the lock bits, and dumping the flash and EEPROM was as easy as connecting an Atmel ICE and dumping everything through Atmel Studio. The reason why I'm doing this is that I want a standalone programmer for programming UPDI compatible devices.
I started comparing the simplest mEDBG based board I have, the ATtiny817 Xplained mini. I dumped the flash and EEPROM content and loaded it into my Olimex 32u4 board. After setting the correct fuses the Olimex board did show up as an available programmer in Atmel Studio. So far so good!
To test the Olimex programmer I just "made" I disconnected the onboard mEDBG chip on the Xplained 817 board by removing a 0R resistor, and I connected pin PE6 on the Olimex board to the target (ATtiny817). Using Atmel Studio I was able to read the device signature, read and write to flash and EEPROM and set fuses. However, the target voltage seems to be stuck at 3.3V even though the target is powered at 5V. The onboard mEDBG did report 5V before I removed the 0R resistor.
First question: How does the mEDBG chip reads the target voltage? And why does my standalone programmer reads 3.3V even if I tie every free pin to 5V?
It's time to test the standalone board with Avrdude. As I start I'm just trying to read the device signature of the Attiny817 with Avrdude using the Olimex board:
avrdude -C/path/to/avrdude.conf -v -pattiny817 -cxplainedmini_updi -Pusb
Avrdude detects the programmer and returns 3.3V as the target voltage (even though is 5V), but I always get this exact error when I run the command for the first time:
avrdude: Short read, read only 0 out of 64 bytes avrdude: jtag3_edbg_recv(): Unexpected response 0x12 avrdude: retrying with external reset applied avrdude: jtag3_edbg_send(): Unexpected response 0x81, 0x11 avrdude: jtag3_edbg_recv(): Unexpected response 0x80 avrdude: retrying with external reset applied avrdude: JTAGEN fuse disabled? avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check. avrdude: jtag3_edbg_send(): Unexpected response 0x81, 0x11 avrdude: jtag3_edbg_recv(): Unexpected response 0x80 avrdude: jtag3_edbg_send(): Unexpected response 0x81, 0x11 avrdude: jtag3_edbg_recv(): Unexpected response 0x80 avrdude: jtag3_edbg_signoff(): unexpected response 0x81, 0x11 avrdude: jtag3_edbg_signoff(): unexpected response 0x01, 0x00 avrdude done. Thank you.
If I run the exact same command again Avrdude still detects the programmer, but I now get this error. I'll need to unplug the programmer and re-insert it in order to get the previous error.
avrdude: jtag3_edbg_recv(): Inconsistent fragment number; expect 1, got 0 avrdude done. Thank you.
It seems like Avrdude struggles with the mEDBG chip. However, if I add the 0R resistor to the Xplained 817 board again and uses the onboard mEDBG chip (the one I dumped the firmware from) to communicate with the ATtiny817 it works like a charm! I really don't understand this.
How can my custom programmer work with Atmel Studio but not with Avrdude?
I've attached the dumped hex and eep file from my (working) Xplained 817 mEDBG chip for reference