Browse Source

first commit

Votre Nom 2 years ago
commit
f1efa42507

+ 2 - 0
README.md

@@ -0,0 +1,2 @@
+AVR_toolchain builder v1.0
+Scripts for building avr-gcc and avrdude stuff

+ 25 - 0
avr-file-names

@@ -0,0 +1,25 @@
+# Names of the files (with version) that will be used to build the avr-gcc toolchain
+
+# Number of CPUs to use for parallel builds
+JOBCOUNT=8
+
+# Install location
+PREFIX=/usr/local/avr
+
+# binuitls name and version
+NAME_BINUTILS="binutils-2.37"
+
+# gcc name and version
+NAME_GCC="gcc-7.5.0"
+
+# avr-libc name and version
+NAME_LIBC="avr-libc-2.0.0"
+
+# avrdude name and version
+NAME_AVRDUDE="avrdude-6.3"
+
+# gdb name and version
+NAME_GDB="gdb-8.1.1"
+
+# simulavr name and version
+NAME_SIMULAVR="simulavr"

+ 75 - 0
build-avr-binutils

@@ -0,0 +1,75 @@
+#!/bin/bash
+
+# http://www.nongnu.org/avr-libc/user-manual/install_tools.html
+
+# Stop on errors
+set -e
+
+source avr-file-names
+
+# Figure out which version of the patch to use
+OLD_PATCH_CUTOFF="2.32"
+OLD_PATCH_CUTOFF_MAJ=${OLD_PATCH_CUTOFF%%.*}
+OLD_PATCH_CUTOFF_MIN=${OLD_PATCH_CUTOFF#*.}
+
+BINUTILS_VER=${NAME_BINUTILS#binutils-}
+BINUTILS_VER_MAJ=${BINUTILS_VER%%.*}
+BINUTILS_VER_MIN_TMP=${BINUTILS_VER#*.}
+BINUTILS_VER_MIN=${BINUTILS_VER_MIN_TMP%.*}
+
+if [ $BINUTILS_VER_MAJ -eq "1" ]; then
+  echo "ERROR:  Binutils version 1.xx is too old -- use at least version 2.xx"
+  exit 1;
+fi
+
+if [ $BINUTILS_VER_MAJ -gt $OLD_PATCH_CUTOFF_MAJ ] || \
+( [ $BINUTILS_VER_MAJ -eq $OLD_PATCH_CUTOFF_MAJ ] && [ $BINUTILS_VER_MIN -gt $OLD_PATCH_CUTOFF_MIN ] ) ; then
+  NAME_BINUTILS_SIZE_PATCH="avr-binutils-size-2.33.patch";
+else
+  NAME_BINUTILS_SIZE_PATCH="avr-binutils-size-2.32.patch";
+fi
+
+
+TIME_START=$(date +%s)
+
+makeDir()
+{
+	rm -rf "$1/"
+	mkdir -p "$1"
+}
+
+
+echo "Downloading sources..."
+
+if [ ! -f $NAME_BINUTILS.tar.xz ]; then
+    wget http://wareck.free.fr/cross_compilation/avr_toolchain/$NAME_BINUTILS.tar.xz
+fi
+
+
+# Make AVR-Binutils
+NAME_BINUTILS_BLD=${NAME_BINUTILS}_bld
+echo "Making Binutils in $NAME_BINUTILS_BLD..."
+echo "Extracting..."
+rm -rf $NAME_BINUTILS/
+tar xJf $NAME_BINUTILS.tar.xz
+
+# Patch the size function
+cd $NAME_BINUTILS/binutils
+patch -p 1 < ../../pack/$NAME_BINUTILS_SIZE_PATCH
+cd ../..
+
+makeDir $NAME_BINUTILS_BLD
+cd $NAME_BINUTILS_BLD
+../$NAME_BINUTILS/configure --prefix=$PREFIX --target=avr --disable-nls
+make -j $JOBCOUNT
+sudo make install-strip
+cd ..
+
+
+TIME_END=$(date +%s)
+TIME_RUN=$(($TIME_END - $TIME_START))
+
+echo ""
+echo "Done in $TIME_RUN seconds"
+
+exit 0

+ 54 - 0
build-avr-gcc

@@ -0,0 +1,54 @@
+#!/bin/bash
+
+# http://www.nongnu.org/avr-libc/user-manual/install_tools.html
+
+# Stop on errors
+set -e
+
+source avr-file-names
+
+TIME_START=$(date +%s)
+
+makeDir()
+{
+	rm -rf "$1/"
+	mkdir -p "$1"
+}
+
+
+echo "Downloading sources..."
+
+if [ ! -f $NAME_GCC.tar.xz ]; then
+    wget http://wareck.free.fr/cross_compilation/avr_toolchain/$NAME_GCC.tar.xz
+fi
+
+
+# Make AVR-GCC
+NAME_GCC_BLD=${NAME_GCC}_bld
+echo "Making GCC in $NAME_GCC_BLD..."
+echo "Extracting..."
+rm -rf $NAME_GCC/
+tar xJf $NAME_GCC.tar.xz
+
+# Patch the download_prerequisites script
+cd $NAME_GCC
+sed -i 's/ftp/https/g' ./contrib/download_prerequisites
+./contrib/download_prerequisites
+cd ..
+
+makeDir $NAME_GCC_BLD
+cd $NAME_GCC_BLD
+../$NAME_GCC/configure --prefix=$PREFIX --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --disable-libada \
+--with-dwarf2 --disable-shared --enable-static
+make -j $JOBCOUNT
+sudo make -j4 install-strip
+cd ..
+
+
+TIME_END=$(date +%s)
+TIME_RUN=$(($TIME_END - $TIME_START))
+
+echo ""
+echo "Done in $TIME_RUN seconds"
+
+exit 0

+ 46 - 0
build-avr-gdb

@@ -0,0 +1,46 @@
+#!/bin/bash
+
+# http://www.nongnu.org/avr-libc/user-manual/install_tools.html
+
+# Stop on errors
+set -e
+
+source avr-file-names
+
+TIME_START=$(date +%s)
+
+makeDir()
+{
+	rm -rf "$1/"
+	mkdir -p "$1"
+}
+
+
+echo "Downloading sources..."
+
+if [ ! -f $NAME_GDB.tar.xz ]; then
+    wget http://wareck.free.fr/cross_compilation/avr_toolchain/$NAME_GDB.tar.xz
+fi
+
+
+# Make AVR-libc
+NAME_GDB_BLD=${NAME_GDB}_bld
+echo "Making AVR-GDB in $NAME_GDB_BLD..."
+echo "Extracting..."
+rm -rf $NAME_GDB/
+tar xJf $NAME_GDB.tar.xz
+
+makeDir $NAME_GDB_BLD
+cd $NAME_GDB_BLD
+../$NAME_GDB/configure --prefix=$PREFIX --target=avr
+make -j $JOBCOUNT
+sudo make install
+cd ..
+
+TIME_END=$(date +%s)
+TIME_RUN=$(($TIME_END - $TIME_START))
+
+echo ""
+echo "Done in $TIME_RUN seconds"
+
+exit 0

+ 46 - 0
build-avr-libc

@@ -0,0 +1,46 @@
+#!/bin/bash
+
+# http://www.nongnu.org/avr-libc/user-manual/install_tools.html
+
+# Stop on errors
+set -e
+
+source avr-file-names
+
+TIME_START=$(date +%s)
+
+makeDir()
+{
+	rm -rf "$1/"
+	mkdir -p "$1"
+}
+
+
+echo "Downloading sources..."
+
+if [ ! -f $NAME_LIBC.tar.xz ]; then
+    wget http://wareck.free.fr/cross_compilation/avr_toolchain/$NAME_LIBC.tar.xz
+fi
+
+
+# Make AVR-libc
+NAME_LIBC_BLD=${NAME_LIBC}_bld
+echo "Making AVR-LIBC in $NAME_LIBC_BLD..."
+echo "Extracting..."
+rm -rf $NAME_LIBC/
+tar xJf $NAME_LIBC.tar.xz
+
+makeDir $NAME_LIBC_BLD
+cd $NAME_LIBC_BLD
+../$NAME_LIBC/configure --prefix=$PREFIX --build=$(../$NAME_LIBC/config.guess) --host=avr
+make -j $JOBCOUNT
+sudo env "PATH=$PATH" make install-strip
+cd ..
+
+TIME_END=$(date +%s)
+TIME_RUN=$(($TIME_END - $TIME_START))
+
+echo ""
+echo "Done in $TIME_RUN seconds"
+
+exit 0

+ 46 - 0
build-avrdude

@@ -0,0 +1,46 @@
+#!/bin/bash
+
+# http://www.nongnu.org/avr-libc/user-manual/install_tools.html
+
+# Stop on errors
+set -e
+
+source avr-file-names
+
+TIME_START=$(date +%s)
+
+makeDir()
+{
+	rm -rf "$1/"
+	mkdir -p "$1"
+}
+
+
+echo "Downloading sources..."
+
+if [ ! -f $NAME_AVRDUDE.tar.xz ]; then
+    wget http://wareck.free.fr/cross_compilation/avr_toolchain/$NAME_AVRDUDE.tar.xz
+fi
+
+
+# Make avrdude
+NAME_AVRDUDE_BLD=${NAME_AVRDUDE}_bld
+echo "Making AVRDUDE in $NAME_AVRDUDE_BLD..."
+echo "Extracting..."
+rm -rf $NAME_AVRDUDE/
+tar xJf $NAME_AVRDUDE.tar.xz
+
+makeDir $NAME_AVRDUDE_BLD
+cd $NAME_AVRDUDE_BLD
+../$NAME_AVRDUDE/configure --prefix=$PREFIX
+make -j $JOBCOUNT
+sudo make install-strip
+cd ..
+
+TIME_END=$(date +%s)
+TIME_RUN=$(($TIME_END - $TIME_START))
+
+echo ""
+echo "Done in $TIME_RUN seconds"
+
+exit 0

+ 40 - 0
build-simulavr

@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# http://reprap.org/wiki/SimulAVR
+# (because I can't get the official SimulAVR at savannah to build a working executable)
+
+# Stop on errors
+set -e
+
+source avr-file-names
+
+TIME_START=$(date +%s)
+
+echo "Downloading sources..."
+wget -c http://wareck.free.fr/cross_compilation/avr_toolchain/simulavr.tar.xz
+tar xfJ pack/simulavr.tar.xz
+
+# Make simulavr
+echo "Making simulavr in $NAME_SIMULAVR..."
+cd $NAME_SIMULAVR/
+git checkout traumflug
+
+cp ../pack/simulavr_patch1.patch .
+cp ../pack/simulavr_patch2.patch .
+patch -p1 < simulavr_patch1.patch
+patch -p1 < simulavr_patch2.patch
+
+./bootstrap
+./configure --enable-tcl --prefix=$PREFIX
+make
+sudo make install-strip
+
+cd ..
+
+TIME_END=$(date +%s)
+TIME_RUN=$(($TIME_END - $TIME_START))
+
+echo ""
+echo "Done in $TIME_RUN seconds"
+
+exit 0

+ 19 - 0
clean.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+rm -r -f binutils-2.37
+rm -r -f binutils-2.37_bld
+rm -r -f swig-3.0.12
+rm -r -f gcc-7.5.0
+rm -r -f gcc-7.5.0_bld
+rm -r -f gdb-8.1.1
+rm -r -f gdb-8.1.1_bld
+rm -r -f avrdude-6.3_bld
+rm -r -f avrdude-6.3
+rm -r -f avr-libc-2.0.0_bld
+rm -r -f avr-libc-2.0.0
+rm -r -f simulavr
+rm avrdude-6.3.tar.xz
+rm avr-libc-2.0.0.tar.xz
+rm binutils-2.37.tar.xz
+rm gdb-8.1.1.tar.xz
+rm simulavr.tar.xz
+rm gcc-7.5.0.tar.xz

+ 523 - 0
pack/avr-binutils-size-2.32.patch

@@ -0,0 +1,523 @@
+AVR only; support -C for AVR memory usage
+
+Source: http://git.makehackvoid.com/cgi-bin/gitweb.cgi?p=mhvavrtools.git;a=blob_plain;f=mhvavrtools/patches/binutils-001-avr-size.patch;h=e80d28eae46217551d996a2253256c97d10aa4b5;hb=refs/heads/master
+===========================================================
+--- binutils/size.c	2007-08-06 13:56:14.000000000 -0600
++++ binutils/size.c	2007-09-13 09:13:10.281250000 -0600
+@@ -36,10 +36,31 @@
+ #include "getopt.h"
+ #include "bucomm.h"
+ 
+-#ifndef BSD_DEFAULT
+-#define BSD_DEFAULT 1
++typedef enum
++{
++    format_sysv = 0,
++    format_bsd = 1,
++    format_avr = 2,
++} format_type_t;
++
++
++/* Set the default format. */
++#define FORMAT_DEFAULT_SYSV 0
++#define FORMAT_DEFAULT_BSD 1
++#define FORMAT_DEFAULT_AVR 0
++
++#if FORMAT_DEFAULT_SYSV
++    #define FORMAT_DEFAULT format_sysv
++    #define FORMAT_NAME "sysv"
++#elif FORMAT_DEFAULT_BSD
++    #define FORMAT_DEFAULT format_bsd
++    #define FORMAT_NAME "berkeley"
++#elif FORMAT_DEFAULT_AVR
++    #define FORMAT_DEFAULT format_avr
++    #define FORMAT_NAME "avr"
+ #endif
+ 
++
+ /* Program options.  */
+ 
+ static enum
+@@ -48,9 +69,8 @@ static enum
+   }
+ radix = decimal;
+ 
+-/* 0 means use AT&T-style output.  */
+-static int berkeley_format = BSD_DEFAULT;
+ 
++format_type_t format = FORMAT_DEFAULT;
+ static int show_version = 0;
+ static int show_help = 0;
+ static int show_totals = 0;
+@@ -64,6 +84,246 @@ static bfd_size_type total_textsize;
+ /* Program exit status.  */
+ static int return_code = 0;
+ 
++
++/* AVR Size specific stuff */
++
++#define AVR64 64UL
++#define AVR128 128UL
++#define AVR256 256UL
++#define AVR512 512UL
++#define AVR1K 1024UL
++#define AVR2K 2048UL
++#define AVR4K 4096UL
++#define AVR8K 8192UL
++#define AVR16K 16384UL
++#define AVR20K 20480UL
++#define AVR24K 24576UL
++#define AVR32K 32768UL
++#define AVR36K 36864UL
++#define AVR40K 40960UL
++#define AVR64K 65536UL
++#define AVR68K 69632UL
++#define AVR128K 131072UL
++#define AVR136K 139264UL
++#define AVR200K 204800UL
++#define AVR256K 262144UL
++#define AVR264K 270336UL
++
++typedef struct
++{
++    char *name;
++	long flash;
++	long ram;
++	long eeprom;
++} avr_device_t;
++
++avr_device_t avr[] =
++{
++	{"atxmega256a3",  AVR264K, AVR16K, AVR4K},
++	{"atxmega256a3b", AVR264K, AVR16K, AVR4K},
++	{"atxmega256d3",  AVR264K, AVR16K, AVR4K},
++
++	{"atmega2560",    AVR256K, AVR8K,  AVR4K},
++	{"atmega2561",    AVR256K, AVR8K,  AVR4K},
++
++	{"atxmega192a3",  AVR200K, AVR16K, AVR2K},
++	{"atxmega192d3",  AVR200K, AVR16K, AVR2K},
++
++	{"atxmega128a1",  AVR136K, AVR8K,  AVR2K},
++	{"atxmega128a1u", AVR136K, AVR8K,  AVR2K},
++	{"atxmega128a3",  AVR136K, AVR8K,  AVR2K},
++	{"atxmega128d3",  AVR136K, AVR8K,  AVR2K},
++
++	{"at43usb320",    AVR128K, 608UL,  0UL},
++	{"at90can128",    AVR128K, AVR4K,  AVR4K},
++	{"at90usb1286",   AVR128K, AVR8K,  AVR4K},
++	{"at90usb1287",   AVR128K, AVR8K,  AVR4K},
++	{"atmega128",     AVR128K, AVR4K,  AVR4K},
++	{"atmega1280",    AVR128K, AVR8K,  AVR4K},
++	{"atmega1281",    AVR128K, AVR8K,  AVR4K},
++	{"atmega1284p",   AVR128K, AVR16K, AVR4K},
++	{"atmega128rfa1", AVR128K, AVR16K, AVR4K},
++	{"atmega103",     AVR128K, 4000UL, AVR4K},
++
++	{"atxmega64a1",   AVR68K,  AVR4K,  AVR2K},
++	{"atxmega64a1u",  AVR68K,  AVR4K,  AVR2K},
++	{"atxmega64a3",   AVR68K,  AVR4K,  AVR2K},
++	{"atxmega64d3",   AVR68K,  AVR4K,  AVR2K},
++
++	{"at90can64",     AVR64K,  AVR4K,  AVR2K},
++	{"at90scr100",    AVR64K,  AVR4K,  AVR2K},
++	{"at90usb646",    AVR64K,  AVR4K,  AVR2K},
++	{"at90usb647",    AVR64K,  AVR4K,  AVR2K},
++	{"atmega64",      AVR64K,  AVR4K,  AVR2K},
++	{"atmega640",     AVR64K,  AVR8K,  AVR4K},
++	{"atmega644",     AVR64K,  AVR4K,  AVR2K},
++	{"atmega644a",    AVR64K,  AVR4K,  AVR2K},
++	{"atmega644p",    AVR64K,  AVR4K,  AVR2K},
++	{"atmega644pa",   AVR64K,  AVR4K,  AVR2K},
++	{"atmega645",     AVR64K,  AVR4K,  AVR2K},
++	{"atmega645a",    AVR64K,  AVR4K,  AVR2K},
++	{"atmega645p",    AVR64K,  AVR4K,  AVR2K},
++	{"atmega6450",    AVR64K,  AVR4K,  AVR2K},
++	{"atmega6450a",   AVR64K,  AVR4K,  AVR2K},
++	{"atmega6450p",   AVR64K,  AVR4K,  AVR2K},
++	{"atmega649",     AVR64K,  AVR4K,  AVR2K},
++	{"atmega649a",    AVR64K,  AVR4K,  AVR2K},
++	{"atmega649p",    AVR64K,  AVR4K,  AVR2K},
++	{"atmega6490",    AVR64K,  AVR4K,  AVR2K},
++	{"atmega6490a",   AVR64K,  AVR4K,  AVR2K},
++	{"atmega6490p",   AVR64K,  AVR4K,  AVR2K},
++	{"atmega64c1",    AVR64K,  AVR4K,  AVR2K},
++	{"atmega64hve",   AVR64K,  AVR4K,  AVR1K},
++	{"atmega64m1",    AVR64K,  AVR4K,  AVR2K},
++   {"m3000",         AVR64K,  AVR4K,  0UL},
++
++	{"atmega406",     AVR40K,  AVR2K,  AVR512},
++
++	{"atxmega32a4",   AVR36K,  AVR4K,  AVR1K},
++	{"atxmega32d4",   AVR36K,  AVR4K,  AVR1K},
++
++	{"at90can32",     AVR32K,  AVR2K,  AVR1K},
++	{"at94k",         AVR32K,  AVR4K,  0UL},
++	{"atmega32",      AVR32K,  AVR2K,  AVR1K},
++	{"atmega323",     AVR32K,  AVR2K,  AVR1K},
++	{"atmega324a",    AVR32K,  AVR2K,  AVR1K},
++	{"atmega324p",    AVR32K,  AVR2K,  AVR1K},
++	{"atmega324pa",   AVR32K,  AVR2K,  AVR1K},
++	{"atmega325",     AVR32K,  AVR2K,  AVR1K},
++	{"atmega325a",    AVR32K,  AVR2K,  AVR1K},
++	{"atmega325p",    AVR32K,  AVR2K,  AVR1K},
++	{"atmega3250",    AVR32K,  AVR2K,  AVR1K},
++	{"atmega3250a",   AVR32K,  AVR2K,  AVR1K},
++	{"atmega3250p",   AVR32K,  AVR2K,  AVR1K},
++	{"atmega328",     AVR32K,  AVR2K,  AVR1K},
++	{"atmega328p",    AVR32K,  AVR2K,  AVR1K},
++	{"atmega329",     AVR32K,  AVR2K,  AVR1K},
++	{"atmega329a",    AVR32K,  AVR2K,  AVR1K},
++	{"atmega329p",    AVR32K,  AVR2K,  AVR1K},
++	{"atmega329pa",   AVR32K,  AVR2K,  AVR1K},
++	{"atmega3290",    AVR32K,  AVR2K,  AVR1K},
++	{"atmega3290a",   AVR32K,  AVR2K,  AVR1K},
++	{"atmega3290p",   AVR32K,  AVR2K,  AVR1K},
++	{"atmega32hvb",   AVR32K,  AVR2K,  AVR1K},
++	{"atmega32c1",    AVR32K,  AVR2K,  AVR1K},
++   {"atmega32hvb",   AVR32K,  AVR2K,  AVR1K},
++	{"atmega32m1",    AVR32K,  AVR2K,  AVR1K},
++	{"atmega32u2",    AVR32K,  AVR1K,  AVR1K},
++	{"atmega32u4",    AVR32K,  2560UL, AVR1K},
++	{"atmega32u6",    AVR32K,  2560UL, AVR1K},
++
++	{"at43usb355",    AVR24K,  1120UL,   0UL},
++
++	{"atxmega16a4",   AVR20K,  AVR2K,  AVR1K},
++	{"atxmega16d4",   AVR20K,  AVR2K,  AVR1K},
++
++	{"at76c711",      AVR16K,  AVR2K,  0UL},
++	{"at90pwm216",    AVR16K,  AVR1K,  AVR512},
++	{"at90pwm316",    AVR16K,  AVR1K,  AVR512},
++	{"at90usb162",    AVR16K,  AVR512, AVR512},
++	{"atmega16",      AVR16K,  AVR1K,  AVR512},
++	{"atmega16a",     AVR16K,  AVR1K,  AVR512},
++	{"atmega161",     AVR16K,  AVR1K,  AVR512},
++	{"atmega162",     AVR16K,  AVR1K,  AVR512},
++	{"atmega163",     AVR16K,  AVR1K,  AVR512},
++	{"atmega164",     AVR16K,  AVR1K,  AVR512},
++	{"atmega164a",    AVR16K,  AVR1K,  AVR512},
++	{"atmega164p",    AVR16K,  AVR1K,  AVR512},
++	{"atmega165a",    AVR16K,  AVR1K,  AVR512},
++	{"atmega165",     AVR16K,  AVR1K,  AVR512},
++	{"atmega165p",    AVR16K,  AVR1K,  AVR512},
++	{"atmega168",     AVR16K,  AVR1K,  AVR512},
++	{"atmega168a",    AVR16K,  AVR1K,  AVR512},
++	{"atmega168p",    AVR16K,  AVR1K,  AVR512},
++	{"atmega169",     AVR16K,  AVR1K,  AVR512},
++	{"atmega169a",    AVR16K,  AVR1K,  AVR512},
++	{"atmega169p",    AVR16K,  AVR1K,  AVR512},
++	{"atmega169pa",   AVR16K,  AVR1K,  AVR512},
++	{"atmega16hva",   AVR16K,  768UL,  AVR256},
++	{"atmega16hva2",  AVR16K,  AVR1K,  AVR256},
++   {"atmega16hvb",   AVR16K,  AVR1K,  AVR512},
++	{"atmega16m1",    AVR16K,  AVR1K,  AVR512},
++	{"atmega16u2",    AVR16K,  AVR512, AVR512},
++	{"atmega16u4",    AVR16K,  1280UL, AVR512},
++	{"attiny167",     AVR16K,  AVR512, AVR512},
++
++	{"at90c8534",     AVR8K,   352UL,  AVR512},
++	{"at90pwm1",      AVR8K,   AVR512, AVR512},
++	{"at90pwm2",      AVR8K,   AVR512, AVR512},
++	{"at90pwm2b",     AVR8K,   AVR512, AVR512},
++	{"at90pwm3",      AVR8K,   AVR512, AVR512},
++	{"at90pwm3b",     AVR8K,   AVR512, AVR512},
++	{"at90pwm81",     AVR8K,   AVR256, AVR512},
++	{"at90s8515",     AVR8K,   AVR512, AVR512},
++	{"at90s8535",     AVR8K,   AVR512, AVR512},
++	{"at90usb82",     AVR8K,   AVR512, AVR512},
++	{"ata6289",       AVR8K,   AVR512, 320UL},
++	{"atmega8",       AVR8K,   AVR1K,  AVR512},
++	{"atmega8515",    AVR8K,   AVR512, AVR512},
++	{"atmega8535",    AVR8K,   AVR512, AVR512},
++	{"atmega88",      AVR8K,   AVR1K,  AVR512},
++	{"atmega88a",     AVR8K,   AVR1K,  AVR512},
++	{"atmega88p",     AVR8K,   AVR1K,  AVR512},
++	{"atmega88pa",    AVR8K,   AVR1K,  AVR512},
++	{"atmega8hva",    AVR8K,   768UL,  AVR256},
++	{"atmega8u2",     AVR8K,   AVR512, AVR512},
++	{"attiny84",      AVR8K,   AVR512, AVR512},
++	{"attiny84a",     AVR8K,   AVR512, AVR512},
++	{"attiny85",      AVR8K,   AVR512, AVR512},
++	{"attiny861",     AVR8K,   AVR512, AVR512},
++	{"attiny861a",    AVR8K,   AVR512, AVR512},
++	{"attiny87",      AVR8K,   AVR512, AVR512},
++	{"attiny88",      AVR8K,   AVR512, AVR64},
++
++	{"at90s4414",     AVR4K,   352UL,  AVR256},
++	{"at90s4433",     AVR4K,   AVR128, AVR256},
++	{"at90s4434",     AVR4K,   352UL,  AVR256},
++	{"atmega48",      AVR4K,   AVR512, AVR256},
++	{"atmega48a",     AVR4K,   AVR512, AVR256},
++	{"atmega48p",     AVR4K,   AVR512, AVR256},
++	{"attiny4313",    AVR4K,   AVR256, AVR256},
++	{"attiny43u",     AVR4K,   AVR256, AVR64},
++	{"attiny44",      AVR4K,   AVR256, AVR256},
++	{"attiny44a",     AVR4K,   AVR256, AVR256},
++	{"attiny45",      AVR4K,   AVR256, AVR256},
++	{"attiny461",     AVR4K,   AVR256, AVR256},
++	{"attiny461a",    AVR4K,   AVR256, AVR256},
++	{"attiny48",      AVR4K,   AVR256, AVR64},
++
++	{"at86rf401",     AVR2K,   224UL,  AVR128},
++	{"at90s2313",     AVR2K,   AVR128, AVR128},
++	{"at90s2323",     AVR2K,   AVR128, AVR128},
++	{"at90s2333",     AVR2K,   224UL,  AVR128},
++	{"at90s2343",     AVR2K,   AVR128, AVR128},
++   {"attiny20",      AVR2K,   AVR128, 0UL},
++	{"attiny22",      AVR2K,   224UL,  AVR128},
++	{"attiny2313",    AVR2K,   AVR128, AVR128},
++	{"attiny2313a",   AVR2K,   AVR128, AVR128},
++	{"attiny24",      AVR2K,   AVR128, AVR128},
++	{"attiny24a",     AVR2K,   AVR128, AVR128},
++	{"attiny25",      AVR2K,   AVR128, AVR128},
++	{"attiny26",      AVR2K,   AVR128, AVR128},
++	{"attiny261",     AVR2K,   AVR128, AVR128},
++	{"attiny261a",    AVR2K,   AVR128, AVR128},
++	{"attiny28",      AVR2K,   0UL,    0UL},
++   {"attiny40",      AVR2K,   AVR256, 0UL},
++
++	{"at90s1200",     AVR1K,   0UL,    AVR64},
++   {"attiny9",       AVR1K,   32UL,   0UL},
++   {"attiny10",      AVR1K,   32UL,   0UL},
++	{"attiny11",      AVR1K,   0UL,    AVR64},
++	{"attiny12",      AVR1K,   0UL,    AVR64},
++	{"attiny13",      AVR1K,   AVR64,  AVR64},
++	{"attiny13a",     AVR1K,   AVR64,  AVR64},
++	{"attiny15",      AVR1K,   0UL,    AVR64},
++
++   {"attiny4",       AVR512,  32UL,   0UL},
++   {"attiny5",       AVR512,  32UL,   0UL},
++};
++
++static char *avrmcu = NULL;
++
++
+ static char *target = NULL;
+ 
+ /* Forward declarations.  */
+@@ -79,7 +337,8 @@ usage (FILE *stream, int status)
+   fprintf (stream, _(" Displays the sizes of sections inside binary files\n"));
+   fprintf (stream, _(" If no input file(s) are specified, a.out is assumed\n"));
+   fprintf (stream, _(" The options are:\n\
+-  -A|-B     --format={sysv|berkeley}  Select output style (default is %s)\n\
++  -A|-B|-C  --format={sysv|berkeley|avr}  Select output style (default is %s)\n\
++            --mcu=<avrmcu>            MCU name for AVR format only\n\
+   -o|-d|-x  --radix={8|10|16}         Display numbers in octal, decimal or hex\n\
+   -t        --totals                  Display the total sizes (Berkeley only)\n\
+             --common                  Display total size for *COM* syms\n\
+@@ -88,11 +337,7 @@ usage (FILE *stream, int status)
+   -h        --help                    Display this information\n\
+   -v        --version                 Display the program's version\n\
+ \n"),
+-#if BSD_DEFAULT
+-  "berkeley"
+-#else
+-  "sysv"
+-#endif
++FORMAT_NAME
+ );
+   list_supported_targets (program_name, stream);
+   if (REPORT_BUGS_TO[0] && status == 0)
+@@ -103,6 +359,7 @@ usage (FILE *stream, int status)
+ #define OPTION_FORMAT (200)
+ #define OPTION_RADIX (OPTION_FORMAT + 1)
+ #define OPTION_TARGET (OPTION_RADIX + 1)
++#define OPTION_MCU (OPTION_TARGET + 1) 
+ 
+ static struct option long_options[] =
+ {
+@@ -110,6 +368,7 @@ static struct option long_options[] =
+   {"format", required_argument, 0, OPTION_FORMAT},
+   {"radix", required_argument, 0, OPTION_RADIX},
+   {"target", required_argument, 0, OPTION_TARGET},
++  {"mcu", required_argument, 0, 203},
+   {"totals", no_argument, &show_totals, 1},
+   {"version", no_argument, &show_version, 1},
+   {"help", no_argument, &show_help, 1},
+@@ -141,7 +399,7 @@ main (int argc, char **argv)
+   bfd_init ();
+   set_default_bfd_target ();
+ 
+-  while ((c = getopt_long (argc, argv, "ABHhVvdfotx", long_options,
++  while ((c = getopt_long (argc, argv, "ABCHhVvdfotx", long_options,
+ 			   (int *) 0)) != EOF)
+     switch (c)
+       {
+@@ -150,11 +409,15 @@ main (int argc, char **argv)
+ 	  {
+ 	  case 'B':
+ 	  case 'b':
+-	    berkeley_format = 1;
++	    format = format_bsd;
+ 	    break;
+ 	  case 'S':
+ 	  case 's':
+-	    berkeley_format = 0;
++	    format = format_sysv;
++	    break;
++	  case 'A':
++	  case 'a':
++	    format = format_avr;
+ 	    break;
+ 	  default:
+ 	    non_fatal (_("invalid argument to --format: %s"), optarg);
+@@ -162,6 +424,10 @@ main (int argc, char **argv)
+ 	  }
+ 	break;
+ 
++      case OPTION_MCU:
++	avrmcu = optarg;
++	break;
++
+       case OPTION_TARGET:
+ 	target = optarg;
+ 	break;
+@@ -190,11 +457,14 @@ main (int argc, char **argv)
+ 	break;
+ 
+       case 'A':
+-	berkeley_format = 0;
++	format = format_sysv;
+ 	break;
+       case 'B':
+-	berkeley_format = 1;
++	format = format_bsd;
+ 	break;
++      case 'C':
++    format = format_avr;
++    break;
+       case 'v':
+       case 'V':
+ 	show_version = 1;
+@@ -240,7 +509,7 @@ main (int argc, char **argv)
+     for (; optind < argc;)
+       display_file (argv[optind++]);
+ 
+-  if (show_totals && berkeley_format)
++  if (show_totals && format == format_bsd)
+     {
+       bfd_size_type total = total_textsize + total_datasize + total_bsssize;
+ 
+@@ -599,13 +869,117 @@ print_sysv_format (bfd *file)
+   printf ("\n\n");
+ }
+ 
++
++static avr_device_t *
++avr_find_device (void)
++{
++  unsigned int i;
++  if (avrmcu != NULL)
++  {
++    for (i = 0; i < sizeof(avr) / sizeof(avr[0]); i++)
++    {
++      if (strcmp(avr[i].name, avrmcu) == 0)
++      {
++        /* Match found */
++        return (&avr[i]);
++      }
++    }
++  }
++  return (NULL);
++}
++
++
++
++static void
++print_avr_format (bfd *file)
++{
++  char *avr_name = "Unknown";
++  int flashmax = 0;
++  int rammax = 0;
++  int eeprommax = 0;
++  asection *section; 
++  bfd_size_type my_datasize = 0;
++  bfd_size_type my_textsize = 0;
++  bfd_size_type my_bsssize = 0;
++  bfd_size_type bootloadersize = 0;
++  bfd_size_type noinitsize = 0;
++  bfd_size_type eepromsize = 0;
++
++  avr_device_t *avrdevice = avr_find_device();
++  if (avrdevice != NULL)
++  {
++    avr_name = avrdevice->name;
++    flashmax = avrdevice->flash;
++    rammax = avrdevice->ram;
++    eeprommax = avrdevice->eeprom;
++  }
++
++  if ((section = bfd_get_section_by_name (file, ".data")) != NULL)
++    my_datasize = bfd_section_size (file, section);
++  if ((section = bfd_get_section_by_name (file, ".text")) != NULL)
++    my_textsize = bfd_section_size (file, section);
++  if ((section = bfd_get_section_by_name (file, ".bss")) != NULL)
++    my_bsssize = bfd_section_size (file, section);
++  if ((section = bfd_get_section_by_name (file, ".bootloader")) != NULL)
++    bootloadersize = bfd_section_size (file, section);
++  if ((section = bfd_get_section_by_name (file, ".noinit")) != NULL)
++    noinitsize = bfd_section_size (file, section);
++  if ((section = bfd_get_section_by_name (file, ".eeprom")) != NULL)
++    eepromsize = bfd_section_size (file, section);
++  
++  bfd_size_type text = my_textsize + my_datasize + bootloadersize;
++  bfd_size_type data = my_datasize + my_bsssize + noinitsize;
++  bfd_size_type eeprom = eepromsize;
++  
++  printf ("AVR Memory Usage\n"
++          "----------------\n"
++          "Device: %s\n\n", avr_name);
++  
++  /* Text size */
++  printf ("Program:%8ld bytes", text);
++  if (flashmax > 0)
++  {
++    printf (" (%2.1f%% Full)", ((float)text / flashmax) * 100);
++  }
++  printf ("\n(.text + .data + .bootloader)\n\n");
++  
++  /* Data size */
++  printf ("Data:   %8ld bytes", data);
++  if (rammax > 0)
++  {
++    printf (" (%2.1f%% Full)", ((float)data / rammax) * 100);
++  }
++  printf ("\n(.data + .bss + .noinit)\n\n");
++  
++  /* EEPROM size */
++  if (eeprom > 0) 
++  { 
++    printf ("EEPROM: %8ld bytes", eeprom);
++    if (eeprommax > 0)
++    {
++      printf (" (%2.1f%% Full)", ((float)eeprom / eeprommax) * 100);
++    }
++    printf ("\n(.eeprom)\n\n");
++  }
++}
++
++
+ static void
+ print_sizes (bfd *file)
+ {
+   if (show_common)
+     calculate_common_size (file);
+-  if (berkeley_format)
+-    print_berkeley_format (file);
+-  else
+-    print_sysv_format (file);
++  switch (format)
++  {
++    case format_sysv:
++      print_sysv_format (file);
++      break;
++    case format_bsd:
++      print_berkeley_format (file);
++      break;
++    case format_avr:
++    default:
++      print_avr_format (file);
++      break;
++  }
+ }

+ 485 - 0
pack/avr-binutils-size-2.33.patch

@@ -0,0 +1,485 @@
+--- binutils/size.c	2021-07-08 07:37:19.000000000 -0400
++++ binutils/size.c	2021-12-26 12:29:54.429154946 -0500
+@@ -34,8 +34,8 @@
+ #include "getopt.h"
+ #include "bucomm.h"
+ 
+-#ifndef BSD_DEFAULT
+-#define BSD_DEFAULT 1
++#ifndef AVR_DEFAULT
++#define AVR_DEFAULT 1
+ #endif
+ 
+ /* Program options.  */
+@@ -51,10 +51,13 @@
+   {
+    FORMAT_BERKLEY,
+    FORMAT_SYSV,
+-   FORMAT_GNU
++   FORMAT_GNU,
++   FORMAT_AVR
+   };
+ static enum output_format selected_output_format =
+-#if BSD_DEFAULT
++#if AVR_DEFAULT
++  FORMAT_AVR
++#elif BSD_DEFAULT
+   FORMAT_BERKLEY
+ #else
+   FORMAT_SYSV
+@@ -73,6 +76,246 @@
+ 
+ /* Program exit status.  */
+ static int return_code = 0;
++ 
++
++/* AVR Size specific stuff */
++
++#define AVR64 64UL
++#define AVR128 128UL
++#define AVR256 256UL
++#define AVR512 512UL
++#define AVR1K 1024UL
++#define AVR2K 2048UL
++#define AVR4K 4096UL
++#define AVR8K 8192UL
++#define AVR16K 16384UL
++#define AVR20K 20480UL
++#define AVR24K 24576UL
++#define AVR32K 32768UL
++#define AVR36K 36864UL
++#define AVR40K 40960UL
++#define AVR64K 65536UL
++#define AVR68K 69632UL
++#define AVR128K 131072UL
++#define AVR136K 139264UL
++#define AVR200K 204800UL
++#define AVR256K 262144UL
++#define AVR264K 270336UL
++
++typedef struct
++{
++  char *name;
++  long flash;
++  long ram;
++  long eeprom;
++} avr_device_t;
++
++avr_device_t avr[] =
++{
++  {"atxmega256a3",  AVR264K, AVR16K, AVR4K},
++  {"atxmega256a3b", AVR264K, AVR16K, AVR4K},
++  {"atxmega256d3",  AVR264K, AVR16K, AVR4K},
++
++  {"atmega2560",    AVR256K, AVR8K,  AVR4K},
++  {"atmega2561",    AVR256K, AVR8K,  AVR4K},
++
++  {"atxmega192a3",  AVR200K, AVR16K, AVR2K},
++  {"atxmega192d3",  AVR200K, AVR16K, AVR2K},
++
++  {"atxmega128a1",  AVR136K, AVR8K,  AVR2K},
++  {"atxmega128a1u", AVR136K, AVR8K,  AVR2K},
++  {"atxmega128a3",  AVR136K, AVR8K,  AVR2K},
++  {"atxmega128d3",  AVR136K, AVR8K,  AVR2K},
++
++  {"at43usb320",    AVR128K, 608UL,  0UL},
++  {"at90can128",    AVR128K, AVR4K,  AVR4K},
++  {"at90usb1286",   AVR128K, AVR8K,  AVR4K},
++  {"at90usb1287",   AVR128K, AVR8K,  AVR4K},
++  {"atmega128",     AVR128K, AVR4K,  AVR4K},
++  {"atmega1280",    AVR128K, AVR8K,  AVR4K},
++  {"atmega1281",    AVR128K, AVR8K,  AVR4K},
++  {"atmega1284p",   AVR128K, AVR16K, AVR4K},
++  {"atmega128rfa1", AVR128K, AVR16K, AVR4K},
++  {"atmega103",     AVR128K, 4000UL, AVR4K},
++
++  {"atxmega64a1",   AVR68K,  AVR4K,  AVR2K},
++  {"atxmega64a1u",  AVR68K,  AVR4K,  AVR2K},
++  {"atxmega64a3",   AVR68K,  AVR4K,  AVR2K},
++  {"atxmega64d3",   AVR68K,  AVR4K,  AVR2K},
++
++  {"at90can64",     AVR64K,  AVR4K,  AVR2K},
++  {"at90scr100",    AVR64K,  AVR4K,  AVR2K},
++  {"at90usb646",    AVR64K,  AVR4K,  AVR2K},
++  {"at90usb647",    AVR64K,  AVR4K,  AVR2K},
++  {"atmega64",      AVR64K,  AVR4K,  AVR2K},
++  {"atmega640",     AVR64K,  AVR8K,  AVR4K},
++  {"atmega644",     AVR64K,  AVR4K,  AVR2K},
++  {"atmega644a",    AVR64K,  AVR4K,  AVR2K},
++  {"atmega644p",    AVR64K,  AVR4K,  AVR2K},
++  {"atmega644pa",   AVR64K,  AVR4K,  AVR2K},
++  {"atmega645",     AVR64K,  AVR4K,  AVR2K},
++  {"atmega645a",    AVR64K,  AVR4K,  AVR2K},
++  {"atmega645p",    AVR64K,  AVR4K,  AVR2K},
++  {"atmega6450",    AVR64K,  AVR4K,  AVR2K},
++  {"atmega6450a",   AVR64K,  AVR4K,  AVR2K},
++  {"atmega6450p",   AVR64K,  AVR4K,  AVR2K},
++  {"atmega649",     AVR64K,  AVR4K,  AVR2K},
++  {"atmega649a",    AVR64K,  AVR4K,  AVR2K},
++  {"atmega649p",    AVR64K,  AVR4K,  AVR2K},
++  {"atmega6490",    AVR64K,  AVR4K,  AVR2K},
++  {"atmega6490a",   AVR64K,  AVR4K,  AVR2K},
++  {"atmega6490p",   AVR64K,  AVR4K,  AVR2K},
++  {"atmega64c1",    AVR64K,  AVR4K,  AVR2K},
++  {"atmega64hve",   AVR64K,  AVR4K,  AVR1K},
++  {"atmega64m1",    AVR64K,  AVR4K,  AVR2K},
++  {"m3000",         AVR64K,  AVR4K,  0UL},
++
++  {"atmega406",     AVR40K,  AVR2K,  AVR512},
++
++  {"atxmega32a4",   AVR36K,  AVR4K,  AVR1K},
++  {"atxmega32d4",   AVR36K,  AVR4K,  AVR1K},
++
++  {"at90can32",     AVR32K,  AVR2K,  AVR1K},
++  {"at94k",         AVR32K,  AVR4K,  0UL},
++  {"atmega32",      AVR32K,  AVR2K,  AVR1K},
++  {"atmega323",     AVR32K,  AVR2K,  AVR1K},
++  {"atmega324a",    AVR32K,  AVR2K,  AVR1K},
++  {"atmega324p",    AVR32K,  AVR2K,  AVR1K},
++  {"atmega324pa",   AVR32K,  AVR2K,  AVR1K},
++  {"atmega325",     AVR32K,  AVR2K,  AVR1K},
++  {"atmega325a",    AVR32K,  AVR2K,  AVR1K},
++  {"atmega325p",    AVR32K,  AVR2K,  AVR1K},
++  {"atmega3250",    AVR32K,  AVR2K,  AVR1K},
++  {"atmega3250a",   AVR32K,  AVR2K,  AVR1K},
++  {"atmega3250p",   AVR32K,  AVR2K,  AVR1K},
++  {"atmega328",     AVR32K,  AVR2K,  AVR1K},
++  {"atmega328p",    AVR32K,  AVR2K,  AVR1K},
++  {"atmega329",     AVR32K,  AVR2K,  AVR1K},
++  {"atmega329a",    AVR32K,  AVR2K,  AVR1K},
++  {"atmega329p",    AVR32K,  AVR2K,  AVR1K},
++  {"atmega329pa",   AVR32K,  AVR2K,  AVR1K},
++  {"atmega3290",    AVR32K,  AVR2K,  AVR1K},
++  {"atmega3290a",   AVR32K,  AVR2K,  AVR1K},
++  {"atmega3290p",   AVR32K,  AVR2K,  AVR1K},
++  {"atmega32hvb",   AVR32K,  AVR2K,  AVR1K},
++  {"atmega32c1",    AVR32K,  AVR2K,  AVR1K},
++  {"atmega32hvb",   AVR32K,  AVR2K,  AVR1K},
++  {"atmega32m1",    AVR32K,  AVR2K,  AVR1K},
++  {"atmega32u2",    AVR32K,  AVR1K,  AVR1K},
++  {"atmega32u4",    AVR32K,  2560UL, AVR1K},
++  {"atmega32u6",    AVR32K,  2560UL, AVR1K},
++
++  {"at43usb355",    AVR24K,  1120UL,   0UL},
++
++  {"atxmega16a4",   AVR20K,  AVR2K,  AVR1K},
++  {"atxmega16d4",   AVR20K,  AVR2K,  AVR1K},
++
++  {"at76c711",      AVR16K,  AVR2K,  0UL},
++  {"at90pwm216",    AVR16K,  AVR1K,  AVR512},
++  {"at90pwm316",    AVR16K,  AVR1K,  AVR512},
++  {"at90usb162",    AVR16K,  AVR512, AVR512},
++  {"atmega16",      AVR16K,  AVR1K,  AVR512},
++  {"atmega16a",     AVR16K,  AVR1K,  AVR512},
++  {"atmega161",     AVR16K,  AVR1K,  AVR512},
++  {"atmega162",     AVR16K,  AVR1K,  AVR512},
++  {"atmega163",     AVR16K,  AVR1K,  AVR512},
++  {"atmega164",     AVR16K,  AVR1K,  AVR512},
++  {"atmega164a",    AVR16K,  AVR1K,  AVR512},
++  {"atmega164p",    AVR16K,  AVR1K,  AVR512},
++  {"atmega165a",    AVR16K,  AVR1K,  AVR512},
++  {"atmega165",     AVR16K,  AVR1K,  AVR512},
++  {"atmega165p",    AVR16K,  AVR1K,  AVR512},
++  {"atmega168",     AVR16K,  AVR1K,  AVR512},
++  {"atmega168a",    AVR16K,  AVR1K,  AVR512},
++  {"atmega168p",    AVR16K,  AVR1K,  AVR512},
++  {"atmega169",     AVR16K,  AVR1K,  AVR512},
++  {"atmega169a",    AVR16K,  AVR1K,  AVR512},
++  {"atmega169p",    AVR16K,  AVR1K,  AVR512},
++  {"atmega169pa",   AVR16K,  AVR1K,  AVR512},
++  {"atmega16hva",   AVR16K,  768UL,  AVR256},
++  {"atmega16hva2",  AVR16K,  AVR1K,  AVR256},
++  {"atmega16hvb",   AVR16K,  AVR1K,  AVR512},
++  {"atmega16m1",    AVR16K,  AVR1K,  AVR512},
++  {"atmega16u2",    AVR16K,  AVR512, AVR512},
++  {"atmega16u4",    AVR16K,  1280UL, AVR512},
++  {"attiny167",     AVR16K,  AVR512, AVR512},
++
++  {"at90c8534",     AVR8K,   352UL,  AVR512},
++  {"at90pwm1",      AVR8K,   AVR512, AVR512},
++  {"at90pwm2",      AVR8K,   AVR512, AVR512},
++  {"at90pwm2b",     AVR8K,   AVR512, AVR512},
++  {"at90pwm3",      AVR8K,   AVR512, AVR512},
++  {"at90pwm3b",     AVR8K,   AVR512, AVR512},
++  {"at90pwm81",     AVR8K,   AVR256, AVR512},
++  {"at90s8515",     AVR8K,   AVR512, AVR512},
++  {"at90s8535",     AVR8K,   AVR512, AVR512},
++  {"at90usb82",     AVR8K,   AVR512, AVR512},
++  {"ata6289",       AVR8K,   AVR512, 320UL},
++  {"atmega8",       AVR8K,   AVR1K,  AVR512},
++  {"atmega8515",    AVR8K,   AVR512, AVR512},
++  {"atmega8535",    AVR8K,   AVR512, AVR512},
++  {"atmega88",      AVR8K,   AVR1K,  AVR512},
++  {"atmega88a",     AVR8K,   AVR1K,  AVR512},
++  {"atmega88p",     AVR8K,   AVR1K,  AVR512},
++  {"atmega88pa",    AVR8K,   AVR1K,  AVR512},
++  {"atmega8hva",    AVR8K,   768UL,  AVR256},
++  {"atmega8u2",     AVR8K,   AVR512, AVR512},
++  {"attiny84",      AVR8K,   AVR512, AVR512},
++  {"attiny84a",     AVR8K,   AVR512, AVR512},
++  {"attiny85",      AVR8K,   AVR512, AVR512},
++  {"attiny861",     AVR8K,   AVR512, AVR512},
++  {"attiny861a",    AVR8K,   AVR512, AVR512},
++  {"attiny87",      AVR8K,   AVR512, AVR512},
++  {"attiny88",      AVR8K,   AVR512, AVR64},
++
++  {"at90s4414",     AVR4K,   352UL,  AVR256},
++  {"at90s4433",     AVR4K,   AVR128, AVR256},
++  {"at90s4434",     AVR4K,   352UL,  AVR256},
++  {"atmega48",      AVR4K,   AVR512, AVR256},
++  {"atmega48a",     AVR4K,   AVR512, AVR256},
++  {"atmega48p",     AVR4K,   AVR512, AVR256},
++  {"attiny4313",    AVR4K,   AVR256, AVR256},
++  {"attiny43u",     AVR4K,   AVR256, AVR64},
++  {"attiny44",      AVR4K,   AVR256, AVR256},
++  {"attiny44a",     AVR4K,   AVR256, AVR256},
++  {"attiny45",      AVR4K,   AVR256, AVR256},
++  {"attiny461",     AVR4K,   AVR256, AVR256},
++  {"attiny461a",    AVR4K,   AVR256, AVR256},
++  {"attiny48",      AVR4K,   AVR256, AVR64},
++
++  {"at86rf401",     AVR2K,   224UL,  AVR128},
++  {"at90s2313",     AVR2K,   AVR128, AVR128},
++  {"at90s2323",     AVR2K,   AVR128, AVR128},
++  {"at90s2333",     AVR2K,   224UL,  AVR128},
++  {"at90s2343",     AVR2K,   AVR128, AVR128},
++  {"attiny20",      AVR2K,   AVR128, 0UL},
++  {"attiny22",      AVR2K,   224UL,  AVR128},
++  {"attiny2313",    AVR2K,   AVR128, AVR128},
++  {"attiny2313a",   AVR2K,   AVR128, AVR128},
++  {"attiny24",      AVR2K,   AVR128, AVR128},
++  {"attiny24a",     AVR2K,   AVR128, AVR128},
++  {"attiny25",      AVR2K,   AVR128, AVR128},
++  {"attiny26",      AVR2K,   AVR128, AVR128},
++  {"attiny261",     AVR2K,   AVR128, AVR128},
++  {"attiny261a",    AVR2K,   AVR128, AVR128},
++  {"attiny28",      AVR2K,   0UL,    0UL},
++  {"attiny40",      AVR2K,   AVR256, 0UL},
++
++  {"at90s1200",     AVR1K,   0UL,    AVR64},
++  {"attiny9",       AVR1K,   32UL,   0UL},
++  {"attiny10",      AVR1K,   32UL,   0UL},
++  {"attiny11",      AVR1K,   0UL,    AVR64},
++  {"attiny12",      AVR1K,   0UL,    AVR64},
++  {"attiny13",      AVR1K,   AVR64,  AVR64},
++  {"attiny13a",     AVR1K,   AVR64,  AVR64},
++  {"attiny15",      AVR1K,   0UL,    AVR64},
++
++  {"attiny4",       AVR512,  32UL,   0UL},
++  {"attiny5",       AVR512,  32UL,   0UL},
++};
++
++static char *avrmcu = NULL;
++
+ 
+ static char *target = NULL;
+ 
+@@ -89,16 +332,19 @@
+   fprintf (stream, _(" Displays the sizes of sections inside binary files\n"));
+   fprintf (stream, _(" If no input file(s) are specified, a.out is assumed\n"));
+   fprintf (stream, _(" The options are:\n\
+-  -A|-B|-G  --format={sysv|berkeley|gnu}  Select output style (default is %s)\n\
+-  -o|-d|-x  --radix={8|10|16}         Display numbers in octal, decimal or hex\n\
+-  -t        --totals                  Display the total sizes (Berkeley only)\n\
+-            --common                  Display total size for *COM* syms\n\
+-            --target=<bfdname>        Set the binary file format\n\
+-            @<file>                   Read options from <file>\n\
+-  -h        --help                    Display this information\n\
+-  -v        --version                 Display the program's version\n\
++  -A|-B|-G|-C  --format={sysv|berkeley|gnu|avr}  Select output style (default is %s)\n\
++               --mcu=<avrmcu>            MCU name for AVR format only\n\
++  -o|-d|-x     --radix={8|10|16}         Display numbers in octal, decimal or hex\n\
++  -t           --totals                  Display the total sizes (Berkeley only)\n\
++               --common                  Display total size for *COM* syms\n\
++               --target=<bfdname>        Set the binary file format\n\
++               @<file>                   Read options from <file>\n\
++  -h           --help                    Display this information\n\
++  -v           --version                 Display the program's version\n\
+ \n"),
+-#if BSD_DEFAULT
++#if AVR_DEFAULT
++  "avr"
++#elif BSD_DEFAULT
+   "berkeley"
+ #else
+   "sysv"
+@@ -113,6 +359,7 @@
+ #define OPTION_FORMAT (200)
+ #define OPTION_RADIX (OPTION_FORMAT + 1)
+ #define OPTION_TARGET (OPTION_RADIX + 1)
++#define OPTION_MCU (OPTION_TARGET + 1)
+ 
+ static struct option long_options[] =
+ {
+@@ -120,6 +367,7 @@
+   {"format", required_argument, 0, OPTION_FORMAT},
+   {"radix", required_argument, 0, OPTION_RADIX},
+   {"target", required_argument, 0, OPTION_TARGET},
++  {"mcu", required_argument, 0, 203},
+   {"totals", no_argument, &show_totals, 1},
+   {"version", no_argument, &show_version, 1},
+   {"help", no_argument, &show_help, 1},
+@@ -151,7 +399,7 @@
+     fatal (_("fatal error: libbfd ABI mismatch"));
+   set_default_bfd_target ();
+ 
+-  while ((c = getopt_long (argc, argv, "ABGHhVvdfotx", long_options,
++  while ((c = getopt_long (argc, argv, "ABGCHhVvdfotx", long_options,
+ 			   (int *) 0)) != EOF)
+     switch (c)
+       {
+@@ -170,12 +418,20 @@
+ 	  case 'g':
+ 	    selected_output_format = FORMAT_GNU;
+ 	    break;
++	  case 'C':
++	  case 'c':
++	    selected_output_format = FORMAT_AVR;
++	    break;
+ 	  default:
+ 	    non_fatal (_("invalid argument to --format: %s"), optarg);
+ 	    usage (stderr, 1);
+ 	  }
+ 	break;
+ 
++      case OPTION_MCU:
++	avrmcu = optarg;
++	break;
++
+       case OPTION_TARGET:
+ 	target = optarg;
+ 	break;
+@@ -212,6 +468,9 @@
+       case 'G':
+ 	selected_output_format = FORMAT_GNU;
+ 	break;
++      case 'C':
++	selected_output_format = FORMAT_AVR;
++	break;
+       case 'v':
+       case 'V':
+ 	show_version = 1;
+@@ -654,13 +913,118 @@
+   printf ("\n\n");
+ }
+ 
++static avr_device_t *
++avr_find_device (void)
++{
++  unsigned int i;
++  if (avrmcu != NULL)
++  {
++    for (i = 0; i < sizeof(avr) / sizeof(avr[0]); i++)
++    {
++      if (strcmp(avr[i].name, avrmcu) == 0)
++      {
++        /* Match found */
++        return (&avr[i]);
++      }
++    }
++  }
++  return (NULL);
++}
++
++
++
++static void
++print_avr_format (bfd *file)
++{
++  char *avr_name = "Unknown";
++  int flashmax = 0;
++  int rammax = 0;
++  int eeprommax = 0;
++  asection *section; 
++  bfd_size_type my_datasize = 0;
++  bfd_size_type my_textsize = 0;
++  bfd_size_type my_bsssize = 0;
++  bfd_size_type bootloadersize = 0;
++  bfd_size_type noinitsize = 0;
++  bfd_size_type eepromsize = 0;
++
++  avr_device_t *avrdevice = avr_find_device();
++  if (avrdevice != NULL)
++  {
++    avr_name = avrdevice->name;
++    flashmax = avrdevice->flash;
++    rammax = avrdevice->ram;
++    eeprommax = avrdevice->eeprom;
++  }
++
++  if ((section = bfd_get_section_by_name (file, ".data")) != NULL)
++    my_datasize = bfd_section_size (section);
++  if ((section = bfd_get_section_by_name (file, ".text")) != NULL)
++    my_textsize = bfd_section_size (section);
++  if ((section = bfd_get_section_by_name (file, ".bss")) != NULL)
++    my_bsssize = bfd_section_size (section);
++  if ((section = bfd_get_section_by_name (file, ".bootloader")) != NULL)
++    bootloadersize = bfd_section_size (section);
++  if ((section = bfd_get_section_by_name (file, ".noinit")) != NULL)
++    noinitsize = bfd_section_size (section);
++  if ((section = bfd_get_section_by_name (file, ".eeprom")) != NULL)
++    eepromsize = bfd_section_size (section);
++  
++  bfd_size_type text = my_textsize + my_datasize + bootloadersize;
++  bfd_size_type data = my_datasize + my_bsssize + noinitsize;
++  bfd_size_type eeprom = eepromsize;
++  
++  printf ("AVR Memory Usage\n"
++          "----------------\n"
++          "Device: %s\n\n", avr_name);
++  
++  /* Text size */
++  printf ("Program:%8ld bytes", text);
++  if (flashmax > 0)
++  {
++    printf (" (%2.1f%% Full)", ((float)text / flashmax) * 100);
++  }
++  printf ("\n(.text + .data + .bootloader)\n\n");
++  
++  /* Data size */
++  printf ("Data:   %8ld bytes", data);
++  if (rammax > 0)
++  {
++    printf (" (%2.1f%% Full)", ((float)data / rammax) * 100);
++  }
++  printf ("\n(.data + .bss + .noinit)\n\n");
++  
++  /* EEPROM size */
++  if (eeprom > 0) 
++  { 
++    printf ("EEPROM: %8ld bytes", eeprom);
++    if (eeprommax > 0)
++    {
++      printf (" (%2.1f%% Full)", ((float)eeprom / eeprommax) * 100);
++    }
++    printf ("\n(.eeprom)\n\n");
++  }
++}
++
++
++
+ static void
+ print_sizes (bfd *file)
+ {
+   if (show_common)
+     calculate_common_size (file);
+-  if (selected_output_format == FORMAT_SYSV)
+-    print_sysv_format (file);
+-  else
+-    print_berkeley_or_gnu_format (file);
+-}
++  switch (selected_output_format)
++  {
++    case FORMAT_SYSV:
++      print_sysv_format (file);
++      break;
++    case FORMAT_BERKLEY:
++    case FORMAT_GNU: 
++      print_berkeley_or_gnu_format (file);
++      break;
++    case FORMAT_AVR:
++    default:
++      print_avr_format (file);
++      break;
++  }
++}   

+ 60 - 0
pack/simulavr_patch1.patch

@@ -0,0 +1,60 @@
+>From 85ce9cf2aa059c8ce22e0f7a82552a8a248f1ef3 Mon Sep 17 00:00:00 2001
+From: panic <address@hidden>
+Date: Mon, 19 Jun 2017 14:14:11 +0200
+Subject: [PATCH 2/2] delete duplicate architecture definition
+
+Previously, gcc threw errors similar to
+
+  Fatal error: redefinition of mcu type `avr2' to `attiny25'
+
+The mcu type is already defined via command line parameter -mmcu=.
+Removing .arch from the source, avoids the redefinition and the
+error.
+---
+ examples/verilog/Makefile.am     | 2 +-
+ examples/verilog/right-unit.s    | 2 +-
+ examples/verilog/singlepincomm.s | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/examples/verilog/Makefile.am b/examples/verilog/Makefile.am
+index a70941f..6a1aff1 100644
+--- a/examples/verilog/Makefile.am
++++ b/examples/verilog/Makefile.am
+@@ -54,7 +54,7 @@ vst.elf: vst.cpp
+ 
+ 
+ .s.o:
+-	$(AVR_GCC) -c -Wa,-gstabs -x assembler-with-cpp -o $@ $<
++	$(AVR_GCC) -mmcu=attiny25 -c -Wa,-gstabs -x assembler-with-cpp -o $@ $<
+ 
+ left-unit.elf: left-unit.o csinglepincomm.o
+ 
+diff --git a/examples/verilog/right-unit.s b/examples/verilog/right-unit.s
+index f45d2b4..885b4ff 100644
+--- a/examples/verilog/right-unit.s
++++ b/examples/verilog/right-unit.s
+@@ -14,7 +14,7 @@
+ // with this program; if not, write to the Free Software Foundation, Inc.,
+ // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA..
+ //  
+-.arch ATTiny25
++
+ #define __SFR_OFFSET 0
+ 	
+ #define	__AVR_ATtiny25__	1
+diff --git a/examples/verilog/singlepincomm.s b/examples/verilog/singlepincomm.s
+index 088a359..2bd758c 100644
+--- a/examples/verilog/singlepincomm.s
++++ b/examples/verilog/singlepincomm.s
+@@ -23,7 +23,7 @@
+ // warranty!
+ //
+ //-----------------------------------------------------------------------------
+-.arch ATTiny25
++
+ #define	__AVR_ATtiny25__	1
+ #define __SFR_OFFSET 0
+ #include <avr/io.h>
+-- 
+2.11.0
+

+ 34 - 0
pack/simulavr_patch2.patch

@@ -0,0 +1,34 @@
+>From b838672ec515ec7cdb91005581c554c046bfab74 Mon Sep 17 00:00:00 2001
+From: panic <address@hidden>
+Date: Mon, 19 Jun 2017 14:13:31 +0200
+Subject: [PATCH 1/2] remove debugging defines
+
+---
+ regress/gtest/Makefile.am | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/regress/gtest/Makefile.am b/regress/gtest/Makefile.am
+index b8ab6bd..42cf331 100644
+--- a/regress/gtest/Makefile.am
++++ b/regress/gtest/Makefile.am
+@@ -7,8 +7,6 @@ GTEST_OBJS = gtest-1.6.0/src/gtest-all.cc
+ 
+ GTEST_INCLUDE = -Igtest-1.6.0/include/gtest -Igtest-1.6.0/include -Igtest-1.6.0
+ 
+-GTEST_CXXFLAGS = -Dprivate=public -Dprotected=public 
+-
+ GTEST_EXTRA_FILES = gtest-1.6.0/src/gtest-internal-inl.h \
+                     gtest-1.6.0/src/gtest-filepath.cc \
+                     gtest-1.6.0/src/gtest.cc \
+@@ -74,7 +72,7 @@ OBJS_TARGET = session_001/avr_code.atmega32.o \
+               session_irq_check/tc5.atmega32.o \
+               session_io_pin/tc1.atmega128.o
+ 
+-AM_CXXFLAGS = $(GTEST_CXXFLAGS) $(GTEST_INCLUDE) $(SIMULAVR_INCLUDE) -g
++AM_CXXFLAGS = $(GTEST_INCLUDE) $(SIMULAVR_INCLUDE) -g
+ 
+ EXTRA_DIST = $(OBJS_SRC) $(GTEST_EXTRA_FILES)
+ 
+-- 
+2.11.0
+

+ 20 - 0
prerequise.sh

@@ -0,0 +1,20 @@
+#!/bin/bash
+sudo apt-get install wget bzip2 texinfo flex babeltrace python expat bison tk-dev tcl-dev -y
+if ! [ -x "$(command -v swig)" ]
+then
+tar xvfJ swig-3.0.12.tar.xz
+cd swig-3.0.12
+./autogen.sh
+./configure
+make
+sudo make install
+cd
+fi
+
+if ! grep "/usr/local/avr/bin" ~/.bashrc >/dev/null
+	then
+	echo "export PATH=XXXXPATH::/usr/local/avr/bin" >> ~/.bashrc
+	sed -i -e "s/XXXX/$/g" ~/.bashrc
+	source ~/.bashrc
+fi
+

+ 22 - 0
release_package.sh

@@ -0,0 +1,22 @@
+#!/bin/bash
+cwd=$(pwd)
+echo -e "AVR Toolchain packer v1.0\n"
+if (( $EUID != 0 )); then
+   echo -e "\n$(tput setaf 11)This must be run as root. Try 'sudo bash $0'.$(tput setaf 7)\n"
+   exit 1
+fi
+if ! [ -x "$(command -v pv)" ]
+then
+sudo apt-get install pv -y
+fi
+if ! [ -x "$(command -v pixz)" ]
+then
+sudo apt-get install pixz -y
+fi
+echo "Compressing:"
+cd /usr/local
+SIZE=`du -sk avr | cut -f 1`
+tar cf - avr | pv -p -s ${SIZE}k | pixz > avr_toolchain.tar.xz
+cd $cwd
+sudo mv /usr/local/avr_toolchain.tar.xz .
+echo -e "\nDone."