ATMEGA328PB Boot Loader

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does Atmel make a boot loader for the ATMEGA328PB? I was thinking FLIP would work but it's not on the list of supported devices.

Jon Wilder
Freelance Embedded Engineer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Atmel only make bootloaders for their USB chips.

 

If you want a serial (UART) bootloader get one of the 100's that are written by 3rd parties.

 

The most obvious choice for a 328 based chip is the "Optiboot" botloader used in Arduino. That's actually for 328P but I imagine it would take little/no modification to be used for the new 328PB

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not sure if Atmel make one, but Optiboot appears to be compatible with the 328PB, and what with Optiboot being the bootloader used by the Arduino platform, and that it's currently maintained by an active AVR Freaks member, Bill Westfield (westfw), it would certainly be a good choice. It would even allow you to use an Arduino (or clone) as a programmer. Here's the Github page where you can find any relevant info and downloads.

 

Edit: Cliff beat me to it ha!

Last Edited: Mon. Mar 27, 2017 - 06:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
That's actually for 328P but I imagine it would take little/no modification to be used for the new 328PB

 

If you want the extra goodies like UART1 to be used, just add this to the makefile.

atmega328pb: TARGET = atmega328pb
atmega328pb: MCU_TARGET = atmega328pb
atmega328pb: CFLAGS += $(COMMON_OPTIONS) $(UART_CMD)
atmega328pb: AVR_FREQ ?= 16000000L
atmega328pb: LDSECTIONS  = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
atmega328pb: $(PROGRAM)_atmega328pb.hex
atmega328pb: $(PROGRAM)_atmega328pb.lst

Then i'm quite sure i had modified avr/io file to include mega328pb also, i dont know if it's needed to compile.

 

If UART1 is not needed, then it will work if you just use Atmega328 as target without modifications.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

(As Joni implied, the current optiboot build for 328pb "pretends" to be only a 328p, since the current arduino build environment does not fully support the 328pb.)

 

Elektor has a 328pb-based Arduino, and it looks like they have code (probably including bootloader) to support it more fully: https://github.com/ElektorLabs/A...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Atmel only make bootloaders for their USB chips.
Though the Atmel AES bootloader app note has not been updated, that bootloader is in Atmel START for mega328PB :

http://start.atmel.com/#examples/boot

 


Microchip Technology Inc

Microchip

AVR231: AES Bootloader

http://www.microchip.com//wwwAppNotes/AppNotes.aspx?appnote=en591242

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

G'day, new to this forum so hope its ok that I'm posting here - please advise if it should have been a new topic.

I assumed since I am also chasing the same outcome and this one has tailed off I could pick it up, learn some and maybe leave this topic with a final solution for future users?

 

 

I am also following AN2462, as linked by gchapman, however without success yet.

 

I hope to use the resulting bootloader with its AES encryption on 328P or 328PB devices.

 

I have followed the entire AN2462 document to the best of my understanding and am at the point of compiling the bootloader hex file.  

It compiles without error (in ATmel Studio 7) however resulting Hex file does not seem to work when uploaded to the chip.

I assume that I've not compiled it correctly as <6k seems too small to large for a bootloader? When flashed to the 328P it uploads ok but does not seem to respond like it has a working bootloader.

I notice that there is a makefile in the Atmel Studio Solutions output directory - so am I supposed to further compile this project from a command line?

Is it possible that I have not correctly linked in some parts of the project like the aeskeys or bootldr.h files and this is why hex file output is so small?

I have moved these files into the solutions directory, replacing the sample ones that came with the AN2462 project.  I have also tried simply compiling the AN2462 project without any changes and it also produces non functional bootloader hex files. 

 

Any hints please to what I might be doing wrong, 

 

Note - I'm coming from an Arduino environment which I am now learning is an extremely simplified way of attacking these AVR's.  I want to learn to do this 'properly' rather than relying on Arduino IDE and libraries and yes before you say it I know that a secure bootloader is probably not the most practical / simple place to start;)  It is however where Arduino left off being able to help me and so Im in the deep end.  I have spent approx 25 hours trying to nut this out before coming to ask for help - not afraid of late nights, but I am a little stuck and so...

 

 

 

 

 

Last Edited: Sun. Dec 17, 2017 - 10:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry

Forgot to mention, there was one deviation to following the app note that I should mention in case is relevant

 

In order to get the project to compile, I had to change aeskeys.inc

"__flash unsigned char kTable[32] ="

to

"const unsigned char kTable[32] ="

 

in order to avoid error:

Severity

Code

Description

Project

File

Line

Error

 

variable 'kTable' must be const in order to be put into read-only section by means of '__flash'

AVR231AESBootloader0

AVR231 AES Bootloader\AVR231AESBootloader0\AVR231AESBootloader0\AVR231_AES_Bootloader\aeskeys2.inc

19

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It probably should be "const __flash unsigned char kTable[32] ="

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Noted! Ta!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How are you measuring your "6K"? Hope you don't mean the size of the hex file? That's typical x2.5 to x3 the size of the actual binary. So a 6K hex file probably holds 2K to 2.5K of binary. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes that’s exactly how I was measuring it:). Good to know that doesn’t represent actual size! Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But the AS7 build actually reports the exact number of bytes so why try to guess from the hex size?