diff options
| author | Scott Shawcroft <scott@chickadee.tech> | 2016-08-19 20:24:04 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@chickadee.tech> | 2016-08-22 23:53:10 -0700 |
| commit | a5f6cb3c57fa088afa20d2892105fb068cd11645 (patch) | |
| tree | b69866239032c67fed0ad4c5c1bca6f6e7520873 /atmel-samd/Makefile | |
| parent | f2a21a2489325df88acf14a20a286932ed32d500 (diff) | |
Compiled and linked SAMD21x18 version successfully.
Diffstat (limited to 'atmel-samd/Makefile')
| -rw-r--r-- | atmel-samd/Makefile | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/atmel-samd/Makefile b/atmel-samd/Makefile new file mode 100644 index 000000000..2174d67d8 --- /dev/null +++ b/atmel-samd/Makefile @@ -0,0 +1,93 @@ +include ../py/mkenv.mk + +CROSS = 0 + +# qstr definitions (must come before including py.mk) +QSTR_DEFS = qstrdefsport.h + +# include py core make definitions +include ../py/py.mk + +ifeq ($(CROSS), 1) +CROSS_COMPILE = arm-none-eabi- +endif + +BOSSAC := /Users/tannewt/ArduinoCore-samd/tools/bossac_osx + +INC += -I. +INC += -I.. +INC += -I../lib/mp-readline +INC += -I$(BUILD) + +ifeq ($(CROSS), 1) +CFLAGS_CORTEX_M0 = -mthumb -mabi=aapcs-linux -mcpu=cortex-m0plus -fsingle-precision-constant -Wdouble-promotion -D__SAMD21G18A__ +CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M0) $(COPT) +else +CFLAGS = -m32 $(INC) -Wall -Werror -ansi -std=gnu99 $(COPT) +endif + +#Debugging/Optimization +ifeq ($(DEBUG), 1) +CFLAGS += -O0 -ggdb +else +CFLAGS += -Os -DNDEBUG +endif + +LIBS = +ifeq ($(CROSS), 1) +LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) +LDFLAGS = -Lasf/thirdparty/CMSIS/Lib/GCC/ -L $(dir $(LIBGCC_FILE_NAME)) -nostdlib -T samd21.ld -Map=$@.map --cref +LIBS += -larm_cortexM0l_math -lgcc +else +LD = gcc +LDFLAGS = -m32 -Wl,-Map=$@.map,--cref +endif + +SRC_C = \ + main.c \ + uart_core.c \ + lib/utils/stdout_helpers.c \ + lib/utils/printf.c \ + lib/utils/pyexec.c \ + lib/libc/string0.c \ + lib/mp-readline/readline.c \ + $(BUILD)/_frozen_mpy.c \ + +OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) + +ifeq ($(CROSS), 1) +all: $(BUILD)/firmware.bin +else +all: $(BUILD)/firmware.elf +endif + +$(BUILD)/_frozen_mpy.c: frozentest.mpy $(BUILD)/genhdr/qstrdefs.generated.h + $(ECHO) "MISC freezing bytecode" + $(Q)../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 + $(ECHO) "Create $@" + $(Q)$(OBJCOPY) -O binary -j .isr_vector -j .text -j .data $^ $@ + +deploy: $(BUILD)/firmware.bin + $(ECHO) "Writing $< to the board" + $(BOSSAC) -u $< + +# 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 + +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 ../py/mkrules.mk |
