After compiling a lot time the avr toolchain by myself, I found an easier solution.
I tried the gcc version 6.0.0, 4.8.9 and 4.9.2. There is are some problems with the gcc. every time i patched the new device, the gcc doesn't know about the Atmega328pb. It means, the device is never shown in the call:
$ avr-gcc --target-help
but I always could compile the for this device, so the gcc itself knew about. I used the information from the Patch, which someone from Atmel send to the gcc-developer. As someone want to know about all the patches, I did, I wrote all down. But just now, I want to describe the easy way.
Thanks to Atmel, they provide a toolchain for Windows and Linux. Because I am working with Linux, I downloaded the toolchain there:
http://www.atmel.com/tools/atmelavrtoolchainforlinux.aspx
This toolchain contains the gcc 4.9.2 with a few patches from the 6.0.0 version. I don't know exactly, which patches, but I analysed their compiling script (http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/3.5.0/build-avr8-gnu-toolchain-git.sh).
But luckily, they have a finished toolchain. But now we need to add the device. These informations are int the AVR device pack: http://www.atmel.com/images/partpack_ATmega328PB-trunk-6.2.9.zip
But aware, these files are outdated already, there Atmel Studio has newer one.
In the end, I found 3 different header files. In one file, there were some Register missing.
Here is the another Pack Link, which is newer:
http://packs.download.atmel.com/ - Atmel ATmega Series Device Support (1.0.91)
We need the following files:
- libatmega328pb.a
- iom328pb.h
- crtatmega328pb.o
Put the lib and the crtatmega328pb.o into "/avr/lib".
Put the io*.h into "avr/include/avr"
Done !
I also patched the "io.h", but this seems not necessary since the header file can build the filename by itself, when it is not found.
I put everything into Arduino, so I could easy see, if it's working. Because i made my own PCB, I made my own board.txt.
super.name=Super Mini super.upload.tool=avrdude super.upload.protocol=arduino super.bootloader.tool=avrdude super.bootloader.low_fuses=0xff super.bootloader.unlock_bits=0x3F super.bootloader.lock_bits=0x0F super.build.f_cpu=20000000L super.build.board=AVR_MINI super.build.core=arduino:arduino super.build.variant=super ## Super Mini w/ ATmega328PB ## ------------------------- super.menu.cpu.atmega328=ATmega328pb super.menu.cpu.atmega328.upload.maximum_size=28672 super.menu.cpu.atmega328.upload.maximum_data_size=2048 super.menu.cpu.atmega328.upload.speed=115200 super.menu.cpu.atmega328.bootloader.high_fuses=0xd8 super.menu.cpu.atmega328.bootloader.extended_fuses=0x05 super.menu.cpu.atmega328.bootloader.file=optiboot/optiboot_atmega328pb.hex super.menu.cpu.atmega328.build.mcu=atmega328pb super.build.extra_flags=and my own variant "pins_arduino.h". About that, later.
Finally I need to patch the avrdude.conf:
Simply add below the Atmega328 Part:
part parent "m328" id = "m328pb"; desc = "ATmega328PB"; signature = 0x1e 0x95 0x16; ocdrev = 1; ;
Later I explain about the bootloader...
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.