Go Down

Topic: MegaCore - Arduino support for ATmega64/128/1281/2561 and ATmega640/1280/2560 (Read 6030 times) previous topic - next topic

mudassir9999

Hello,
I have installed Mega Core into my my Arduino IDE using "Arduino Boards Manager URL method", After installation when i see into my boards list, i couldn't find Atmega2560...

hansibull

A new, major release is now available. This version adds support for our beloved 100 pin AVRs - ATmega640, ATmega1280 and ATmega2560. There's even an optional pinout if you need more than the 70 IO pin the Arduino MEGA pinout can offer. Make sure to check it out, and please report if you believe you've found a bug :)

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

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

swoudlxy

Hi, thanks for your post.
We are using ATMega2561 for our project but I cannot upload the bootloader to this chip following the instruction.
 
I have a few questions for this instructions, please kindly help us to have a look:
1. Does the programmer have to be Ardunio Mega 2560 or any product from Arduino is fine (we are using Arduino UNO, working under the "Arduino as ISP" mode), or we should change to other programmers;
2. As mentioned in the Pin Out section, do I must have to buy the breakout board for programming 2651?
3. I setup a prototype according to the minimal setup of Mega 2561 on the breadboard, but I am not certain about where to connect J1 and J2 to the Arduino board?

Thanks in advance for your suggestions.

swoudlxy

Hi, thanks for your post.
We are using ATMega2561 for our project but I cannot upload the bootloader to this chip following the instruction.
 
I have a few questions for this instructions, please kindly help us to have a look:
1. Does the programmer have to be Ardunio Mega 2560 or any product from Arduino is fine (we are using Arduino UNO, working under the "Arduino as ISP" mode), or we should change to other programmers;
2. As mentioned in the Pin Out section, do I must have to buy the breakout board for programming 2651?
3. I setup a prototype according to the minimal setup of Mega 2561 on the breadboard, but I am not certain about where to connect J1 and J2 to the Arduino board?

Thanks in advance for your suggestions.
The error message shows:
avrdude: stk500_recv(): programmer is not responding
avrdude: initialization failed, rc=-1

Dirk67

Hello Hans,

thanks a lot for your very good and very useful work.

Can I use the MegaCore (https://github.com/MCUdude/MegaCore) with an ATMEGA 128 with 7.3728 MHz crystal ?
(I have a given system with this unusual configuration)

Or can I modify the MegaCore somehow,
to use it with this 7.3728 MHz crystal, and still get correct timings and baudrates ?
arduino powered car relais / car "micro PLC" / with USB --> http://goo.gl/ofWFW3

hansibull

I'm very busy at the moment, so I'm not able to provide al the support I want. Sorry about that.

Quote
I have a few questions for this instructions, please kindly help us to have a look:
1. Does the programmer have to be Ardunio Mega 2560 or any product from Arduino is fine (we are using Arduino UNO, working under the "Arduino as ISP" mode), or we should change to other programmers;
2. As mentioned in the Pin Out section, do I must have to buy the breakout board for programming 2651?
3. I setup a prototype according to the minimal setup of Mega 2561 on the breadboard, but I am not certain about where to connect J1 and J2 to the Arduino board?
1. Why do you think you'll _have_ to use an ATmega2560 as a programmer? Anny MCU that can run the Arduino as ISP sketch will work. However, the best advice I can give is to buy a proper programmer, because it simply works. SO many issues have been caused by a bad programmer. People seems to like the USBasp or USBtinyISP. Personally I'm using this programmer, and it just always works.

2. You don't need a dedicated breakout boards as long as you're able to hook up the minimal setup, found in the MegaCore readme. A dedicated interface PCB works just fine. Personally I've build a dedicated dev board for use with all AVR 64-pin micros.

3. Me neither. You'll find this info if you're searching for the typical Arduino as ISP tutorials. Again, a dedicated programmer is just so much simpler :)

Quote
The error message shows:
avrdude: stk500_recv(): programmer is not responding
avrdude: initialization failed, rc=-1
First you'll have to burn the bootloader, then you can upload your code using a USB to serial adpter. Enable verbose upload in the Arduino IDE settings to get fore info about what's wrong.
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

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

hansibull

Quote
Hello Hans,

thanks a lot for your very good and very useful work.

Can I use the MegaCore (https://github.com/MCUdude/MegaCore) with an ATMEGA 128 with 7.3728 MHz crystal ?
(I have a given system with this unusual configuration)

Or can I modify the MegaCore somehow,
to use it with this 7.3728 MHz crystal, and still get correct timings and baudrates ?
Hi!
You can use MegaCore with any clock frequency as you like. All you have to do is to compile a bootloader for running at 7.3728 MHz. According to the AVR baud rate calculator 115200 baud is perfect. You can add it to the makeall file, and execute it. tThen you'll need to add the option to the boards.txt file. Copy the 8 MHz external oscillator menu option, and change the baud rate and clock frequency to match your new bootloader
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

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

Dirk67

You can use MegaCore with any clock frequency as you like. All you have to do is to compile a bootloader for running at 7.3728 MHz. According to the AVR baud rate calculator 115200 baud is perfect. You can add it to the makeall file, and execute it. tThen you'll need to add the option to the boards.txt file. Copy the 8 MHz external oscillator menu option, and change the baud rate and clock frequency to match your new bootloader
aah, thanks for this explanation.

But then I think I run into other issues regarding "accurate timing",
linke you mentioned within your readme section, right ?

Quote
* When using the 18.432 MHz option (or any frequency by which 64 cannot be divided evenly), micros() is 4-5 times slower (~110 clocks). It reports the time at the point when it was called, not the end. This clock frequency is not recommended if your application relies on accurate timing, but is superb for UART communication. millis() is not affected, only micros() and delay(). Micros() executes equally fast at all clock speeds, but returns wrong values with anything that 64 doesn't divide evenly by.
since I need very accurate timing, I think it's the best to replace the crystal to a 16MHz type
arduino powered car relais / car "micro PLC" / with USB --> http://goo.gl/ofWFW3

Dirk67

sorry I have a second question,
is it possible to modify the bootloader
to use the second (hardware-)UART (on Pins PD2/PD3) on ATmega128
for uploading arduino sketches with a FTDI-UART Adapter ?

(I have a given hardware where the first UART (PE0/PE1 Pins) are taken / not free)
arduino powered car relais / car "micro PLC" / with USB --> http://goo.gl/ofWFW3

hansibull

Hi!
You can use the second UART port if you want. You just need to compile your it. Follow the instructions, and run this command:

Code: [Select]
make atmega128 AVR_FREQ=16000000L BAUD_RATE=115200 UART=1 LED=B5 LED_START_FLASHES=2 -BIGBOOT

Just change the AVR_FREQ and BAUD_RATE parameter if your hardware is fitted with something else than a 16 MHz crystal :)
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

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

Dirk67

sorry and thanks again for answering such noob questions.  :-[

Now that I see it:
is it possible to switch off the "LED=B5" part (since there are no LEDs at all)
with a compiler command like "LED=0" or something like that ?

I think if I just omit the "LED= ..." part there's still "B5" defined (in case of ATmega128)
--> github

or do I have to edit the sourcecode for that ?
arduino powered car relais / car "micro PLC" / with USB --> http://goo.gl/ofWFW3

hansibull

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

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

Dirk67

I tried to build the bootloader from scratch as described here by you...

Quote
You need to install make, avr-libc, avr-binutils and avr-gcc. This guide contains everything you need for MacOS and Linux.
To build bootloaders for all supported devices, simply run $ ./makeall.
I cloned the whole git-repo to my (virtual) linux machine to get started,

but when I run makeall, not all cores are build,
I think all the cores with EEPROM fails.

As an example here the errors that occur, when I run
  $ make atmega128 AVR_FREQ=16000000L BAUD_RATE=115200 UART=0 LED=B5 LED_START_FLASHES=2 -BIGBOOT
in the terminal:

Code: [Select]
$ make atmega128 AVR_FREQ=16000000L BAUD_RATE=115200 UART=0 LED=B5 LED_START_FLASHES=2 -BIGBOOT
avr-gcc (GCC) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

BAUD RATE CHECK: Desired: 115200, Real: 117647, UBRRL = 16, Error=2.1%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega128 -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=2    -DLED=B5  -DBIGBOOT -DUART=0   -c -o optiboot_flash.o optiboot_flash.c
optiboot_flash.c:311:2: warning: #warning BAUD_RATE error greater than 2% [-Wcpp]
 #warning BAUD_RATE error greater than 2%
  ^
optiboot_flash.c: In function 'main':
optiboot_flash.c:502:93: warning: backslash and newline separated by space
 #if defined(__AVR_ATmega8515__) || defined(__AVR_ATmega8535__) || defined(__AVR_ATmega16__) \
 ^
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega128 -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=2    -DLED=B5  -DBIGBOOT -DUART=0 -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe -Wl,--relax -nostartfiles -nostdlib -o atmega128/optiboot_flash_atmega128_115200_16000000L.elf optiboot_flash.o -lc
optiboot_flash.o: In function `appStart':
/home/osboxes/github/MegaCore/avr/bootloaders/optiboot_flash/optiboot_flash.c:942: undefined reference to `eeprom_write_byte'
/home/osboxes/github/MegaCore/avr/bootloaders/optiboot_flash/optiboot_flash.c:942: undefined reference to `eeprom_read_byte'
collect2: error: ld returned 1 exit status
Makefile:600: recipe for target 'atmega128/optiboot_flash_atmega128_115200_16000000L.elf' failed
make: *** [atmega128/optiboot_flash_atmega128_115200_16000000L.elf] Error 1
rm optiboot_flash.o


I think the main errors are:
Code: [Select]
[..]/optiboot_flash.c:942: undefined reference to `eeprom_write_byte'
[..]/optiboot_flash.c:942: undefined reference to `eeprom_read_byte'

right ?

what is missing in the github repo that I can simply run makeall ?
(or what else is wrong on my side ?)


Edit ------------------------
I found this thread (at AVRfreaks), that (I think) describes exactly what my issue is,
but I can not derive a solution for me from what is said there,
because of a lack of knowledge on my side...
arduino powered car relais / car "micro PLC" / with USB --> http://goo.gl/ofWFW3

Borsoft

Doubling my issue from GitHub...

I have a problem with loading code to Atmega128A with MegaCore bootloader by UART. When I'm trying to upload code - writing process looks successful but then I got verification error like this:
Quote
avrdude: verification error, first mismatch at byte 0x0000
0xff != 0x0c
avrdude: verification error; content mismatch
  • Here is my set: EasyEDA schematics
  • LED on PB5 is flashing so bootloader is in place and working.
  • Fuses: LFUSE - 0x3F; HFUSE - 0xC6; EFUSE - 0xFF; LOCK - 0x0F
  • USB-UART adapter seems working well as it is ok to flash other boards.
  • UART connection seems also working as avrdude starting upload and can read chip signature.
  • I noted that upload starts even without DTR signal - usually other boards waiting for LOW on DTR line or manual Reset to start upload - looks strange
  • Here is Avrdude log: Click
  • I tried UART0 and UART1 options - same issue
  • Versions: Arduino IDE - 1.8.3; avrdude - 6.3; avr-gcc - 7.2.0; MacOS - 10.12.3

Borsoft

I tried to build the bootloader from scratch as described here by you...

I cloned the whole git-repo to my (virtual) linux machine to get started,

but when I run makeall, not all cores are build,
I think all the cores with EEPROM fails.

As an example here the errors that occur, when I run
Try these commands without -nostartfiles -nostdlib:

Quote
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega128 -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=2    -DLED=B5  -DBIGBOOT -DUART=0   -c -o optiboot_flash.o optiboot_flash.c

avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega128 -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=2    -DLED=B5  -DBIGBOOT -DUART=0 -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe -Wl,--relax -o atmega128/optiboot_flash_atmega128_115200_16000000L.elf optiboot_flash.o -lc

avr-objcopy -j .text -j .data -O ihex atmega128/optiboot_flash_atmega128_115200_16000000L.elf atmega128/optiboot_flash_atmega128_115200_16000000L.hex
I faced the same issue when I tried to change UART0 to UART1, it helped me to compile...

Go Up