atmega328 vs atmega328p

686 views
Skip to first unread message

Rich Obermeyer

unread,
Jan 13, 2014, 2:12:10 PM1/13/14
to devel...@arduino.cc, Randy Schafer
I have an arLCD display which has an Atmega328 vs Atmega328p and I can not get it to compile.
It doesn't help that most of the boards in the boards.txt file have names thats say they have 328 but really they are 328p.
"atmega328.name=Arduino Duemilanove w/ ATmega328"

I added the arLCD to the boards.txt file but it does not compile correctly without changing the signature in the avrdude.conf file and say its a 328p.
##############################################################

arLCD.name=arLCD
arLCD.upload.protocol=arduino
arLCD.upload.maximum_size=32768
arLCD.upload.speed=115200
arLCD.bootloader.low_fuses=0xfe
arLCD.bootloader.high_fuses=0xde
arLCD.bootloader.extended_fuses=0x05
arLCD.bootloader.unlock_bits=0x3F
arLCD.bootloader.lock_bits=0x3F
arLCD.build.mcu=atmega328
arLCD.build.f_cpu=16000000L
arLCD.build.core=arduino
arLCD.build.variant=standard

unknown MCU 'atmega328' specified
Known MCU names:
   avr2
   at90s2313
.......
   attiny28
sketch_jan13a.cpp:1: error: MCU 'atmega328' supported for assembler only

Searching around with Google has most solutions lying about the signature in the avrdude.conf file.
Unfortunately the user would have to modify the avrdude.conf file every time they want to use a different board.
I loaded 1.0.5 and 1.5.5 and they both have same issue.

I even saw a solution that looked right but still does not compile.
part parent "m328p"
    id = "m328";
    desc = "ATmega328";
    signature = 0x1e 0x95 0x14;

;

However the date in the two releases Arduino ships are before the 328 was included.
Using the latest version from
Does not work.

1) My question then is why are the Arduino releases not using the latest Avrdude?
2) Why does the latest Avrdude not work (may answer question above!)?
3) How does the Arduino suppose to support 328 and 328p at same time without modifying the avrdude.conf each time?
 

Michael Shiloh

unread,
Jan 14, 2014, 8:16:33 PM1/14/14
to devel...@arduino.cc
Do all arLCDs have an Atmega328? I programmed mine with no difficulty.
How did I miss this problem?

Michael
> http://download.savannah.gnu.org/releas ... ingw32.zip<http://download.savannah.gnu.org/releases/avrdude/avrdude-6.1-svn-20131205-mingw32.zip>
> Does not work.
>
> 1) My question then is why are the Arduino releases not using the latest
> Avrdude?
> 2) Why does the latest Avrdude not work (may answer question above!)?
> 3) How does the Arduino suppose to support 328 and 328p at same time
> without modifying the avrdude.conf each time?
>
>

--
Michael Shiloh
teachmetomake.com/wordpress
KA6RCQ

Arduino Education at Arduino.cc
Electronics, Robotics, Digital Fabrication, and Arduino educator
California College of the Arts
San Francisco Art Institute
San Francisco State University

Rich Obermeyer

unread,
Jan 15, 2014, 1:30:12 AM1/15/14
to Michael Shiloh, devel...@arduino.cc
Hi Michael,
All arLCDs are the same.
I found out only lately, we program the 328 bootloader by hacking the avrdude.conf file.  We changed the signature of the 328p to match the 328.
The bootloader itself never reads the ID again.
Apparently the GCC compiler does not support the 328!  So I am told by customer.
I noticed in the Arduino boards.txt file they erroneously call all the 328p boards 328 instead.
You can check and see I am right.
That probably led to us using the 328 vs 328p to start with.

I recently have changed the upload routine of the firmware to SPI based and removed the bootloader.  The serial is no longer used for upload.  Bootloader is gone.  
The user gets 512 bytes more code space.  
The sketch starts up instantly instead of waiting in the bootloader for a few seconds.  
The customer can't blow away the bootloader since there is none. 
We don't have to load the bootloader in production.
SPI programming is way faster than any serial upload.
The SPI does not conflict with using the serial IO the display is using.

Do a search for 328 vs 328p and you will see a ton of people have noticed the problem with Arduino and 328Non-P
Nobody has shown a solution but hacking the conf file.

Any ideas?




--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.



--
Rich

Pierce Nichols

unread,
Jan 15, 2014, 4:44:23 PM1/15/14
to Rich Obermeyer, Michael Shiloh, Arduino Developers
Ob pedant: This is *NOT* a problem with avr-gcc; this is a problem with avrdude.

You have two reasonable options. One, use the '-F' (force) option when
invoking avrdude. Second, replace your avrdude with the current
version. Avrdude has correctly supported the 328 non-P chip for at
least two years (see
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=922850).

Anyone know off the top of their head what version of AVRDude Arduino
1.0.x is currently shipping with?

-p
>> email to developers+...@arduino.cc.
>
>
>
>
> --
> Rich
>
> --
> You received this message because you are subscribed to the Google Groups
> "Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to developers+...@arduino.cc.



--
Pierce Nichols
Principal Engineer
Logos Electromechanical, LLC

Rich Obermeyer

unread,
Jan 15, 2014, 5:15:09 PM1/15/14
to Pierce Nichols, Michael Shiloh, Arduino Developers
Hi Pierce,
I did see the post on avrfreaks previously as well as a dozen other misguided attempts to work around the problem.  With all respect, they were no help.  It was all speculation on what might work on a good day.  I tried to do what they suggested and I get the compiler error 328 not supported.  I also tried to use the latest avrdude.exe and/or avrdude.conf file.  All combinations gave me a similar error or just did not work at all.

The only thing that I got to work and was suggested many places was lie about the 328 ID by hacking the avrdude.conf 328P entry.

Majority of the customers I supply product too would not be confident hacking the avrdude.conf even if we suggested it to them.  They have suggested that this restricts them from using real 328P products without undoing the hack.

In my opinion Arduino is successful because no hacking is needed for the end customer. The experts do the hacking and provide a package of modules and documentation so the end user can conveniently use what makes sense to them.
Suggesting "get the latest version from the SVN repository and build it." is a typical answer that is used but simply not something most Arduino customers are capable of.

The version of the avrdude that supposedly works with was build December 2012.
The latest arduino 1.0.5-r2 is supplying 9/2/2011 as you can see below.
Inline image 1
As many complaints that have been made about lack of support for 328, I am very surprised this did not get fixed 2 years ago.  Whats the real fix?

Regards,
Rich
--
Rich
image.png

Scott Howard

unread,
Jan 15, 2014, 5:28:25 PM1/15/14
to Pierce Nichols, Rich Obermeyer, Michael Shiloh, Arduino Developers
On Wed, Jan 15, 2014 at 4:44 PM, Pierce Nichols
<pie...@logos-electro.com> wrote:
> Ob pedant: This is *NOT* a problem with avr-gcc; this is a problem with avrdude.
>
> You have two reasonable options. One, use the '-F' (force) option when
> invoking avrdude. Second, replace your avrdude with the current
> version. Avrdude has correctly supported the 328 non-P chip for at
> least two years (see
> http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=922850).
>
> Anyone know off the top of their head what version of AVRDude Arduino
> 1.0.x is currently shipping with?

a patched version avrdude 5.11 (I believe the patch was for autoreset,
which was implemented by vanilla avrdude post 5.11)

> As many complaints that have been made about lack of support for 328, I am very surprised this did not get fixed 2 years ago. Whats the real fix?

have arduino ship avrdude > 6, which was just released in September. I
think arduino team has been focusing on 1.5.x - but that too is using
avrdue 5.11.

Victor Aprea

unread,
Jan 15, 2014, 5:31:47 PM1/15/14
to Rich Obermeyer, Arduino Developers, Pierce Nichols, Michael Shiloh

Rich, the 328 is AFAIK binary compatible with the 328p.

Vic

image.png

Rich Obermeyer

unread,
Jan 15, 2014, 5:38:43 PM1/15/14
to Victor Aprea, Arduino Developers, Pierce Nichols, Michael Shiloh
Hi Vic,
I understand its the same (almost)  The point is Arduino IDE as shipped does not work with 328.  My customers expect to download the latest Arduino IDE and have it work without hacking or tweaking.

Rich
--
Rich
image.png

Victor Aprea

unread,
Jan 15, 2014, 5:43:31 PM1/15/14
to Rich Obermeyer, Pierce Nichols, Arduino Developers, Michael Shiloh

To be clear, the only thing that doesn't work out of the box is the Burn Bootloader functionaloty right?

Vic

image.png

Rich Obermeyer

unread,
Jan 15, 2014, 5:50:39 PM1/15/14
to Victor Aprea, Pierce Nichols, Arduino Developers, Michael Shiloh
In my application I do not have a bootloader.  I have a graphics GPU that programs the part.
So the Burnloader option is not used.
The bootloader itself I guess does not ask for the ID after its loaded.

I use the SPI to program the sketch so the serial is not effected and it always checks the ID check.
I use Upload using programmer and it fails every time with 328.  With 328p it works great.
--
Rich
image.png

William "Chops" Westfield

unread,
Jan 16, 2014, 1:09:32 AM1/16/14
to Rich Obermeyer, Victor Aprea, Pierce Nichols, Arduino Developers, Michael Shiloh
> Ob pedant: This is *NOT* a problem with avr-gcc; this is a problem with avrdude.

It's closer to the other way around. It's pretty easy to install a new avrdude that supports both 328 and 328P, but the gcc compiler shipped with Arduino is an older version that doesn't understand the "328" (yes, even though it's binary compatible with 328p. The 328 is a "newer" chip and apparently didn't exist when 4.3.2 was finalized.)
Unfortunately, upgrading the compiler is much more complicated and prone to problems, than merely upgrading avrdude.

The usual solution is to adjust avrdude long enough to install a bootloader on the 328, and then have the bootloader "lie" and tell the IDE that the chip is a 328p. But this won't help if you're not using the bootloader. (None of the Arduino bootloaders report the actual chip signature to the "programmer" (avrdude); they all have the signature hardwired as a constant.)


> 3) How does the Arduino suppose to support 328 and 328p at same time without modifying the avrdude.conf each time?

Why should they? Is arLCD an official arduino product? Are there any any official arduino products that use a 328 rather than a 328p?

If running 1.5.x, you could presumably include a custom platform.txt and a hacked version of avrdude, just for the "board" that has a 328…

WestfW


Rich Obermeyer

unread,
Jan 16, 2014, 2:07:38 AM1/16/14
to William Chops Westfield, Victor Aprea, Pierce Nichols, Arduino Developers, Michael Shiloh
On Jan 15, 2014, at 10:09 PM, "William \"Chops\" Westfield" <wes...@mac.com> wrote:

>> Ob pedant: This is *NOT* a problem with avr-gcc; this is a problem with avrdude.
>
> It's closer to the other way around. It's pretty easy to install a new avrdude that supports both 328 and 328P, but the gcc compiler shipped with Arduino is an older version that doesn't understand the "328" (yes, even though it's binary compatible with 328p. The 328 is a "newer" chip and apparently didn't exist when 4.3.2 was finalized.)
> Unfortunately, upgrading the compiler is much more complicated and prone to problems, than merely upgrading avrdude.
>
> The usual solution is to adjust avrdude long enough to install a bootloader on the 328, and then have the bootloader "lie" and tell the IDE that the chip is a 328p. But this won't help if you're not using the bootloader. (None of the Arduino bootloaders report the actual chip signature to the "programmer" (avrdude); they all have the signature hardwired as a constant.)
>
>
>> 3) How does the Arduino suppose to support 328 and 328p at same time without modifying the avrdude.conf each time?
>
> Why should they?
I thought the Arduino was a community supported software. I have seen considerable complaints with no reasonable solution provided for customers with 328 boards.
That's why the 328 should be supported by IDE.
> Is arLCD an official arduino product?
The arLCD is an at heart product on the Arduino web site.
> Are there any any official arduino products that use a 328 rather than a 328p?
At least this one!
>
> If running 1.5.x, you could presumably include a custom platform.txt and a hacked version of avrdude, just for the "board" that has a 328…
Would avrdude.exe 6.11 work with 1.5.5-r2?
This sounds promising. Thanks! This would still be a kludge, IMHO.
>
> WestfW
>
>

Guglielmo Braguglia

unread,
Jan 16, 2014, 2:09:11 AM1/16/14
to devel...@arduino.cc, Rich Obermeyer, Pierce Nichols, Michael Shiloh
AFAIK is NOT true, is very very similar, but not totally compatible and, if you want to be sure of your code, you need the specific core for the 328.  Totally different situation, for example, with the ATmega1284 where 1284 and 1284p which have the same core and are totally compatibles.

From the Atmel datasheet :
   - BODS and BODSE only available for picoPower devices ATmega48PA/88PA/168PA/328P
   - JMP, CALL : These instructions are only available in ATmega168PA and ATmega328P

The two MCU have also, obviously, a different "signature".

The 328 is NOT supported by the gcc 4.3.2 (included in Arduino IDE) ... just do avr-gcc --target-help to see the list of supported MCU and after do the same with the gcc included in the last Atmel AVR Toolchain (Toolchain 3.4.3, avr-gcc 4.8.1) and you see the difference. The first one doesn't have 328 in the "Know MCU names" (only the 328p), the second one have both (328, 328p).

So, if your code is "mission critical", for your security you can't compile with the old gcc for the 328, you need the new compiler (ver >= 4.7.2) which know the 328 ... but using new compilers create a lot of incompatibility with the actual Arduino code ... :(

You can find many discussion about this on the "Italian" section of the forum ... but in Italian language (sorry).

Guglielmo

Randy Glenn

unread,
Jan 16, 2014, 12:45:23 PM1/16/14
to devel...@arduino.cc, Guglielmo Braguglia
Where in the Atmel datasheet is it saying that the 328 doesn't support JMP or CALL? 

I know that JMP and CALL can't be used in the interrupt vector table for the 48 and 88 because those instructions need two words, and those parts only allow one instruction word per interrupt vector - but the 168s and 328s of all varieties use 2 instruction words per vector (according to page 6 of http://www.atmel.ca/Images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet.pdf).

It'd be pretty hard to write any useful code without JMP or CALL...

Thanks,

-Randy


Guglielmo Braguglia

unread,
Jan 16, 2014, 1:01:34 PM1/16/14
to devel...@arduino.cc, Guglielmo Braguglia
On the datasheet revision "Rev. 8271BS–AVR–04/10" (which includes ATmega48A ATmega48PA ATmega88A ATmega88PA ATmega168A ATmega168PA ATmega328 ATmega328P), on page 12 you can see a little "(1)" near JMP and CALL ... go on page 14 (end of instructions) and you will find the following Note :

Note: 1. These instructions are only available in ATmega168PA and ATmega328P.

Guglielmo
To unsubscribe from this group and stop receiving emails from it, send an email to developers+unsubscribe@arduino.cc.

Randy Glenn

unread,
Jan 16, 2014, 1:03:33 PM1/16/14
to devel...@arduino.cc, Guglielmo Braguglia
Sorry, now I'm seeing it - the note at the end of the Instruction Set Summary. I think that is likely to be an artifact of when the datasheet just covered the ATmega48PA/88PA/168PA/328P (this version: http://www.atmel.com/Images/doc8161.pdf). Checking the ATmega48/88/168 datasheet, it indicates that the instruction is only supported on the 168, so my guess is that it's supported on the parts with more than 16K of flash. I can't find the datasheet that only covered the ATmega328, though.

This is bugging me now, so I'm going to follow up with Atmel.

(That the 48s and 88s can only do relative and indirect jumps and calls surprises me. I guess with 8K of program memory you don't really need to worry about it.)

Thanks,

-Randy

Guglielmo Braguglia

unread,
Jan 16, 2014, 1:08:00 PM1/16/14
to devel...@arduino.cc, Guglielmo Braguglia
... and with reference to the pdf that you linked, you have to go on page 626 to find the "(1)" nearest JPM and CALL and the note is on page 628. ;)

Guglielmo

William "Chops" Westfield

unread,
Jan 16, 2014, 9:26:19 PM1/16/14
to Guglielmo Braguglia, devel...@arduino.cc, Rich Obermeyer, Pierce Nichols, Michael Shiloh
> From the Atmel datasheet :
> - BODS and BODSE only available for picoPower devices ATmega48PA/88PA/168PA/328P

Not used by Arduino core.


> - JMP, CALL : These instructions are only available in ATmega168PA and ATmega328P
>
Hmm. I'd be VERY surprised if this is not an error in the datasheet (but it is still in the latest datasheet._ Chips with less than 8k don't have JMP/CALL because they don't need them (the entire address space is reachable with rjmp/rcall), but I'm pretty sure all ATmega chips with more than 8k DO have the JMP/CALL instructions…


> if your code is "mission critical", for your security you can't compile with the old gcc for the 328

If your code is mission critical, there are no currently "validated" compilers that support Arduino-like devices on ATmega328. :-(

WestfW

Cristian Maglie

unread,
Jan 20, 2014, 7:12:10 AM1/20/14
to devel...@arduino.cc
Hi Rich,

In data giovedì 16 gennaio 2014 08:07:38, Rich Obermeyer ha scritto:
> > Is arLCD an official arduino product?
>
> The arLCD is an at heart product on the Arduino web site.

arLCD is supposed to be programmed through the bootloader (without an ISP) so
it should have no problems to upload with the default IDE.

> > If running 1.5.x, you could presumably include a custom platform.txt and
> > a hacked version of avrdude, just for the "board" that has a 328…
>
> Would avrdude.exe 6.11 work with 1.5.5-r2?
> This sounds promising. Thanks! This would still be a kludge, IMHO.

I don't know if upgrading avrdude is enough to solve the problem you're
facing, probably some tricks are needed on the boards/platform.txt to allow
compiling for 328p and uploading on 328.

BTW I'd like to consider an upgrade to avrdude, are there any concerns / known
problems in doing that?

C
Reply all
Reply to author
Forward
0 new messages