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:
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:
Put the lib and the crtatmega328pb.o into "/avr/lib".
Put the io*.h into "avr/include/avr"
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 Mini w/ ATmega328PB
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...