Go Down

Topic: Add a new Atmega328 clone device (Read 1 time) previous topic - next topic

HugoPT

Happy new year folks.
I'm strugling to put a new board on boards.txt
I bought some Atmega328P on ebay and for my surprise they have a different Signature. The original one should have a device signature = 0x1e 0x95 0x0F but mine has 0x1e 0x95 0x14 so every time I want to upload a program to it I changed the avrdude.conf to the new signature. I also have a Arduino Duemilanove and when I change to this board has expected it complains about wrong signature and again i change manual the signature to the original one.
I'm tired to very time change the file, so today I try to add a new board to boards.txt
I just copy the existing entry for the original Atmega328 and edit it like this:
Code: [Select]
#atmega328.name=TempController

atmega328.upload.protocol=arduino
atmega328.upload.maximum_size=30720
atmega328.upload.speed=57600

atmega328.bootloader.low_fuses=0xFF
atmega328.bootloader.high_fuses=0xDA
atmega328.bootloader.extended_fuses=0x05
atmega328.bootloader.path=atmega
atmega328.bootloader.file=ATmegaBOOT_168_atmega328.hex
atmega328.bootloader.unlock_bits=0x3F
atmega328.bootloader.lock_bits=0x0F

atmega328.build.mcu=ATmega328
atmega328.build.f_cpu=16000000L
atmega328.build.core=arduino
atmega328.build.variant=standard


If I save and then restart arduino IDE it wont appear on the device list, but if I remove the existing it then appears then.
Also I know this will not fix my problem about the signatures because AVRdude is still using the same cpu target atmega328.build.mcu=ATmega328

Any help how can I fix this?



Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

WizenedEE

The very first string before the . is the "internal name" of the device. It has to be different for every board. So change "atmega328.<whatever>" to "<somethingelse>.<whatever>"

eg
Code: [Select]

#tempcontroller.name=TempController

tempcontroller.upload.protocol=arduino
tempcontroller.upload.maximum_size=30720
tempcontroller.upload.speed=57600

tempcontroller.bootloader.low_fuses=0xFF
tempcontroller.bootloader.high_fuses=0xDA
tempcontroller.bootloader.extended_fuses=0x05
tempcontroller.bootloader.path=atmega
tempcontroller.bootloader.file=ATmegaBOOT_168_atmega328.hex
tempcontroller.bootloader.unlock_bits=0x3F
tempcontroller.bootloader.lock_bits=0x0F

tempcontroller.build.mcu=ATmega328
tempcontroller.build.f_cpu=16000000L
tempcontroller.build.core=arduino
tempcontroller.build.variant=standard

HugoPT

#2
Jan 01, 2013, 11:57 pm Last Edit: Jan 02, 2013, 06:07 pm by HugoPT Reason: 1
OK it worked.
Now is there any way to create new devices on AVRDUDE?
Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

MarkT

What you seem to have acquired there are ATmega328, not ATmega328P - the difference is the 328P has some extra power-saving features.
Check what's printed on the package.
[ I won't respond to messages, use the forum please ]

WizenedEE


OK it worked.
Now is there any way to create new devices on AVRDUDE?


in avrdude.conf (hardware/tools/avrdude.conf) search for "atmega328p." Copy its entire entry and change the appropriate options (probably id, desc, and signature). Then make your new boards.txt entry reference the new id.

HugoPT

Thanks for your help.
I made this changes, in my boards.txt file I add:
Code: [Select]
##############################################################
tempcontroller.name=TempController

tempcontroller.upload.protocol=arduino
tempcontroller.upload.maximum_size=30720
tempcontroller.upload.speed=57600

tempcontroller.bootloader.low_fuses=0xFF
tempcontroller.bootloader.high_fuses=0xDA
tempcontroller.bootloader.extended_fuses=0x05
tempcontroller.bootloader.path=atmega
tempcontroller.bootloader.file=ATmegaBOOT_168_atmega328.hex
tempcontroller.bootloader.unlock_bits=0x3F
tempcontroller.bootloader.lock_bits=0x0F
tempcontroller.build.mcu=m328pu
tempcontroller.build.f_cpu=16000000L
tempcontroller.build.core=arduino
tempcontroller.build.variant=standard
##############################################################

And as you sugest in my avrdude.conf I add:
Code: [Select]
# ATmega328-PU
#------------------------------------------------------------

part
    id = "m328pu";
    desc = "ATMEGA328Pu";
    has_debugwire = yes;
    flash_instr = 0xB6, 0x01, 0x11;
    eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
  0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
  0x99, 0xF9, 0xBB, 0xAF;
    stk500_devcode = 0x86;
    # avr910_devcode = 0x;
    signature = 0x1e 0x95 0x14;
    pagel = 0xd7;
    bs2 = 0xc2;
    chip_erase_delay = 9000;
    pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
"x x x x x x x x x x x x x x x x";

    chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
"x x x x x x x x x x x x x x x x";

    timeout = 200;
    stabdelay = 100;
    cmdexedelay = 25;
    synchloops = 32;
    bytedelay = 0;
    pollindex = 3;
    pollvalue = 0x53;
    predelay = 1;
    postdelay = 1;
    pollmethod = 1;

    pp_controlstack =
0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
    hventerstabdelay = 100;
    progmodedelay = 0;
    latchcycles = 5;
    togglevtg = 1;
    poweroffdelay = 15;
    resetdelayms = 1;
    resetdelayus = 0;
    hvleavestabdelay = 15;
    resetdelay = 15;
    chiperasepulsewidth = 0;
    chiperasepolltimeout = 10;
    programfusepulsewidth = 0;
    programfusepolltimeout = 5;
    programlockpulsewidth = 0;
    programlockpolltimeout = 5;

    memory "eeprom"
paged = no;
page_size = 4;
size = 1024;
min_write_delay = 3600;
max_write_delay = 3600;
readback_p1 = 0xff;
readback_p2 = 0xff;
read = " 1 0 1 0 0 0 0 0",
       " 0 0 0 x x x a9 a8",
       " a7 a6 a5 a4 a3 a2 a1 a0",
       " o o o o o o o o";

write = " 1 1 0 0 0 0 0 0",
      " 0 0 0 x x x a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";

loadpage_lo = " 1 1 0 0 0 0 0 1",
      " 0 0 0 0 0 0 0 0",
      " 0 0 0 0 0 0 a1 a0",
      " i i i i i i i i";

writepage = " 1 1 0 0 0 0 1 0",
    " 0 0 x x x x a9 a8",
    " a7 a6 a5 a4 a3 a2 0 0",
    " x x x x x x x x";

mode = 0x41;
delay = 20;
blocksize = 4;
readsize = 256;
    ;

    memory "flash"
paged = yes;
size = 32768;
page_size = 128;
num_pages = 256;
min_write_delay = 4500;
max_write_delay = 4500;
readback_p1 = 0xff;
readback_p2 = 0xff;
read_lo = " 0 0 1 0 0 0 0 0",
  " 0 0 a13 a12 a11 a10 a9 a8",
  " a7 a6 a5 a4 a3 a2 a1 a0",
  " o o o o o o o o";

read_hi = " 0 0 1 0 1 0 0 0",
  " 0 0 a13 a12 a11 a10 a9 a8",
  " a7 a6 a5 a4 a3 a2 a1 a0",
  " o o o o o o o o";

loadpage_lo = " 0 1 0 0 0 0 0 0",
      " 0 0 0 x x x x x",
      " x x a5 a4 a3 a2 a1 a0",
      " i i i i i i i i";

loadpage_hi = " 0 1 0 0 1 0 0 0",
      " 0 0 0 x x x x x",
      " x x a5 a4 a3 a2 a1 a0",
      " i i i i i i i i";

writepage = " 0 1 0 0 1 1 0 0",
    " 0 0 a13 a12 a11 a10 a9 a8",
    " a7 a6 x x x x x x",
    " x x x x x x x x";

mode = 0x41;
delay = 6;
blocksize = 128;
readsize = 256;

    ;

    memory "lfuse"
size = 1;
min_write_delay = 4500;
max_write_delay = 4500;
read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
       "x x x x x x x x o o o o o o o o";

write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
      "x x x x x x x x i i i i i i i i";
    ;

    memory "hfuse"
size = 1;
min_write_delay = 4500;
max_write_delay = 4500;
read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
       "x x x x x x x x o o o o o o o o";

write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
      "x x x x x x x x i i i i i i i i";
    ;

    memory "efuse"
size = 1;
min_write_delay = 4500;
max_write_delay = 4500;
read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
       "x x x x x x x x x x x x x o o o";

write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
      "x x x x x x x x x x x x x i i i";
    ;

    memory "lock"
size = 1;
min_write_delay = 4500;
max_write_delay = 4500;
read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
       "x x x x x x x x x x o o o o o o";

write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
      "x x x x x x x x 1 1 i i i i i i";
    ;

    memory "calibration"
size = 1;
read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
       "0 0 0 0 0 0 0 0 o o o o o o o o";
    ;

    memory "signature"
size = 3;
read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
       "x x x x x x a1 a0 o o o o o o o o";
    ;
;


When I try to compile I get this error:
avr-g++: error: unrecognized argument in option '-mmcu=m328pu'

There must be in some part where the arduino IDE must match with a expected cpu type.
If I use the console to see if the avrdude is talking with cpu using the new settings it works as expected, so the problem remains somewhere in arduino core.
Quote
$ sudo /usr/bin/avrdude -c usbtiny -p m328pu

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9514

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

dc42

#6
Jan 04, 2013, 11:37 pm Last Edit: Jan 05, 2013, 12:05 am by dc42 Reason: 1
Last time I saw someone have this problem, he resolved the problem by pretending the device was an atmega328p and editing the device signature in the atmega328p entry in avrdude.conf. Not ideal, but it worked for him. We never did get to the bottom of why adding a new entry to avrdude.conf didn't work.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

HugoPT

Quote
pretending the device was an atmega328p and editing the device signature in the atmega328p entry in avrdude.conf

Well that's what I had done until now, that's because I'm looking for the answer since when I get the duemilanove attached I must go to the avrdude and change the signature again and again.Boring  ]:)
I understand the compiler, the new entry for it is new, it must know how many pins, register and so on about this new device apart of being the same as the atmega328p his name must be diferent because of the signature differences.
I will still look for my answer :smiley-mr-green:
Thanks anyway
Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

dc42

It might be worth searching for avrdude.conf on your computer, in case there is more than one.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

HugoPT

#9
Jan 05, 2013, 12:23 am Last Edit: Jan 05, 2013, 12:27 am by HugoPT Reason: 1
I activate the debug option on arduino IDE and I found the problem is on avr gcc
Avr-gcc have an internal list of devices:
Code: [Select]

Known MCU names:
 avr1 avr2 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 avrxmega1
 avrxmega2 avrxmega3 avrxmega4 avrxmega5 avrxmega6 avrxmega7 at90s1200
 attiny11 attiny12 attiny15 attiny28 at90s2313 at90s2323 at90s2333
 at90s2343 attiny22 attiny26 at90s4414 at90s4433 at90s4434 at90s8515
 at90c8534 at90s8535 attiny13 attiny13a attiny2313 attiny2313a attiny24
 attiny24a attiny4313 attiny44 attiny44a attiny84 attiny84a attiny25
 attiny45 attiny85 attiny261 attiny261a attiny461 attiny461a attiny861
 attiny861a attiny87 attiny43u attiny48 attiny88 at86rf401 ata6289
 at43usb355 at76c711 atmega103 at43usb320 attiny167 at90usb82 at90usb162
 atmega8u2 atmega16u2 atmega32u2 atmega8 atmega48 atmega48a atmega48p
 atmega88 atmega88a atmega88p atmega88pa atmega8515 atmega8535 atmega8hva
 at90pwm1 at90pwm2 at90pwm2b at90pwm3 at90pwm3b at90pwm81 atmega16
 atmega16a atmega161 atmega162 atmega163 atmega164a atmega164p atmega165
 atmega165a atmega165p atmega168 atmega168a atmega168p atmega169
 atmega169a atmega169p atmega169pa atmega32 atmega323 atmega324a
 atmega324p atmega324pa atmega325 atmega325a atmega325p atmega325pa
 atmega3250 atmega3250a atmega3250p atmega3250pa atmega328 atmega328p
 atmega329 atmega329a atmega329p atmega329pa atmega3290 atmega3290a
 atmega3290p atmega3290pa atmega406 atmega64 atmega640 atmega644
 atmega644a atmega644p atmega644pa atmega645 atmega645a atmega645p
 atmega649 atmega649a atmega649p atmega6450 atmega6450a atmega6450p
 atmega6490 atmega6490a atmega6490p atmega16hva atmega16hva2 atmega16hvb
 atmega16hvbrevb atmega32hvb atmega32hvbrevb atmega64hve at90can32
 at90can64 at90pwm161 at90pwm216 at90pwm316 atmega32c1 atmega64c1
 atmega16m1 atmega32m1 atmega64m1 atmega16u4 atmega32u4 atmega32u6
 at90usb646 at90usb647 at90scr100 at94k m3000 atmega128 atmega1280
 atmega1281 atmega1284p atmega128rfa1 at90can128 at90usb1286 at90usb1287
 atmega2560 atmega2561 atxmega16a4 atxmega16d4 atxmega16x1 atxmega32a4
 atxmega32d4 atxmega32x1 atxmega64a3 atxmega64d3 atxmega64a1 atxmega64a1u
 atxmega128a3 atxmega128b1 atxmega128d3 atxmega192a3 atxmega192d3
 atxmega256a3 atxmega256a3b atxmega256a3bu atxmega256d3 atxmega128a1
 atxmega128a1u


Now I have no clue how can I add a new device but I notice that there is a device called atmega328
I used that (I still don't know the diferences) atmega328 on my boards.txt and in avrdude.conf and now it compiles ok.
Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

HugoPT

Also found this
Quote
gregsmithcts - Oct 18, 2011 - 08:21 PM
Post subject: RE: Difference between ATmega328, 328P and 328PU I think you'll find the differences are just in the silicon and affect the power consumption. In terms for functionality and pin compatibility (and programming) there is no difference.


So my problem is solved.In duemilanove I use the atmega328P and in my custom board I use atmega328  XD
Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

retrolefty

Didn't user westfw come up with a bootloader 'fix' for this problem where it would report back to AVRDUDE the signature of a 328p chip even though it was installed into a 328 non p chip. Simply lying to AVRDUDE seemed to be the simplest method. I guess the trick is how to get such a 'modified' bootloader installed into a 328 non p chip in the first place, chick and egg problem? Anyway maybe contacting westfw would give you a direct path to success as I'm pretty sure he dealt with this issue in the past.

Lefty

Go Up