PARTIALLY SOLVED: AVRDude writes corrupt data to ATxmega128D4 using Atmel ICE

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello, everyone!

 

I was running into an issue posting (it said "Unpublished Post"), so my question is in the comment below.

This topic has a solution.
Last Edited: Mon. Nov 20, 2017 - 09:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using Atmel ICE to program the XMEGA128D4 using PDI. The chip is on the ChipWhisperer-Lite Target Board (if it makes any difference. You can find more info here: https://wiki.newae.com/CW1173_ChipWhisperer-Lite and a schematic here: https://github.com/newaetech/chipwhisperer/blob/master/hardware/capture/chipwhisperer-lite/pcb/cw-lite-main.pdf )

 

I am connecting the pins:  8 – V_Target, 13 – PDIC, 15 – PDID, and one of the ground pins https://wiki.newae.com/CW1173_ChipWhisperer-Lite#20-Pin_Connector ) from the 20-pin connector to Atmel ICE.

 

NOTE: I am NOT using the ChipWhisperer-Lite Main Board at all. I have a 1MHz clock square wave (Pin 4) from a Signal Generator and an external Power Supply (Pin 3). Nothing else from the 20-pin connector is being used.

 

I am trying to program the chip using Atmel ICE with AVRDude. I can successfully program it using the ChipWhisperer-Lite Main Board and the ChipWhisperer software. However, when I try to run the following command:

sudo avrdude -v -B 8 -c atmelice_pdi -p x128d4 -e -U flash:w:chipwhisperer/hardware/victims/firmware/glitch-simple/glitchsimple-CW303.hex

EDIT: The output below is without the "-e" option. For the output with this option, see my next comment.

 

I get the following printout:

avrdude: Version 6.3-20160220, compiled on Jun 29 2017 at 18:29:54
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/usr/local/etc/avrdude.conf"
         User configuration file is "/home/cwuser/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : atmelice_pdi
         Setting bit clk period        : 8.0
avrdude: Found CMSIS-DAP compliant device, using EDBG protocol
         AVR Part                      : ATxmega128D4
         Chip Erase delay              : 0 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 0
         StabDelay                     : 0
         CmdexeDelay                   : 0
         SyncLoops                     : 0
         ByteDelay                     : 0
         PollIndex                     : 0
         PollValue                     : 0x00
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           prodsig        0     0     0    0 no         50   50      0     0     0 0x00 0x00
           fuse1          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse2          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse4          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse5          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0     0     0 0x00 0x00
           data           0     0     0    0 no          0    0      0     0     0 0x00 0x00
           eeprom         0     0     0    0 no       2048   32      0     0     0 0x00 0x00
           application    0     0     0    0 no     131072  512      0     0     0 0x00 0x00
           apptable       0     0     0    0 no       8192  512      0     0     0 0x00 0x00
           boot           0     0     0    0 no       8192  512      0     0     0 0x00 0x00
           flash          0     0     0    0 no     139264  512      0     0     0 0x00 0x00
           usersig        0     0     0    0 no        512  512      0     0     0 0x00 0x00

         Programmer Type : JTAGICE3_PDI
         Description     : Atmel-ICE (ARM/AVR) in PDI mode
         ICE hardware version: 0
         ICE firmware version: 1.38 (rel. 129)
         Serial number   : J41800047250
         Vtarget         : 3.40 V
         JTAG clock megaAVR/program: 200 kHz
         JTAG clock megaAVR/debug:   200 kHz
         JTAG clock Xmega: 1000 kHz
         PDI clock Xmega : 4000 kHz

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9747 (probably x128d4)
avrdude: erasing chip
avrdude: reading input file "chipwhisperer/hardware/victims/firmware/glitch-simple/glitchsimple-CW303.hex"
avrdude: input file chipwhisperer/hardware/victims/firmware/glitch-simple/glitchsimple-CW303.hex auto detected as Intel Hex
avrdude: writing flash (3150 bytes):

Writing | ################################################## | 100% 0.45s

avrdude: 3150 bytes of flash written
avrdude: verifying flash memory against chipwhisperer/hardware/victims/firmware/glitch-simple/glitchsimple-CW303.hex:
avrdude: load data flash data from input file chipwhisperer/hardware/victims/firmware/glitch-simple/glitchsimple-CW303.hex:
avrdude: input file chipwhisperer/hardware/victims/firmware/glitch-simple/glitchsimple-CW303.hex auto detected as Intel Hex
avrdude: input file chipwhisperer/hardware/victims/firmware/glitch-simple/glitchsimple-CW303.hex contains 3150 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.44s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0002
         0x08 != 0x6b
avrdude: verification error; content mismatch

avrdude done.  Thank you.

 

As you can see, it’s a verification error. If there was working code on the chip prior to running this command, it stops working. I am not sure what the chip is doing after I program it using AVRDude, but it looks like it's executing some random code that AVRDude (Atmel ICE) writes to it. It looks like the data that it is writing to the chip gets corrupted.

 

I have contacted the makers of the ChipWhisperer-Lite and they said:

 

Try slowing down the PDI clock – I see from the debug file it’s running at 4000 kHz (see line PDI clock Xmega : 4000 kHz). I’m not sure if this is specified with the “-B” option or not, but I’d try to get a clock down around 250KHz even if possible. With the shunt in the power supply things tend not to work as well at higher frequencies (+ all the extra cabling to the ChipWhisperer).

 

I have tried to set the frequency down to various levels including the one they recommended (250KHz) and even down to the lowest setting it works at (32kHz using the option “-B 31.2”) and it still gives the same error.

 

I can successfully debug the chip using Atmel ICE and AVaRICE/AVR-GDB, so the ICE definitely works as it should.

 

NOTE: I am on Ubuntu.

 

What am I missing here? How can I program the chip?

 

Thank you very much!

Last Edited: Thu. Aug 3, 2017 - 01:20 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys. Anyone have any ideas on this?

 

 

NOTE: In the original comment above, said I used the "-e"  option, but the printout was actually without "-e" . I updated the command above and it is now correct. See below about what the "-e" option outputs.

 

 

I have some new info on the issue (still no solution, though sad ).

 

 

In the attachments, there are various files:

 

The file "glitchsimple-CW303.hex" is what I am trying to download onto the chip.

 

The file "CW_program.txt" is what the ChipWhisperer software writes onto the chip. (As noted in the previous comment, this is the only way I found to successfully flash the chip.)

 

The file "AVRDude.txt" is what I get when I try to write using AVRDude (flash option). That file contains 4 AVRDude commands I ran (1-erase, 2-read, 3-write, 4-read):

  1. The AVRDude erase chip command. (It seems to crash, but the next command shows that it does erase at least part of it.)
  2. Read various memories from the chip using AVRDude. NOTE: It says the flash is empty for the application, apptable, boot, and flash memories.
  3. AVRDude command to program the chip. I also tried with the “application” and the “apptable” options and I get similar results for both (same verification error, but some of the other values are different according to the printout from AVRDude – see the both files).
  4. Command (2) again, but this time it shows the **REPEATABLE** “corrupt” data that is written to the chip. Notice that the "verification error, first mismatch at byte 0x0002" from command (3) matches the byte at that location in using this read function.

 

 

Also, NOTE: I must unplug the ICE and plug it back into the USB to make it work again after each chip erase. If I don’t, I get this error from AVRDude (it freezes at the last line, so I have to press “Ctrl+C”):

cwuser@chipwhisperer-vm:~$ sudo avrdude -v -B 8 -c atmelice_pdi -p x128d4 -U flash:w:chipwhisperer/hardware/victims/firmware/glitch-simple/glitchsimple-CW303.hex
avrdude: Version 6.3-20160220, compiled on Jun 29 2017 at 18:29:54
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/usr/local/etc/avrdude.conf"
         User configuration file is "/home/cwuser/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : atmelice_pdi
         Setting bit clk period        : 8.0
avrdude: usbhid_open(): No response from device
avrdude: usbdev_open(): Found Atmel-ICE CMSIS-DAP, serno: J41800047250
avrdude: Found CMSIS-DAP compliant device, using EDBG protocol
avrdude: jtag3_edbg_prepare(): unexpected response 0x81, 0x11
avrdude: jtag3_edbg_prepare(): unexpected response 0x80, 0x01
avrdude: jtag3_edbg_send(): Unexpected response 0x81, 0x00
^Ccwuser@chipwhisperer-vm:~$

And this from AVaRICE:

cwuser@chipwhisperer-vm:~$ sudo arice -4 -X -P atxmega128b3 -d -j usb localhost:4242
AVaRICE version 2.13svn20160229, Jun 12 2017 21:25:28

Found HID PID:VID 0x03eb:0x2141, serno J41800047250
Probing for HID max. packet size
openhid(): device not responding to DAP_Info
cwuser@chipwhisperer-vm:~$

Maybe that will give someone a clue of what is going on.

 

 

 

I have ran the AVRDude programming/reading commands a few times and the output is the same each time. It seems like this is not some noise from the circuitry, but some setting that I am missing (if it’s repeatable, it’s not noise).

 

 

I also have an STK600 and I tried using both the ChipWhisperer hardware/software (only the 4 pins used for programming were connected - described in the previous comment) and Atmel ICE to program it and I got the same issue exact issue! AVaRICE still works flawlessly on both the STK600 and the ChipWhisperer-Lite Target Board using Atmel ICE, though…

 

 

Do I need to change some settings? Do I need to prep the chip somehow? Am I using the wrong options? Am I missing some pre-flashing steps?

 

Any help/feedback/ideas are very much appreciated. Thank you!

Attachment(s): 

Last Edited: Thu. Aug 3, 2017 - 01:42 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Solved! (Well, sort of.) Using the ATmega2560 instead of ATxmega128D4 did the trick. Still no idea what the issue was, but whatever, it works with this new microcontroller!