Skip to content

Commit 6cfc103

Browse files
authored
Merge pull request #47 from arduino/staging
Staging AVR toolchain 3.6.0 (with 328pb support files)
2 parents 2763394 + 9da5600 commit 6cfc103

11 files changed

+172
-41
lines changed

Readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Therefore, the resulting binaries may differ significantly from Atmel's. And you
99

1010
Edit the `build.conf` file, currently the only thing worth changing is `AVR_VERSION` on the first line to match whatever the [latest version is](http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/).
1111

12-
At time of writing, the latest toolchain available is based on Atmel 3.5.4 version. It contains:
12+
At time of writing, the latest toolchain available is based on Atmel 3.6.1 version. It contains:
1313
- binutils-2.26
14-
- gcc-4.9.2
14+
- gcc-5.4.0
1515
- avr-libc-2.0.0
1616
- gdb-7.8
1717

atpack.build.bash

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash -ex
2+
# Copyright (c) 2017 Arduino LLC
3+
#
4+
# This program is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU General Public License
6+
# as published by the Free Software Foundation; either version 2
7+
# of the License, or (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program; if not, write to the Free Software
16+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
18+
source build.conf
19+
20+
mkdir -p atpack
21+
cd atpack
22+
rm -rf *
23+
mv ../*.atpack .
24+
25+
mv ${ATMEL_ATMEGA_PACK_FILENAME}.atpack ${ATMEL_ATMEGA_PACK_FILENAME}.zip
26+
unzip ${ATMEL_ATMEGA_PACK_FILENAME}.zip
27+
28+
ALL_FILES=`find ../objdir`
29+
30+
#copy relevant files to the right folders
31+
# 1- copy includes definitions
32+
EXTRA_INCLUDES=`diff -q ../objdir/avr/include/avr ../atpack/include/avr | grep "Only in" | grep atpack | cut -f4 -d" "`
33+
for x in $EXTRA_INCLUDES; do
34+
cp include/avr/${x} ../objdir/avr/include/avr
35+
done
36+
37+
# 2 - compact specs into a single folder
38+
SPECS_FOLDERS=`ls gcc/dev`
39+
mkdir temp
40+
for folder in $SPECS_FOLDERS; do
41+
cp -r gcc/dev/${folder}/* temp/
42+
done
43+
44+
# 3 - find different files (device-specs)
45+
EXTRA_SPECS=`diff -q ../objdir/lib/gcc/avr/${GCC_VERSION}/device-specs/ temp/device-specs | grep "Only in" | grep temp | cut -f4 -d" "`
46+
for x in $EXTRA_SPECS; do
47+
cp temp/device-specs/${x} ../objdir/lib/gcc/avr/${GCC_VERSION}/device-specs/
48+
done
49+
50+
#since https://github.com/gcc-mirror/gcc/commit/21a6b87b86defda10ac903a9cd49e34b1f8ce6fb a lot of devices has specs but avr-libc doesn't support them yet
51+
ALL_DEVICE_SPECS=`ls temp/device-specs`
52+
rm -rf temp/device-specs
53+
54+
EXTRA_LIBS=`diff -r -q ../objdir/avr/lib temp/ | grep "Only in" | grep temp | cut -f4 -d" "`
55+
for x in $EXTRA_LIBS; do
56+
if [ ! -d temp/${x} ]; then
57+
cd temp
58+
LOCATION=`find . | grep ${x}`
59+
cd ..
60+
else
61+
LOCATION=${x}
62+
fi
63+
cp -r temp/${LOCATION} ../objdir/avr/lib/${LOCATION}
64+
done
65+
66+
# 4 - extract the correct includes and add them to io.h
67+
# ARGH! difficult!
68+
for x in $ALL_DEVICE_SPECS; do
69+
DEFINITION=`cat ../objdir/lib/gcc/avr/${GCC_VERSION}/device-specs/${x} | grep __AVR_DEVICE_NAME__ | cut -f1 -d" " | cut -f2 -d"D"`
70+
FANCY_NAME=`cat ../objdir/lib/gcc/avr/${GCC_VERSION}/device-specs/${x} | grep __AVR_DEVICE_NAME__ | cut -f2 -d"="`
71+
LOWERCASE_DEFINITION="${DEFINITION,,}"
72+
HEADER_TEMP="${LOWERCASE_DEFINITION#__avr_atmega}"
73+
HEADER="${HEADER_TEMP%__}"
74+
_DEFINITION="#elif defined (${DEFINITION})"
75+
_HEADER="# include <avr/iom${HEADER}.h>"
76+
if [ "$(grep -c "${DEFINITION}" ../objdir/avr/include/avr/io.h)" == 0 ]; then
77+
NEWFILE=`awk '/iom3000.h/ { print; print "____DEFINITION____"; print "____HEADER____"; next }1' ../objdir/avr/include/avr/io.h | sed "s/____DEFINITION____/$_DEFINITION/g" | sed "s@____HEADER____@$_HEADER@g"`
78+
echo "$NEWFILE" > ../objdir/avr/include/avr/io.h
79+
fi
80+
done
81+
82+
#NEW_ALL_FILES=`find ../objdir`
83+
84+
#echo "NEW FILES ADDED: "
85+
#diff <(echo "$ALL_FILES" ) <(echo "$NEW_ALL_FILES")
86+
87+
cd ..
88+
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- /automake.in 2017-12-18 12:26:59.455263520 +0100
2+
+++ /automake.in 2017-12-18 12:27:21.228596603 +0100
3+
@@ -4110,7 +4110,7 @@
4+
sub substitute_ac_subst_variables ($)
5+
{
6+
my ($text) = @_;
7+
- $text =~ s/\${([^ \t=:+{}]+)}/&substitute_ac_subst_variables_worker ($1)/ge;
8+
+ $text =~ s/\$[{]([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1)/ge;
9+
return $text;
10+
}
11+

avr-gcc-patches/0001-gcc-lto-wrapper.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
--- gcc/lto-wrapper.c.orig 2016-06-14 21:13:06.985134945 +0200
2-
+++ gcc/lto-wrapper.c 2016-06-14 21:15:37.825167119 +0200
1+
--- gcc/lto-wrapper.c 2016-08-22 11:19:17.000000000 +0200
2+
+++ gcc/lto-wrapper.c 2017-12-18 12:48:25.685248735 +0100
33
@@ -594,7 +594,7 @@
44
filename[p - argv[i]] = '\0';
55
file_offset = (off_t) loffset;

binutils.build.bash

+9-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ then
2323
exit 1
2424
fi
2525

26+
if [[ x$CROSS_COMPILE != x ]] ; then
27+
EXTRA_CONFARGS="--host=$OUTPUT_TAG"
28+
fi
29+
2630
cd toolsdir/bin
2731
TOOLS_BIN_PATH=`pwd`
2832
cd -
@@ -58,12 +62,13 @@ CONFARGS=" \
5862
--disable-werror \
5963
--enable-install-libiberty \
6064
--enable-install-libbfd \
61-
--enable-lto \
62-
--enable-plugins\
63-
--with-pic \
65+
--disable-libdecnumber \
66+
--disable-gdb \
67+
--disable-readline \
68+
--disable-sim \
6469
--target=avr"
6570

66-
CFLAGS="-w -O2 -g0 $CFLAGS" CXXFLAGS="-w -O2 -g0 $CXXFLAGS" LDFLAGS="-s $LDFLAGS" ../binutils/configure $CONFARGS
71+
CFLAGS="-w -O2 -g0 $CFLAGS" CXXFLAGS="-w -O2 -g0 $CXXFLAGS" LDFLAGS="-s $LDFLAGS" ../binutils/configure $CONFARGS $EXTRA_CONFARGS
6772

6873
if [ -z "$MAKE_JOBS" ]; then
6974
MAKE_JOBS="2"

build.conf

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
AVR_VERSION=3.5.4
1+
AVR_VERSION=3.6.1
22
BUILD_NUMBER=arduino2
33

44
AVR_SOURCES="http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/${AVR_VERSION}"
5+
ATMEL_PACKS_SOURCES="http://packs.download.atmel.com/"
56
GNU_SOURCES="http://mirror.switch.ch/ftp/mirror/gnu"
67
MPC_SOURCES="http://www.multiprecision.org/downloads"
78

@@ -15,6 +16,10 @@ MPC_SOURCES="http://www.multiprecision.org/downloads"
1516
# MPFR_VERSION=3.0.0
1617
# MPC_VERSION=0.9
1718

19+
ATMEL_ATMEGA_PACK_VERSION=1.2.203
20+
ATMEL_ATMEGA_PACK_FILENAME=Atmel.ATmega_DFP.${ATMEL_ATMEGA_PACK_VERSION}
21+
ATMEL_ATMEGA_PACK_URL=${ATMEL_PACKS_SOURCES}/${ATMEL_ATMEGA_PACK_FILENAME}.atpack
22+
1823
# With any luck, you don't need to edit the below
1924
################################################################################
2025

gcc.build.bash

+18-23
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,20 @@ fi
5757

5858
tar xfv avr-gcc.tar.bz2
5959

60-
pushd gcc
60+
#pushd gcc
6161
#pushd gcc/config/avr/
6262
#sh genopt.sh avr-mcus.def > avr-tables.opt
6363
#cat avr-mcus.def | awk -f genmultilib.awk FORMAT="Makefile" > t-multilib
6464
#popd
65-
pushd gcc
66-
for p in ../../avr-gcc-patches/*.patch
67-
do
68-
echo Applying $p
69-
patch -p1 < $p
70-
done
71-
autoconf
72-
popd
73-
popd
65+
#pushd gcc
66+
#for p in ../../avr-gcc-patches/*.patch
67+
#do
68+
# echo Applying $p
69+
# patch -p1 < $p
70+
#done
71+
#autoconf
72+
#popd
73+
#popd
7474

7575
mv gmp-${GMP_VERSION} gcc/gmp
7676
mv mpfr-${MPFR_VERSION} gcc/mpfr
@@ -81,32 +81,27 @@ cd objdir
8181
PREFIX=`pwd`
8282
cd -
8383

84+
if [[ x$CROSS_COMPILE != x ]] ; then
85+
EXTRA_CONFARGS="--host=$OUTPUT_TAG"
86+
fi
87+
8488
mkdir -p gcc-build
8589
cd gcc-build
8690

8791
CONFARGS=" \
8892
--enable-fixed-point \
8993
--enable-languages=c,c++ \
9094
--prefix=$PREFIX \
91-
--enable-long-long \
9295
--disable-nls \
93-
--disable-checking \
9496
--disable-libssp \
95-
--disable-libada \
97+
--disable-libada \
9698
--disable-shared \
97-
--enable-lto \
98-
--with-avrlibc=yes \
99+
--with-avrlibc=yes \
99100
--with-dwarf2 \
100-
--disable-doc \
101+
--disable-doc \
101102
--target=avr"
102103

103-
if [ `uname -s` == "Darwin" ]
104-
then
105-
# Use default system libraries (no other Macports libraries)
106-
LDFLAGS="$LDFLAGS -L/usr/lib"
107-
fi
108-
109-
CFLAGS="-w -O2 -g0 $CFLAGS" CXXFLAGS="-w -O2 -g0 $CXXFLAGS" LDFLAGS="-s $LDFLAGS" ../gcc/configure $CONFARGS
104+
CFLAGS="-w -O2 -g0 $CFLAGS" CXXFLAGS="-w -O2 -g0 $CXXFLAGS" LDFLAGS="-s $LDFLAGS" ../gcc/configure $CONFARGS $EXTRA_CONFARGS
110105

111106
if [ -z "$MAKE_JOBS" ]; then
112107
MAKE_JOBS="2"

gdb.build.bash

+12-8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ cd toolsdir/bin
2727
TOOLS_BIN_PATH=`pwd`
2828
cd -
2929

30+
if [[ x$CROSS_COMPILE != x ]] ; then
31+
EXTRA_CONFARGS="--host=$OUTPUT_TAG"
32+
fi
33+
3034
export PATH="$TOOLS_BIN_PATH:$PATH"
3135

3236
if [[ ! -f avr-gdb.tar.bz2 ]] ;
@@ -36,13 +40,13 @@ fi
3640

3741
tar xfv avr-gdb.tar.bz2
3842

39-
cd gdb
40-
for p in ../avr-gdb-patches/*.patch
41-
do
42-
echo Applying $p
43-
patch -p1 < $p
44-
done
45-
cd -
43+
#cd gdb
44+
#for p in ../avr-gdb-patches/*.patch
45+
#do
46+
# echo Applying $p
47+
# patch -p1 < $p
48+
#done
49+
#cd -
4650

4751
mkdir -p objdir
4852
cd objdir
@@ -59,7 +63,7 @@ CONFARGS=" \
5963
--disable-binutils \
6064
--target=avr"
6165

62-
CFLAGS="-w -O2 -g0 $CFLAGS" CXXFLAGS="-w -O2 -g0 $CXXFLAGS" LDFLAGS="-s $LDFLAGS" ../gdb/configure $CONFARGS
66+
CFLAGS="-w -O2 -g0 $CFLAGS" CXXFLAGS="-w -O2 -g0 $CXXFLAGS" LDFLAGS="-s $LDFLAGS" ../gdb/configure $CONFARGS $EXTRA_CONFARGS
6367

6468
if [ -z "$MAKE_JOBS" ]; then
6569
MAKE_JOBS="2"

package-avr-gcc.bash

+22-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,23 @@ if [[ $CROSS_COMPILE == "mingw" ]] ; then
2828
export CXX="i686-w64-mingw32-g++"
2929
export CROSS_COMPILE_HOST="i686-w64-mingw32"
3030
export TARGET_OS="Windows"
31-
OUTPUT_TAG=i686-w64-mingw32
31+
export OUTPUT_TAG=i686-w64-mingw32
32+
33+
elif [[ $CROSS_COMPILE == "osxcross" ]] ; then
34+
35+
export CC="o32-clang"
36+
export CXX="o32-clang++"
37+
export CROSS_COMPILE_HOST="i386-apple-darwin13"
38+
export TARGET_OS="OSX"
39+
export OUTPUT_TAG=i386-apple-darwin13
40+
41+
elif [[ $CROSS_COMPILE == "arm-cross" ]] ; then
42+
43+
export CC="arm-linux-gnueabihf-gcc"
44+
export CXX="arm-linux-gnueabihf-g++"
45+
export CROSS_COMPILE_HOST="arm-linux-gnueabihf"
46+
export TARGET_OS="LinuxARM"
47+
export OUTPUT_TAG=arm-linux-gnueabihf
3248

3349
elif [[ $OS == "GNU/Linux" ]] ; then
3450

@@ -83,6 +99,11 @@ rm -rf toolsdir objdir *-build
8399

84100
rm -rf objdir/{info,man,share}
85101

102+
if [[ -f ${ATMEL_ATMEGA_PACK_FILENAME}.atpack ]] ; then
103+
#add extra files from atpack (only if the package is altrady there)
104+
${BASH} ./atpack.build.bash
105+
fi
106+
86107
# if producing a windows build, compress as zip and
87108
# copy *toolchain-precompiled* content to any folder containing a .exe
88109
if [[ ${OUTPUT_TAG} == *"mingw"* ]] ; then
50.5 KB
Binary file not shown.

tools.bash

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ tar xfjv automake-${AUTOMAKE_VERSION}.tar.bz2
5858

5959
cd automake-${AUTOMAKE_VERSION}
6060

61+
patch -p1 < ../automake-patches/0001-fix-perl-522.patch
62+
6163
cp ../config.guess-am-1.11.4 lib/config.guess
6264
./bootstrap
6365

0 commit comments

Comments
 (0)