From ee0013d24ee53d7d9af30e08163c746ebfbf6e4a Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Wed, 8 Jan 2014 09:09:47 -0800 Subject: [PATCH] Update teemsy/Makefile to use py.mk I also fixed main.c to compile with the new str lexer --- teensy/Makefile | 114 ++++++++++-------------------------------------- teensy/main.c | 3 +- 2 files changed, 23 insertions(+), 94 deletions(-) diff --git a/teensy/Makefile b/teensy/Makefile index 0e42867641..fa1ec63e8f 100644 --- a/teensy/Makefile +++ b/teensy/Makefile @@ -1,12 +1,19 @@ +# define main target +all: all2 + +# include py core make definitions +include ../py/py.mk + +# program for deletion +RM = /bin/rm + ifeq ($(ARDUINO),) $(error Please define ARDUINO (where TeensyDuino is installed)) endif TOOLS_PATH = $(ARDUINO)/hardware/tools COMPILER_PATH = $(TOOLS_PATH)/arm-none-eabi/bin CORE_PATH = $(ARDUINO)/hardware/teensy/cores/teensy3 - -PYSRC=../py -BUILD=build +TARGET=TEENSY AS = $(COMPILER_PATH)/arm-none-eabi-as CC = $(COMPILER_PATH)/arm-none-eabi-gcc @@ -14,9 +21,9 @@ LD = $(COMPILER_PATH)/arm-none-eabi-ld OBJCOPY = $(COMPILER_PATH)/arm-none-eabi-objcopy SIZE = $(COMPILER_PATH)/arm-none-eabi-size -CFLAGS_TEENSY = -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX256__ +CFLAGS_TEENSY = -DF_CPU=96000000 -DUSB_SERIAL -D__MK20DX256__ CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -fsingle-precision-constant -Wdouble-promotion $(CFLAGS_TEENSY) -CFLAGS = -I. -I$(PYSRC) -I$(CORE_PATH) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4) +CFLAGS = -I. -I$(PY_SRC) -I$(CORE_PATH) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4) -D$(TARGET) LDFLAGS = -nostdlib -T mk20dx256.ld LIBS = -L $(COMPILER_PATH)/../lib/gcc/arm-none-eabi/4.7.2/thumb2 -lgcc @@ -36,55 +43,6 @@ STM_SRC_C = \ STM_SRC_S = \ gchelper.s \ -PY_O = \ - nlrthumb.o \ - gc.o \ - malloc.o \ - qstr.o \ - vstr.o \ - unicode.o \ - lexer.o \ - lexerstr.o \ - parse.o \ - scope.o \ - compile.o \ - emitcommon.o \ - emitpass1.o \ - emitbc.o \ - asmthumb.o \ - emitnthumb.o \ - emitinlinethumb.o \ - runtime.o \ - map.o \ - obj.o \ - objbool.o \ - objboundmeth.o \ - objcell.o \ - objclass.o \ - objclosure.o \ - objcomplex.o \ - objdict.o \ - objexcept.o \ - objfloat.o \ - objfun.o \ - objgenerator.o \ - objinstance.o \ - objint.o \ - objlist.o \ - objmodule.o \ - objnone.o \ - objrange.o \ - objset.o \ - objslice.o \ - objstr.o \ - objtuple.o \ - objtype.o \ - builtin.o \ - builtinimport.o \ - vm.o \ - showbc.o \ - repl.o \ - SRC_TEENSY = \ mk20dx128.c \ pins_teensy.c \ @@ -95,36 +53,29 @@ SRC_TEENSY = \ usb_serial.c \ yield.c \ -STM_SRC_C_OBJ = $(STM_SRC_C:.c=.o) -STM_SRC_S_OBJ = $(STM_SRC_S:.s=.o) - -OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(STM_SRC_C_OBJ) $(STM_SRC_S_OBJ) $(PY_O) $(SRC_TEENSY:.c=.o)) +OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(STM_SRC_C:.c=.o) $(STM_SRC_S:.s=.o) $(SRC_TEENSY:.c=.o)) $(PY_O) #LIB = -lreadline # the following is needed for BSD #LIB += -ltermcap -PROG = micropython -all: hex -hex: $(PROG).hex +all2: $(BUILD) hex +hex: $(BUILD)/flash.hex -post_compile: $(PROG).hex - $(TOOLS_PATH)/teensy_post_compile -file="$(basename $<)" -path="$(CURDIR)" -tools="$(TOOLS_PATH)" +post_compile: $(BUILD)/flash.hex + $(TOOLS_PATH)/teensy_post_compile -file="$(basename $<)" -path="$(BUILD)" -tools="$(TOOLS_PATH)" reboot: -$(TOOLS_PATH)/teensy_reboot upload: post_compile reboot -$(PROG).elf: $(BUILD) $(OBJ) - $(CC) $(LDFLAGS) -o "$@" -Wl,-Map,$(PROG).map $(OBJ) $(LIBS) +$(BUILD)/flash.elf: $(OBJ) + $(CC) $(LDFLAGS) -o "$@" -Wl,-Map,$(@:.elf=.map) $(OBJ) $(LIBS) + $(SIZE) $@ -%.hex: %.elf - $(SIZE) "$<" +$(BUILD)/%.hex: $(BUILD)/%.elf $(OBJCOPY) -O ihex -R .eeprom "$<" "$@" -$(BUILD): - mkdir -p $@ - $(BUILD)/%.o: %.c $(CC) $(CFLAGS) -c -o $@ $< @@ -134,33 +85,12 @@ $(BUILD)/%.o: ../stm/%.s $(BUILD)/%.o: ../stm/%.c $(CC) $(CFLAGS) -c -o $@ $< -$(BUILD)/%.o: $(PYSRC)/%.S - $(CC) $(CFLAGS) -c -o $@ $< - -$(BUILD)/%.o: $(PYSRC)/%.c mpconfigport.h - $(CC) $(CFLAGS) -c -o $@ $< - $(BUILD)/%.o: $(CORE_PATH)/%.c $(CC) $(CFLAGS) -c -o $@ $< -$(BUILD)/emitnthumb.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h - $(CC) $(CFLAGS) -DN_THUMB -c -o $@ $< - -# optimising gc for speed; 5ms down to 4ms -$(BUILD)/gc.o: $(PYSRC)/gc.c - $(CC) $(CFLAGS) -O3 -c -o $@ $< - -# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster) -$(BUILD)/vm.o: $(PYSRC)/vm.c - $(CC) $(CFLAGS) -O3 -c -o $@ $< - $(BUILD)/main.o: mpconfigport.h -$(BUILD)/parse.o: $(PYSRC)/grammar.h -$(BUILD)/compile.o: $(PYSRC)/grammar.h -$(BUILD)/emitbc.o: $(PYSRC)/emit.h clean: /bin/rm -rf $(BUILD) - /bin/rm -f $(PROG).elf $(PROG).hex $(PROG).map -.PHONY: clean +.PHONY: all all2 clean diff --git a/teensy/main.c b/teensy/main.c index ce6aa029da..fd5aec0459 100644 --- a/teensy/main.c +++ b/teensy/main.c @@ -347,8 +347,7 @@ void do_repl(void) { } } - mp_lexer_str_buf_t sb; - mp_lexer_t *lex = mp_lexer_new_from_str_len("", vstr_str(&line), vstr_len(&line), false, &sb); + mp_lexer_t *lex = mp_lexer_new_from_str_len("", vstr_str(&line), vstr_len(&line), 0); mp_parse_node_t pn = mp_parse(lex, MP_PARSE_SINGLE_INPUT); mp_lexer_free(lex);