AVRDUDE Support For Non-PicoPower ATMega328 MCU

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

TL;DR: If your're having problems with AVRDUDE not supporting the ATMega328 (non-"picoPower" variant of the ATMega328P), get the latest version from the SVN repository and build it.

In just over a month, I've seen 3 threads here all seeming to have at least something to do with issues related to trying to program the non-"picoPower" ATMega328 MCUs using AVRDUDE:

When I first encountered this myself back in early Dec 2011, the latest version of AVRDUDE (5.11.1) supported the ATMega328P ("picoPower" variant, with signature 0x1e950f) but not the non-P variant (with signature 0x1e9514). It seems that more people (like myself) are starting to encounter this non-P chip.

Back then, I did an Internet search and found that most people were doing one of 2 things:

  • using the '-p m328p -F' options on AVRDUDE to force it to treat their ATMega328 like an ATMega328P and ignore the resultant signature error (with the inherent danger therein)
  • hacking their 'avrdude.conf' file to simply copy the "ATmega328P" section and editing the 3 lines required to make it into an ATMega328 (non-P) section
Myself, after thoroughly reviewing the datasheets for the non-P/P variants to be sure there were no negative implications, I simply used the '-F' option since that was effectively equivalent to the more involved 2nd option.

As I stated in one of those 3 threads referred to above, if I knew for certain that those 3 simple changes were the only changes (in that voluminous 'avrdude.conf' entry) needed to support the non-P ATMega328, I'd have submitted a patch to the AVRDUDE project back then.

Well, tonight I was determined to ask about this issue on the AVRDUDE mailing list. But I first thought to check the SVN repository and ...eureka!... found that less than a month after I first encountered and worked around the issue, support for the non-P ATMega328 was added in the repository! Just my luck! :D Here's the slightly condensed/edited entry from the 'ChangeLog-2011' file:

2011-12-29 Rene Liebscher 

	bug #34302: Feature request : device configuration with parent classes
	* config_gram.y: Added part parent rule and allow overwriting existing
	data at several places
	* avrdude.conf.in: Added description comment and m328/m328p as example

You can grab the latest AVRDUDE code from the SVN repository with a command like this:

svn co svn://svn.savannah.nongnu.org/avrdude/trunk

Simple build instructions are provided in the 'BUILD-FROM-SVN' file. Being a GNU/Linux-only guy for AVR stuff, I don't know how the Windows (and Mac?) users of AVRDUDE build their hot-off-the-presses SVN repository code (maybe MinGW?), but maybe one of the advanced AVR/Windows users can chime in here with suggestions and/or comments.

Here's what the new 'avrdude.conf' will look like if you build AVRDUDE from the SVN sources:

#------------------------------------------------------------
# ATmega328
#------------------------------------------------------------

part
    id			= "m328";
    desc		= "ATmega328";
    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;

       .
       .
       .

    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";
    ;
;

part parent "m328"
    id			= "m328p";
    desc		= "ATmega328P";
    signature		= 0x1e 0x95 0x0F;
;

A big chunk was intentionally omitted in the middle but note how the ATMega328P is now defined as a "child" of the "parent" ATMega328. Very nice and very clean!

My thanks to Rene Liebscher for the patch and to Jörg Wunsch and all the other great folks who provide and support AVRDUDE -- a great app indeed! My hat is off to you all!

I guess my caution about copying the "m328p" section and just changing the obvious lines was unfounded, but I'm a cautious guy by nature. :)

Anyway, I just wanted to report this here so that anyone encountering this issue will know about it, even if they're too inexperienced to actually build from SVN. Hopefully they'll find this post if they're searching or someone can point them to this if they aren't.

Good luck to all you ATMega328 users! Hope this information proves helpful....

Regards,
Bill

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I don't know how the Windows (and Mac?) users of AVRDUDE build their hot-off-the-presses SVN repository code (maybe MinGW?), but maybe one of the advanced AVR/Windows users can chime in here with suggestions and/or comments.

But this is exactly the problem - the majority of people wanting avrdude want the .exe for Windows (90% of all PC users are using Windows apparently). Yet no one (with the possible exception of Eric and Joerg) know how to build a .exe version from the source. So if anyone ever does PLEASE make the .exe available somewhere for download.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The parent-child syntax is an excellent idea. Especially since we have ATmega168, ATmega168A, ATmega168P, ATmega168PA variants. Admittedly some share the same Signature i.e P and non-P

And you can guarantee that Studio5 or Toolchain will bu*ger something up in the process.

For example, my AS5 Toolchain does not even have a ATtiny4313 entry. The tiny4313 has been available for a lot longer than the NEW mega328.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is avrdude from January 22th 2012, you can test it, I included the changelog since 2011.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you! I've been trying to get this to work for hours.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are responding to a 7 year old post and using a version that is 7.5 years old. You sure you want to do that??

 

These days avrdude is into v6

 

Often the quickest/easiest way to get a fairly up to date avrdude.exe is to install Arduino then pick it out of that. For example:

D:\arduino-1.8.8\hardware\tools\avr\bin>avrdude.exe
Usage: avrdude.exe [options]
Options:
  -p <partno>                Required. Specify AVR device.
  -b <baudrate>              Override RS-232 baud rate.
  -B <bitclock>              Specify JTAG/STK500v2 bit clock period (us).
  -C <config-file>           Specify location of configuration file.
  -c <programmer>            Specify programmer type.
  -D                         Disable auto erase for flash memory
  -i <delay>                 ISP Clock Delay [in microseconds]
  -P <port>                  Specify connection port.
  -F                         Override invalid signature check.
  -e                         Perform a chip erase.
  -O                         Perform RC oscillator calibration (see AVR053).
  -U <memtype>:r|w|v:<filename>[:format]
                             Memory operation specification.
                             Multiple -U options are allowed, each request
                             is performed in the order specified.
  -n                         Do not write anything to the device.
  -V                         Do not verify.
  -u                         Disable safemode, default when running from a script.
  -s                         Silent safemode operation, will not ask you if
                             fuses should be changed back.
  -t                         Enter terminal mode.
  -E <exitspec>[,<exitspec>] List programmer exit specifications.
  -x <extended_param>        Pass <extended_param> to programmer.
  -y                         Count # erase cycles in EEPROM.
  -Y <number>                Initialize erase cycle # in EEPROM.
  -v                         Verbose output. -v -v for more.
  -q                         Quell progress output. -q -q for less.
  -l logfile                 Use logfile rather than stderr for diagnostics.
  -?                         Display this usage.

avrdude version 6.3-20171130, URL: <http://savannah.nongnu.org/projects/avrdude/>