Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: usb_serial Makefile problem (Teensy 3.1)

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    2

    usb_serial Makefile problem (Teensy 3.1)

    Hi,
    I'm trying to make the usb_serial example under OS X 10.9.1. I edited the Makefile
    to set the MCU to Teensy 3.1s, like so...

    MCU = __MX20DX256__ # Teensy 3.1

    ... on running make I get this...

    Compiling C: example.c
    avr-gcc -c -mmcu=__MX20DX256__ -I. -gdwarf-2 -DF_CPU=96000000UL -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./example.lst -std=gnu99 -MMD -MP -MF .dep/example.o.d example.c -o example.o
    avr-gcc: error: unrecognized argument in option '-mmcu=__MX20DX256__'
    avr-gcc: note: valid arguments to '-mmcu=' are: at43usb320 at43usb355 (and on and on with a long list of MCUs)

    I have the latest avr-gcc (20131216).
    Any ideas why the MCU isn't recognized?

    thanks,
    Mark

  2. #2
    Senior Member
    Join Date
    Jan 2013
    Posts
    966
    This may be a simple case of a typo.
    The processor is not a __MX.... But a __MK....

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    2
    Thanks Headroom, but I still get the same error.
    Anyone have a working Makefile for Teensy 3.1 I could use as a template?

  4. #4
    Here is the Makefile I am using. It is a derivative of the sample in ...\arduino-1.0.5\hardware\teensy\cores\teensy3. You have to copy the .c and .h files from that same directory to the directory of the Makefile. Not sure how many of those files I really need; I just left them all in. Clumsy, but it works and disk space is cheap.

    I have commented out the changes I made from the original sample. I couldn't get the automatic download to work (I'm on Windows XP and I think it doesn't like the spaces in the filepath. ) So I just press the button to download.

    Good Luck!

    Code:
    # The name of your project (used to name the compiled .hex file)
    TARGET = main
    
    # configurable options
    OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH
    
    # options needed by many Arduino libraries to configure for Teensy 3.0
    #OPTIONS += -D__MK20DX128__ -DARDUIO=104
    # options needed by many Arduino libraries to configure for Teensy 3.0
    OPTIONS += -D__MK20DX256__ -DARDUIO=105
    
    
    #************************************************************************
    # Location of Teensyduino utilities, Toolchain, and Arduino Libraries.
    # To use this makefile without Arduino, copy the resources from these
    # locations and edit the pathnames.  The rest of Arduino is not needed.
    #************************************************************************
    
    # path location for Teensy Loader, teensy_post_compile and teensy_reboot
    TOOLSPATH = ../../../../ARM/Arduino/arduino-1.0.5/hardware/tools   
    #TOOLSPATH = C:/Documents and Settings/Administrator/My Documents/ARM/Arduino/arduino-1.0.5/hardware/tools
    
    # path location for the arm-none-eabi compiler
    #COMPILERPATH = ../../../ARM/Arduino/arduino-1.0.5/hardware/tools/arm-none-eabi/bin
    COMPILERPATH = C:/Documents and Settings/Administrator/My Documents/ARM/Arduino/arduino-1.0.5/hardware/tools/arm-none-eabi/bin
    
    INCPATH = C:/Documents and Settings/Administrator/My Documents/ARM/Arduino/arduino-1.0.5/hardware/teensy/cores/teensy3
    
    #************************************************************************
    # Settings below this point usually do not need to be edited
    #************************************************************************
    
    # CPPFLAGS = compiler options for C and C++
    CPPFLAGS = -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD $(OPTIONS) -I.
    
    # compiler options for C++ only
    CXXFLAGS = -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti
    
    # compiler options for C only
    CFLAGS =
    
    # linker options
    # LDFLAGS = -Os -Wl,--gc-sections -mcpu=cortex-m4 -mthumb -Tmk20dx128.ld  # Teensy 3.0
    LDFLAGS = -Os -Wl,--gc-sections -mcpu=cortex-m4 -mthumb -Tmk20dx256.ld  # Teensy 3.1
    
    # additional libraries to link
    LIBS = -lm
    
    
    # names for the compiler programs
    #CC = $(abspath $(COMPILERPATH))/arm-none-eabi-gcc
    #CXX = $(abspath $(COMPILERPATH))/arm-none-eabi-g++
    #OBJCOPY = $(abspath $(COMPILERPATH))/arm-none-eabi-objcopy
    #SIZE = $(abspath $(COMPILERPATH))/arm-none-eabi-size
    
    CC = $(COMPILERPATH)/arm-none-eabi-gcc
    CXX = $(COMPILERPATH)/arm-none-eabi-g++
    OBJCOPY = $(COMPILERPATH)/arm-none-eabi-objcopy
    SIZE = $(COMPILERPATH)/arm-none-eabi-size
    
    # automatically create lists of the sources and objects
    # TODO: this does not handle Arduino libraries yet...
    C_FILES := $(wildcard *.c)
    CPP_FILES := $(wildcard *.cpp)
    OBJS := $(C_FILES:.c=.o) $(CPP_FILES:.cpp=.o)
    
    
    # the actual makefile rules (all .o files built by GNU make's default implicit rules)
    
    all: $(TARGET).hex
    
    # Teensy 3.0
    # $(TARGET).elf: $(OBJS) mk20dx128.ld
    # Teensy 3.1
    $(TARGET).elf: $(OBJS) mk20dx256.ld
    	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
    
    %.hex: %.elf
    	$(SIZE) $<
    	$(OBJCOPY) -O ihex -R .eeprom $< $@
    #	$(TOOLSPATH)/teensy_post_compile -file=$(basename $@) -path=$(shell pwd) -tools=$(TOOLSPATH) -$(TOOLSPATH)/teensy_reboot
    #	$(abspath $(TOOLSPATH))/teensy_post_compile -file=$(basename $@) -path=$(shell pwd) -tools=$(abspath $(TOOLSPATH))
    #	-$(abspath $(TOOLSPATH))/teensy_reboot
    
    
    # compiler generated dependency info
    -include $(OBJS:.o=.d)
    
    clean:
    	rm -f *.o *.d $(TARGET).elf $(TARGET).hex

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •