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

Thread: More Teensy3.1 Makefile Questions

  1. #1

    More Teensy3.1 Makefile Questions

    I am switching over to a Teensy3.1 from a Teensy 2.0.

    I want to use C code to be able to access some features (Quadrature Decoding on the Flex Timer Module).

    So the first step is getting the Makefile working and I am a Makefile newbie.

    I edited the included Makefile

    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
    
    
    #************************************************************************
    # 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   # on Linux
    #TOOLSPATH = ../../../tools/avr/bin   # on Mac or Windows
    
    # path location for the arm-none-eabi compiler
    COMPILERPATH = ../../../ARM/Arduino/arduino-1.0.5/hardware/tools/arm-none-eabi/bin
    
    #************************************************************************
    # 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
    
    # 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
    
    # 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
    
    $(TARGET).elf: $(OBJS) mk20dx128.ld
    	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
    
    %.hex: %.elf
    	$(SIZE) $<
    	$(OBJCOPY) -O ihex -R .eeprom $< $@
    	$(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
    and am trying to compile the sample program

    Code:
    #include "WProgram.h"
    
    extern "C" int main(void)
    {
    
    	// To use Teensy 3.0 without Arduino, simply put your code here.
    	// For example:
    
    	pinMode(13, OUTPUT);
    	while (1) {
    		digitalWriteFast(13, HIGH);
    		delay(500);
    		digitalWriteFast(13, LOW);
    		delay(500);
    	}
    
    }
    I get the error
    main.cpp|1 col 22| fatal error: WProgram.h: No such file or directory
    How to tell the Makefile/program where to find the #include files. I am used to using the <avr\xxx.h> for Teensy 2.0.

    Thanks,

    TLB

  2. #2
    Quick question:

    The default Makefile included under arduino-1.0.5\hardware\teensy\cores\teensy3 includes the line:

    Code:
    # options needed by many Arduino libraries to configure for Teensy 3.0
    OPTIONS += -D__MK20DX128__ -DARDUIO=104
    Does DARDUIO refer to the Arduino version and have to be updated to 105?

    I updated MK20DX128 to MK20DX256 for Teensy 3.1.

    Blinky works fine with the original line, but I assume there might be something more sophisticated where it matters.

    TLB

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,559
    Quote Originally Posted by tlb View Post
    Does DARDUIO refer to the Arduino version and have to be updated to 105?
    You have an old version. This typo was fixed some time ago.

  4. #4
    Is there supposed to be a teensy31 directory somewhere? Or am I looking in a completely wrong place.

    I am looking at the default Makefile included under arduino-1.0.5\hardware\teensy\cores\teensy3

    From the website:
    To use Teensy 3.0 without Arduino, first install Teensyduino. A sample makefile is installed in hardware/teensy/cores/teensy3
    I just ran the Teensyduino 1.18-rc1 Installer. The date stamp shows it updated this Makefile.

    The Makefile is still configured for Teensy 3.0 and Arduino 1.0.4.

    Code:
    # options needed by many Arduino libraries to configure for Teensy 3.0
    OPTIONS += -D__MK20DX128__ -DARDUIO=104
    I couldn't find any other Teensy3+ Makefile under the directory structure.

    TLB

  5. #5
    BTW, the previous is on a Windows XP system.

    TLB

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,559
    Quote Originally Posted by tlb View Post
    Is there supposed to be a teensy31 directory somewhere?
    No. The same code is used for Teensy 3.0 & 3.1. There are only minor differences, mostly in analog.c, with #ifdef checks in the code.

  7. #7
    Is there an updated version of the sample Makefile past the one that has

    Code:
    # options needed by many Arduino libraries to configure for Teensy 3.0
    OPTIONS += -D__MK20DX128__ -DARDUIO=104
    If so, it is not showing up in the Windows XP version of Teensyduino 1.18-rc1.

    Re your response

    You have an old version. This typo was fixed some time ago.
    I have re-downloaded and re-ran to make sure I have the latest version available. And the installer says Teensyduino 1.18-rc1 Installer

    TLB

Posting Permissions

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