2014-11-27 20:30:33 +00:00
|
|
|
include ../py/mkenv.mk
|
|
|
|
|
|
|
|
# qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h
|
|
|
|
|
2016-04-27 22:46:51 +01:00
|
|
|
MICROPY_PY_USSL = 1
|
2016-07-12 23:59:41 +01:00
|
|
|
MICROPY_SSL_AXTLS = 1
|
2016-07-31 00:39:59 +01:00
|
|
|
MICROPY_PY_BTREE = 1
|
2016-04-27 22:46:51 +01:00
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
# include py core make definitions
|
|
|
|
include ../py/py.mk
|
|
|
|
|
2016-05-11 16:57:29 +01:00
|
|
|
MPY_CROSS = ../mpy-cross/mpy-cross
|
|
|
|
MPY_TOOL = ../tools/mpy-tool.py
|
2015-05-05 23:19:26 +01:00
|
|
|
MAKE_FROZEN = ../tools/make-frozen.py
|
|
|
|
|
|
|
|
SCRIPTDIR = scripts
|
2016-05-11 16:57:29 +01:00
|
|
|
FROZEN_MPY_DIR = modules
|
2015-12-22 10:44:08 +00:00
|
|
|
PORT ?= /dev/ttyACM0
|
2015-12-30 18:37:58 +00:00
|
|
|
BAUD ?= 115200
|
2014-11-27 20:30:33 +00:00
|
|
|
CROSS_COMPILE = xtensa-lx106-elf-
|
2014-11-28 18:05:25 +00:00
|
|
|
ESP_SDK = $(shell $(CC) -print-sysroot)/usr
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2015-10-19 16:22:16 +01:00
|
|
|
INC += -I.
|
2014-12-29 01:02:19 +00:00
|
|
|
INC += -I..
|
2014-11-27 20:30:33 +00:00
|
|
|
INC += -I../stmhal
|
2015-01-12 02:21:58 +00:00
|
|
|
INC += -I../lib/mp-readline
|
2015-05-02 20:24:25 +01:00
|
|
|
INC += -I../lib/netutils
|
2015-05-11 20:11:37 +01:00
|
|
|
INC += -I../lib/timeutils
|
2014-11-27 20:30:33 +00:00
|
|
|
INC += -I$(BUILD)
|
|
|
|
INC += -I$(ESP_SDK)/include
|
|
|
|
|
2016-03-29 19:10:10 +01:00
|
|
|
# UART for "os" messages. 0 is normal UART as used by MicroPython REPL,
|
2016-05-26 22:44:05 +01:00
|
|
|
# 1 is debug UART (tx only), -1 to disable.
|
2016-03-29 19:10:10 +01:00
|
|
|
UART_OS = 0
|
2015-05-13 14:39:25 +01:00
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
CFLAGS_XTENSA = -fsingle-precision-constant -Wdouble-promotion \
|
|
|
|
-D__ets__ -DICACHE_FLASH \
|
|
|
|
-fno-inline-functions \
|
2016-04-26 22:35:13 +01:00
|
|
|
-Wl,-EL -mlongcalls -mtext-section-literals -mforce-l32 \
|
2016-03-08 03:29:05 +00:00
|
|
|
-DLWIP_OPEN_SRC
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2015-05-13 14:39:25 +01:00
|
|
|
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
|
2016-04-27 22:44:52 +01:00
|
|
|
$(CFLAGS_XTENSA) $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
|
2014-11-27 20:30:33 +00:00
|
|
|
|
|
|
|
LDFLAGS = -nostdlib -T esp8266.ld -Map=$(@:.elf=.map) --cref
|
2016-04-27 22:44:52 +01:00
|
|
|
LIBS = -L$(ESP_SDK)/lib -lmain -ljson -llwip_open -lpp -lnet80211 -lwpa -lphy -lnet80211 $(LDFLAGS_MOD)
|
2014-11-27 20:30:33 +00:00
|
|
|
|
|
|
|
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
2014-11-28 14:58:25 +00:00
|
|
|
LIBS += -L$(dir $(LIBGCC_FILE_NAME)) -lgcc
|
2014-11-27 20:30:33 +00:00
|
|
|
|
|
|
|
# Debugging/Optimization
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CFLAGS += -g
|
|
|
|
COPT = -O0
|
|
|
|
else
|
|
|
|
CFLAGS += -fdata-sections -ffunction-sections
|
2016-04-26 22:35:13 +01:00
|
|
|
COPT += -Os -DNDEBUG
|
2014-11-27 20:30:33 +00:00
|
|
|
LDFLAGS += --gc-sections
|
|
|
|
endif
|
|
|
|
|
|
|
|
SRC_C = \
|
2014-11-28 14:58:25 +00:00
|
|
|
strtoll.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
main.c \
|
2016-04-28 22:17:11 +01:00
|
|
|
help.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
esp_mphal.c \
|
|
|
|
gccollect.c \
|
2016-03-17 15:06:47 +00:00
|
|
|
lexerstr32.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
uart.c \
|
2016-03-02 13:37:27 +00:00
|
|
|
esppwm.c \
|
2016-04-14 12:33:54 +01:00
|
|
|
esponewire.c \
|
2016-02-11 13:19:11 +00:00
|
|
|
espneopixel.c \
|
2016-03-28 00:58:14 +01:00
|
|
|
espapa102.c \
|
2016-04-14 11:15:43 +01:00
|
|
|
intr.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
modpyb.c \
|
2015-02-13 22:21:44 +00:00
|
|
|
modpybpin.c \
|
2016-03-02 13:37:27 +00:00
|
|
|
modpybpwm.c \
|
2015-05-11 20:11:37 +01:00
|
|
|
modpybrtc.c \
|
2015-05-18 17:35:56 +01:00
|
|
|
modpybadc.c \
|
2016-04-06 17:45:52 +01:00
|
|
|
modpybuart.c \
|
2016-03-01 22:53:23 +00:00
|
|
|
modpybspi.c \
|
2016-06-07 20:40:56 +01:00
|
|
|
modpybhspi.c \
|
2015-01-22 22:34:16 +00:00
|
|
|
modesp.c \
|
2015-06-12 15:16:52 +01:00
|
|
|
modnetwork.c \
|
2015-05-11 20:11:37 +01:00
|
|
|
modutime.c \
|
2015-05-18 17:35:25 +01:00
|
|
|
moduos.c \
|
2015-12-30 22:52:01 +00:00
|
|
|
modmachine.c \
|
2015-12-29 00:20:34 +00:00
|
|
|
modonewire.c \
|
2016-03-11 02:43:39 +00:00
|
|
|
ets_alt_task.c \
|
2015-05-05 23:19:26 +01:00
|
|
|
$(BUILD)/frozen.c \
|
2016-04-16 12:47:17 +01:00
|
|
|
fatfs_port.c \
|
2016-04-27 11:45:44 +01:00
|
|
|
axtls_helpers.c \
|
2016-06-07 20:40:56 +01:00
|
|
|
hspi.c \
|
2016-07-31 00:39:59 +01:00
|
|
|
$(SRC_MOD)
|
2014-11-27 20:30:33 +00:00
|
|
|
|
|
|
|
STM_SRC_C = $(addprefix stmhal/,\
|
2015-02-13 15:04:53 +00:00
|
|
|
pybstdio.c \
|
2016-04-14 22:08:39 +01:00
|
|
|
input.c \
|
2015-01-12 02:21:58 +00:00
|
|
|
)
|
|
|
|
|
2016-01-01 16:12:39 +00:00
|
|
|
EXTMOD_SRC_C = $(addprefix extmod/,\
|
2016-04-16 12:47:17 +01:00
|
|
|
modlwip.c \
|
2016-01-01 16:12:39 +00:00
|
|
|
)
|
|
|
|
|
2015-01-12 02:21:58 +00:00
|
|
|
LIB_SRC_C = $(addprefix lib/,\
|
2015-04-05 19:44:20 +01:00
|
|
|
libc/string0.c \
|
2015-12-18 21:07:58 +00:00
|
|
|
libm/math.c \
|
|
|
|
libm/fmodf.c \
|
|
|
|
libm/roundf.c \
|
|
|
|
libm/ef_sqrt.c \
|
2015-12-18 21:43:01 +00: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-12 02:21:58 +00:00
|
|
|
mp-readline/readline.c \
|
2015-05-02 20:24:25 +01:00
|
|
|
netutils/netutils.c \
|
2015-05-11 20:11:37 +01:00
|
|
|
timeutils/timeutils.c \
|
2015-10-31 16:35:10 +00:00
|
|
|
utils/pyexec.c \
|
2016-04-28 22:17:11 +01:00
|
|
|
utils/pyhelp.c \
|
2015-11-10 16:57:45 +00:00
|
|
|
utils/printf.c \
|
2016-03-27 15:13:47 +01:00
|
|
|
fatfs/ff.c \
|
|
|
|
fatfs/option/ccsbcs.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
)
|
|
|
|
|
2016-05-26 17:11:43 +01:00
|
|
|
DRIVERS_SRC_C = $(addprefix drivers/,\
|
|
|
|
dht/dht.c \
|
|
|
|
)
|
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
SRC_S = \
|
|
|
|
gchelper.s \
|
|
|
|
|
2016-05-11 16:57:29 +01:00
|
|
|
FROZEN_MPY_PY_FILES := $(shell find $(FROZEN_MPY_DIR)/ -type f -name '*.py')
|
|
|
|
FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy))
|
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
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))
|
2016-01-01 16:12:39 +00:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o))
|
2015-01-12 02:21:58 +00:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
|
2016-05-26 17:11:43 +01:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o))
|
2016-05-11 16:57:29 +01:00
|
|
|
OBJ += $(BUILD)/$(BUILD)/frozen_mpy.o
|
2014-11-27 20:30:33 +00:00
|
|
|
#OBJ += $(BUILD)/pins_$(BOARD).o
|
|
|
|
|
2016-04-16 12:47:17 +01:00
|
|
|
# List of sources for qstr extraction
|
2016-05-26 17:11:43 +01:00
|
|
|
SRC_QSTR += $(SRC_C) $(STM_SRC_C) $(EXTMOD_SRC_C) $(DRIVERS_SRC_C)
|
2016-04-16 12:47:17 +01:00
|
|
|
# Append any auto-generated sources that are needed by sources listed in SRC_QSTR
|
|
|
|
SRC_QSTR_AUTO_DEPS +=
|
|
|
|
|
2016-07-16 02:53:33 +01:00
|
|
|
all: $(BUILD)/libaxtls.a $(BUILD)/firmware-combined.bin
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2015-05-13 14:39:25 +01:00
|
|
|
CONFVARS_FILE = $(BUILD)/confvars
|
2015-05-05 23:19:26 +01:00
|
|
|
|
2015-05-13 14:39:25 +01:00
|
|
|
ifeq ($(wildcard $(CONFVARS_FILE)),)
|
2015-05-05 23:19:26 +01:00
|
|
|
$(shell $(MKDIR) -p $(BUILD))
|
2015-05-13 14:39:25 +01: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 23:19:26 +01:00
|
|
|
endif
|
|
|
|
|
2015-05-13 14:39:25 +01:00
|
|
|
$(BUILD)/uart.o: $(CONFVARS_FILE)
|
|
|
|
|
|
|
|
$(BUILD)/frozen.c: $(wildcard $(SCRIPTDIR)/*) $(CONFVARS_FILE)
|
2015-05-05 23:19:26 +01:00
|
|
|
$(ECHO) "Generating $@"
|
|
|
|
$(Q)$(MAKE_FROZEN) $(SCRIPTDIR) > $@
|
|
|
|
|
2016-05-11 16:57:29 +01:00
|
|
|
# to build .mpy files from .py files
|
|
|
|
$(BUILD)/$(FROZEN_MPY_DIR)/%.mpy: $(FROZEN_MPY_DIR)/%.py
|
|
|
|
@$(ECHO) "MPY $<"
|
|
|
|
$(Q)$(MKDIR) -p $(dir $@)
|
|
|
|
$(Q)$(MPY_CROSS) -o $@ -s $(^:$(FROZEN_MPY_DIR)/%=%) $^
|
|
|
|
|
|
|
|
# to build frozen_mpy.c from all .mpy files
|
|
|
|
$(BUILD)/frozen_mpy.c: $(FROZEN_MPY_MPY_FILES) $(BUILD)/genhdr/qstrdefs.generated.h
|
|
|
|
@$(ECHO) "Creating $@"
|
|
|
|
$(Q)$(PYTHON) $(MPY_TOOL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $(FROZEN_MPY_MPY_FILES) > $@
|
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
.PHONY: deploy
|
|
|
|
|
|
|
|
deploy: $(BUILD)/firmware-combined.bin
|
|
|
|
$(ECHO) "Writing $< to the board"
|
2016-06-12 16:50:24 +01:00
|
|
|
$(Q)esptool.py --port $(PORT) --baud $(BAUD) write_flash --verify --flash_size=8m 0 $<
|
2016-04-03 13:48:46 +01:00
|
|
|
#$(Q)esptool.py --port $(PORT) --baud $(BAUD) write_flash --flash_size=8m 0 $(BUILD)/firmware.elf-0x00000.bin 0x9000 $(BUILD)/firmware.elf-0x0[1-f]000.bin
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2015-01-30 22:51:12 +00:00
|
|
|
reset:
|
2016-04-28 12:23:55 +01:00
|
|
|
echo -e "\r\nimport machine; machine.reset()\r\n" >$(PORT)
|
2015-01-30 22:51:12 +00:00
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
$(BUILD)/firmware-combined.bin: $(BUILD)/firmware.elf
|
|
|
|
$(ECHO) "Create $@"
|
|
|
|
$(Q)esptool.py elf2image $^
|
2016-04-03 13:40:53 +01:00
|
|
|
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x0[1-f]000.bin $@
|
2014-11-27 20:30:33 +00:00
|
|
|
|
|
|
|
$(BUILD)/firmware.elf: $(OBJ)
|
|
|
|
$(ECHO) "LINK $@"
|
2015-10-24 00:26:10 +01:00
|
|
|
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
2014-11-27 20:30:33 +00: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
|
2016-04-26 22:35:13 +01:00
|
|
|
|
2016-07-16 02:53:33 +01:00
|
|
|
axtls: $(BUILD)/libaxtls.a
|
|
|
|
|
|
|
|
$(BUILD)/libaxtls.a:
|
2016-04-26 22:35:13 +01:00
|
|
|
cd ../lib/axtls; cp config/upyconfig config/.config
|
|
|
|
cd ../lib/axtls; make oldconfig -B
|
|
|
|
cd ../lib/axtls; make clean
|
2016-05-01 23:22:42 +01:00
|
|
|
cd ../lib/axtls; make all CC="$(CC)" LD="$(LD)" AR="$(AR)" CFLAGS_EXTRA="$(CFLAGS_XTENSA) -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=3072"
|
2016-07-16 02:53:33 +01:00
|
|
|
cp ../lib/axtls/_stage/libaxtls.a $@
|