2016-11-03 15:50:59 -07:00
|
|
|
# Select the board to build for: if not given on the command line,
|
|
|
|
# then default to PYBV10.
|
|
|
|
BOARD ?= feather_huzzah
|
|
|
|
ifeq ($(wildcard boards/$(BOARD)/.),)
|
|
|
|
$(error Invalid BOARD specified)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# If the build directory is not given, make it reflect the board name.
|
2016-11-30 15:08:34 -08:00
|
|
|
BUILD ?= build
|
|
|
|
|
2017-09-06 14:09:13 +10:00
|
|
|
include ../../py/mkenv.mk
|
2016-11-03 15:50:59 -07:00
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
# qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h
|
|
|
|
|
2016-04-28 00:46:51 +03:00
|
|
|
MICROPY_PY_USSL = 1
|
2016-07-13 01:59:41 +03:00
|
|
|
MICROPY_SSL_AXTLS = 1
|
2016-10-25 00:37:33 +03:00
|
|
|
MICROPY_FATFS = 1
|
2016-07-31 02:39:59 +03:00
|
|
|
MICROPY_PY_BTREE = 1
|
2017-09-10 13:54:00 +03:00
|
|
|
BTREE_DEFS_EXTRA = -DDEFPSIZE=1024 -DMINCACHE=3
|
2016-04-28 00:46:51 +03:00
|
|
|
|
2017-06-15 18:45:18 +10:00
|
|
|
FROZEN_DIR ?= scripts
|
|
|
|
FROZEN_MPY_DIR ?= modules
|
2016-10-21 01:08:43 +03:00
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
# include py core make definitions
|
2017-08-11 12:22:19 +10:00
|
|
|
include $(TOP)/py/py.mk
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2017-01-02 19:29:41 +03:00
|
|
|
FWBIN = $(BUILD)/firmware-combined.bin
|
2015-12-22 10:44:08 +00:00
|
|
|
PORT ?= /dev/ttyACM0
|
2015-12-30 18:37:58 +00:00
|
|
|
BAUD ?= 115200
|
2016-09-26 22:22:39 +02:00
|
|
|
FLASH_MODE ?= qio
|
2016-10-18 00:06:59 +03:00
|
|
|
FLASH_SIZE ?= detect
|
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
|
2018-05-02 09:34:21 -04:00
|
|
|
ESPTOOL = esptool.py
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2015-10-19 18:22:16 +03:00
|
|
|
INC += -I.
|
2017-08-11 12:22:19 +10:00
|
|
|
INC += -I$(TOP)
|
2014-11-27 20:30:33 +00:00
|
|
|
INC += -I$(BUILD)
|
|
|
|
INC += -I$(ESP_SDK)/include
|
|
|
|
|
2016-03-29 21:10:10 +03:00
|
|
|
# UART for "os" messages. 0 is normal UART as used by MicroPython REPL,
|
2016-05-27 00:44:05 +03:00
|
|
|
# 1 is debug UART (tx only), -1 to disable.
|
2016-03-29 21:10:10 +03:00
|
|
|
UART_OS = 0
|
2015-05-13 15:39:25 +02: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-27 00:35:13 +03:00
|
|
|
-Wl,-EL -mlongcalls -mtext-section-literals -mforce-l32 \
|
2016-03-08 10:29:05 +07:00
|
|
|
-DLWIP_OPEN_SRC
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2018-04-09 21:17:26 -05:00
|
|
|
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -Wno-strict-aliasing -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
|
2016-04-28 00:44:52 +03:00
|
|
|
$(CFLAGS_XTENSA) $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2016-10-25 00:37:33 +03:00
|
|
|
LDSCRIPT = esp8266.ld
|
|
|
|
LDFLAGS = -nostdlib -T $(LDSCRIPT) -Map=$(@:.elf=.map) --cref
|
2016-04-28 00:44:52 +03: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-27 00:35:13 +03: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-29 00:17:11 +03:00
|
|
|
help.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
esp_mphal.c \
|
2016-10-18 15:18:07 +03:00
|
|
|
esp_init_data.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
gccollect.c \
|
2016-03-17 23:06:47 +08:00
|
|
|
lexerstr32.c \
|
2017-04-10 13:32:19 -07:00
|
|
|
espuart.c \
|
2016-03-02 13:37:27 +00:00
|
|
|
esppwm.c \
|
2016-02-11 13:19:11 +00:00
|
|
|
espneopixel.c \
|
2016-04-14 11:15:43 +01:00
|
|
|
intr.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
modpyb.c \
|
2016-11-06 01:30:19 +03: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-23 00:34:16 +02:00
|
|
|
modesp.c \
|
2015-06-12 17:16:52 +03:00
|
|
|
modnetwork.c \
|
2016-03-11 09:43:39 +07:00
|
|
|
ets_alt_task.c \
|
2016-04-16 12:47:17 +01:00
|
|
|
fatfs_port.c \
|
2017-09-10 09:47:20 +03:00
|
|
|
posix_helpers.c \
|
2016-06-07 21:40:56 +02:00
|
|
|
hspi.c \
|
2016-11-03 15:50:59 -07:00
|
|
|
boards/$(BOARD)/pins.c \
|
2016-07-31 02:39:59 +03:00
|
|
|
$(SRC_MOD)
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2016-11-03 15:50:59 -07:00
|
|
|
SRC_COMMON_HAL = \
|
|
|
|
microcontroller/__init__.c \
|
|
|
|
microcontroller/Pin.c \
|
2017-08-31 13:48:30 -04:00
|
|
|
microcontroller/Processor.c \
|
2017-04-10 13:32:19 -07:00
|
|
|
analogio/__init__.c \
|
|
|
|
analogio/AnalogIn.c \
|
|
|
|
analogio/AnalogOut.c \
|
|
|
|
digitalio/__init__.c \
|
|
|
|
digitalio/DigitalInOut.c \
|
|
|
|
pulseio/__init__.c \
|
|
|
|
pulseio/PulseIn.c \
|
|
|
|
pulseio/PulseOut.c \
|
|
|
|
pulseio/PWMOut.c \
|
|
|
|
busio/__init__.c \
|
|
|
|
busio/SPI.c \
|
|
|
|
busio/UART.c \
|
2017-08-07 14:30:11 -07:00
|
|
|
multiterminal/__init__.c \
|
2016-11-03 15:50:59 -07:00
|
|
|
neopixel_write/__init__.c \
|
2017-06-27 15:17:30 -07:00
|
|
|
os/__init__.c \
|
2017-06-28 16:18:13 -07:00
|
|
|
storage/__init__.c \
|
2016-11-03 15:50:59 -07:00
|
|
|
time/__init__.c \
|
|
|
|
board/__init__.c
|
|
|
|
|
2017-10-02 20:49:40 -04:00
|
|
|
|
2017-06-16 13:47:01 -07:00
|
|
|
# These don't have corresponding files in each port but are still located in
|
|
|
|
# shared-bindings to make it clear what the contents of the modules are.
|
|
|
|
SRC_BINDINGS_ENUMS = \
|
|
|
|
digitalio/Direction.c \
|
|
|
|
digitalio/DriveMode.c \
|
2017-10-02 20:49:40 -04:00
|
|
|
digitalio/Pull.c \
|
2017-10-20 12:21:41 -07:00
|
|
|
math/__init__.c \
|
2018-01-02 21:25:41 -05:00
|
|
|
microcontroller/RunMode.c \
|
2017-10-02 20:49:40 -04:00
|
|
|
util.c
|
2017-06-16 13:47:01 -07:00
|
|
|
|
2016-11-03 15:50:59 -07:00
|
|
|
SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
|
2017-06-16 13:47:01 -07:00
|
|
|
$(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \
|
2016-11-03 15:50:59 -07:00
|
|
|
$(addprefix common-hal/, $(SRC_COMMON_HAL))
|
|
|
|
SRC_SHARED_MODULE = \
|
|
|
|
bitbangio/__init__.c \
|
|
|
|
bitbangio/I2C.c \
|
2017-03-25 12:04:49 +00:00
|
|
|
bitbangio/OneWire.c \
|
2016-11-03 15:50:59 -07:00
|
|
|
bitbangio/SPI.c \
|
2017-04-10 13:32:19 -07:00
|
|
|
busio/I2C.c \
|
|
|
|
busio/OneWire.c \
|
2017-08-07 14:30:11 -07:00
|
|
|
multiterminal/__init__.c \
|
2017-06-27 15:17:30 -07:00
|
|
|
os/__init__.c \
|
2017-06-27 17:37:24 -07:00
|
|
|
random/__init__.c \
|
2017-10-18 12:50:20 -07:00
|
|
|
storage/__init__.c \
|
2017-10-20 12:21:41 -07:00
|
|
|
struct/__init__.c
|
2016-11-03 15:50:59 -07:00
|
|
|
|
|
|
|
SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \
|
|
|
|
$(addprefix shared-module/, $(SRC_SHARED_MODULE))
|
|
|
|
|
2016-01-01 16:12:39 +00:00
|
|
|
EXTMOD_SRC_C = $(addprefix extmod/,\
|
2016-04-16 12:47:17 +01:00
|
|
|
modlwip.c \
|
2017-06-22 16:06:00 +10:00
|
|
|
modonewire.c \
|
2016-01-01 16:12:39 +00:00
|
|
|
)
|
|
|
|
|
2015-01-12 04:21:58 +02:00
|
|
|
LIB_SRC_C = $(addprefix lib/,\
|
2015-04-05 21:44:20 +03:00
|
|
|
libc/string0.c \
|
2015-12-18 21:07:58 +00:00
|
|
|
libm/math.c \
|
|
|
|
libm/fmodf.c \
|
2017-03-24 10:40:25 +11:00
|
|
|
libm/nearbyintf.c \
|
2015-12-18 21:07:58 +00:00
|
|
|
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 04:21:58 +02:00
|
|
|
mp-readline/readline.c \
|
2015-05-02 21:24:25 +02:00
|
|
|
netutils/netutils.c \
|
2015-05-11 21:11:37 +02:00
|
|
|
timeutils/timeutils.c \
|
2017-04-20 11:24:05 -07:00
|
|
|
utils/buffer_helper.c \
|
2017-02-19 16:11:33 +01:00
|
|
|
utils/context_manager_helpers.c \
|
2015-10-31 19:35:10 +03:00
|
|
|
utils/pyexec.c \
|
2016-09-29 10:13:17 -07:00
|
|
|
utils/interrupt_char.c \
|
2017-06-15 18:55:34 +10:00
|
|
|
utils/sys_stdio_mphal.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
)
|
|
|
|
|
2016-10-25 00:37:33 +03:00
|
|
|
ifeq ($(MICROPY_FATFS), 1)
|
|
|
|
LIB_SRC_C += \
|
2017-01-24 23:53:53 +11:00
|
|
|
lib/oofatfs/ff.c \
|
|
|
|
lib/oofatfs/option/unicode.c
|
2016-10-25 00:37:33 +03:00
|
|
|
endif
|
|
|
|
|
2018-03-09 17:25:58 +11:00
|
|
|
bus/softspi.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
SRC_S = \
|
|
|
|
gchelper.s \
|
|
|
|
|
|
|
|
OBJ =
|
|
|
|
OBJ += $(PY_O)
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
|
2016-11-03 15:50:59 -07:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o))
|
2014-11-27 20:30:33 +00:00
|
|
|
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 04:21:58 +02:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2016-04-16 12:47:17 +01:00
|
|
|
# List of sources for qstr extraction
|
2016-11-03 15:50:59 -07:00
|
|
|
SRC_QSTR += $(SRC_C) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) $(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 +=
|
|
|
|
|
2017-01-02 19:29:41 +03:00
|
|
|
all: $(BUILD)/libaxtls.a $(FWBIN)
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2015-05-13 15:39:25 +02:00
|
|
|
CONFVARS_FILE = $(BUILD)/confvars
|
2015-05-06 00:19:26 +02:00
|
|
|
|
2015-05-13 15:39:25 +02:00
|
|
|
ifeq ($(wildcard $(CONFVARS_FILE)),)
|
2015-05-06 00:19:26 +02:00
|
|
|
$(shell $(MKDIR) -p $(BUILD))
|
2016-09-17 20:24:28 +03: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-06 00:19:26 +02:00
|
|
|
endif
|
|
|
|
|
2015-05-13 15:39:25 +02:00
|
|
|
$(BUILD)/uart.o: $(CONFVARS_FILE)
|
|
|
|
|
2016-09-17 20:57:43 +03:00
|
|
|
FROZEN_EXTRA_DEPS = $(CONFVARS_FILE)
|
2015-05-06 00:19:26 +02:00
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
.PHONY: deploy
|
|
|
|
|
|
|
|
deploy: $(BUILD)/firmware-combined.bin
|
|
|
|
$(ECHO) "Writing $< to the board"
|
2018-05-02 09:34:21 -04:00
|
|
|
$(Q)$(ESPTOOL) --port $(PORT) --baud $(BAUD) write_flash --verify --flash_size=$(FLASH_SIZE) --flash_mode=$(FLASH_MODE) 0 $<
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2016-12-15 00:34:40 +11:00
|
|
|
erase:
|
|
|
|
$(ECHO) "Erase flash"
|
2018-05-02 09:34:21 -04:00
|
|
|
$(Q)$(ESPTOOL) --port $(PORT) --baud $(BAUD) erase_flash
|
2016-12-15 00:34:40 +11:00
|
|
|
|
2015-01-31 00:51:12 +02:00
|
|
|
reset:
|
2016-04-28 12:23:55 +01:00
|
|
|
echo -e "\r\nimport machine; machine.reset()\r\n" >$(PORT)
|
2015-01-31 00:51:12 +02:00
|
|
|
|
2017-01-02 19:29:41 +03:00
|
|
|
$(FWBIN): $(BUILD)/firmware.elf
|
2014-11-27 20:30:33 +00:00
|
|
|
$(ECHO) "Create $@"
|
2018-05-02 09:34:21 -04:00
|
|
|
$(Q)$(ESPTOOL) elf2image $^
|
2016-12-14 17:44:05 +03:00
|
|
|
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x[0-5][1-f]000.bin $@
|
2014-11-27 20:30:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
$(BUILD)/firmware.elf: $(OBJ)
|
2017-02-24 15:59:59 +01:00
|
|
|
$(STEPECHO) "LINK $@"
|
2015-10-24 02:26:10 +03:00
|
|
|
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
2014-11-27 20:30:33 +00:00
|
|
|
$(Q)$(SIZE) $@
|
|
|
|
|
2016-10-25 00:37:33 +03:00
|
|
|
512k:
|
|
|
|
$(MAKE) LDSCRIPT=esp8266_512k.ld CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_512k.h>"' MICROPY_FATFS=0 MICROPY_PY_BTREE=0
|
|
|
|
|
2016-12-14 17:44:05 +03:00
|
|
|
ota:
|
2016-12-20 23:23:45 +03:00
|
|
|
rm -f $(BUILD)/firmware.elf $(BUILD)/firmware.elf*.bin
|
2017-01-04 10:36:28 +03:00
|
|
|
$(MAKE) LDSCRIPT=esp8266_ota.ld FWBIN=$(BUILD)/firmware-ota.bin
|
2016-12-14 17:44:05 +03:00
|
|
|
|
2017-08-11 12:22:19 +10:00
|
|
|
include $(TOP)/py/mkrules.mk
|
2016-04-27 00:35:13 +03:00
|
|
|
|
2016-07-16 04:53:33 +03:00
|
|
|
axtls: $(BUILD)/libaxtls.a
|
|
|
|
|
|
|
|
$(BUILD)/libaxtls.a:
|
2017-08-11 12:22:19 +10:00
|
|
|
cd $(TOP)/lib/axtls; cp config/upyconfig config/.config
|
|
|
|
cd $(TOP)/lib/axtls; $(MAKE) oldconfig -B
|
|
|
|
cd $(TOP)/lib/axtls; $(MAKE) clean
|
|
|
|
cd $(TOP)/lib/axtls; $(MAKE) all CC="$(CC)" LD="$(LD)" AR="$(AR)" CFLAGS_EXTRA="$(CFLAGS_XTENSA) -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=4096"
|
|
|
|
cp $(TOP)/lib/axtls/_stage/libaxtls.a $@
|
2017-06-10 18:13:43 +03:00
|
|
|
|
|
|
|
clean-modules:
|
|
|
|
git clean -f -d modules
|
|
|
|
rm -f build/frozen*.c
|