d6d8722558
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>
107 lines
2.8 KiB
Makefile
107 lines
2.8 KiB
Makefile
include ../../py/mkenv.mk
|
|
|
|
CROSS = 0
|
|
|
|
# qstr definitions (must come before including py.mk)
|
|
QSTR_DEFS = qstrdefsport.h
|
|
|
|
# MicroPython feature configurations
|
|
MICROPY_ROM_TEXT_COMPRESSION ?= 1
|
|
|
|
# include py core make definitions
|
|
include $(TOP)/py/py.mk
|
|
|
|
ifeq ($(CROSS), 1)
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
|
endif
|
|
|
|
INC += -I.
|
|
INC += -I$(TOP)
|
|
INC += -I$(BUILD)
|
|
|
|
ifeq ($(CROSS), 1)
|
|
DFU = $(TOP)/tools/dfu.py
|
|
PYDFU = $(TOP)/tools/pydfu.py
|
|
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -fsingle-precision-constant -Wdouble-promotion -Wfloat-conversion
|
|
CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
|
|
LDFLAGS += -nostdlib -T stm32f405.ld -Map=$@.map --cref --gc-sections
|
|
else
|
|
LD = gcc
|
|
CFLAGS += $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
|
|
LDFLAGS += -Wl,-Map=$@.map,--cref -Wl,--gc-sections
|
|
endif
|
|
|
|
CSUPEROPT = -Os # save some code space
|
|
|
|
# Tune for Debugging or Optimization
|
|
CFLAGS += -g # always include debug info in the ELF
|
|
ifeq ($(DEBUG), 1)
|
|
CFLAGS += -O0
|
|
else
|
|
CFLAGS += -Os -DNDEBUG
|
|
CFLAGS += -fdata-sections -ffunction-sections
|
|
endif
|
|
|
|
# Flags for optional C++ source code
|
|
CXXFLAGS += $(filter-out -std=c99,$(CFLAGS))
|
|
|
|
LIBS =
|
|
|
|
SRC_C = \
|
|
main.c \
|
|
uart_core.c \
|
|
shared/libc/printf.c \
|
|
shared/readline/readline.c \
|
|
shared/runtime/pyexec.c \
|
|
shared/runtime/stdout_helpers.c \
|
|
$(BUILD)/_frozen_mpy.c \
|
|
|
|
ifeq ($(CROSS), 1)
|
|
SRC_C += shared/libc/string0.c
|
|
endif
|
|
|
|
SRC_QSTR += shared/readline/readline.c shared/runtime/pyexec.c
|
|
|
|
OBJ += $(PY_CORE_O)
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
|
|
|
|
ifeq ($(CROSS), 1)
|
|
all: $(BUILD)/firmware.dfu
|
|
else
|
|
all: $(BUILD)/firmware.elf
|
|
endif
|
|
|
|
$(BUILD)/_frozen_mpy.c: $(TOP)/tests/frozen/frozentest.mpy $(BUILD)/genhdr/qstrdefs.generated.h
|
|
$(ECHO) "MISC freezing bytecode"
|
|
$(Q)$(TOP)/tools/mpy-tool.py -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h -mlongint-impl=none $< > $@
|
|
|
|
$(BUILD)/firmware.elf: $(OBJ)
|
|
$(ECHO) "LINK $@"
|
|
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
|
$(Q)$(SIZE) $@
|
|
|
|
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
|
|
$(Q)$(OBJCOPY) -O binary -j .isr_vector -j .text -j .data $^ $(BUILD)/firmware.bin
|
|
|
|
$(BUILD)/firmware.dfu: $(BUILD)/firmware.bin
|
|
$(ECHO) "Create $@"
|
|
$(Q)$(PYTHON) $(DFU) -b 0x08000000:$(BUILD)/firmware.bin $@
|
|
|
|
deploy: $(BUILD)/firmware.dfu
|
|
$(ECHO) "Writing $< to the board"
|
|
$(Q)$(PYTHON) $(PYDFU) -u $<
|
|
|
|
# Run emulation build on a POSIX system with suitable terminal settings
|
|
run:
|
|
@saved_=`stty -g`; \
|
|
stty raw opost -echo; \
|
|
$(BUILD)/firmware.elf; \
|
|
echo "Exit status: $$?"; \
|
|
stty $$saved_
|
|
|
|
test: $(BUILD)/firmware.elf
|
|
$(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"
|
|
|
|
include $(TOP)/py/mkrules.mk
|