2014-11-27 15:30:33 -05:00
|
|
|
include ../py/mkenv.mk
|
|
|
|
|
|
|
|
# qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h
|
|
|
|
|
|
|
|
# include py core make definitions
|
|
|
|
include ../py/py.mk
|
|
|
|
|
2015-05-05 18:19:26 -04:00
|
|
|
MAKE_FROZEN = ../tools/make-frozen.py
|
|
|
|
|
|
|
|
SCRIPTDIR = scripts
|
2015-12-22 05:44:08 -05:00
|
|
|
PORT ?= /dev/ttyACM0
|
2015-12-30 13:37:58 -05:00
|
|
|
BAUD ?= 115200
|
2014-11-27 15:30:33 -05:00
|
|
|
CROSS_COMPILE = xtensa-lx106-elf-
|
2014-11-28 13:05:25 -05:00
|
|
|
ESP_SDK = $(shell $(CC) -print-sysroot)/usr
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2015-10-19 11:22:16 -04:00
|
|
|
INC += -I.
|
2014-12-28 20:02:19 -05:00
|
|
|
INC += -I..
|
2014-11-27 15:30:33 -05:00
|
|
|
INC += -I../stmhal
|
2015-01-11 21:21:58 -05:00
|
|
|
INC += -I../lib/mp-readline
|
2015-05-02 15:24:25 -04:00
|
|
|
INC += -I../lib/netutils
|
2015-05-11 15:11:37 -04:00
|
|
|
INC += -I../lib/timeutils
|
2014-11-27 15:30:33 -05:00
|
|
|
INC += -I$(BUILD)
|
|
|
|
INC += -I$(ESP_SDK)/include
|
|
|
|
|
2015-05-13 09:39:25 -04:00
|
|
|
UART_OS = 1
|
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
CFLAGS_XTENSA = -fsingle-precision-constant -Wdouble-promotion \
|
|
|
|
-D__ets__ -DICACHE_FLASH \
|
|
|
|
-fno-inline-functions \
|
|
|
|
-Wl,-EL -mlongcalls -mtext-section-literals \
|
2016-03-07 22:29:05 -05:00
|
|
|
-DLWIP_OPEN_SRC
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2015-05-13 09:39:25 -04:00
|
|
|
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
|
2016-01-07 18:30:06 -05:00
|
|
|
$(CFLAGS_XTENSA) $(COPT) $(CFLAGS_EXTRA)
|
2014-11-27 15:30:33 -05:00
|
|
|
|
|
|
|
LDFLAGS = -nostdlib -T esp8266.ld -Map=$(@:.elf=.map) --cref
|
2015-12-31 09:09:00 -05:00
|
|
|
LIBS = -L$(ESP_SDK)/lib -lmain -ljson -lssl -llwip -lpp -lnet80211 -lwpa -lphy -lnet80211
|
2014-11-27 15:30:33 -05:00
|
|
|
|
|
|
|
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
2014-11-28 09:58:25 -05:00
|
|
|
LIBS += -L$(dir $(LIBGCC_FILE_NAME)) -lgcc
|
2014-11-27 15:30:33 -05:00
|
|
|
|
|
|
|
# Debugging/Optimization
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CFLAGS += -g
|
|
|
|
COPT = -O0
|
|
|
|
else
|
|
|
|
CFLAGS += -fdata-sections -ffunction-sections
|
|
|
|
COPT += -Os -DNDEBUG
|
|
|
|
LDFLAGS += --gc-sections
|
|
|
|
endif
|
|
|
|
|
|
|
|
SRC_C = \
|
2014-11-28 09:58:25 -05:00
|
|
|
strtoll.c \
|
2014-11-27 15:30:33 -05:00
|
|
|
main.c \
|
|
|
|
esp_mphal.c \
|
|
|
|
gccollect.c \
|
|
|
|
uart.c \
|
|
|
|
modpyb.c \
|
2015-02-13 17:21:44 -05:00
|
|
|
modpybpin.c \
|
2015-05-11 15:11:37 -04:00
|
|
|
modpybrtc.c \
|
2015-05-18 12:35:56 -04:00
|
|
|
modpybadc.c \
|
2015-01-22 17:34:16 -05:00
|
|
|
modesp.c \
|
2015-06-12 10:16:52 -04:00
|
|
|
modnetwork.c \
|
2015-05-11 15:11:37 -04:00
|
|
|
modutime.c \
|
2015-05-18 12:35:25 -04:00
|
|
|
moduos.c \
|
2015-12-30 17:52:01 -05:00
|
|
|
modmachine.c \
|
2015-05-02 15:24:25 -04:00
|
|
|
utils.c \
|
2015-05-05 18:19:26 -04:00
|
|
|
$(BUILD)/frozen.c \
|
2015-12-28 05:23:30 -05:00
|
|
|
../extmod/modlwip.o \
|
2014-11-27 15:30:33 -05:00
|
|
|
|
|
|
|
STM_SRC_C = $(addprefix stmhal/,\
|
2015-02-13 10:04:53 -05:00
|
|
|
pybstdio.c \
|
2015-01-11 21:21:58 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
LIB_SRC_C = $(addprefix lib/,\
|
2015-04-05 14:44:20 -04:00
|
|
|
libc/string0.c \
|
2015-12-18 16:07:58 -05:00
|
|
|
libm/math.c \
|
|
|
|
libm/fmodf.c \
|
|
|
|
libm/roundf.c \
|
|
|
|
libm/ef_sqrt.c \
|
2015-12-18 16:43:01 -05:00
|
|
|
libm/kf_rem_pio2.c \
|
|
|
|
libm/kf_sin.c \
|
|
|
|
libm/kf_cos.c \
|
|
|
|
libm/kf_tan.c \
|
|
|
|
libm/ef_rem_pio2.c \
|
|
|
|
libm/sf_sin.c \
|
|
|
|
libm/sf_cos.c \
|
|
|
|
libm/sf_tan.c \
|
|
|
|
libm/sf_frexp.c \
|
|
|
|
libm/sf_modf.c \
|
|
|
|
libm/sf_ldexp.c \
|
|
|
|
libm/asinfacosf.c \
|
|
|
|
libm/atanf.c \
|
|
|
|
libm/atan2f.c \
|
2015-01-11 21:21:58 -05:00
|
|
|
mp-readline/readline.c \
|
2015-05-02 15:24:25 -04:00
|
|
|
netutils/netutils.c \
|
2015-05-11 15:11:37 -04:00
|
|
|
timeutils/timeutils.c \
|
2015-10-31 12:35:10 -04:00
|
|
|
utils/pyexec.c \
|
2015-11-10 11:57:45 -05:00
|
|
|
utils/printf.c \
|
2014-11-27 15:30:33 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
SRC_S = \
|
|
|
|
gchelper.s \
|
|
|
|
|
|
|
|
OBJ =
|
|
|
|
OBJ += $(PY_O)
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
|
2015-01-11 21:21:58 -05:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
|
2014-11-27 15:30:33 -05:00
|
|
|
#OBJ += $(BUILD)/pins_$(BOARD).o
|
|
|
|
|
|
|
|
all: $(BUILD)/firmware-combined.bin
|
|
|
|
|
2015-05-13 09:39:25 -04:00
|
|
|
CONFVARS_FILE = $(BUILD)/confvars
|
2015-05-05 18:19:26 -04:00
|
|
|
|
2015-05-13 09:39:25 -04:00
|
|
|
ifeq ($(wildcard $(CONFVARS_FILE)),)
|
2015-05-05 18:19:26 -04:00
|
|
|
$(shell $(MKDIR) -p $(BUILD))
|
2015-05-13 09:39:25 -04:00
|
|
|
$(shell echo $(SCRIPTDIR) $(UART_OS) > $(CONFVARS_FILE))
|
|
|
|
else ifneq ($(shell cat $(CONFVARS_FILE)), $(SCRIPTDIR) $(UART_OS))
|
|
|
|
$(shell echo $(SCRIPTDIR) $(UART_OS) > $(CONFVARS_FILE))
|
2015-05-05 18:19:26 -04:00
|
|
|
endif
|
|
|
|
|
2015-05-13 09:39:25 -04:00
|
|
|
$(BUILD)/uart.o: $(CONFVARS_FILE)
|
|
|
|
|
|
|
|
$(BUILD)/frozen.c: $(wildcard $(SCRIPTDIR)/*) $(CONFVARS_FILE)
|
2015-05-05 18:19:26 -04:00
|
|
|
$(ECHO) "Generating $@"
|
|
|
|
$(Q)$(MAKE_FROZEN) $(SCRIPTDIR) > $@
|
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
.PHONY: deploy
|
|
|
|
|
|
|
|
deploy: $(BUILD)/firmware-combined.bin
|
|
|
|
$(ECHO) "Writing $< to the board"
|
2014-11-28 05:22:01 -05:00
|
|
|
#$(Q)esptool.py --port $(PORT) write_flash 0 $<
|
2015-09-12 17:22:30 -04:00
|
|
|
$(Q)esptool.py --port $(PORT) --baud $(BAUD) write_flash 0 $(BUILD)/firmware.elf-0x00000.bin 0x10000 $(BUILD)/firmware.elf-0x10000.bin
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2015-01-30 17:51:12 -05:00
|
|
|
reset:
|
|
|
|
echo -e "\r\nimport pyb; pyb.hard_reset()\r\n" >$(PORT)
|
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
$(BUILD)/firmware-combined.bin: $(BUILD)/firmware.elf
|
|
|
|
$(ECHO) "Create $@"
|
|
|
|
$(Q)esptool.py elf2image $^
|
|
|
|
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x10000.bin $@
|
|
|
|
|
|
|
|
$(BUILD)/firmware.elf: $(OBJ)
|
|
|
|
$(ECHO) "LINK $@"
|
2015-10-23 19:26:10 -04:00
|
|
|
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
2014-11-27 15:30:33 -05:00
|
|
|
$(Q)$(SIZE) $@
|
|
|
|
|
|
|
|
#MAKE_PINS = boards/make-pins.py
|
|
|
|
#BOARD_PINS = boards/$(BOARD)/pins.csv
|
|
|
|
#AF_FILE = boards/stm32f4xx_af.csv
|
|
|
|
#PREFIX_FILE = boards/stm32f4xx_prefix.c
|
|
|
|
#GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c
|
|
|
|
#GEN_PINS_HDR = $(HEADER_BUILD)/pins.h
|
|
|
|
#GEN_PINS_QSTR = $(BUILD)/pins_qstr.h
|
|
|
|
#GEN_PINS_AF_CONST = $(HEADER_BUILD)/pins_af_const.h
|
|
|
|
#GEN_PINS_AF_PY = $(BUILD)/pins_af.py
|
|
|
|
|
|
|
|
# Making OBJ use an order-only depenedency on the generated pins.h file
|
|
|
|
# has the side effect of making the pins.h file before we actually compile
|
|
|
|
# any of the objects. The normal dependency generation will deal with the
|
|
|
|
# case when pins.h is modified. But when it doesn't exist, we don't know
|
|
|
|
# which source files might need it.
|
|
|
|
#$(OBJ): | $(HEADER_BUILD)/pins.h
|
|
|
|
|
|
|
|
# Use a pattern rule here so that make will only call make-pins.py once to make
|
|
|
|
# both pins_$(BOARD).c and pins.h
|
|
|
|
#$(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_af_const.h $(BUILD)/%_qstr.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
|
|
|
|
# $(ECHO) "Create $@"
|
|
|
|
# $(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --qstr $(GEN_PINS_QSTR) --af-const $(GEN_PINS_AF_CONST) --af-py $(GEN_PINS_AF_PY) > $(GEN_PINS_SRC)
|
|
|
|
#
|
|
|
|
#$(BUILD)/pins_$(BOARD).o: $(BUILD)/pins_$(BOARD).c
|
|
|
|
# $(call compile_c)
|
|
|
|
|
|
|
|
include ../py/mkrules.mk
|