2017-09-06 00:09:13 -04:00
|
|
|
include ../../py/mkenv.mk
|
2015-01-12 20:17:47 -05:00
|
|
|
|
2015-01-12 21:02:56 -05:00
|
|
|
CROSS = 0
|
|
|
|
|
2015-01-12 20:17:47 -05: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 05:56:44 -05:00
|
|
|
# MicroPython feature configurations
|
|
|
|
MICROPY_ROM_TEXT_COMPRESSION ?= 1
|
|
|
|
|
2015-01-12 20:17:47 -05:00
|
|
|
# include py core make definitions
|
2017-08-10 22:22:19 -04:00
|
|
|
include $(TOP)/py/py.mk
|
2015-01-12 20:17:47 -05:00
|
|
|
|
2015-01-12 21:02:56 -05:00
|
|
|
ifeq ($(CROSS), 1)
|
2019-12-21 15:22:26 -05:00
|
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
2015-01-12 21:02:56 -05:00
|
|
|
endif
|
2015-01-12 20:17:47 -05:00
|
|
|
|
2015-10-19 11:22:16 -04:00
|
|
|
INC += -I.
|
2017-08-10 22:22:19 -04:00
|
|
|
INC += -I$(TOP)
|
2015-01-12 20:17:47 -05:00
|
|
|
INC += -I$(BUILD)
|
|
|
|
|
2015-01-12 21:02:56 -05:00
|
|
|
ifeq ($(CROSS), 1)
|
2017-08-10 22:22:19 -04:00
|
|
|
DFU = $(TOP)/tools/dfu.py
|
|
|
|
PYDFU = $(TOP)/tools/pydfu.py
|
2020-04-09 07:59:11 -04:00
|
|
|
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -fsingle-precision-constant -Wdouble-promotion -Wfloat-conversion
|
2022-10-08 08:08:53 -04:00
|
|
|
CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
|
|
|
|
LDFLAGS += -nostdlib -T stm32f405.ld -Map=$@.map --cref --gc-sections
|
2015-01-12 21:02:56 -05:00
|
|
|
else
|
2022-01-10 07:53:44 -05:00
|
|
|
LD = $(CC)
|
2022-10-08 08:08:53 -04:00
|
|
|
CFLAGS += $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
|
|
|
|
LDFLAGS += -Wl,-Map=$@.map,--cref -Wl,--gc-sections
|
2015-01-12 21:02:56 -05:00
|
|
|
endif
|
2015-01-12 20:17:47 -05:00
|
|
|
|
2019-09-12 08:14:51 -04:00
|
|
|
CSUPEROPT = -Os # save some code space
|
|
|
|
|
2017-07-18 22:21:52 -04:00
|
|
|
# Tune for Debugging or Optimization
|
2022-07-28 03:56:27 -04:00
|
|
|
CFLAGS += -g # always include debug info in the ELF
|
2015-01-12 20:17:47 -05:00
|
|
|
ifeq ($(DEBUG), 1)
|
2022-07-28 03:56:27 -04:00
|
|
|
CFLAGS += -O0
|
2015-01-12 20:17:47 -05:00
|
|
|
else
|
|
|
|
CFLAGS += -Os -DNDEBUG
|
2017-07-18 22:21:52 -04:00
|
|
|
CFLAGS += -fdata-sections -ffunction-sections
|
2015-01-12 20:17:47 -05:00
|
|
|
endif
|
|
|
|
|
2021-07-22 22:02:03 -04:00
|
|
|
# Flags for optional C++ source code
|
|
|
|
CXXFLAGS += $(filter-out -std=c99,$(CFLAGS))
|
|
|
|
|
2015-01-12 20:17:47 -05:00
|
|
|
LIBS =
|
|
|
|
|
|
|
|
SRC_C = \
|
|
|
|
main.c \
|
2015-01-12 21:02:56 -05:00
|
|
|
uart_core.c \
|
2021-07-09 00:19:15 -04:00
|
|
|
shared/libc/printf.c \
|
|
|
|
shared/readline/readline.c \
|
|
|
|
shared/runtime/pyexec.c \
|
|
|
|
shared/runtime/stdout_helpers.c \
|
2016-01-31 17:16:41 -05:00
|
|
|
$(BUILD)/_frozen_mpy.c \
|
2015-01-12 20:17:47 -05:00
|
|
|
|
2020-05-29 17:35:19 -04:00
|
|
|
ifeq ($(CROSS), 1)
|
2021-07-09 00:19:15 -04:00
|
|
|
SRC_C += shared/libc/string0.c
|
2020-05-29 17:35:19 -04:00
|
|
|
endif
|
|
|
|
|
2022-07-02 16:05:41 -04:00
|
|
|
SRC_QSTR += shared/readline/readline.c shared/runtime/pyexec.c
|
2021-07-22 22:02:03 -04: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_CORE_O)
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
2021-07-22 22:02:03 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
|
2015-01-12 20:17:47 -05:00
|
|
|
|
2016-01-07 12:43:07 -05:00
|
|
|
ifeq ($(CROSS), 1)
|
|
|
|
all: $(BUILD)/firmware.dfu
|
|
|
|
else
|
2015-01-12 20:17:47 -05:00
|
|
|
all: $(BUILD)/firmware.elf
|
2016-01-07 12:43:07 -05:00
|
|
|
endif
|
2015-01-12 20:17:47 -05:00
|
|
|
|
2022-09-18 22:03:38 -04:00
|
|
|
$(BUILD)/_frozen_mpy.c: $(TOP)/tests/frozen/frozentest.mpy $(BUILD)/genhdr/qstrdefs.generated.h
|
2016-01-31 17:16:41 -05:00
|
|
|
$(ECHO) "MISC freezing bytecode"
|
2017-08-10 22:22:19 -04:00
|
|
|
$(Q)$(TOP)/tools/mpy-tool.py -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h -mlongint-impl=none $< > $@
|
2016-01-31 17:16:41 -05:00
|
|
|
|
2015-01-12 20:17:47 -05:00
|
|
|
$(BUILD)/firmware.elf: $(OBJ)
|
|
|
|
$(ECHO) "LINK $@"
|
2015-10-23 19:26:10 -04:00
|
|
|
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
2015-01-12 20:17:47 -05:00
|
|
|
$(Q)$(SIZE) $@
|
|
|
|
|
2016-10-22 15:01:44 -04:00
|
|
|
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
|
2016-01-07 12:43:07 -05:00
|
|
|
$(Q)$(OBJCOPY) -O binary -j .isr_vector -j .text -j .data $^ $(BUILD)/firmware.bin
|
2016-10-22 15:01:44 -04:00
|
|
|
|
|
|
|
$(BUILD)/firmware.dfu: $(BUILD)/firmware.bin
|
|
|
|
$(ECHO) "Create $@"
|
2016-01-07 12:43:07 -05:00
|
|
|
$(Q)$(PYTHON) $(DFU) -b 0x08000000:$(BUILD)/firmware.bin $@
|
|
|
|
|
|
|
|
deploy: $(BUILD)/firmware.dfu
|
|
|
|
$(ECHO) "Writing $< to the board"
|
|
|
|
$(Q)$(PYTHON) $(PYDFU) -u $<
|
|
|
|
|
2015-01-12 21:07:03 -05:00
|
|
|
# Run emulation build on a POSIX system with suitable terminal settings
|
|
|
|
run:
|
2022-07-31 12:01:13 -04:00
|
|
|
@saved_=`stty -g`; \
|
|
|
|
stty raw opost -echo; \
|
|
|
|
$(BUILD)/firmware.elf; \
|
|
|
|
echo "Exit status: $$?"; \
|
|
|
|
stty $$saved_
|
2015-01-12 21:07:03 -05:00
|
|
|
|
2015-01-13 07:39:29 -05:00
|
|
|
test: $(BUILD)/firmware.elf
|
2015-01-13 19:26:39 -05: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 07:39:29 -05:00
|
|
|
|
2017-08-10 22:22:19 -04:00
|
|
|
include $(TOP)/py/mkrules.mk
|