2015-01-12 20:17:47 -05:00
|
|
|
include ../py/mkenv.mk
|
|
|
|
|
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
|
|
|
|
include ../py/py.mk
|
|
|
|
|
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
|
|
|
|
|
|
|
INC = -I.
|
|
|
|
INC += -I..
|
2015-01-12 21:02:56 -05:00
|
|
|
INC += -I../lib/mp-readline
|
2015-01-13 07:23:13 -05:00
|
|
|
INC += -I../stmhal
|
2015-01-12 20:17:47 -05:00
|
|
|
INC += -I$(BUILD)
|
|
|
|
|
2015-01-12 21:02:56 -05:00
|
|
|
ifeq ($(CROSS), 1)
|
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
|
|
|
|
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
|
2015-01-12 21:02:56 -05:00
|
|
|
else
|
|
|
|
CFLAGS = -m32 $(INC) -Wall -Werror -ansi -std=gnu99 $(COPT)
|
|
|
|
endif
|
2015-01-12 20:17:47 -05:00
|
|
|
|
|
|
|
#Debugging/Optimization
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CFLAGS += -O0 -ggdb
|
|
|
|
else
|
|
|
|
CFLAGS += -Os -DNDEBUG
|
|
|
|
endif
|
|
|
|
|
2015-01-12 21:02:56 -05:00
|
|
|
ifeq ($(CROSS), 1)
|
2015-01-12 20:17:47 -05:00
|
|
|
LDFLAGS = -nostdlib -T stm32f405.ld -Map=$@.map --cref
|
2015-01-12 21:02:56 -05:00
|
|
|
else
|
|
|
|
LD = gcc
|
|
|
|
LDFLAGS = -m32 -Wl,-Map=$@.map,--cref
|
|
|
|
endif
|
2015-01-12 20:17:47 -05:00
|
|
|
LIBS =
|
|
|
|
|
|
|
|
SRC_C = \
|
|
|
|
main.c \
|
2015-01-12 21:02:56 -05:00
|
|
|
uart_core.c \
|
|
|
|
uart_extra.c \
|
|
|
|
stmhal/printf.c \
|
|
|
|
stmhal/string0.c \
|
|
|
|
stmhal/pyexec.c \
|
|
|
|
lib/mp-readline/readline.c \
|
2015-01-12 20:17:47 -05:00
|
|
|
|
|
|
|
SRC_S = \
|
|
|
|
# startup_stm32f40xx.s \
|
|
|
|
gchelper.s \
|
|
|
|
|
|
|
|
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o))
|
|
|
|
|
|
|
|
all: $(BUILD)/firmware.elf
|
|
|
|
|
|
|
|
$(BUILD)/firmware.elf: $(OBJ)
|
|
|
|
$(ECHO) "LINK $@"
|
|
|
|
$(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
|
|
|
$(Q)$(SIZE) $@
|
|
|
|
|
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
|
|
|
|
$(Q)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-12 20:17:47 -05:00
|
|
|
include ../py/mkrules.mk
|