forked from pfalcon/esp-open-sdk
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
369 lines (298 loc) · 13.3 KB
/
Makefile
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
TOP = $(PWD)
TOOLCHAIN = $(TOP)/xtensa-lx106-elf
VENDOR_SDK = 2.0.0
UNZIP = unzip -q -o
VENDOR_SDK_ZIP = $(VENDOR_SDK_ZIP_$(VENDOR_SDK))
VENDOR_SDK_DIR = $(VENDOR_SDK_DIR_$(VENDOR_SDK))
VENDOR_SDK_ZIP_2.0.0 = ESP8266_NONOS_SDK_V2.0.0_16_08_10.zip
VENDOR_SDK_ZIP_2.0.0dead1 = ESP8266_NONOS_SDK_V2.0.0_16_07_19.zip
VENDOR_SDK_DIR_2.0.0 = ESP8266_NONOS_SDK
VENDOR_SDK_ZIP_1.5.2 = ESP8266_NONOS_SDK_V1.5.2_16_01_29.zip
VENDOR_SDK_DIR_1.5.2 = esp_iot_sdk_v1.5.2
VENDOR_SDK_ZIP_1.5.0 = esp_iot_sdk_v1.5.0_15_11_27.zip
VENDOR_SDK_DIR_1.5.0 = esp_iot_sdk_v1.5.0
VENDOR_SDK_ZIP_1.4.1 = esp_iot_sdk_v1.4.1_pre5_15_10_27.zip
VENDOR_SDK_DIR_1.4.1 = esp_iot_sdk_v1.4.1_pre5
VENDOR_SDK_ZIP_1.4.0 = esp_iot_sdk_v1.4.0_15_09_18.zip
VENDOR_SDK_DIR_1.4.0 = esp_iot_sdk_v1.4.0
VENDOR_SDK_ZIP_1.3.0 = esp_iot_sdk_v1.3.0_15_08_08.zip
VENDOR_SDK_DIR_1.3.0 = esp_iot_sdk_v1.3.0
VENDOR_SDK_ZIP_1.2.0 = esp_iot_sdk_v1.2.0_15_07_03.zip
VENDOR_SDK_DIR_1.2.0 = esp_iot_sdk_v1.2.0
VENDOR_SDK_ZIP_1.1.2 = esp_iot_sdk_v1.1.2_15_06_12.zip
VENDOR_SDK_DIR_1.1.2 = esp_iot_sdk_v1.1.2
VENDOR_SDK_ZIP_1.1.1 = esp_iot_sdk_v1.1.1_15_06_05.zip
VENDOR_SDK_DIR_1.1.1 = esp_iot_sdk_v1.1.1
VENDOR_SDK_ZIP_1.1.0 = esp_iot_sdk_v1.1.0_15_05_26.zip
VENDOR_SDK_DIR_1.1.0 = esp_iot_sdk_v1.1.0
# MIT-licensed version was released without changing version number
#VENDOR_SDK_ZIP_1.1.0 = esp_iot_sdk_v1.1.0_15_05_22.zip
#VENDOR_SDK_DIR_1.1.0 = esp_iot_sdk_v1.1.0
VENDOR_SDK_ZIP_1.0.1 = esp_iot_sdk_v1.0.1_15_04_24.zip
VENDOR_SDK_DIR_1.0.1 = esp_iot_sdk_v1.0.1
VENDOR_SDK_ZIP_1.0.1b2 = esp_iot_sdk_v1.0.1_b2_15_04_10.zip
VENDOR_SDK_DIR_1.0.1b2 = esp_iot_sdk_v1.0.1_b2
VENDOR_SDK_ZIP_1.0.1b1 = esp_iot_sdk_v1.0.1_b1_15_04_02.zip
VENDOR_SDK_DIR_1.0.1b1 = esp_iot_sdk_v1.0.1_b1
VENDOR_SDK_ZIP_1.0.0 = esp_iot_sdk_v1.0.0_15_03_20.zip
VENDOR_SDK_DIR_1.0.0 = esp_iot_sdk_v1.0.0
VENDOR_SDK_ZIP_0.9.6b1 = esp_iot_sdk_v0.9.6_b1_15_02_15.zip
VENDOR_SDK_DIR_0.9.6b1 = esp_iot_sdk_v0.9.6_b1
VENDOR_SDK_ZIP_0.9.5 = esp_iot_sdk_v0.9.5_15_01_23.zip
VENDOR_SDK_DIR_0.9.5 = esp_iot_sdk_v0.9.5
VENDOR_SDK_ZIP_0.9.4 = esp_iot_sdk_v0.9.4_14_12_19.zip
VENDOR_SDK_DIR_0.9.4 = esp_iot_sdk_v0.9.4
VENDOR_SDK_ZIP_0.9.3 = esp_iot_sdk_v0.9.3_14_11_21.zip
VENDOR_SDK_DIR_0.9.3 = esp_iot_sdk_v0.9.3
VENDOR_SDK_ZIP_0.9.2 = esp_iot_sdk_v0.9.2_14_10_24.zip
VENDOR_SDK_DIR_0.9.2 = esp_iot_sdk_v0.9.2
STANDALONE = y
.PHONY: crosstool-NG toolchain libhal sdk
LIBHAL := $(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr/lib/libhal.a
LIBGCC := $(TOOLCHAIN)/lib/gcc/xtensa-lx106-elf/4.8.5/libgcc.a
all: esptool standalone sdk .sdk_patch $(LIBHAL) $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc
@echo
@echo "Xtensa toolchain is built, to use it:"
@echo
@echo 'export PATH=$(TOOLCHAIN)/bin:$$PATH'
@echo
ifneq ($(STANDALONE),y)
@echo "Espressif ESP8266 SDK is installed. Toolchain contains only Open Source components"
@echo "To link external proprietary libraries add:"
@echo
@echo "xtensa-lx106-elf-gcc -I$(TOP)/sdk/include -L$(TOP)/sdk/lib"
@echo
else
@echo "Espressif ESP8266 SDK is installed, its libraries and headers are merged with the toolchain"
@echo
endif
esptool: toolchain
cp esptool/esptool.py $(TOOLCHAIN)/bin/
.sdk_patch: .sdk_patch_$(VENDOR_SDK) $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc
for l in sdk/lib/lib*.a; do \
$(TOOLCHAIN)/bin/xtensa-lx106-elf-objcopy \
--rename-section .text=.fast.text \
--rename-section .irom0.text=.text \
$$l; \
done
@touch $@
.sdk_patch_2.0.0:
echo -e "#undef ESP_SDK_VERSION\n#define ESP_SDK_VERSION 010502" >>$(VENDOR_SDK_DIR)/include/esp_sdk_ver.h
patch -N -d $(VENDOR_SDK_DIR_2.0.0) -p1 < c_types-c99_sdk_2.patch
@touch $@
.sdk_patch_1.5.2:
echo -e "#undef ESP_SDK_VERSION\n#define ESP_SDK_VERSION 010502" >>$(VENDOR_SDK_DIR)/include/esp_sdk_ver.h
patch -N -d $(VENDOR_SDK_DIR_1.5.2) -p1 < c_types-c99.patch
@touch $@
.sdk_patch_1.5.0:
patch -N -d $(VENDOR_SDK_DIR_1.5.0) -p1 < c_types-c99.patch
@touch $@
.sdk_patch_1.4.1:
patch -N -d $(VENDOR_SDK_DIR_1.4.1) -p1 < c_types-c99.patch
@touch $@
.sdk_patch_1.4.0:
patch -N -d $(VENDOR_SDK_DIR_1.4.0) -p1 < c_types-c99.patch
@touch $@
.sdk_patch_1.3.0:
patch -N -d $(VENDOR_SDK_DIR_1.3.0) -p1 < c_types-c99.patch
@touch $@
.sdk_patch_1.2.0: lib_mem_optimize_150714.zip libssl_patch_1.2.0-2.zip empty_user_rf_pre_init.o
#$(UNZIP) libssl_patch_1.2.0-2.zip
#$(UNZIP) libsmartconfig_2.4.2.zip
$(UNZIP) lib_mem_optimize_150714.zip
#mv libsmartconfig_2.4.2.a $(VENDOR_SDK_DIR_1.2.0)/lib/libsmartconfig.a
mv libssl.a libnet80211.a libpp.a libsmartconfig.a $(VENDOR_SDK_DIR_1.2.0)/lib/
patch -N -f -d $(VENDOR_SDK_DIR_1.2.0) -p1 < c_types-c99.patch
$(TOOLCHAIN)/bin/xtensa-lx106-elf-ar r $(VENDOR_SDK_DIR_1.2.0)/lib/libmain.a empty_user_rf_pre_init.o
@touch $@
.sdk_patch_1.1.2: scan_issue_test.zip 1.1.2_patch_02.zip empty_user_rf_pre_init.o
$(UNZIP) scan_issue_test.zip
$(UNZIP) 1.1.2_patch_02.zip
mv libmain.a libnet80211.a libpp.a $(VENDOR_SDK_DIR_1.1.2)/lib/
patch -N -f -d $(VENDOR_SDK_DIR_1.1.2) -p1 < c_types-c99.patch
$(TOOLCHAIN)/bin/xtensa-lx106-elf-ar r $(VENDOR_SDK_DIR_1.1.2)/lib/libmain.a empty_user_rf_pre_init.o
@touch $@
.sdk_patch_1.1.1: empty_user_rf_pre_init.o
patch -N -f -d $(VENDOR_SDK_DIR_1.1.1) -p1 < c_types-c99.patch
$(TOOLCHAIN)/bin/xtensa-lx106-elf-ar r $(VENDOR_SDK_DIR_1.1.1)/lib/libmain.a empty_user_rf_pre_init.o
@touch $@
.sdk_patch_1.1.0: lib_patch_on_sdk_v1.1.0.zip empty_user_rf_pre_init.o
$(UNZIP) $<
mv libsmartconfig_patch_01.a $(VENDOR_SDK_DIR_1.1.0)/lib/libsmartconfig.a
mv libmain_patch_01.a $(VENDOR_SDK_DIR_1.1.0)/lib/libmain.a
mv libssl_patch_01.a $(VENDOR_SDK_DIR_1.1.0)/lib/libssl.a
patch -N -f -d $(VENDOR_SDK_DIR_1.1.0) -p1 < c_types-c99.patch
$(TOOLCHAIN)/bin/xtensa-lx106-elf-ar r $(VENDOR_SDK_DIR_1.1.0)/lib/libmain.a empty_user_rf_pre_init.o
@touch $@
empty_user_rf_pre_init.o: empty_user_rf_pre_init.c $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc
$(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc -O2 -c $<
.sdk_patch_1.0.1: libnet80211.zip esp_iot_sdk_v1.0.1/.dir
$(UNZIP) $<
mv libnet80211.a $(VENDOR_SDK_DIR_1.0.1)/lib/
patch -N -f -d $(VENDOR_SDK_DIR_1.0.1) -p1 < c_types-c99.patch
@touch $@
.sdk_patch_1.0.1b2: libssl.zip esp_iot_sdk_v1.0.1_b2/.dir
$(UNZIP) $<
mv libssl/libssl.a $(VENDOR_SDK_DIR_1.0.1b2)/lib/
patch -N -d $(VENDOR_SDK_DIR_1.0.1b2) -p1 < c_types-c99.patch
@touch $@
.sdk_patch_1.0.1b1:
patch -N -d $(VENDOR_SDK_DIR_1.0.1b1) -p1 < c_types-c99.patch
@touch $@
.sdk_patch_1.0.0:
patch -N -d $(VENDOR_SDK_DIR_1.0.0) -p1 < c_types-c99.patch
@touch $@
.sdk_patch_0.9.6b1:
patch -N -d $(VENDOR_SDK_DIR_0.9.6b1) -p1 < c_types-c99.patch
@touch $@
.sdk_patch_0.9.5: sdk095_patch1.zip esp_iot_sdk_v0.9.5/.dir
$(UNZIP) $<
mv libmain_fix_0.9.5.a $(VENDOR_SDK_DIR)/lib/libmain.a
mv user_interface.h $(VENDOR_SDK_DIR)/include/
patch -N -d $(VENDOR_SDK_DIR_0.9.5) -p1 < c_types-c99.patch
@touch $@
.sdk_patch_0.9.4:
patch -N -d $(VENDOR_SDK_DIR_0.9.4) -p1 < c_types-c99.patch
@touch $@
.sdk_patch_0.9.3: esp_iot_sdk_v0.9.3_14_11_21_patch1.zip esp_iot_sdk_v0.9.3/.dir
$(UNZIP) $<
@touch $@
.sdk_patch_0.9.2: FRM_ERR_PATCH.rar esp_iot_sdk_v0.9.2/.dir
unrar x -o+ $<
cp FRM_ERR_PATCH/*.a $(VENDOR_SDK_DIR)/lib/
@touch $@
standalone: sdk .sdk_patch toolchain
ifeq ($(STANDALONE),y)
@echo "Installing vendor SDK headers into toolchain sysroot"
@cp -Rf sdk/include/* $(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr/include/
@echo "Installing vendor SDK libs into toolchain sysroot"
@cp -Rf sdk/lib/* $(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr/lib/
@echo "Installing vendor SDK linker scripts into toolchain sysroot"
@sed -e 's/\r//' sdk/ld/eagle.app.v6.ld | sed -e s@../ld/@@ >$(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr/lib/eagle.app.v6.ld
@sed -e 's/\r//' sdk/ld/eagle.rom.addr.v6.ld >$(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr/lib/eagle.rom.addr.v6.ld
endif
FRM_ERR_PATCH.rar:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=10"
esp_iot_sdk_v0.9.3_14_11_21_patch1.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=73"
sdk095_patch1.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=190"
libssl.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=316"
libnet80211.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=361"
lib_patch_on_sdk_v1.1.0.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=432"
scan_issue_test.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=525"
1.1.2_patch_02.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=546"
libssl_patch_1.2.0-1.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=583" -O $@
libssl_patch_1.2.0-2.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=586" -O $@
libsmartconfig_2.4.2.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=585"
lib_mem_optimize_150714.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=594"
sdk: $(VENDOR_SDK_DIR)/.dir
ln -snf $(VENDOR_SDK_DIR) sdk
$(VENDOR_SDK_DIR)/.dir: $(VENDOR_SDK_ZIP)
$(UNZIP) $^
-mv License $(VENDOR_SDK_DIR)
touch $@
ESP8266_NONOS_SDK_V2.0.0_16_08_10.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=1690"
ESP8266_NONOS_SDK_V2.0.0_16_07_19.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=1613"
ESP8266_NONOS_SDK_V1.5.2_16_01_29.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=1079"
esp_iot_sdk_v1.5.0_15_11_27.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=989"
esp_iot_sdk_v1.4.1_pre5_15_10_27.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=917"
esp_iot_sdk_v1.4.0_15_09_18.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=838"
esp_iot_sdk_v1.3.0_15_08_08.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=664"
esp_iot_sdk_v1.2.0_15_07_03.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=564"
esp_iot_sdk_v1.1.2_15_06_12.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=521"
esp_iot_sdk_v1.1.1_15_06_05.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=484"
esp_iot_sdk_v1.1.0_15_05_26.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=425"
esp_iot_sdk_v1.1.0_15_05_22.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=423"
esp_iot_sdk_v1.0.1_15_04_24.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=325"
esp_iot_sdk_v1.0.1_b2_15_04_10.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=293"
esp_iot_sdk_v1.0.1_b1_15_04_02.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=276"
esp_iot_sdk_v1.0.0_15_03_20.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=250"
esp_iot_sdk_v0.9.6_b1_15_02_15.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=220"
esp_iot_sdk_v0.9.5_15_01_23.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=189"
esp_iot_sdk_v0.9.4_14_12_19.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=111"
esp_iot_sdk_v0.9.3_14_11_21.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=72"
esp_iot_sdk_v0.9.2_14_10_24.zip:
wget --content-disposition "http://bbs.espressif.com/download/file.php?id=9"
libhal: $(LIBHAL) .patch_libhal
$(LIBHAL): $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc
make -C lx106-hal -f ../Makefile _libhal
.patch_libhal: $(LIBHAL)
$(TOOLCHAIN)/bin/xtensa-lx106-elf-objcopy \
--rename-section .text=.fast.text \
$(LIBHAL)
@touch $@
_libhal:
autoreconf -i
PATH=$(TOOLCHAIN)/bin:$(PATH) ./configure --host=xtensa-lx106-elf --prefix=$(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr
PATH=$(TOOLCHAIN)/bin:$(PATH) make
PATH=$(TOOLCHAIN)/bin:$(PATH) make install
toolchain: $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc .patch_libgcc
$(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc: crosstool-NG/ct-ng
cp -f 1000-mforce-l32.patch crosstool-NG/local-patches/gcc/4.8.5/
make -C crosstool-NG -f ../Makefile _toolchain
.patch_libgcc: $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc
$(TOOLCHAIN)/bin/xtensa-lx106-elf-objcopy \
--rename-section .text=.fast.text \
$(LIBGCC)
@touch $@
_toolchain:
./ct-ng xtensa-lx106-elf
sed -r -i.org s%CT_PREFIX_DIR=.*%CT_PREFIX_DIR="$(TOOLCHAIN)"% .config
sed -r -i s%CT_INSTALL_DIR_RO=y%"#"CT_INSTALL_DIR_RO=y% .config
cat ../crosstool-config-overrides >> .config
rm -f local-patches/gdb/7.5.1/*
./ct-ng build
crosstool-NG: crosstool-NG/ct-ng
crosstool-NG/ct-ng: crosstool-NG/bootstrap
cp *-newlib-*.patch crosstool-NG/local-patches/newlib/2.0.0
cp *-libgcc-*.patch crosstool-NG/local-patches/gcc/4.8.5
make -C crosstool-NG -f ../Makefile _ct-ng
_ct-ng:
./bootstrap
./configure --prefix=`pwd`
make MAKELEVEL=0
make install MAKELEVEL=0
crosstool-NG/bootstrap:
@echo "You cloned without --recursive, fetching submodules for you."
git submodule update --init --recursive
clean: clean-sdk
make -C crosstool-NG clean MAKELEVEL=0
-rm -rf crosstool-NG/.build/src
-rm -rf $(TOOLCHAIN)
clean-sdk:
rm -rf $(VENDOR_SDK_DIR)
rm -f sdk
rm -f .sdk_patch_$(VENDOR_SDK)
clean-sysroot:
rm -rf $(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr/lib/*
rm -rf $(TOOLCHAIN)/xtensa-lx106-elf/sysroot/usr/include/*