-
Notifications
You must be signed in to change notification settings - Fork 4
/
build_01_gcc_newlib.sh
executable file
·174 lines (141 loc) · 3.94 KB
/
build_01_gcc_newlib.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
source include.sh
#################
### GCC #########
#################
ver_gcc=gcc-4.6.2
arch_url=ftp://ftp.sunet.se/pub/gnu/gcc/releases/$ver_gcc/$ver_gcc.tar.bz2
arch_dir=$ver_gcc
arch_name=$ver_gcc.tar.bz2
cd $stm_dir_tools
did_it_work $?
if [ -f $arch_name ]; then
echo file exists - $arch_name
else
wget $arch_url
did_it_work $?
fi
if [ -d $arch_dir ]; then
echo old dir exists - rm -rf $arch_dir
rm -rf $arch_dir
did_it_work $?
fi
tar -xvjf $arch_name
did_it_work $?
cd $arch_dir
did_it_work $?
mkdir build
did_it_work $?
cd build
did_it_work $?
../configure --target=arm-none-eabi \
--prefix=$TOOLPATH_STM32 \
--enable-interwork \
--enable-multilib \
--enable-languages="c,c++" \
--with-newlib \
--without-headers \
--disable-shared \
--with-gnu-as \
--with-float=soft \
--with-cpu=cortex-m3 \
--with-tune=cortex-m3 \
--with-mode=thumb \
--disable-libssp \
--with-gnu-ld \
--with-system-zlib
did_it_work $?
make $PARALLEL all-gcc
did_it_work $?
make install-gcc
did_it_work $?
#################
## NewLib #######
#################
ver=newlib-1.20.0
arch_url=ftp://sources.redhat.com/pub/newlib/$ver.tar.gz
arch_dir=$ver
arch_name=$ver.tar.gz
cd $stm_dir_tools
did_it_work $?
if [ -f $arch_name ]; then
echo file exists - $arch_name
else
wget $arch_url
did_it_work $?
fi
if [ -d $arch_dir ]; then
echo old dir exists - rm -rf $arch_dir
rm -rf $arch_dir
did_it_work $?
fi
tar -xvzf $arch_name
did_it_work $?
cd $arch_dir
did_it_work $?
mkdir build
did_it_work $?
cd build
did_it_work $?
../configure --target=arm-none-eabi \
--prefix=$TOOLPATH_STM32 \
--enable-interwork \
--with-gnu-ld \
--with-gnu-as \
--disable-shared \
--disable-newlib-supplied-syscalls
did_it_work $?
# Malloc issue:
# Shall we use the --disable-newlib-supplied-syscalls flag?
# Float issue:
# http://gcc.gnu.org/gcc-4.4/changes.html
# GCC now supports the VFPv3 variant with 16 double-precision
# registers with -mfpu=vfpv3-d16. The option -mfpu=vfp3 has been
# renamed to -mfpu=vfpv3.
# GCC now supports the -mfix-cortex-m3-ldrd option to work around
# an erratum on Cortex-M3 processors.
# http://www.codesourcery.com/sgpp/lite/arm/portal/kbentry27
# Use the compiler options -mfpu=vfp -mfloat-abi=softfp to enable VFP instructions.
# If you have a VFPv3 target you may use -mfpu=vfp3 -mfloat-abi=softfp i
# to enable VFPv3 instructions.
# Using -mfloat-abi=hard generates code that is not ABI-compatible with
# other floating-point options.
#-mabi=aapcs
# gcc 4.4.6 use -mfix-cortex-m3-ldrd ?
#-DREENTRANT_SYSCALLS_PROVIDED \
#--disable-newlib-supplied-syscalls \
make $PARALLEL CFLAGS_FOR_TARGET="-ffunction-sections \
-fdata-sections \
-DPREFER_SIZE_OVER_SPEED \
-D__OPTIMIZE_SIZE__ \
-Os \
-fomit-frame-pointer \
-mcpu=cortex-m3 \
-mthumb \
-mfix-cortex-m3-ldrd \
-mfloat-abi=softfp \
-D__thumb2__ \
-D__BUFSIZ__=256" \
CCASFLAGS="-mcpu=cortex-m3 \
-mthumb \
-mfix-cortex-m3-ldrd \
-D__thumb2__"
did_it_work $?
make install
did_it_work $?
#################
### More GCC ####
#################
cd $stm_dir_tools
did_it_work $?
cd $ver_gcc/build
did_it_work $?
make $PARALLEL CFLAGS="-mcpu=cortex-m3 -mthumb" \
CXXFLAGS="-mcpu=cortex-m3 -mthumb" \
LIBCXXFLAGS="-mcpu=cortex-m3 -mthumb" \
all
did_it_work $?
make install
did_it_work $?
echo "Done:"$0
exit 0