Skip to content

Commit 39a88fd

Browse files
committed
[TEST] Add Attiny pack
1 parent b235983 commit 39a88fd

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
lines changed

atpack.build.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ source build.conf
2020
mkdir -p atpack
2121
cd atpack
2222
rm -rf *
23-
mv ../*.atpack .
23+
mv ../${ATMEL_ATMEGA_PACK_FILENAME}.atpack .
2424

2525
mv ${ATMEL_ATMEGA_PACK_FILENAME}.atpack ${ATMEL_ATMEGA_PACK_FILENAME}.zip
2626
unzip ${ATMEL_ATMEGA_PACK_FILENAME}.zip

atpack.tiny.build.bash

Lines changed: 88 additions & 0 deletions
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 ../${ATMEL_ATTINY_PACK_FILENAME}.atpack .
24+
25+
mv ${ATMEL_ATTINY_PACK_FILENAME}.atpack ${ATMEL_ATTINY_PACK_FILENAME}.zip
26+
unzip ${ATMEL_ATTINY_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+

build.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ ATMEL_ATMEGA_PACK_VERSION=1.3.300
2323
ATMEL_ATMEGA_PACK_FILENAME=Atmel.ATmega_DFP.${ATMEL_ATMEGA_PACK_VERSION}
2424
ATMEL_ATMEGA_PACK_URL=${ATMEL_PACKS_SOURCES}/${ATMEL_ATMEGA_PACK_FILENAME}.atpack
2525

26+
ATMEL_ATTINY_PACK_VERSION=1.3.229
27+
ATMEL_ATTINY_PACK_FILENAME=Atmel.ATtiny_DFP.${ATMEL_ATMEGA_PACK_VERSION}
28+
ATMEL_ATTINY_PACK_URL=${ATMEL_PACKS_SOURCES}/${ATMEL_ATMEGA_PACK_FILENAME}.atpack
29+
2630
# With any luck, you don't need to edit the below
2731
################################################################################
2832

package-avr-gcc.bash

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ if [[ -f ${ATMEL_ATMEGA_PACK_FILENAME}.atpack ]] ; then
104104
${BASH} ./atpack.build.bash
105105
fi
106106

107+
if [[ -f ${ATMEL_ATTINY_PACK_FILENAME}.atpack ]] ; then
108+
#add extra files from atpack (only if the package is altrady there)
109+
${BASH} ./atpack.tiny.build.bash
110+
fi
111+
107112
# if producing a windows build, compress as zip and
108113
# copy *toolchain-precompiled* content to any folder containing a .exe
109114
if [[ ${OUTPUT_TAG} == *"mingw"* ]] ; then

0 commit comments

Comments
 (0)