2017-09-06 00:09:13 -04:00
|
|
|
include ../../py/mkenv.mk
|
2014-11-27 15:30:33 -05:00
|
|
|
|
|
|
|
# qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h
|
|
|
|
|
2016-04-27 17:46:51 -04:00
|
|
|
MICROPY_PY_USSL = 1
|
2016-07-12 18:59:41 -04:00
|
|
|
MICROPY_SSL_AXTLS = 1
|
2018-10-22 21:18:25 -04:00
|
|
|
AXTLS_DEFS_EXTRA = -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=4096
|
2016-10-24 17:37:33 -04:00
|
|
|
MICROPY_FATFS = 1
|
2016-07-30 19:39:59 -04:00
|
|
|
MICROPY_PY_BTREE = 1
|
2017-09-10 06:54:00 -04:00
|
|
|
BTREE_DEFS_EXTRA = -DDEFPSIZE=1024 -DMINCACHE=3
|
2016-04-27 17:46:51 -04:00
|
|
|
|
2017-06-15 04:45:18 -04:00
|
|
|
FROZEN_DIR ?= scripts
|
|
|
|
FROZEN_MPY_DIR ?= modules
|
2016-10-20 18:08:43 -04:00
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
# include py core make definitions
|
2017-08-10 22:22:19 -04:00
|
|
|
include $(TOP)/py/py.mk
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2017-01-02 11:29:41 -05:00
|
|
|
FWBIN = $(BUILD)/firmware-combined.bin
|
2015-12-22 05:44:08 -05:00
|
|
|
PORT ?= /dev/ttyACM0
|
2015-12-30 13:37:58 -05:00
|
|
|
BAUD ?= 115200
|
2016-09-26 16:22:39 -04:00
|
|
|
FLASH_MODE ?= qio
|
2016-10-17 17:06:59 -04:00
|
|
|
FLASH_SIZE ?= detect
|
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.
|
2017-08-10 22:22:19 -04:00
|
|
|
INC += -I$(TOP)
|
2014-11-27 15:30:33 -05:00
|
|
|
INC += -I$(BUILD)
|
|
|
|
INC += -I$(ESP_SDK)/include
|
|
|
|
|
2016-03-29 14:10:10 -04:00
|
|
|
# UART for "os" messages. 0 is normal UART as used by MicroPython REPL,
|
2016-05-26 17:44:05 -04:00
|
|
|
# 1 is debug UART (tx only), -1 to disable.
|
2016-03-29 14:10:10 -04:00
|
|
|
UART_OS = 0
|
2015-05-13 09:39:25 -04:00
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
CFLAGS_XTENSA = -fsingle-precision-constant -Wdouble-promotion \
|
|
|
|
-D__ets__ -DICACHE_FLASH \
|
|
|
|
-fno-inline-functions \
|
2016-04-26 17:35:13 -04:00
|
|
|
-Wl,-EL -mlongcalls -mtext-section-literals -mforce-l32 \
|
2016-03-07 22:29:05 -05:00
|
|
|
-DLWIP_OPEN_SRC
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2017-03-05 07:28:27 -05:00
|
|
|
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
|
2016-04-27 17:44:52 -04:00
|
|
|
$(CFLAGS_XTENSA) $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2016-10-24 17:37:33 -04:00
|
|
|
LDSCRIPT = esp8266.ld
|
|
|
|
LDFLAGS = -nostdlib -T $(LDSCRIPT) -Map=$(@:.elf=.map) --cref
|
2016-04-27 17:44:52 -04:00
|
|
|
LIBS = -L$(ESP_SDK)/lib -lmain -ljson -llwip_open -lpp -lnet80211 -lwpa -lphy -lnet80211 $(LDFLAGS_MOD)
|
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
|
2016-04-26 17:35:13 -04:00
|
|
|
COPT += -Os -DNDEBUG
|
2014-11-27 15:30:33 -05:00
|
|
|
LDFLAGS += --gc-sections
|
|
|
|
endif
|
|
|
|
|
2019-03-13 21:20:39 -04:00
|
|
|
# Options for mpy-cross
|
|
|
|
MPY_CROSS_FLAGS += -march=xtensa
|
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
SRC_C = \
|
2014-11-28 09:58:25 -05:00
|
|
|
strtoll.c \
|
2014-11-27 15:30:33 -05:00
|
|
|
main.c \
|
2016-04-28 17:17:11 -04:00
|
|
|
help.c \
|
2014-11-27 15:30:33 -05:00
|
|
|
esp_mphal.c \
|
2016-10-18 08:18:07 -04:00
|
|
|
esp_init_data.c \
|
2014-11-27 15:30:33 -05:00
|
|
|
gccollect.c \
|
2016-03-17 11:06:47 -04:00
|
|
|
lexerstr32.c \
|
2014-11-27 15:30:33 -05:00
|
|
|
uart.c \
|
2016-03-02 08:37:27 -05:00
|
|
|
esppwm.c \
|
2016-02-11 08:19:11 -05:00
|
|
|
espneopixel.c \
|
2016-03-27 19:58:14 -04:00
|
|
|
espapa102.c \
|
2016-04-14 06:15:43 -04:00
|
|
|
intr.c \
|
2014-11-27 15:30:33 -05:00
|
|
|
modpyb.c \
|
2016-11-05 18:30:19 -04:00
|
|
|
modmachine.c \
|
|
|
|
machine_pin.c \
|
|
|
|
machine_pwm.c \
|
|
|
|
machine_rtc.c \
|
|
|
|
machine_adc.c \
|
|
|
|
machine_uart.c \
|
|
|
|
machine_wdt.c \
|
|
|
|
machine_hspi.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 \
|
2016-03-10 21:43:39 -05:00
|
|
|
ets_alt_task.c \
|
2016-04-16 07:47:17 -04:00
|
|
|
fatfs_port.c \
|
2017-09-10 02:47:20 -04:00
|
|
|
posix_helpers.c \
|
2016-06-07 15:40:56 -04:00
|
|
|
hspi.c \
|
2016-07-30 19:39:59 -04:00
|
|
|
$(SRC_MOD)
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2016-01-01 11:12:39 -05:00
|
|
|
EXTMOD_SRC_C = $(addprefix extmod/,\
|
2016-04-16 07:47:17 -04:00
|
|
|
modlwip.c \
|
2017-06-22 02:06:00 -04:00
|
|
|
modonewire.c \
|
2016-01-01 11:12:39 -05:00
|
|
|
)
|
|
|
|
|
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 \
|
2017-03-23 19:40:25 -04:00
|
|
|
libm/nearbyintf.c \
|
2015-12-18 16:07:58 -05:00
|
|
|
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 \
|
2016-09-29 13:13:17 -04:00
|
|
|
utils/interrupt_char.c \
|
2017-06-15 04:55:34 -04:00
|
|
|
utils/sys_stdio_mphal.c \
|
2014-11-27 15:30:33 -05:00
|
|
|
)
|
|
|
|
|
2016-10-24 17:37:33 -04:00
|
|
|
ifeq ($(MICROPY_FATFS), 1)
|
|
|
|
LIB_SRC_C += \
|
2017-01-24 07:53:53 -05:00
|
|
|
lib/oofatfs/ff.c \
|
2019-02-25 07:46:17 -05:00
|
|
|
lib/oofatfs/ffunicode.c
|
2016-10-24 17:37:33 -04:00
|
|
|
endif
|
|
|
|
|
2016-05-26 12:11:43 -04:00
|
|
|
DRIVERS_SRC_C = $(addprefix drivers/,\
|
2018-03-09 01:25:58 -05:00
|
|
|
bus/softspi.c \
|
2016-05-26 12:11:43 -04:00
|
|
|
dht/dht.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))
|
2016-01-01 11:12:39 -05:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o))
|
2015-01-11 21:21:58 -05:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
|
2016-05-26 12:11:43 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o))
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2016-04-16 07:47:17 -04:00
|
|
|
# List of sources for qstr extraction
|
2017-06-20 01:20:09 -04:00
|
|
|
SRC_QSTR += $(SRC_C) $(EXTMOD_SRC_C) $(LIB_SRC_C) $(DRIVERS_SRC_C)
|
2016-04-16 07:47:17 -04:00
|
|
|
# Append any auto-generated sources that are needed by sources listed in SRC_QSTR
|
|
|
|
SRC_QSTR_AUTO_DEPS +=
|
|
|
|
|
2018-09-05 00:11:55 -04:00
|
|
|
all: $(FWBIN)
|
2014-11-27 15:30:33 -05:00
|
|
|
|
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))
|
2016-09-17 13:24:28 -04:00
|
|
|
$(shell echo $(FROZEN_DIR) $(UART_OS) > $(CONFVARS_FILE))
|
|
|
|
else ifneq ($(shell cat $(CONFVARS_FILE)), $(FROZEN_DIR) $(UART_OS))
|
|
|
|
$(shell echo $(FROZEN_DIR) $(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)
|
|
|
|
|
2016-09-17 13:57:43 -04:00
|
|
|
FROZEN_EXTRA_DEPS = $(CONFVARS_FILE)
|
2015-05-05 18:19:26 -04:00
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
.PHONY: deploy
|
|
|
|
|
|
|
|
deploy: $(BUILD)/firmware-combined.bin
|
|
|
|
$(ECHO) "Writing $< to the board"
|
2016-09-26 16:22:39 -04:00
|
|
|
$(Q)esptool.py --port $(PORT) --baud $(BAUD) write_flash --verify --flash_size=$(FLASH_SIZE) --flash_mode=$(FLASH_MODE) 0 $<
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2016-12-14 08:34:40 -05:00
|
|
|
erase:
|
|
|
|
$(ECHO) "Erase flash"
|
|
|
|
$(Q)esptool.py --port $(PORT) --baud $(BAUD) erase_flash
|
|
|
|
|
2015-01-30 17:51:12 -05:00
|
|
|
reset:
|
2016-04-28 07:23:55 -04:00
|
|
|
echo -e "\r\nimport machine; machine.reset()\r\n" >$(PORT)
|
2015-01-30 17:51:12 -05:00
|
|
|
|
2017-01-02 11:29:41 -05:00
|
|
|
$(FWBIN): $(BUILD)/firmware.elf
|
2014-11-27 15:30:33 -05:00
|
|
|
$(ECHO) "Create $@"
|
|
|
|
$(Q)esptool.py elf2image $^
|
2016-12-14 09:44:05 -05:00
|
|
|
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x[0-5][1-f]000.bin $@
|
2014-11-27 15:30:33 -05:00
|
|
|
|
|
|
|
$(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) $@
|
|
|
|
|
2016-10-24 17:37:33 -04:00
|
|
|
512k:
|
|
|
|
$(MAKE) LDSCRIPT=esp8266_512k.ld CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_512k.h>"' MICROPY_FATFS=0 MICROPY_PY_BTREE=0
|
|
|
|
|
2016-12-14 09:44:05 -05:00
|
|
|
ota:
|
2016-12-20 15:23:45 -05:00
|
|
|
rm -f $(BUILD)/firmware.elf $(BUILD)/firmware.elf*.bin
|
2017-01-04 02:36:28 -05:00
|
|
|
$(MAKE) LDSCRIPT=esp8266_ota.ld FWBIN=$(BUILD)/firmware-ota.bin
|
2016-12-14 09:44:05 -05:00
|
|
|
|
2017-08-10 22:22:19 -04:00
|
|
|
include $(TOP)/py/mkrules.mk
|
2016-04-26 17:35:13 -04:00
|
|
|
|
2017-06-10 11:13:43 -04:00
|
|
|
clean-modules:
|
|
|
|
git clean -f -d modules
|
|
|
|
rm -f build/frozen*.c
|