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
|
|
|
|
|
|
|
|
# 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)
|
2015-01-12 20:17:47 -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
|
2015-01-12 20:17:47 -05:00
|
|
|
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
|
2017-03-23 00:41:38 -04:00
|
|
|
CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
|
2017-07-18 22:21:52 -04:00
|
|
|
LDFLAGS = -nostdlib -T stm32f405.ld -Map=$@.map --cref --gc-sections
|
2015-01-12 21:02:56 -05:00
|
|
|
else
|
2017-07-18 22:21:52 -04:00
|
|
|
LD = gcc
|
2017-03-23 00:41:38 -04:00
|
|
|
CFLAGS = -m32 $(INC) -Wall -Werror -std=c99 $(COPT)
|
2017-07-18 22:21:52 -04:00
|
|
|
LDFLAGS = -m32 -Wl,-Map=$@.map,--cref -Wl,--gc-sections
|
2015-01-12 21:02:56 -05:00
|
|
|
endif
|
2015-01-12 20:17:47 -05:00
|
|
|
|
2017-07-18 22:21:52 -04:00
|
|
|
# Tune for Debugging or Optimization
|
2015-01-12 20:17:47 -05:00
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CFLAGS += -O0 -ggdb
|
|
|
|
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
|
|
|
|
|
|
|
|
LIBS =
|
|
|
|
|
|
|
|
SRC_C = \
|
|
|
|
main.c \
|
2015-01-12 21:02:56 -05:00
|
|
|
uart_core.c \
|
2018-02-21 21:19:09 -05:00
|
|
|
lib/utils/printf.c \
|
2016-07-22 12:56:27 -04:00
|
|
|
lib/utils/stdout_helpers.c \
|
2015-10-31 12:35:10 -04:00
|
|
|
lib/utils/pyexec.c \
|
2015-04-05 14:44:20 -04:00
|
|
|
lib/libc/string0.c \
|
2015-01-12 21:02:56 -05:00
|
|
|
lib/mp-readline/readline.c \
|
2016-01-31 17:16:41 -05:00
|
|
|
$(BUILD)/_frozen_mpy.c \
|
2015-01-12 20:17:47 -05:00
|
|
|
|
2018-02-21 19:15:48 -05:00
|
|
|
OBJ = $(PY_CORE_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.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
|
|
|
|
2016-04-16 08:05:47 -04:00
|
|
|
$(BUILD)/_frozen_mpy.c: 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:
|
|
|
|
stty raw opost -echo
|
|
|
|
build/firmware.elf
|
|
|
|
@echo Resetting terminal...
|
|
|
|
# This sleep is useful to spot segfaults
|
|
|
|
sleep 1
|
|
|
|
reset
|
|
|
|
|
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
|