2017-09-06 00:09:13 -04:00
|
|
|
include ../../py/mkenv.mk
|
2014-01-08 12:09:47 -05:00
|
|
|
|
2014-01-15 01:23:56 -05:00
|
|
|
# qstr definitions (must come before including py.mk)
|
2022-10-08 08:23:52 -04:00
|
|
|
QSTR_DEFS = qstrdefsport.h $(GEN_PINS_QSTR)
|
2014-01-15 01:23:56 -05: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 05:56:44 -05:00
|
|
|
# MicroPython feature configurations
|
|
|
|
MICROPY_ROM_TEXT_COMPRESSION ?= 1
|
|
|
|
|
2021-12-08 00:02:42 -05:00
|
|
|
USE_FROZEN = 1
|
|
|
|
USE_MEMZIP = 0
|
|
|
|
|
|
|
|
ifeq ($(USE_MEMZIP),1)
|
|
|
|
SRC_C += \
|
|
|
|
shared/memzip/import.c \
|
|
|
|
shared/memzip/lexermemzip.c \
|
|
|
|
shared/memzip/memzip.c \
|
|
|
|
|
|
|
|
OBJ += $(BUILD)/memzip-files.o
|
|
|
|
|
|
|
|
MAKE_MEMZIP = $(TOP)/shared/memzip/make-memzip.py
|
|
|
|
ifeq ($(MEMZIP_DIR),)
|
|
|
|
MEMZIP_DIR = memzip_files
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(BUILD)/memzip-files.o: $(BUILD)/memzip-files.c
|
|
|
|
$(call compile_c)
|
|
|
|
|
|
|
|
$(BUILD)/memzip-files.c: $(shell find ${MEMZIP_DIR} -type f)
|
|
|
|
@$(ECHO) "Creating $@"
|
|
|
|
$(Q)$(PYTHON) $(MAKE_MEMZIP) --zip-file $(BUILD)/memzip-files.zip --c-file $@ $(MEMZIP_DIR)
|
|
|
|
|
|
|
|
endif # USE_MEMZIP
|
|
|
|
|
|
|
|
ifeq ($(USE_FROZEN),1)
|
|
|
|
|
|
|
|
FROZEN_MANIFEST ?= "manifest.py"
|
|
|
|
|
|
|
|
CFLAGS += -DMICROPY_MODULE_FROZEN_STR
|
|
|
|
|
|
|
|
SRC_C += \
|
|
|
|
lexerfrozen.c
|
|
|
|
|
|
|
|
endif # USE_FROZEN
|
|
|
|
|
2014-01-08 12:09:47 -05:00
|
|
|
# include py core make definitions
|
2017-08-10 22:22:19 -04:00
|
|
|
include $(TOP)/py/py.mk
|
2022-06-17 12:11:30 -04:00
|
|
|
include $(TOP)/extmod/extmod.mk
|
2014-01-08 12:09:47 -05:00
|
|
|
|
2014-09-22 01:40:42 -04:00
|
|
|
# If you set USE_ARDUINO_TOOLCHAIN=1 then this makefile will attempt to use
|
|
|
|
# the toolchain that comes with Teensyduino
|
|
|
|
ifeq ($(USE_ARDUINO_TOOLCHAIN),)
|
|
|
|
USE_ARDUINO_TOOLCHAIN = 0
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(USE_ARDUINO_TOOLCHAIN),1)
|
|
|
|
ifeq ($(ARDUINO),)
|
|
|
|
$(error USE_ARDUINO_TOOLCHAIN requires that ARDUINO be set)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(USE_ARDUINO_TOOLCHAIN),1)
|
|
|
|
$(info Using ARDUINO toolchain)
|
2019-12-21 15:22:26 -05:00
|
|
|
CROSS_COMPILE ?= $(ARDUINO)/hardware/tools/arm-none-eabi/bin/arm-none-eabi-
|
2014-09-22 01:40:42 -04:00
|
|
|
else
|
|
|
|
$(info Using toolchain from PATH)
|
2019-12-21 15:22:26 -05:00
|
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
2014-09-22 01:40:42 -04:00
|
|
|
endif
|
2014-01-06 03:20:11 -05:00
|
|
|
|
2022-10-08 08:23:52 -04:00
|
|
|
MAKE_PINS = make-pins.py
|
|
|
|
BOARD_PINS = teensy_pins.csv
|
|
|
|
AF_FILE = mk20dx256_af.csv
|
|
|
|
PREFIX_FILE = mk20dx256_prefix.c
|
|
|
|
GEN_PINS_SRC = $(BUILD)/pins_gen.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
|
|
|
|
|
2014-01-08 12:09:47 -05:00
|
|
|
CFLAGS_TEENSY = -DF_CPU=96000000 -DUSB_SERIAL -D__MK20DX256__
|
2014-09-22 01:40:42 -04:00
|
|
|
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -mfloat-abi=soft -fsingle-precision-constant -Wdouble-promotion $(CFLAGS_TEENSY)
|
2014-04-16 17:10:33 -04:00
|
|
|
|
2015-10-19 11:22:16 -04:00
|
|
|
INC += -I.
|
2017-08-10 22:22:19 -04:00
|
|
|
INC += -I$(TOP)
|
2017-09-06 00:09:13 -04:00
|
|
|
INC += -I$(TOP)/ports/stm32
|
2014-04-17 13:03:27 -04:00
|
|
|
INC += -I$(BUILD)
|
2014-06-16 12:38:24 -04:00
|
|
|
INC += -Icore
|
2014-04-16 17:10:33 -04:00
|
|
|
|
2022-10-08 08:08:53 -04:00
|
|
|
CFLAGS += $(INC) -Wall -Wpointer-arith -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4)
|
|
|
|
LDFLAGS += -nostdlib -T mk20dx256.ld -msoft-float -mfloat-abi=soft
|
2014-06-16 12:38:24 -04:00
|
|
|
|
2014-09-22 01:40:42 -04:00
|
|
|
ifeq ($(USE_ARDUINO_TOOLCHAIN),1)
|
|
|
|
|
|
|
|
LIBGCC_FILE_NAME = $(ARDUINO)/hardware/tools/arm-none-eabi/lib/gcc/arm-none-eabi/4.7.2/thumb2/libgcc.a
|
|
|
|
LIBM_FILE_NAME = $(ARDUINO)/hardware/tools/arm-none-eabi/arm-none-eabi/lib/thumb2/libm.a
|
|
|
|
LIBC_FILE_NAME = $(ARDUINO)/hardware/tools/arm-none-eabi/arm-none-eabi/lib/thumb2/libc.a
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
|
|
|
LIBM_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a)
|
|
|
|
LIBC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libc.a)
|
|
|
|
|
|
|
|
endif
|
2014-06-16 12:38:24 -04:00
|
|
|
|
|
|
|
#$(info %%%%% LIBGCC_FILE_NAME = $(LIBGCC_FILE_NAME))
|
|
|
|
#$(info %%%%% LIBM_FILE_NAME = $(LIBM_FILE_NAME))
|
|
|
|
#$(info %%%%% LIBC_FILE_NAME = $(LIBC_FILE_NAME))
|
|
|
|
|
|
|
|
#$(info %%%%% dirname LIBGCC_FILE_NAME = $(dir $(LIBGCC_FILE_NAME)))
|
|
|
|
#$(info %%%%% dirname LIBM_FILE_NAME = $(dir $(LIBM_FILE_NAME)))
|
|
|
|
#$(info %%%%% dirname LIBC_FILE_NAME = $(dir $(LIBC_FILE_NAME)))
|
|
|
|
|
|
|
|
LIBS = -L $(dir $(LIBM_FILE_NAME)) -lm
|
|
|
|
LIBS += -L $(dir $(LIBC_FILE_NAME)) -lc
|
|
|
|
LIBS += -L $(dir $(LIBGCC_FILE_NAME)) -lgcc
|
2014-01-06 03:20:11 -05:00
|
|
|
|
2014-01-13 08:25:10 -05:00
|
|
|
#Debugging/Optimization
|
2022-07-28 03:56:27 -04:00
|
|
|
CFLAGS += -g # always include debug info in the ELF
|
2014-01-13 08:25:10 -05:00
|
|
|
ifdef DEBUG
|
2022-07-28 03:56:27 -04:00
|
|
|
CFLAGS += -Og
|
2014-01-13 08:25:10 -05:00
|
|
|
else
|
|
|
|
CFLAGS += -Os #-DNDEBUG
|
|
|
|
endif
|
2014-08-20 16:21:11 -04:00
|
|
|
CFLAGS += -fdata-sections -ffunction-sections
|
|
|
|
LDFLAGS += -Wl,--gc-sections
|
2014-01-13 08:25:10 -05:00
|
|
|
|
2021-12-08 00:02:42 -05:00
|
|
|
SRC_C += \
|
2014-08-20 16:21:11 -04:00
|
|
|
hal_ftm.c \
|
2014-06-16 01:33:14 -04:00
|
|
|
hal_gpio.c \
|
|
|
|
help.c \
|
2014-01-06 03:20:11 -05:00
|
|
|
main.c \
|
2014-01-07 12:49:42 -05:00
|
|
|
lcd.c \
|
2014-01-06 03:20:11 -05:00
|
|
|
led.c \
|
2014-06-16 01:33:14 -04:00
|
|
|
modpyb.c \
|
2014-07-22 10:57:36 -04:00
|
|
|
pin_defs_teensy.c \
|
2014-08-20 16:21:11 -04:00
|
|
|
reg.c \
|
2014-06-16 01:33:14 -04:00
|
|
|
teensy_hal.c \
|
2014-08-20 16:21:11 -04:00
|
|
|
timer.c \
|
2014-06-16 01:33:14 -04:00
|
|
|
uart.c \
|
2014-01-07 12:49:42 -05:00
|
|
|
usb.c \
|
|
|
|
|
2017-09-06 00:09:13 -04:00
|
|
|
STM_SRC_C = $(addprefix ports/stm32/,\
|
2014-08-24 15:21:12 -04:00
|
|
|
irq.c \
|
2014-06-16 01:33:14 -04:00
|
|
|
pin.c \
|
|
|
|
pin_named_pins.c \
|
2014-01-24 04:05:30 -05:00
|
|
|
)
|
2014-01-06 03:20:11 -05:00
|
|
|
|
2021-07-09 00:19:15 -04:00
|
|
|
SHARED_SRC_C = $(addprefix shared/,\
|
2015-04-05 14:44:20 -04:00
|
|
|
libc/string0.c \
|
2021-07-09 00:19:15 -04:00
|
|
|
readline/readline.c \
|
|
|
|
runtime/gchelper_native.c \
|
|
|
|
runtime/pyexec.c \
|
|
|
|
runtime/sys_stdio_mphal.c \
|
2015-01-11 21:26:15 -05:00
|
|
|
)
|
|
|
|
|
2014-06-16 12:38:24 -04:00
|
|
|
SRC_TEENSY = $(addprefix core/,\
|
2014-01-06 03:20:11 -05:00
|
|
|
mk20dx128.c \
|
|
|
|
pins_teensy.c \
|
|
|
|
analog.c \
|
|
|
|
usb_desc.c \
|
|
|
|
usb_dev.c \
|
|
|
|
usb_mem.c \
|
|
|
|
usb_serial.c \
|
|
|
|
yield.c \
|
2014-06-16 12:38:24 -04:00
|
|
|
)
|
2014-01-06 03:20:11 -05:00
|
|
|
|
extmod: Make extmod.mk self-contained.
This makes it so that all a port needs to do is set the relevant variables
and "include extmod.mk" and doesn't need to worry about adding anything to
OBJ, CFLAGS, SRC_QSTR, etc.
Make all extmod variables (src, flags, etc) private to extmod.mk.
Also move common/shared, extmod-related fragments (e.g. wiznet, cyw43,
bluetooth) into extmod.mk.
Now that SRC_MOD, CFLAGS_MOD, CXXFLAGS_MOD are unused by both extmod.mk
(and user-C-modules in a previous commit), remove all uses of them from
port makefiles.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-08 08:59:08 -04:00
|
|
|
OBJ += $(PY_O)
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_TEENSY:.c=.o))
|
2021-07-09 00:19:15 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SHARED_SRC_C:.c=.o))
|
|
|
|
OBJ += $(BUILD)/shared/runtime/gchelper_m3.o
|
2022-10-08 08:23:52 -04:00
|
|
|
OBJ += $(GEN_PINS_SRC:.c=.o)
|
2014-01-06 03:20:11 -05:00
|
|
|
|
2014-01-24 04:05:30 -05:00
|
|
|
all: hex
|
2015-11-01 00:24:47 -04:00
|
|
|
hex: $(BUILD)/micropython.hex
|
2014-01-06 03:20:11 -05:00
|
|
|
|
2014-06-16 12:38:24 -04:00
|
|
|
ifeq ($(ARDUINO),)
|
2015-11-01 00:24:47 -04:00
|
|
|
post_compile: $(BUILD)/micropython.hex
|
2014-06-16 12:38:24 -04:00
|
|
|
$(ECHO) "Please define ARDUINO (where TeensyDuino is installed)"
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
reboot:
|
|
|
|
$(ECHO) "Please define ARDUINO (where TeensyDuino is installed)"
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
else
|
|
|
|
TOOLS_PATH = $(ARDUINO)/hardware/tools
|
|
|
|
|
2015-11-01 00:24:47 -04:00
|
|
|
post_compile: $(BUILD)/micropython.hex
|
2014-01-08 13:15:39 -05:00
|
|
|
$(ECHO) "Preparing $@ for upload"
|
2014-08-03 12:55:24 -04:00
|
|
|
$(Q)$(TOOLS_PATH)/teensy_post_compile -file="$(basename $(<F))" -path="$(abspath $(<D))" -tools="$(TOOLS_PATH)"
|
2014-01-06 03:20:11 -05:00
|
|
|
|
|
|
|
reboot:
|
2014-01-08 13:15:39 -05:00
|
|
|
$(ECHO) "REBOOT"
|
|
|
|
-$(Q)$(TOOLS_PATH)/teensy_reboot
|
2014-06-16 12:38:24 -04:00
|
|
|
endif
|
2014-01-06 03:20:11 -05:00
|
|
|
|
2014-06-16 12:38:24 -04:00
|
|
|
.PHONY: deploy
|
|
|
|
deploy: post_compile reboot
|
2014-01-06 03:20:11 -05:00
|
|
|
|
2014-01-08 04:00:22 -05:00
|
|
|
$(BUILD)/micropython.elf: $(OBJ)
|
2014-06-16 01:33:14 -04:00
|
|
|
$(ECHO) "LINK $@"
|
2015-10-23 19:26:10 -04:00
|
|
|
$(Q)$(CC) $(LDFLAGS) -o "$@" -Wl,-Map,$(@:.elf=.map) $^ $(LIBS)
|
2014-01-08 13:15:39 -05:00
|
|
|
$(Q)$(SIZE) $@
|
2014-01-06 03:20:11 -05:00
|
|
|
|
2014-01-08 12:09:47 -05:00
|
|
|
$(BUILD)/%.hex: $(BUILD)/%.elf
|
2014-01-08 13:15:39 -05:00
|
|
|
$(ECHO) "HEX $<"
|
|
|
|
$(Q)$(OBJCOPY) -O ihex -R .eeprom "$<" "$@"
|
2014-01-06 03:20:11 -05:00
|
|
|
|
py: Add rules for automated extraction of qstrs from sources.
- add template rule that converts a specified source file into a qstring file
- add special rule for generating a central header that contains all
extracted/autogenerated strings - defined by QSTR_DEFS_COLLECTED
variable. Each platform appends a list of sources that may contain
qstrings into a new build variable: SRC_QSTR. Any autogenerated
prerequisities are should be appened to SRC_QSTR_AUTO_DEPS variable.
- remove most qstrings from py/qstrdefs, keep only qstrings that
contain special characters - these cannot be easily detected in the
sources without additional annotations
- remove most manual qstrdefs, use qstrdef autogen for: py, cc3200,
stmhal, teensy, unix, windows, pic16bit:
- remove all micropython generic qstrdefs except for the special strings that contain special characters (e.g. /,+,<,> etc.)
- remove all port specific qstrdefs except for special strings
- append sources for qstr generation in platform makefiles (SRC_QSTR)
2016-03-10 04:22:41 -05:00
|
|
|
# List of sources for qstr extraction
|
2021-07-09 00:19:15 -04:00
|
|
|
SRC_QSTR += $(SRC_C) $(STM_SRC_C) $(SHARED_SRC_C)
|
py: Add rules for automated extraction of qstrs from sources.
- add template rule that converts a specified source file into a qstring file
- add special rule for generating a central header that contains all
extracted/autogenerated strings - defined by QSTR_DEFS_COLLECTED
variable. Each platform appends a list of sources that may contain
qstrings into a new build variable: SRC_QSTR. Any autogenerated
prerequisities are should be appened to SRC_QSTR_AUTO_DEPS variable.
- remove most qstrings from py/qstrdefs, keep only qstrings that
contain special characters - these cannot be easily detected in the
sources without additional annotations
- remove most manual qstrdefs, use qstrdef autogen for: py, cc3200,
stmhal, teensy, unix, windows, pic16bit:
- remove all micropython generic qstrdefs except for the special strings that contain special characters (e.g. /,+,<,> etc.)
- remove all port specific qstrdefs except for special strings
- append sources for qstr generation in platform makefiles (SRC_QSTR)
2016-03-10 04:22:41 -05:00
|
|
|
# Append any auto-generated sources that are needed by sources listed in
|
|
|
|
# SRC_QSTR
|
|
|
|
SRC_QSTR_AUTO_DEPS +=
|
|
|
|
|
2014-06-16 01:33:14 -04:00
|
|
|
# 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
|
2014-08-08 17:34:06 -04:00
|
|
|
$(BUILD)/%_gen.c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_af_const.h $(BUILD)/%_qstr.h: teensy_%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
|
2014-06-16 01:33:14 -04:00
|
|
|
$(ECHO) "Create $@"
|
2014-08-20 16:21:11 -04:00
|
|
|
$(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)
|
2014-06-16 01:33:14 -04:00
|
|
|
|
2022-10-08 08:23:52 -04:00
|
|
|
$(GEN_PINS_SRC:.c=.o): $(GEN_PINS_SRC)
|
2014-06-16 01:33:14 -04:00
|
|
|
$(call compile_c)
|
|
|
|
|
|
|
|
$(BUILD)/%.pp: $(BUILD)/%.c
|
|
|
|
$(ECHO) "PreProcess $<"
|
|
|
|
$(Q)$(CC) $(CFLAGS) -E -Wp,-C,-dD,-dI -o $@ $<
|
|
|
|
|
2017-08-10 22:22:19 -04:00
|
|
|
include $(TOP)/py/mkrules.mk
|