2021-03-12 05:03:03 -05:00
|
|
|
# Include the core environment definitions; this will set $(TOP).
|
2017-09-06 00:09:13 -04:00
|
|
|
include ../../py/mkenv.mk
|
2014-04-12 08:07:45 -04:00
|
|
|
|
2021-03-12 05:03:03 -05:00
|
|
|
# Include py core make definitions.
|
|
|
|
include $(TOP)/py/py.mk
|
2014-04-12 08:07:45 -04:00
|
|
|
|
2021-03-12 05:03:03 -05:00
|
|
|
# Set makefile-level MicroPython feature configurations.
|
2021-04-27 09:52:40 -04: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 05:56:44 -05:00
|
|
|
|
2021-03-12 05:03:03 -05:00
|
|
|
# Define toolchain and other tools.
|
2019-12-21 15:22:26 -05:00
|
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
2021-03-12 05:03:03 -05:00
|
|
|
DFU ?= $(TOP)/tools/dfu.py
|
|
|
|
PYDFU ?= $(TOP)/tools/pydfu.py
|
2014-04-12 08:07:45 -04:00
|
|
|
|
2021-03-12 05:03:03 -05: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 08:07:45 -04:00
|
|
|
|
2021-03-12 05:03:03 -05:00
|
|
|
# Select debugging or optimisation build.
|
2014-04-12 08:07:45 -04:00
|
|
|
ifeq ($(DEBUG), 1)
|
2021-03-12 05:03:03 -05:00
|
|
|
CFLAGS += -Og
|
2014-04-12 08:07:45 -04:00
|
|
|
else
|
|
|
|
CFLAGS += -Os -DNDEBUG
|
2021-03-12 05:03:03 -05:00
|
|
|
CFLAGS += -fdata-sections -ffunction-sections
|
2014-04-12 08:07:45 -04:00
|
|
|
endif
|
|
|
|
|
2021-03-12 05:03:03 -05:00
|
|
|
# Set linker flags.
|
|
|
|
LDFLAGS += -nostdlib -T stm32f405.ld --gc-sections
|
2014-04-12 08:07:45 -04:00
|
|
|
|
2021-03-12 05:03:03 -05:00
|
|
|
# Define the required source files.
|
|
|
|
SRC_C += lib.c main.c system.c
|
2014-04-12 08:07:45 -04:00
|
|
|
|
2021-03-12 05:03:03 -05:00
|
|
|
# Define the required object files.
|
|
|
|
OBJ += $(PY_CORE_O)
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
2014-04-12 08:07:45 -04:00
|
|
|
|
2021-03-12 05:03:03 -05:00
|
|
|
# Define the top-level target, the main firmware.
|
|
|
|
all: $(BUILD)/firmware.dfu
|
2014-04-12 08:07:45 -04:00
|
|
|
|
2014-05-10 08:45:47 -04:00
|
|
|
$(BUILD)/firmware.elf: $(OBJ)
|
2014-04-12 08:07:45 -04:00
|
|
|
$(ECHO) "LINK $@"
|
2021-03-12 05:03:03 -05:00
|
|
|
$(Q)$(LD) $(LDFLAGS) -o $@ $^
|
2014-04-12 08:07:45 -04:00
|
|
|
$(Q)$(SIZE) $@
|
|
|
|
|
2021-03-12 05:03:03 -05: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-10 22:22:19 -04:00
|
|
|
include $(TOP)/py/mkrules.mk
|