Go Down

Topic: [SOLVED] Arduino support for ATmega16, ATmega164, ATmega32, ATmega324, ATmega644, ATmega1284  (Read 16119 times) previous topic - next topic

hansibull

This post is solved. The idea was to make a core that supported all major DIP-40s.
I was able to make ATmega8535, ATmega16, ATmega32, ATmega164, ATmega324, ATmega644 and ATmega1284 work under the same core. If you're interested, please download the latest version from my Github repository: https://github.com/mcudude/MightyCore















Hi! A few months ago I designed an DIP-40 Arduino compatible board. This boards currently supports Atmega16, Atmega32, Atmega644p and Atmega1284p through Arduino 1.0.6. I'm using the Arduino software on a mac, and I have the newest version of Java installed.

I downloaded the newest version, Arduino 1.6.4 a few days ago, but have struggled a lot trying to make it work. I found a guide that explains how to migrate custom boards to Arduino 1.6, but I still get upload errors. Here are my boards.txt file:

Code: [Select]


##############################################################

atmega1284o.name=ATmega1284p [Optiboot]
atmega1284o.upload.protocol=arduino
atmega1284o.upload.tool=arduino:avrdude
atmega1284o.upload.maximum_size=130048
atmega1284o.upload.speed=115200
atmega1284o.bootloader.tool=arduino:avrdude
atmega1284o.bootloader.low_fuses=0xf7
atmega1284o.bootloader.high_fuses=0xde
atmega1284o.bootloader.extended_fuses=0xfd #0x05
atmega1284o.bootloader.file=optiboot/optiboot_atmega1284p.hex
atmega1284o.bootloader.unlock_bits=0x3F
atmega1284o.bootloader.lock_bits=0x0F
atmega1284o.build.mcu=atmega1284p
atmega1284o.build.f_cpu=16000000L
atmega1284o.build.core=standard
atmega1284o.build.variant=standard1284

##############################################################

atmega644o.name=ATmega644p [Optiboot]
atmega644o.upload.protocol=arduino
atmega644o.upload.tool=arduino:avrdude
atmega644o.upload.maximum_size= 63488
atmega644o.upload.speed=115200
atmega644o.bootloader.low_fuses=0xff
atmega644o.bootloader.high_fuses=0xdc
atmega644o.bootloader.extended_fuses=0xfd
atmega644o.bootloader.file=optiboot/optiboot_atmega644p.hex
atmega644o.bootloader.unlock_bits=0x3F
atmega644o.bootloader.lock_bits=0x0F
atmega644o.build.mcu=atmega644p
atmega644o.build.f_cpu=16000000L
atmega644o.build.core=standard
atmega644o.build.variant=standard644

##############################################################

atmega32o.name=ATmega32 [Optiboot]
atmega32o.upload.protocol=arduino
atmega32o.upload.tool=arduino:avrdude
atmega32o.upload.maximum_size=32256
atmega32o.upload.speed=115200
atmega32o.bootloader.low_fuses=0xff
atmega32o.bootloader.high_fuses=0xde
atmega32o.bootloader.file=optiboot/optiboot_atmega32.hex
atmega32o.bootloader.unlock_bits=0x3F
atmega32o.bootloader.lock_bits=0x0F
atmega32o.build.mcu=atmega32
atmega32o.build.f_cpu=16000000L
atmega32o.build.core=standard
atmega32o.build.variant=mega32

##############################################################

mighty16h.name=ATmega16 [Optiboot]
mighty16h.upload.protocol=arduino
mighty16h.upload.tool=arduino:avrdude
mighty16h.upload.maximum_size=15360
mighty16h.upload.speed=115200
mighty16h.bootloader.low_fuses=0xFF
mighty16h.bootloader.high_fuses=0xda
mighty16h.bootloader.file=optiboot/optiboot_atmega16.hex
mighty16h.bootloader.unlock_bits=0x3F
mighty16h.bootloader.lock_bits=0x0F
mighty16h.build.mcu=atmega16
mighty16h.build.f_cpu=16000000L
mighty16h.build.core=standard
mighty16h.build.variant=Mega16

##############################################################



When I choose the Atmega1284p from the boards menu, and tries to upload a simple sketch, I get this error:
Code: [Select]

Sketch uses 506 bytes (0%) of program storage space. Maximum is 130,048 bytes.
Global variables use 9 bytes of dynamic memory.
java.lang.NullPointerException
 at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:73)
 at processing.app.debug.Compiler.upload(Compiler.java:163)
 at processing.app.Sketch.upload(Sketch.java:1220)
 at processing.app.Sketch.exportApplet(Sketch.java:1194)
 at processing.app.Sketch.exportApplet(Sketch.java:1166)
 at processing.app.Editor$DefaultExportHandler.run(Editor.java:2487)
 at java.lang.Thread.run(Thread.java:745)




When I choose the Atmega644 from the boards menu, and tries to upload a simple sketch, I get this error:

Code: [Select]
/Users/hansi/Documents/Arduino/hardware/AVR/DIP-40/cores/standard/HardwareSerial.cpp:132:15: error: attempt to use poisoned "SIG_USART1_RECV"
 #elif defined(SIG_USART1_RECV)
               ^
Error compiling.



When I choose the Atmega32 from the boards menu, and tries to upload a simple sketch, I get this error:
Code: [Select]
/Users/hansi/Documents/Arduino/hardware/AVR/DIP-40/cores/standard/HardwareSerial.cpp:93:11: error: attempt to use poisoned "SIG_UART_RECV"
  !defined(SIG_UART_RECV)
           ^
/Users/hansi/Documents/Arduino/hardware/AVR/DIP-40/cores/standard/HardwareSerial.cpp:94:4: error: #error "Don't know what the Data Received vector is called for the first UART"
   #error "Don't know what the Data Received vector is called for the first UART"
    ^
Error compiling.



When I choose the Atmega16 from the boards menu, and tries to upload a simple sketch, I get this error:
Code: [Select]
Build options changed, rebuilding all
/Users/hansi/Documents/Arduino/hardware/AVR/DIP-40/cores/standard/HardwareSerial.cpp:93:11: error: attempt to use poisoned "SIG_UART_RECV"
  !defined(SIG_UART_RECV)
           ^
/Users/hansi/Documents/Arduino/hardware/AVR/DIP-40/cores/standard/HardwareSerial.cpp:94:4: error: #error "Don't know what the Data Received vector is called for the first UART"
   #error "Don't know what the Data Received vector is called for the first UART"
    ^
Error compiling.



Have anybody got the DIP40 Atmegas to work in the new Arduino 1.6? And can all the new libraries be used with these Atmegas? I've read that the new libraries are more optimized than the old ones. I have not touched the platform.txt file, but just copied the original AVR one.
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

MiniCore - ATmega8, mega48, mega88, mega168, mega328
Github.com/MCUdude/MiniCore

DrAzzy

SIG_USART1_RECV has been deprecated for ages, not supported anymore.

Find/replace that with USART1_RX_vect
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

hansibull

Later I replaced the HardwareSerial files with the new ones, and the error have now changed. Alll the boards got this error now:

Code: [Select]

Sketch uses 512 bytes (0%) of program storage space. Maximum is 130,048 bytes.
Global variables use 9 bytes of dynamic memory.
java.lang.NullPointerException
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:73)
at processing.app.debug.Compiler.upload(Compiler.java:163)
at processing.app.Sketch.upload(Sketch.java:1220)
at processing.app.Sketch.exportApplet(Sketch.java:1194)
at processing.app.Sketch.exportApplet(Sketch.java:1166)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2487)
at java.lang.Thread.run(Thread.java:745)


Is this some kind of java bug?
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

MiniCore - ATmega8, mega48, mega88, mega168, mega328
Github.com/MCUdude/MiniCore

DrAzzy

I suspect it's a problem in one of the .txt files (programmers, platform, or boards) but I don't know which one or where.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

hansibull

OK, I got it working by editing the boards.txt file. It looks like this now:

Code: [Select]


##############################################################

atmega1284o.name=ATmega1284p [Optiboot]
atmega1284o.upload.protocol=arduino
atmega1284o.upload.tool=avrdude
atmega1284o.upload.maximum_size=130048
atmega1284o.upload.speed=115200
atmega1284o.bootloader.tool=avrdude
atmega1284o.bootloader.low_fuses=0xf7
atmega1284o.bootloader.high_fuses=0xde
atmega1284o.bootloader.extended_fuses=0xfd #0x05
atmega1284o.bootloader.file=optiboot/optiboot_atmega1284p.hex
atmega1284o.bootloader.unlock_bits=0x3F
atmega1284o.bootloader.lock_bits=0x0F
atmega1284o.build.mcu=atmega1284p
atmega1284o.build.f_cpu=16000000L
atmega1284o.build.core=standard
atmega1284o.build.variant=standard1284

##############################################################

atmega644o.name=ATmega644p [Optiboot]
atmega644o.upload.protocol=arduino
atmega644o.upload.tool=avrdude
atmega644o.upload.maximum_size=63488
atmega644o.upload.speed=115200
atmega644o.bootloader.tool=avrdude
atmega644o.bootloader.low_fuses=0xff
atmega644o.bootloader.high_fuses=0xdc
atmega644o.bootloader.extended_fuses=0xfd
atmega644o.bootloader.file=optiboot/optiboot_atmega644p.hex
atmega644o.bootloader.unlock_bits=0x3F
atmega644o.bootloader.lock_bits=0x0F
atmega644o.build.mcu=atmega644p
atmega644o.build.f_cpu=16000000L
atmega644o.build.core=standard
atmega644o.build.variant=standard644

##############################################################

atmega32o.name=ATmega32 [Optiboot]
atmega32o.upload.protocol=arduino
atmega32o.upload.tool=avrdude
atmega32o.upload.maximum_size=32256
atmega32o.upload.speed=115200
atmega32o.bootloader.tool=avrdude
atmega32o.bootloader.low_fuses=0xff
atmega32o.bootloader.high_fuses=0xde
atmega32o.bootloader.file=optiboot/optiboot_atmega32.hex
atmega32o.bootloader.unlock_bits=0x3F
atmega32o.bootloader.lock_bits=0x0F
atmega32o.build.mcu=atmega32
atmega32o.build.f_cpu=16000000L
atmega32o.build.core=standard
atmega32o.build.variant=mega32

##############################################################

atmega16o.name=ATmega16 [Optiboot]
atmega16o.upload.protocol=arduino
atmega16o.upload.tool=avrdude
atmega16o.upload.maximum_size=15360
atmega16o.upload.speed=115200
atmega16o.bootloader.tool=avrdude
atmega16o.bootloader.low_fuses=0xFF
atmega16o.bootloader.high_fuses=0xda
atmega16o.bootloader.file=optiboot/optiboot_atmega16.hex
atmega16o.bootloader.unlock_bits=0x3F
atmega16o.bootloader.lock_bits=0x0F
atmega16o.build.mcu=atmega16
atmega16o.build.f_cpu=16000000L
atmega16o.build.core=standard
atmega16o.build.variant=mega16

##############################################################



The "new" problem is that I can't upload bootloader for any of these ATmegas. This is the error message I get when I select a programmer and hit "Burn bootloader":
Code: [Select]
Error while burning bootloader.
java.lang.NullPointerException
at cc.arduino.packages.uploaders.SerialUploader.burnBootloader(SerialUploader.java:294)
at processing.app.Editor$52.run(Editor.java:2665)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:702)
at java.awt.EventQueue$3.run(EventQueue.java:696)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:719)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)


I've tried to copy parts of the original boards.txt file, inside the Arduino program, but the error still occur. I guess there might be a problem with another *.txt file. Have any of you guys done this before and succeeded?
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

MiniCore - ATmega8, mega48, mega88, mega168, mega328
Github.com/MCUdude/MiniCore


hansibull

#6
May 15, 2015, 01:33 am Last Edit: Nov 23, 2015, 06:33 pm by hansibull Reason: Updated to the latest core
After a lot of research and testing I finally got everything to work as intended :)
You can now upload Arduino code and burn Optiboot bootloader to the following microcontrollers:
Atmega1284p  
Atmega644p      
Atmega324p
Atmega32
Atmega164p
ATmega16
ATmega8535


You can also choose these clock settings:
20MHz external
16MHz external (default)
8MHz internal
1MHz internal




The core can be downloaded from my Github repo: https://github.com/mcudude/MightyCore


The pin configuration are all the same on these microcontrollers, and looks like this:



This will only work in the new Arduino IDE 1.6.x (tested with Arduino IDE 1.6.5)
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

MiniCore - ATmega8, mega48, mega88, mega168, mega328
Github.com/MCUdude/MiniCore

oric_dan

Thanks, I've been using mostly 1284s for the past couple of years, but also have some mega32s in the box. Now that you have the bootloader and pins_arduino.h for the 32, I may get the chips to finally work.

For reference, will this all still work with IDE 1.0.6, or only with 1.6.x? Thanks.


hansibull

MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

MiniCore - ATmega8, mega48, mega88, mega168, mega328
Github.com/MCUdude/MiniCore

codedsteele

Can't get this to work as is. I get stk500_recv() programmer is not responding. I was able to successfully bootload an atmega644P but I can't load a sketch on to it. I am using the arduino uno with the Atmega328P removed and hooking the reset and UART pins, and power pins up to the appropriate pins on the 644P. Is there something I am missing or can you not use the arduino uno board as an FTDI to program this. 

codedsteele

The TX and RX leds also blink a few times before failing to upload. I have tried using the arduino and an FTDI now and neither work. I do have a 16MHz crystal hooked up in case someone asks.

hansibull

I haven't actually tried it on the Atmega644p, but I guess there is something wrong with the upload baud rate. Uploading with an Arduino UNO without the Atmega328p in the IC socket should work fine. I've compiled a Optiboot bootloader for the ATmega644p @ 16MHz. The ZIP file in post #6 is now updated with the latest version :)

Download the Latest ZIP file, and replace the previous one. Burn the bootloader again, and try to upload the code using Arduino Uno.
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

MiniCore - ATmega8, mega48, mega88, mega168, mega328
Github.com/MCUdude/MiniCore

bigfun

i'm curious what avrdudecustom is for when programming Atmega32s-- in any case, i get an error about that being missing when i go to burn a bootloader. it must have something to do with there not being an efuse setting on older atmel chips, and presumably avrdudecustom doesn't try to set one.
#####################

hansibull

Hi! The ATmega32 doesn't have an extended fuse. The brown-out fuse bits are actually set in the low fuse. avrdudecustom is a simple modification that let Arduino IDE burn the bootloader to microcontrollers with no extended fuse. the avrdudeCustom is just a few lines at the bottom of the platform.txt file.

Please post your error message. And what version of the IDE are you using? I haven't tested with 1.6.6 yet.

I've uploaded the latest version of the core, fixing a lot of bugs :)
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

MiniCore - ATmega8, mega48, mega88, mega168, mega328
Github.com/MCUdude/MiniCore

Go Up