2019-09-18 06:08:06 +01:00
|
|
|
# Select the board to build for: if not given on the command line,
|
|
|
|
# then default to GENERIC.
|
|
|
|
BOARD ?= GENERIC
|
|
|
|
|
|
|
|
# If the build directory is not given, make it reflect the board name.
|
|
|
|
BUILD ?= build-$(BOARD)
|
|
|
|
|
|
|
|
BOARD_DIR ?= boards/$(BOARD)
|
|
|
|
ifeq ($(wildcard $(BOARD_DIR)/.),)
|
|
|
|
$(error Invalid BOARD specified: $(BOARD_DIR))
|
|
|
|
endif
|
|
|
|
|
2017-09-06 05:09:13 +01:00
|
|
|
include ../../py/mkenv.mk
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2019-09-18 06:08:06 +01:00
|
|
|
# Optional
|
|
|
|
-include $(BOARD_DIR)/mpconfigboard.mk
|
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
# qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h
|
2019-09-18 06:08:06 +01:00
|
|
|
QSTR_GLOBAL_DEPENDENCIES = $(BOARD_DIR)/mpconfigboard.h
|
2014-11-27 20:30:33 +00:00
|
|
|
|
ports: Enable error text compression for various ports, but not all.
Enabled on: bare-arm, minimal, unix coverage/dev/minimal, stm32, esp32,
esp8266, cc3200, teensy, qemu-arm, nrf. Not enabled on others to be able
to test the code when the feature is disabled (the default case).
Code size change for this commit:
bare-arm: -600 -0.906%
minimal x86: -308 -0.208%
unix x64: +0 +0.000%
unix nanbox: +0 +0.000%
stm32: -3368 -0.869% PYBV10
cc3200: -1024 -0.558%
esp8266: -2512 -0.368% GENERIC
esp32: -2876 -0.205% GENERIC[incl -3168(data)]
nrf: -1708 -1.173% pca10040
samd: +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
2020-03-04 10:56:44 +00:00
|
|
|
# MicroPython feature configurations
|
|
|
|
MICROPY_ROM_TEXT_COMPRESSION ?= 1
|
2016-04-27 22:46:51 +01:00
|
|
|
MICROPY_PY_USSL = 1
|
2016-07-12 23:59:41 +01:00
|
|
|
MICROPY_SSL_AXTLS = 1
|
2018-10-23 02:18:25 +01:00
|
|
|
AXTLS_DEFS_EXTRA = -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=4096
|
2017-09-10 11:54:00 +01:00
|
|
|
BTREE_DEFS_EXTRA = -DDEFPSIZE=1024 -DMINCACHE=3
|
2016-04-27 22:46:51 +01:00
|
|
|
|
2019-10-10 13:01:29 +01:00
|
|
|
FROZEN_MANIFEST ?= boards/manifest.py
|
|
|
|
FROZEN_DIR ?=
|
|
|
|
FROZEN_MPY_DIR ?=
|
2016-10-20 23:08:43 +01:00
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
# include py core make definitions
|
2017-08-11 03:22:19 +01:00
|
|
|
include $(TOP)/py/py.mk
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2019-10-14 02:09:06 +01:00
|
|
|
GIT_SUBMODULES = lib/axtls lib/berkeley-db-1.xx
|
|
|
|
|
2017-01-02 16:29:41 +00: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 21:22:39 +01:00
|
|
|
FLASH_MODE ?= qio
|
2016-10-17 22:06:59 +01:00
|
|
|
FLASH_SIZE ?= detect
|
2019-12-21 20:22:26 +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.
|
2017-08-11 03:22:19 +01:00
|
|
|
INC += -I$(TOP)
|
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.
|
2020-09-11 07:47:29 +01:00
|
|
|
UART_OS = -1
|
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
|
|
|
|
2017-03-05 12:28:27 +00:00
|
|
|
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
|
2019-09-18 06:08:06 +01:00
|
|
|
$(CFLAGS_XTENSA) $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) -I$(BOARD_DIR)
|
2014-11-27 20:30:33 +00:00
|
|
|
|
esp8266: Change from FAT to littlefs v2 as default filesystem.
This commit changes the esp8266 boards to use littlefs v2 as the
filesystem, rather than FAT. Since the esp8266 doesn't expose the
filesystem to the PC over USB there's no strong reason to keep it as FAT.
Littlefs is smaller in code size, is more efficient in use of flash to
store data, is resilient over power failure, and using it saves about 4k of
heap RAM, which can now be used for other things.
This is a backwards incompatible change because all existing esp8266 boards
will need to update their filesystem after installing new firmware (eg
backup old files, install firmware, restore files to new filesystem).
As part of this commit the memory layout of the default board (GENERIC) has
changed. It now allocates all 1M of memory-mapped flash to the firmware,
so the filesystem area starts at the 2M point. This is done to allow more
frozen bytecode to be stored in the 1M of memory-mapped flash. This
requires an esp8266 module with 2M or more of flash to work, so a new board
called GENERIC_1M is added which has the old memory-mapping (but still
changed to use littlefs for the filesystem).
In summary there are now 3 esp8266 board definitions:
- GENERIC_512K: for 512k modules, doesn't have a filesystem.
- GENERIC_1M: for 1M modules, 572k for firmware+frozen code, 396k for
filesystem (littlefs).
- GENERIC: for 2M (or greater) modules, 968k for firmware+frozen code,
1M+ for filesystem (littlefs), FAT driver also included in firmware for
use on, eg, external SD cards.
2020-03-26 11:35:32 +00:00
|
|
|
LD_FILES ?= boards/esp8266_2m.ld
|
2019-09-18 06:08:06 +01:00
|
|
|
LDFLAGS = -nostdlib -T $(LD_FILES) -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
|
|
|
|
|
2019-03-14 01:20:39 +00:00
|
|
|
# Options for mpy-cross
|
|
|
|
MPY_CROSS_FLAGS += -march=xtensa
|
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
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 \
|
2016-10-18 13:18:07 +01:00
|
|
|
esp_init_data.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
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-03-28 00:58:14 +01:00
|
|
|
espapa102.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
modpyb.c \
|
2016-11-05 22:30:19 +00:00
|
|
|
modmachine.c \
|
2021-08-11 06:14:46 +01:00
|
|
|
machine_bitstream.c \
|
2016-11-05 22:30:19 +00:00
|
|
|
machine_pin.c \
|
|
|
|
machine_rtc.c \
|
|
|
|
machine_adc.c \
|
|
|
|
machine_uart.c \
|
|
|
|
machine_wdt.c \
|
|
|
|
machine_hspi.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 \
|
2016-03-11 02:43:39 +00:00
|
|
|
ets_alt_task.c \
|
2016-04-16 12:47:17 +01:00
|
|
|
fatfs_port.c \
|
2017-09-10 07:47:20 +01:00
|
|
|
posix_helpers.c \
|
2016-06-07 20:40:56 +01:00
|
|
|
hspi.c \
|
2019-09-18 06:08:06 +01:00
|
|
|
$(wildcard $(BOARD_DIR)/*.c) \
|
2016-07-31 00:39:59 +01:00
|
|
|
$(SRC_MOD)
|
2014-11-27 20:30:33 +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 \
|
2017-06-22 07:06:00 +01:00
|
|
|
modonewire.c \
|
2016-01-01 16:12:39 +00:00
|
|
|
)
|
|
|
|
|
2015-01-12 02:21:58 +00:00
|
|
|
LIB_SRC_C = $(addprefix lib/,\
|
2015-12-18 21:07:58 +00:00
|
|
|
libm/math.c \
|
|
|
|
libm/fmodf.c \
|
2017-03-23 23:40:25 +00:00
|
|
|
libm/nearbyintf.c \
|
2015-12-18 21:07:58 +00:00
|
|
|
libm/ef_sqrt.c \
|
2020-07-24 08:13:05 +01:00
|
|
|
libm/erf_lgamma.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 \
|
2020-07-24 08:13:05 +01:00
|
|
|
libm/sf_erf.c \
|
2015-12-18 21:43:01 +00:00
|
|
|
libm/sf_sin.c \
|
|
|
|
libm/sf_cos.c \
|
|
|
|
libm/sf_tan.c \
|
|
|
|
libm/sf_frexp.c \
|
|
|
|
libm/sf_modf.c \
|
|
|
|
libm/sf_ldexp.c \
|
2020-07-24 08:13:05 +01:00
|
|
|
libm/acoshf.c \
|
2015-12-18 21:43:01 +00:00
|
|
|
libm/asinfacosf.c \
|
2020-07-24 08:13:05 +01:00
|
|
|
libm/asinhf.c \
|
2015-12-18 21:43:01 +00:00
|
|
|
libm/atanf.c \
|
2020-07-24 08:13:05 +01:00
|
|
|
libm/atanhf.c \
|
2015-12-18 21:43:01 +00:00
|
|
|
libm/atan2f.c \
|
2020-07-24 08:13:05 +01:00
|
|
|
libm/log1pf.c \
|
2020-03-24 07:11:36 +00:00
|
|
|
libm/roundf.c \
|
2020-07-24 08:13:05 +01:00
|
|
|
libm/wf_lgamma.c \
|
|
|
|
libm/wf_tgamma.c \
|
2021-07-09 05:19:15 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
SHARED_SRC_C = $(addprefix shared/,\
|
|
|
|
libc/__errno.c \
|
|
|
|
libc/string0.c \
|
2015-05-02 20:24:25 +01:00
|
|
|
netutils/netutils.c \
|
2021-07-09 05:19:15 +01:00
|
|
|
readline/readline.c \
|
|
|
|
runtime/interrupt_char.c \
|
|
|
|
runtime/pyexec.c \
|
|
|
|
runtime/stdout_helpers.c \
|
|
|
|
runtime/sys_stdio_mphal.c \
|
2015-05-11 20:11:37 +01:00
|
|
|
timeutils/timeutils.c \
|
2014-11-27 20:30:33 +00:00
|
|
|
)
|
|
|
|
|
2016-05-26 17:11:43 +01:00
|
|
|
DRIVERS_SRC_C = $(addprefix drivers/,\
|
2018-03-09 06:25:58 +00:00
|
|
|
bus/softspi.c \
|
2016-05-26 17:11:43 +01:00
|
|
|
dht/dht.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-01-01 16:12:39 +00:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o))
|
2021-07-09 05:19:15 +01:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SHARED_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))
|
2014-11-27 20:30:33 +00:00
|
|
|
|
2016-04-16 12:47:17 +01:00
|
|
|
# List of sources for qstr extraction
|
2021-07-09 05:19:15 +01:00
|
|
|
SRC_QSTR += $(SRC_C) $(EXTMOD_SRC_C) $(SHARED_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 +=
|
|
|
|
|
2018-09-05 05:11:55 +01:00
|
|
|
all: $(FWBIN)
|
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))
|
2019-10-10 13:01:29 +01:00
|
|
|
$(shell echo $(FROZEN_MANIFEST) $(UART_OS) > $(CONFVARS_FILE))
|
|
|
|
else ifneq ($(shell cat $(CONFVARS_FILE)), $(FROZEN_MANIFEST) $(UART_OS))
|
|
|
|
$(shell echo $(FROZEN_MANIFEST) $(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)
|
|
|
|
|
2016-09-17 18:57:43 +01:00
|
|
|
FROZEN_EXTRA_DEPS = $(CONFVARS_FILE)
|
2015-05-05 23:19:26 +01:00
|
|
|
|
2019-10-18 14:39:04 +01:00
|
|
|
ifneq ($(FROZEN_MANIFEST)$(FROZEN_MPY_DIR),)
|
|
|
|
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
|
|
|
|
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(FROZEN_MANIFEST)$(FROZEN_DIR),)
|
|
|
|
CFLAGS += -DMICROPY_MODULE_FROZEN_STR
|
|
|
|
endif
|
|
|
|
|
2014-11-27 20:30:33 +00:00
|
|
|
.PHONY: deploy
|
|
|
|
|
|
|
|
deploy: $(BUILD)/firmware-combined.bin
|
|
|
|
$(ECHO) "Writing $< to the board"
|
2016-09-26 21:22:39 +01:00
|
|
|
$(Q)esptool.py --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-14 13:34:40 +00:00
|
|
|
erase:
|
|
|
|
$(ECHO) "Erase flash"
|
|
|
|
$(Q)esptool.py --port $(PORT) --baud $(BAUD) erase_flash
|
|
|
|
|
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
|
|
|
|
2017-01-02 16:29:41 +00:00
|
|
|
$(FWBIN): $(BUILD)/firmware.elf
|
2014-11-27 20:30:33 +00:00
|
|
|
$(ECHO) "Create $@"
|
|
|
|
$(Q)esptool.py elf2image $^
|
2016-12-14 14:44:05 +00: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)
|
|
|
|
$(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) $@
|
|
|
|
|
2016-12-14 14:44:05 +00:00
|
|
|
ota:
|
2016-12-20 20:23:45 +00:00
|
|
|
rm -f $(BUILD)/firmware.elf $(BUILD)/firmware.elf*.bin
|
2019-09-18 06:08:06 +01:00
|
|
|
$(MAKE) LD_FILES=boards/esp8266_ota.ld FWBIN=$(BUILD)/firmware-ota.bin
|
2016-12-14 14:44:05 +00:00
|
|
|
|
2017-08-11 03:22:19 +01:00
|
|
|
include $(TOP)/py/mkrules.mk
|
2016-04-26 22:35:13 +01:00
|
|
|
|
2017-06-10 16:13:43 +01:00
|
|
|
clean-modules:
|
|
|
|
git clean -f -d modules
|
2019-09-18 06:08:06 +01:00
|
|
|
rm -f $(BUILD)/frozen*.c
|