2021-03-12 10:03:03 +00:00
|
|
|
# Include the core environment definitions; this will set $(TOP).
|
2017-09-06 05:09:13 +01:00
|
|
|
include ../../py/mkenv.mk
|
2014-04-12 13:07:45 +01:00
|
|
|
|
2021-03-12 10:03:03 +00:00
|
|
|
# Include py core make definitions.
|
|
|
|
include $(TOP)/py/py.mk
|
2014-04-12 13:07:45 +01:00
|
|
|
|
2021-03-12 10:03:03 +00:00
|
|
|
# Set makefile-level MicroPython feature configurations.
|
2021-04-27 14:52:40 +01:00
|
|
|
MICROPY_ROM_TEXT_COMPRESSION ?= 0
|
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
|
|
|
|
2021-03-12 10:03:03 +00:00
|
|
|
# Define toolchain and other tools.
|
2019-12-21 20:22:26 +00:00
|
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
2021-03-12 10:03:03 +00:00
|
|
|
DFU ?= $(TOP)/tools/dfu.py
|
|
|
|
PYDFU ?= $(TOP)/tools/pydfu.py
|
2014-04-12 13:07:45 +01:00
|
|
|
|
2021-03-12 10:03:03 +00:00
|
|
|
# Set CFLAGS.
|
|
|
|
CFLAGS += -I. -I$(TOP) -I$(BUILD)
|
|
|
|
CFLAGS += -Wall -Werror -std=c99 -nostdlib
|
|
|
|
CFLAGS += -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float
|
|
|
|
CSUPEROPT = -Os # save some code space for performance-critical code
|
2014-04-12 13:07:45 +01:00
|
|
|
|
2021-03-12 10:03:03 +00:00
|
|
|
# Select debugging or optimisation build.
|
2014-04-12 13:07:45 +01:00
|
|
|
ifeq ($(DEBUG), 1)
|
2021-03-12 10:03:03 +00:00
|
|
|
CFLAGS += -Og
|
2014-04-12 13:07:45 +01:00
|
|
|
else
|
|
|
|
CFLAGS += -Os -DNDEBUG
|
2021-03-12 10:03:03 +00:00
|
|
|
CFLAGS += -fdata-sections -ffunction-sections
|
2014-04-12 13:07:45 +01:00
|
|
|
endif
|
|
|
|
|
2021-03-12 10:03:03 +00:00
|
|
|
# Set linker flags.
|
|
|
|
LDFLAGS += -nostdlib -T stm32f405.ld --gc-sections
|
2014-04-12 13:07:45 +01:00
|
|
|
|
2021-03-12 10:03:03 +00:00
|
|
|
# Define the required source files.
|
|
|
|
SRC_C += lib.c main.c system.c
|
2014-04-12 13:07:45 +01:00
|
|
|
|
2021-03-12 10:03:03 +00:00
|
|
|
# Define the required object files.
|
|
|
|
OBJ += $(PY_CORE_O)
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
2014-04-12 13:07:45 +01:00
|
|
|
|
2021-03-12 10:03:03 +00:00
|
|
|
# Define the top-level target, the main firmware.
|
|
|
|
all: $(BUILD)/firmware.dfu
|
2014-04-12 13:07:45 +01:00
|
|
|
|
2014-05-10 13:45:47 +01:00
|
|
|
$(BUILD)/firmware.elf: $(OBJ)
|
2014-04-12 13:07:45 +01:00
|
|
|
$(ECHO) "LINK $@"
|
2021-03-12 10:03:03 +00:00
|
|
|
$(Q)$(LD) $(LDFLAGS) -o $@ $^
|
2014-04-12 13:07:45 +01:00
|
|
|
$(Q)$(SIZE) $@
|
|
|
|
|
2021-03-12 10:03:03 +00:00
|
|
|
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
|
|
|
|
$(ECHO) "Create $@"
|
|
|
|
$(Q)$(OBJCOPY) -O binary -j .isr_vector -j .text -j .data $^ $@
|
|
|
|
|
|
|
|
$(BUILD)/firmware.dfu: $(BUILD)/firmware.bin
|
|
|
|
$(ECHO) "Create $@"
|
|
|
|
$(Q)$(PYTHON) $(DFU) -b 0x08000000:$^ $@
|
|
|
|
|
|
|
|
deploy: $(BUILD)/firmware.dfu
|
|
|
|
$(Q)$(PYTHON) $(PYDFU) -u $^
|
|
|
|
|
|
|
|
# Include remaining core make rules.
|
2017-08-11 03:22:19 +01:00
|
|
|
include $(TOP)/py/mkrules.mk
|