Go Down

Topic: Atmega328 (no p) has compile/upload catch-22? (Read 971 times) previous topic - next topic

jwatte

I have a standalone breadboard with an atmega328 (rather than 328p) on it.
I am using an USBtinyISP to upload to it.
I have configured the IDE in boards.txt to add a new kind of board, with the appropriate fuse bits.
I have added a device called atmega328 to avrdude.conf which is a copy of the 328p, except with a signature of 0x1e 0x95 0x14 instead of 0x1e 0x95 0x0F.

However, I can't figure out how to make the system compile like a 328p, but upload like a 328.
Here's my snippet from board.txt:

Code: [Select]
##############################################################

standalone328.name=Standalone 328 USBtinyISP
standalone328.upload.using=usbtinyisp
standalone328.upload.maximum_size=32768
standalone328.build.mcu=atmega328p
standalone328.build.f_cpu=16000000L
standalone328.build.core=arduino
standalone328.build.variant=standard
standalone328.bootloader.low_fuses=0xE2
standalone328.bootloader.high_fuses=0xD9
standalone328.bootloader.extended_fuses=0xF5
standalone328.bootloader.path=optiboot
standalone328.bootloader.file=optiboot_atmega328.hex
standalone328.bootloader.unlock_bits=0x3F
standalone328.bootloader.lock_bits=0x0F


The problem is the build.mcu field. When I set it to atmega328p, it tries to call AVRdude with atmega328p, which has the wrong signature bit.
When I change it to atmega328, the compiler complains that it doesn't know about that chip.
I think what I want to do is compile as atmega328p, but upload as atmega328. However, i can't find the right combination of configuration options to make that happen.

Because I'm using the USBtinyISP, is there a configuration option for upload.*** that lets me set the device type to pass to AVRdude?


westfw

Lie.
Set the build.mcu to m328.  Use this boards.txt to "burn bootloader" using the m328p bootloader.
Change the build.mcu back to m328p; the bootloader will happily tell AVRDude that it's a 328p CPU even though it's really just a 328, and all will be happy.

(alternately, leave boards.txt as 328p and use some other mechanism (avrdude, optiloader) to load the 328p bootloader onto the 328...)

kf2qd

Find your AVRDude.conf and make sure there is a 328 chip defined. It can be the same as the 328P except for the signature. Once you have a bootloader it will load from Arduino without a problem.

SirNickity

That's what I do.  I have a target set up in the IDE and avrdude.conf for 328 bootloading, then change the target to a standard Uno to upload a sketch.  I upload via serial, not ISP though.

jwatte


Lie.
Set the build.mcu to m328.  Use this boards.txt to "burn bootloader" using the m328p bootloader.
Change the build.mcu back to m328p; the bootloader will happily tell AVRDude that it's a 328p CPU even though it's really just a 328, and all will be happy.

(alternately, leave boards.txt as 328p and use some other mechanism (avrdude, optiloader) to load the 328p bootloader onto the 328...)



I am not using a bootloader. I am directly programming a stand-alone m328, using direct ISP, and would like to do so through the IDE.
This would work if I could specify a different symbol/model to the compiler than to the uploader. I'm wondering whether there is a way in the config file to do this.
Also, I'm wondering why the compiler recognizes atmega328p, but not atmega328, as a valid target. It recognizes 329, 325, and others without a "p"...

westfw

Quote
if I could specify a different symbol/model to the compiler than to the uploader.

Not that I know of...
Quote
I'm wondering why the compiler recognizes atmega328p, but not atmega328, as a valid target.

It's a pretty old version of the compiler.  I don't think that there was a separate 328 and 328p sold at the time the compiler was created.  (there are other problems with newer versions of the compiler, however.  Atmel has said that they'll have a new "package" version of the compiler (winavr)  "soon."

jwatte

"Real Soon Now," huh? I know what that means :-)
I guess I'll just pony up the extra dollar and get 328p parts for now.

Go Up