Pages: [1]   Go Down
Author Topic: adding a 328(non-p) option in ide  (Read 883 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Im trying to add a. Non p version to the ide for ease of use,
I copied everything that said 328p, and make a new entry without the p
in boards.txt, avrdude.conf, winavrmanifest.log, io.h,(new)im328.h, and  cn328.o
however I get the error mcu atmega328 only supported in assembler, and when I look at the log it lists the mcus and 328 isn't on there,
idk what to do I basically just searched for 328p in files and made a 328 duplicate, : /
p.s I was able to do it in avrdude with the command line.... just not the ide!
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6805
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
mcu atmega328 only supported in assembler
This comes from the gcc compiler itself (which pre-dates the existence of a non-P 328), and I'm pretty sure that it's more complicated to fix than modifying a "config" file somewhere.  (the IDE you update with a config file.  Avrdude you update with a config file.  Gcc you probably modify a source module somewhere and then recompile the compiler.)

Better to lie to everything and tell them you have a 328p.
Logged

Offline Offline
Faraday Member
**
Karma: 66
Posts: 2588
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I copied everything that said 328p, and make a new entry without the p
in boards.txt, avrdude.conf,
Just duplicating won't do. 
There's a different hardware signature, 
0x1e 0x95 0x0f (P signature) vs 0x1e 0x95 0x14 (non-P).
But the avrdude.conf lists only ATmega328.  I think you have to go back and forth, modifying that file.  If there's a way to have them both in that .conf, I don't know how that could be done, to differentiate.
Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just had a 328 and a 328p everywhere, with the only difference being the signature

makes sense about the gcc, since I can upload no problem with avrdude but haven't tried compiling anything yet
I did notice tho when I was switching it back and forth, when I had it changed to the non p and did a regular serial upload without the bootloader it said invalid signature, even though it was the right one, I guess the optiboot tells avrdude the sig instead of checking everytime?
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4094
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Haven't tried this myself, but there's some interesting discussion here:
http://arduino.cc/forum/index.php?topic=58670.0
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6805
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I guess the optiboot tells avrdude the sig
Yes, if you load the 328P optiboot into a 328, it will then tell the arduino dude that the cpu is a 328p.  This is the "lying" that is the (my) preferred technique for getting a 328 to work with Arduino.
Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess using a 328 only affects the ide when trying isp then,
Ill just make sure to get 328p for anything that needs isp
Logged

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1025
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's the changes I made to be able to program the 328 bootloader. Once you have the bootloader the software thinks it is talking to a 328P. This will also let you bypass the bootloader and load sketches directrly with an ISP.
You can modify the Boards.txt file - which (for 1.0) is in the arduino-1.0\hardware\arduino\ directory.
Here's the entry for the Arduino Uno.

##############################################################
uno.name=Arduino Uno
uno.upload.protocol=arduino
uno.upload.maximum_size=32256
uno.upload.speed=115200
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard

I copied that section and then added 328 to the description. Changes are in red.

##############################################################
uno328.name=Arduino328
uno328.upload.protocol=arduino
uno328.upload.maximum_size=32256
uno328.upload.speed=115200
uno328.bootloader.low_fuses=0xff
uno328.bootloader.high_fuses=0xde
uno328.bootloader.extended_fuses=0x05
uno328.bootloader.path=optiboot
uno328.bootloader.file=optiboot_atmega328.hex
uno328.bootloader.unlock_bits=0x3F
uno328.bootloader.lock_bits=0x0F
uno328.build.mcu=atmega328
uno328.build.f_cpu=16000000L
uno328.build.core=arduino
uno328.build.variant=standard

Then I went to arduino-1.0\hardware\tools\avr\etc\ and modified the AVRDude.conf file.
I had to go quiote a ways down the file and find this -
#------------------------------------------------------------
# ATmega328P
#------------------------------------------------------------

part
    id         = "m328p";
    desc      = "ATMEGA328P";
    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 0x0F;
(Lots more stuff here but I didn't touch it)

And I had to change a four lines near the beginning of the copied section.
I have used these changes with ArduinoIDE and with AVRDude for loading the bootloader into some 328 chips that I got.

#------------------------------------------------------------
# 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;
« Last Edit: April 10, 2012, 11:11:59 am by kf2qd » Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's basically what I did, the problem apears to be the comipler wont compile for a 328 and altering that isn't so simple
so uploading with avrdude is no problem its just when the ide compiles the sketch for the 328 instead of the 328p it gets an error and stops it dead
so im just compiling it for the 328p and uploading manually with avrdude for now
Logged

Anchorage, AK
Offline Offline
Edison Member
*
Karma: 42
Posts: 1176
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You only need the non-P setup in the IDE for the bootloader upload.  That's the only part that checks the chip's signature.  Once that's done, I treat mine like a stock 328P Uno by selecting the Uno as a target in the menu, and uploading a sketch.
Logged

Pages: [1]   Go Up
Jump to: