Skip to content

Instantly share code, notes, and snippets.

@goncalor
Last active February 14, 2024 02:50
Show Gist options
  • Save goncalor/51e1c8038cc058b4379552477255b4e1 to your computer and use it in GitHub Desktop.
Save goncalor/51e1c8038cc058b4379552477255b4e1 to your computer and use it in GitHub Desktop.
How to add support for ATmega328PB to avr-gcc and avrdude

Adding support for ATmega328PB to avr-gcc and avrdude

avr-gcc

  1. Download ATmega's support pack from Microchip's website

  2. Unzip the relevant files

     unzip -j Atmel.ATmega_DFP.x.y.zzz.atpack \
     gcc/dev/atmega328pb/avr5/crtatmega328pb.o \
     gcc/dev/atmega328pb/avr5/libatmega328pb.a \
     include/avr/iom328pb.h
    
  3. Place the .o and .a files in /usr/avr/lib/avr5/

  4. Place the .h file in /usr/avr/include/avr/

  5. Add the following to /usr/avr/include/avr/io.h

     #elif defined (__AVR_ATmega328PB__) || defined (__AVR_ATmega328__)
     #  include <avr/iom328pb.h>
    

All set. Ready to compile.

avrdude

Add the following to /etc/avrdude.conf, right below the definition for ATmega328P.

part parent "m328"
	id          = "m328pb";
	desc        = "ATmega328PB";
	signature   = 0x1e 0x95 0x16;

	ocdrev      = 1;
;

Happy flashing!

@sauttefk
Copy link

typo: arv-gcc -> avr-gcc

@goncalor
Copy link
Author

Ha! Fixed! Thanks :)

@andyjpb
Copy link

andyjpb commented Feb 26, 2021

Thanks for this!
I found it really helpful. I've subsequently found a cleaner way for users to provide the pack files to the compiler without modifying the /usr/... directories maintained by the package manager.
If you're interested, I've documented the process here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930195#60
My examples are for the new 0-series and 1-series chips but I have been using atmega328pb recently as well and there's a note about how it applies to that.

@lgacnik
Copy link

lgacnik commented Mar 2, 2021

Hi!

Where to unzip these files I downloaded from Microchip's website? Where do I enter these commands like in 2. ?

@tm-sanjay
Copy link

can i use the same trick for atmega324pb ?

@andyjpb
Copy link

andyjpb commented Jun 13, 2021

Hi TM-Sanjay,

Yes it will work. Support for atmega324pb is included in the " Atmel ATmega Series Device Support (1.6.364)" Pack via the link to Microchip's website in the instructions above.

You'll have to modify the avrdude configuration that is given above. Change occurrences of 328 to 324 and insert the correct signature bytes. These can be found in the datasheet or, alternatively, just run it with the wrong ones and then avrdude will fail to connect and then tell you what it found instead. Then modify the config file a second time, substituting those bytes.

Good luck!

@samego176667
Copy link

Глупые советы.
Никакой архив не скачивается по ссылке. Скачивется инсталлятор, который устанавливает несколько сотен файлов. И чё куда потом копировать???? Авторы - бестолковые.

@sauttefk
Copy link

sauttefk commented Dec 8, 2021

@samego176667 you are wrong!
when doing as described, you get exactly 3 files and it is clearly written where to put them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment