Yet another atmega1284p based arduino- Recomendations for bootloader ?

HI All,

I ve just finished constructing my new standalone arduino based system.

Main features:

Dual atmega 32u4 or atmega1284p support (Either chip can be soldered on the pcb on separate footprints)

Onboard RS232 interface
Onboard RS485 interface
Onboard switching power supply with 10-24V AC or 12-30V DC supply (supplies 12v,5v and 3.3V)
Onboard Serial EEPROM (2 ICs)
Onboard relay driver along with 6 power relays (mains)
Onboard socket for nrf24 radio comms
I2C temperature sensor and I2C interface expansion available
Number of expansion headers available (8 bit digital, LEDs, I2C, etc)

All the above are accommodated in a double sided PCB measuring 10x8cm designed to also fit in a DIN rail mounted BOX if required.

Photos to follow soon..

At this point I am trying to choose a suitable bootloader for the atmega1284p. This is the first time I am using this chip and I have no experience with the available bootloaders. I ve been using just the 32u4 with the arduino micro bootloader so far.

Could someone please make some recommendations for a suitable bootloader?

The Optiboot.

The Optiboot.

Thanks! Can you provide a link to documentation/code etc?

Here is all you need:
Optiboot

Now I see, there is no hex prepared for 1284p. You have to build it yourself or in case of problems ask for help.

Now I see, there is no hex prepared for 1284p. You have to build it yourself or in case of problems ask for help

In the case of 32u4 chip, I use the arduino IDE to burn the bootloader with a MKii compatible programmer.

Once I install the otpiboot files, will I be able to use the same procedure for the 1284p ?

EDIT: I am using IDE 1.0.6.. it looks like optiboot is not compatible!

IDE 1.0.6 is OK (BTW I'm using the same). Optiboot is used also for UNO and most of people use it on 1284p. You have to have the .HEX (compiled image) file exactly for your variant. As I mention, on the GitHub is source code for it but not .HEX for 1284p exactly. You have to create one from source code. The prerequisite is just F_CPU and L LED pin from your board variant.
Bootloading is similar.

Thanks! I ll give it a try later today

GitHub - MCUdude/MightyCore: Arduino hardware package for ATmega1284, ATmega644, ATmega324, ATmega324PB, ATmega164, ATmega32, ATmega16 and ATmega8535 has Optiboot compiled for every configuration of ATmega1284P and friends you could want. It's also a well done, actively maintained core but it only supports Arduino IDE 1.6.2 or higher(you can use the bootloader files with any IDE version though). You can use the boards.txt file as a reference, there are some changes required for 1.0.6 compatibility, details at Arduino Hardware Cores migration guide from 1.0 to 1.6 · arduino/Arduino Wiki · GitHub) It might be worth installing a new IDE version(1.6.5-r5 or 1.6.9 are the good ones) to try MightyCore out, it's well done and actively maintained. You can always leave 1.0.6 installed so you can switch back if you find some incompatibilities in your old code with the new Arduino IDE version, though most things you might encounter are easy to fix.

I have been using xboot, after having issues that ended up not being the bootloader at all (it was my RS-422 stuff), but while struggling I tried xboot and have just kept using it. This very simple Makefile is used to run avrdude, it should have the info you would need for the Arduino IDE.

I compiled xboot with the toolchain on Ubuntu 16.04 (same as I use for my project files). Alex helped me, I could not figure out how to run the xboot makefile with a config file, but it is obvious looking back.

At some point, I'm going to try an xMega and I think xboot will have dividends.

Extra credit: When I look at that Makefile and then think of how much time I spent fiddling with the Arduino IDE... ROGLMAO. I suggest learning the regular toolchain. The most important thing to learn first is how to do a simple Makefile. Elliot Williams at Hack-A-Day did some good starting point pages.

Couple of options here that I was figuring out:
https://forum.arduino.cc/index.php?topic=402335.0

mighty-1284p does have a branch that supports Arduino IDE 1.0.6: GitHub - JChristensen/mighty-1284p: Mighty 1284P Platform for Arduino. It's not as well maintained as MightyCore but it had its day.

Thanks for all the info.

Run into problems burning the optiboot after having to compile a make file. The make process gave out some warnings but still the hex file was produced. Burning the file however gives an error message saying Synchronization error (I ll get the exact wording again later)

Then managed to install mightycore. First time success.

Later, returning to the optiboot for a second attempt, reading the readme file that comes with the optiboot files, I found out about the omake command (as opposed to the make command).
Using omake gives no warning messages, so I will try to burn the optiboot later and see if it works.

It seems like there are lots of different bootloaders available out there. Anyone tried more than one of them and has some comparisons to share? Something like which is best for which application etc?

It seems like there are lots of different bootloaders available out there. Anyone tried more than one of them and has some comparisons to share? Something like which is best for which application etc?

Bootloader is important just to upload a program. Optiboot is small, reliable and offers everything you need. I'm not sure if it worth looking for another solution.

I have experience using mighty-1284P and MightyCore. They both are using optiboot bootloaders but different versions.

mighty-1284P is using an old optiboot version. I also seem to remember them saying that the current hex files were made using some other makefile and/or bootloader source code that's different from what's in the repository, don't ask me why.

MightyCore uses Majek's fork of optiboot(optiboot/optiboot at supermaster · majekw/optiboot · GitHub), which has the flash write feature added. MightyCore is slightly behind Majek's version and Majek's version is missing a few recent commits from the stock optiboot but none of those commits make a difference for this application.

MightyCore will definitely be keeping the bootloaders reasonably up to date and making new releases of the core whenever appropriate. Mighty-1284P is not being actively developed. I put quite a bit of work into getting mighty-1284p up to date but now that a better option exists with a motivated author I've focused all my contributions in that direction instead.

Still having problems with burning of optiboot...

It looks like it fails on the first verification attempt!

Any ideas?

I get this :

***failed;
Arduino: 1.0.6 (Windows 7), Board: "[Optiboot] ATmega1284p"
C:\Program Files\Arduino\hardware/tools/avr/bin/avrdude -CC:\Program Files\Arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega1284p -cstk500v2 -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xde:m -Ulfuse:w:0xf7:m

avrdude: Version 5.11, compiled on Sep 2 2011 at 19:38:36
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "C:\Program Files\Arduino\hardware/tools/avr/etc/avrdude.conf"

Using Port : usb
Using Programmer : stk500v2
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200012345
avrdude: usbdev_open(): using read endpoint 0x83
avrdude: Sent: . [01]
avrdude: Recv: . [01] . [00] . [0a] A [41] V [56] R [52] I [49] S [53] P [50] _ [5f] M [4d] K [4b] 2 [32]
avrdude: stk500v2_getsync(): found AVRISP mkII programmer
AVR Part : ATMEGA1284P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 10 128 0 no 4096 8 0 9000 9000 0xff 0xff
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


flash 65 10 256 0 yes 131072 256 512 4500 4500 0xff 0xff
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00

Programmer Type : STK500V2
Description : Atmel STK500 Version 2.x firmware
Programmer Model: AVRISP mkII
avrdude: Sent: . [03] . [90]
avrdude: Recv: . [03] . [00] . [00]
avrdude: Sent: . [03] . [91]
avrdude: Recv: . [03] . [00] . [01]
avrdude: Sent: . [03] . [92]
avrdude: Recv: . [03] . [00] . [11]
Hardware Version: 0
Firmware Version Master : 1.17
avrdude: Sent: . [03] . [94]
avrdude: Recv: . [03] . [00] ! [21]
Vtarget : 3.3 V
avrdude: Sent: . [03] . [98]
avrdude: Recv: . [03] . [00] . [06]
SCK period : 8.00 us

avrdude: Sent: . [10] . [c8] d [64] . [19] [20] . [00] S [53] . [03] . [ac] S [53] . [00] . [00]
avrdude: Recv: . [10] . [00]
avrdude: AVR device initialized and ready to accept instructions

Reading | avrdude: Sent: . [1d] . [04] . [04] . [00] 0 [30] . [00] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] 0 [30] . [00] . [1e] . [00]
avrdude: Sent: . [1d] . [04] . [04] . [00] 0 [30] . [00] . [01] . [00]
avrdude: Recv: . [1d] . [00] . [00] 0 [30] . [00] . [97] . [00]
################avrdude: Sent: . [1d] . [04] . [04] . [00] 0 [30] . [00] . [02] . [00]
avrdude: Recv: . [1d] . [00] . [00] 0 [30] . [00] . [05] . [00]
################################## | 100% 0.02s

avrdude: Device signature = 0x1e9705
avrdude: Sent: . [1d] . [04] . [04] . [00] . [a0] . [0f] . [fc] . [00]
avrdude: Recv: . [1d] . [00] . [00] . [a0] . [0f] . [ff] . [00]

avrdude: Recv: . [1d] . [00] . [00] P [50] . [08] . [fd] . [00]
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] P [50] . [08] . [fd] . [00]
avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] P [50] . [08] . [fd] . [00]
***failed;
################################################## | 100% 0.09s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: input file 0x05 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | avrdude: Sent: . [1d] . [04] . [04] . [00] P [50] . [08] . [00] . [00]
avrdude: Recv: . [1d] . [00] . [00] P [50] . [08] . [fd] . [00]
################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0x05 != 0xfd
avrdude: verification error; content mismatch
avrdude: Sent: . [11] . [01] . [01]
avrdude: Recv: . [11] . [00]

avrdude done. Thank you.

I remember you said you had success using MighyCore. Were you able to burn bootloader using it?

yes, now I have burned the "maniacbug " mighty 1284p .. it loads first time no problem..

Watcher:

     0x05 != 0xfd

There's some weirdness with how avrdude handles unused fuse bits. An efuse value of 0x05 is BOD 2.7V. An efuse falue of 0xfd is also BOD 2.7V. The only difference between the two is the first has the unused bits set to 0 and the second has them set to 1. So just change your efuse value to 0xfd and it should verify and still result in your desired configuration.

So just change your efuse value to 0xfd and it should verify and still result in your desired configuration.

Hmm... am sorry but i have no idea how to do that :slight_smile: