Tuesday, July 30, 2013

adding a new device to avrdude

So I made a little breakout for the new Atmel AtXmega E5 series. More specifically I'm testing it with the atxmega16e5.

This is a new chip that is not yet supported by the latest avrdude.

Making it work turned out to be reasonably straightforward.

First let's open avrdude.conf, the config file of avrdude.
Let's find a section of a chip that is reasonably similar, I've selected the atxmega16d4:

#------------------------------------------------------------
# ATxmega16D4
#------------------------------------------------------------

part parent ".xmegasmall"
    id  = "x16d4";
    desc = "ATxmega16D4";
    signature = 0x1e 0x94 0x42;
    has_jtag = no;

    memory "eeprom"
        size  = 0x0400;
        offset  = 0x08c0000;
        page_size = 0x20;
        readsize = 0x100;
    ;

    memory "application"
        size  = 0x00004000;
        offset  = 0x0800000;
        page_size = 0x100;
        readsize = 0x100;
    ;

    memory "apptable"
        size  = 0x00001000;
        offset  = 0x00803000;
        page_size = 0x100;
        readsize = 0x100;
    ;

    memory "boot"
        size  = 0x00001000;
        offset  = 0x00804000;
        page_size = 0x100;
        readsize = 0x100;
    ;

    memory "flash"
        size  = 0x00005000;
        offset  = 0x0800000;
        page_size = 0x100;
        readsize = 0x100;
    ;
;

copy this to a new section and change the id to x16e5 and the desc to ATxmega16E5.
Find the signature like by hooking up the PDI to your x16e5 board and doing:

avrdude -P usb -c avrispmkII -p x16d4

It will now say that it is the wrong signature and will print you the signature it actually found:

 0x1e 0x94 0x45

Use that in the config section.

Now find the XML files distributed as part of Atmel AVR Studio that contain the device descriptions of the two devices: ATxmega16D4.xml and ATxmega16E5.xml

Now look at the differences and make the necc. changes. The only changes I made are the eeprom size,  the page_size and readsize settings. The x16e5 uses 128 byte pages and the x16d4 256 byte pages.

This gives as a result:


#------------------------------------------------------------
# ATxmega16E5
#------------------------------------------------------------

part parent ".xmegasmall"
    id  = "x16e5";
    desc = "ATxmega16E5";
    signature = 0x1e 0x94 0x45;
    has_jtag = no;

    memory "eeprom"
        size  = 0x0200; # J
        offset  = 0x08c0000;
        page_size = 0x20;
        readsize = 0x80; # J was 0x100
    ;

    memory "application"
        size  = 0x00004000;
        offset  = 0x0800000;
        page_size = 0x80;
        readsize = 0x80;
    ;

    memory "apptable"
        size  = 0x00001000;
        offset  = 0x00803000;
        page_size = 0x80;
        readsize = 0x80;
    ;

    memory "boot"
        size  = 0x00001000;
        offset  = 0x00804000;
        page_size = 0x80;
        readsize = 0x80;
    ;

    memory "flash"
        size  = 0x00005000;
        offset  = 0x0800000;
        page_size = 0x80;
        readsize = 0x80;
    ;
;

This seems to work fine for programming. I'm pretty sure some things are still missing concerning fuses and such though.

In order to get code compiled with gcc I use another atxmega target as chip as the x16e5 is not yet part of
the avr-gcc I'm using either.

./avrdude -C ./avrdude.conf -e -P usb -c avrispmkII -p x16e5 -U flash:w:blink.hex

And it blinks :)

No comments: