2017-09-06 05:09:13 +01:00
|
|
|
include ../../py/mkenv.mk
|
2015-01-13 01:17:47 +00:00
|
|
|
|
2015-01-13 02:02:56 +00:00
|
|
|
CROSS = 0
|
|
|
|
|
2015-01-13 01:17:47 +00:00
|
|
|
# qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h
|
|
|
|
|
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
|
|
|
|
|
2015-01-13 01:17:47 +00:00
|
|
|
# include py core make definitions
|
2017-08-11 03:22:19 +01:00
|
|
|
include $(TOP)/py/py.mk
|
2015-01-13 01:17:47 +00:00
|
|
|
|
2015-01-13 02:02:56 +00:00
|
|
|
ifeq ($(CROSS), 1)
|
2019-12-21 20:22:26 +00:00
|
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
2015-01-13 02:02:56 +00:00
|
|
|
endif
|
2015-01-13 01:17:47 +00:00
|
|
|
|
2015-10-19 16:22:16 +01:00
|
|
|
INC += -I.
|
2017-08-11 03:22:19 +01:00
|
|
|
INC += -I$(TOP)
|
2015-01-13 01:17:47 +00:00
|
|
|
INC += -I$(BUILD)
|
|
|
|
|
2015-01-13 02:02:56 +00:00
|
|
|
ifeq ($(CROSS), 1)
|
2017-08-11 03:22:19 +01:00
|
|
|
DFU = $(TOP)/tools/dfu.py
|
|
|
|
PYDFU = $(TOP)/tools/pydfu.py
|
2020-04-09 12:59:11 +01:00
|
|
|
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -fsingle-precision-constant -Wdouble-promotion -Wfloat-conversion
|
2017-03-23 04:41:38 +00:00
|
|
|
CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
|
2017-07-19 03:21:52 +01:00
|
|
|
LDFLAGS = -nostdlib -T stm32f405.ld -Map=$@.map --cref --gc-sections
|
2015-01-13 02:02:56 +00:00
|
|
|
else
|
2017-07-19 03:21:52 +01:00
|
|
|
LD = gcc
|
2020-04-09 12:59:11 +01:00
|
|
|
CFLAGS = -m32 $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
|
2017-07-19 03:21:52 +01:00
|
|
|
LDFLAGS = -m32 -Wl,-Map=$@.map,--cref -Wl,--gc-sections
|
2015-01-13 02:02:56 +00:00
|
|
|
endif
|
2015-01-13 01:17:47 +00:00
|
|
|
|
2019-09-12 13:14:51 +01:00
|
|
|
CSUPEROPT = -Os # save some code space
|
|
|
|
|
2017-07-19 03:21:52 +01:00
|
|
|
# Tune for Debugging or Optimization
|
2015-01-13 01:17:47 +00:00
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CFLAGS += -O0 -ggdb
|
|
|
|
else
|
|
|
|
CFLAGS += -Os -DNDEBUG
|
2017-07-19 03:21:52 +01:00
|
|
|
CFLAGS += -fdata-sections -ffunction-sections
|
2015-01-13 01:17:47 +00:00
|
|
|
endif
|
|
|
|
|
2021-07-23 03:02:03 +01:00
|
|
|
# Flags for optional C++ source code
|
|
|
|
CXXFLAGS += $(filter-out -std=c99,$(CFLAGS))
|
|
|
|
CXXFLAGS += $(CXXFLAGS_MOD)
|
|
|
|
|
|
|
|
# Flags for user C modules
|
|
|
|
CFLAGS += $(CFLAGS_MOD)
|
|
|
|
LDFLAGS += $(LDFLAGS_MOD)
|
|
|
|
|
2015-01-13 01:17:47 +00:00
|
|
|
LIBS =
|
|
|
|
|
|
|
|
SRC_C = \
|
|
|
|
main.c \
|
2015-01-13 02:02:56 +00:00
|
|
|
uart_core.c \
|
2021-07-09 05:19:15 +01:00
|
|
|
shared/libc/printf.c \
|
|
|
|
shared/readline/readline.c \
|
|
|
|
shared/runtime/pyexec.c \
|
|
|
|
shared/runtime/stdout_helpers.c \
|
2016-01-31 22:16:41 +00:00
|
|
|
$(BUILD)/_frozen_mpy.c \
|
2015-01-13 01:17:47 +00:00
|
|
|
|
2020-05-29 22:35:19 +01:00
|
|
|
ifeq ($(CROSS), 1)
|
2021-07-09 05:19:15 +01:00
|
|
|
SRC_C += shared/libc/string0.c
|
2020-05-29 22:35:19 +01:00
|
|
|
endif
|
|
|
|
|
2021-07-23 03:02:03 +01:00
|
|
|
SRC_C += $(SRC_MOD)
|
|
|
|
|
|
|
|
SRC_CXX += $(SRC_MOD_CXX)
|
|
|
|
|
|
|
|
SRC_QSTR += $(SRC_MOD) $(SRC_MOD_CXX)
|
|
|
|
|
|
|
|
OBJ += $(PY_CORE_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
|
2015-01-13 01:17:47 +00:00
|
|
|
|
2016-01-07 17:43:07 +00:00
|
|
|
ifeq ($(CROSS), 1)
|
|
|
|
all: $(BUILD)/firmware.dfu
|
|
|
|
else
|
2015-01-13 01:17:47 +00:00
|
|
|
all: $(BUILD)/firmware.elf
|
2016-01-07 17:43:07 +00:00
|
|
|
endif
|
2015-01-13 01:17:47 +00:00
|
|
|
|
2016-04-16 13:05:47 +01:00
|
|
|
$(BUILD)/_frozen_mpy.c: frozentest.mpy $(BUILD)/genhdr/qstrdefs.generated.h
|
2016-01-31 22:16:41 +00:00
|
|
|
$(ECHO) "MISC freezing bytecode"
|
2017-08-11 03:22:19 +01:00
|
|
|
$(Q)$(TOP)/tools/mpy-tool.py -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h -mlongint-impl=none $< > $@
|
2016-01-31 22:16:41 +00:00
|
|
|
|
2015-01-13 01:17:47 +00:00
|
|
|
$(BUILD)/firmware.elf: $(OBJ)
|
|
|
|
$(ECHO) "LINK $@"
|
2015-10-24 00:26:10 +01:00
|
|
|
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
2015-01-13 01:17:47 +00:00
|
|
|
$(Q)$(SIZE) $@
|
|
|
|
|
2016-10-22 20:01:44 +01:00
|
|
|
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
|
2016-01-07 17:43:07 +00:00
|
|
|
$(Q)$(OBJCOPY) -O binary -j .isr_vector -j .text -j .data $^ $(BUILD)/firmware.bin
|
2016-10-22 20:01:44 +01:00
|
|
|
|
|
|
|
$(BUILD)/firmware.dfu: $(BUILD)/firmware.bin
|
|
|
|
$(ECHO) "Create $@"
|
2016-01-07 17:43:07 +00:00
|
|
|
$(Q)$(PYTHON) $(DFU) -b 0x08000000:$(BUILD)/firmware.bin $@
|
|
|
|
|
|
|
|
deploy: $(BUILD)/firmware.dfu
|
|
|
|
$(ECHO) "Writing $< to the board"
|
|
|
|
$(Q)$(PYTHON) $(PYDFU) -u $<
|
|
|
|
|
2015-01-13 02:07:03 +00:00
|
|
|
# Run emulation build on a POSIX system with suitable terminal settings
|
|
|
|
run:
|
|
|
|
stty raw opost -echo
|
|
|
|
build/firmware.elf
|
|
|
|
@echo Resetting terminal...
|
|
|
|
# This sleep is useful to spot segfaults
|
|
|
|
sleep 1
|
|
|
|
reset
|
|
|
|
|
2015-01-13 12:39:29 +00:00
|
|
|
test: $(BUILD)/firmware.elf
|
2015-01-14 00:26:39 +00:00
|
|
|
$(Q)/bin/echo -e "print('hello world!', list(x+1 for x in range(10)), end='eol\\\\n')\\r\\n\\x04" | $(BUILD)/firmware.elf | tail -n2 | grep "^hello world! \\[1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\]eol"
|
2015-01-13 12:39:29 +00:00
|
|
|
|
2017-08-11 03:22:19 +01:00
|
|
|
include $(TOP)/py/mkrules.mk
|