summaryrefslogtreecommitdiffstats
path: root/polycom_recv/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'polycom_recv/Makefile')
-rw-r--r--polycom_recv/Makefile298
1 files changed, 298 insertions, 0 deletions
diff --git a/polycom_recv/Makefile b/polycom_recv/Makefile
new file mode 100644
index 0000000..5103815
--- /dev/null
+++ b/polycom_recv/Makefile
@@ -0,0 +1,298 @@
+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/ttyUSB0
+#BAUD=-b 921600
+#BAUD=-b 460800
+#BAUD=-b 200000
+#BAUD=-b 9600
+
+#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}
+
+
+