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
|
OPT=-Os -g -O2
WARN=-Wpointer-arith -Wundef -Werror
DEFS=-DICACHE_FLASH
INCLUDES=-Idummy
GCCFLAGS=-fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections
PORT=/dev/ttyUSB1
#BAUD=-b 921600
#BAUD=-b 460800
#BAUD=-b 200000
#BOOT=none
BOOT=new
SPI_SPEED=40
SPI_MODE=QIO
SPI_SIZE_MAP=512
#esptool.py write_flash 0x00000 ../bin/eagle.flash.bin 0x40000 ../bin/eagle.irom0text.bin || exit 1
PROG=polycom_xmit
PROG0=${PROG}.0
PROG1=${PROG}.1
PROG2=${PROG}.2
SRC=main.c webserver.c util.c reset.c wifi.c uart.c upgrade.c gpio.c msg.c mdns.c
UART_BAUD=115200
default: flash.stamp
sympathy -b ${UART_BAUD} -d ${PORT} -t -L log
view:
sympathy -b ${UART_BAUD} -d ${PORT} -t -L log
flash:flash.stamp
sympathy -b ${UART_BAUD} -d ${PORT} -t -L log
flash.stamp: user0.bin
${EPSTOOL} ${BAUD} --port ${PORT} write_flash 0x00000 user0.bin 0x40000 user0/eagle.app.v6.irom0text.bin
touch $@
flash1:flash1.stamp
sympathy -b 115200 -d ${PORT} -t -L log
flash1.stamp: user1.bin ${BLANK_BIN} ${BOOT_BIN}
${EPSTOOL} ${BAUD} --port ${PORT} write_flash 0x00000 "${BOOT_BIN}" 0x01000 user1.bin 0x7c000 ${BLANK_BIN}
touch $@
put: put.stamp
put.stamp: user1.bin user2.bin
scp user1.bin user2.bin global:/var/www/esp8266/
clean:
/bin/rm -f ${OBJ} ${PROG0} ${PROG1} ${PROG2} out.stamp flash.stamp put.stamp user0.bin user1.bin user2.bin flash1.stamp *~
/bin/rm -rf user0 user1 user2
protos:
echo -n > prototypes.h
cproto -v -E "${CC} -E" ${CPPFLAGS} ${SRC} > prototypes.h.tmp
mv -f prototypes.h.tmp prototypes.h
tidy:
indent -i2 -ts0 ${SRC}
########################################################################################33
SDK=/usr/xtensa-lx106-elf/esp-8266-sdk
LDDIR=${SDK}/ld/
BOOT_BIN=${SDK}/bin/boot_v1.4(b1).bin
BLANK_BIN=${SDK}/bin/blank.bin
CROSS=xtensa-lx106-elf-
EPSTOOL=esptool.py
CC=${CROSS}cc
AR=${CROSS}ar
OBJDUMP=${CROSS}objdump
OBJCOPY=${CROSS}objcopy
GENAPPBIN=${CROSS}gen_appbin.py
CPROTO=cproto
BOOT?=none
SPI_SPEED?=40
SPI_MODE?=QIO
SPI_SIZE_MAP?=0
ifeq ($(BOOT), new)
boot = new
else
ifeq ($(BOOT), old)
boot = old
else
boot = none
endif
endif
ifeq ($(SPI_SPEED), 26.7)
freqdiv = 1
else
ifeq ($(SPI_SPEED), 20)
freqdiv = 2
else
ifeq ($(SPI_SPEED), 80)
freqdiv = 15
else
freqdiv = 0
endif
endif
endif
ifeq ($(SPI_MODE), QOUT)
mode = 1
else
ifeq ($(SPI_MODE), DIO)
mode = 2
else
ifeq ($(SPI_MODE), DOUT)
mode = 3
else
mode = 0
endif
endif
endif
addr0 = 0x01000
addr1 = 0x01000
ifeq ($(SPI_SIZE_MAP), 1)
size_map = 1
flash = 256
else
ifeq ($(SPI_SIZE_MAP), 2)
size_map = 2
flash = 1024
addr2 = 0x81000
else
ifeq ($(SPI_SIZE_MAP), 3)
size_map = 3
flash = 2048
addr2 = 0x81000
else
ifeq ($(SPI_SIZE_MAP), 4)
size_map = 4
flash = 4096
addr2 = 0x81000
else
ifeq ($(SPI_SIZE_MAP), 5)
size_map = 5
flash = 2048
addr2 = 0x101000
else
ifeq ($(SPI_SIZE_MAP), 6)
size_map = 6
flash = 4096
addr2 = 0x101000
else
size_map = 0
flash = 512
addr2 = 0x41000
endif
endif
endif
endif
endif
endif
flash_b=$(shell echo $(flash) \* 1024 | bc )
hflash_b=$(shell echo $(flash) \* 512 | bc )
LD_FILE0 = $(LDDIR)/eagle.app.v6.ld
LD_FILE1 = i-dont-exist
LD_FILE2 = i-dont-exist
ifneq ($(boot), none)
ifeq ($(size_map), 6)
LD_FILE1 = $(LDDIR)/eagle.app.v6.$(boot).2048.ld
LD_FILE2 = $(LDDIR)/eagle.app.v6.$(boot).2048.ld
else
ifeq ($(size_map), 5)
LD_FILE1 = $(LDDIR)/eagle.app.v6.$(boot).2048.ld
LD_FILE2 = $(LDDIR)/eagle.app.v6.$(boot).2048.ld
else
ifeq ($(size_map), 4)
LD_FILE1 = $(LDDIR)/eagle.app.v6.$(boot).1024.app1.ld
LD_FILE2 = $(LDDIR)/eagle.app.v6.$(boot).1024.app2.ld
else
ifeq ($(size_map), 3)
LD_FILE1 = $(LDDIR)/eagle.app.v6.$(boot).1024.app1.ld
LD_FILE2 = $(LDDIR)/eagle.app.v6.$(boot).1024.app2.ld
else
ifeq ($(size_map), 2)
LD_FILE1 = $(LDDIR)/eagle.app.v6.$(boot).1024.app1.ld
LD_FILE2 = $(LDDIR)/eagle.app.v6.$(boot).1024.app2.ld
else
ifeq ($(size_map), 0)
LD_FILE1 = $(LDDIR)/eagle.app.v6.$(boot).512.app1.ld
LD_FILE2 = $(LDDIR)/eagle.app.v6.$(boot).512.app2.ld
endif
endif
endif
endif
endif
endif
endif
user0.bin:${PROG0}
rm -rf user0
mkdir -p user0
$(OBJDUMP) -x -s $< > user0/eagle.dump
$(OBJDUMP) -S $< > user0/eagle.S
$(OBJCOPY) --only-section .text -O binary $< user0/eagle.app.v6.text.bin
$(OBJCOPY) --only-section .data -O binary $< user0/eagle.app.v6.data.bin
$(OBJCOPY) --only-section .rodata -O binary $< user0/eagle.app.v6.rodata.bin
$(OBJCOPY) --only-section .irom0.text -O binary $< user0/eagle.app.v6.irom0text.bin
(cd user0 && ${GENAPPBIN} ../$< 0 $(mode) $(freqdiv) $(size_map) )
cp user0/eagle.app.flash.bin user0.bin
@echo "** user0.bin uses $$(stat -c '%s' $@) bytes of" $(flash_b) "available"0
if [ $$(stat -c '%s' $@) -gt $$(( $(flash_b) )) ]; then echo "$@ too big!"; false; fi
user1.bin:${PROG1}
rm -rf user1
mkdir -p user1
$(OBJDUMP) -x -s $< > user1/eagle.dump
$(OBJDUMP) -S $< > user1/eagle.S
$(OBJCOPY) --only-section .text -O binary $< user1/eagle.app.v6.text.bin
$(OBJCOPY) --only-section .data -O binary $< user1/eagle.app.v6.data.bin
$(OBJCOPY) --only-section .rodata -O binary $< user1/eagle.app.v6.rodata.bin
$(OBJCOPY) --only-section .irom0.text -O binary $< user1/eagle.app.v6.irom0text.bin
(cd user1 && ${GENAPPBIN} ../$< 1 $(mode) $(freqdiv) $(size_map) )
cp user1/eagle.app.flash.bin user1.bin
@echo "** user1.bin uses $$(stat -c '%s' $@) bytes of" $(hflash_b) "available"0
if [ $$(stat -c '%s' $@) -gt $$(( $(hflash_b) )) ]; then echo "$@ too big!"; false; fi
user2.bin:${PROG2}
rm -rf user2
mkdir -p user2
$(OBJDUMP) -x -s $< > user2/eagle.dump
$(OBJDUMP) -S $< > user2/eagle.S
$(OBJCOPY) --only-section .text -O binary $< user2/eagle.app.v6.text.bin
$(OBJCOPY) --only-section .data -O binary $< user2/eagle.app.v6.data.bin
$(OBJCOPY) --only-section .rodata -O binary $< user2/eagle.app.v6.rodata.bin
$(OBJCOPY) --only-section .irom0.text -O binary $< user2/eagle.app.v6.irom0text.bin
(cd user2 && ${GENAPPBIN} ../$< 2 $(mode) $(freqdiv) $(size_map) )
cp user2/eagle.app.flash.bin user2.bin
if [ $$(stat -c '%s' $@) -gt $$(( $(hflash_b) )) ]; then echo "$@ too big!"; false; fi
CFLAGS=${GCCFLAGS} ${WARN} ${OPT} ${CPPFLAGS}
CPPFLAGS=${DEFS} ${INCLUDES}
OBJ=${SRC:%.c=%.o}
LDFLAGS= -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,-EL
LIBS=-Wl,--start-group -lc -lgcc -lhal -lphy -lpp -lnet80211 -llwip -lwpa -lmain -ljson -lupgrade -lssl -lpwm -lsmartconfig ${OBJ} -Wl,--end-group
%.o:%.c
${CC} ${CFLAGS} ${CPPFLAGS} -c -o $@ $<
${PROG0}: ${OBJ} ${LD_FILE0}
${CC} -o ${PROG0} -T${LD_FILE0} ${CFLAGS} ${LDFLAGS} ${LIBS}
${PROG1}: ${OBJ} ${LD_FILE1}
${CC} -o ${PROG1} -T${LD_FILE1} ${CFLAGS} ${LDFLAGS} ${LIBS}
${PROG2}: ${OBJ} ${LD_FILE2}
${CC} -o ${PROG2} -T${LD_FILE2} ${CFLAGS} ${LDFLAGS} ${LIBS}
|