Compile and Uploading from CLI

Status
Not open for further replies.

Kardacian

Member
I have a Teensy 3.1 and a Teensy CLI. My first project was to create KVM port switcher. My existing KVM will not recognize the hot key sequences from my wireless keyboard (logitech K800) and the KVBM is hidden so using the port switches is not easy. I created a 4 button circuit that lets me switch directly to any port. Both boards work perfectly the code and the wiring were very easy to do. :) I had to use the Arduino IDE in conjunction with Teensyduino. However I don't like using the IDE I prefer to use a simple editor and compile and upload from the CLI. I have been doing this for all of my Arduino projects for a while. So I am trying this with the same code for the KVM switcher. I am getting close but kinda stuck now and I am sure it's some simple tweaks.

I pulled the Makefile from hardware/teensy/avr/cores/teensy3/Makefile

when I run it I get the following error.

beta:Keybrd kardacian$ make
make: *** No rule to make target `mk20dx256.ld', needed by `Keybrd.elf'. Stop.

Here is the code that I am trying to compile and upload. Keep in mind this codes work fine when I compile and upload via teensyduino.

//Sketch to switch iogear KVM active port

void SendIt(int Port);

const int ledPin = 13;
//****************************************************************************************
// Setup - Runs Once
//****************************************************************************************
void setup() {
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
Keyboard.begin() ;
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
}

//****************************************************************************************
// Loop - RUns constantly
//****************************************************************************************
void loop() {
if ( digitalRead( 9 ) == LOW ) { SendIt(1); }
if ( digitalRead( 10 ) == LOW ) { SendIt(2); }
if ( digitalRead( 11 ) == LOW ) { SendIt(4); }
if ( digitalRead( 12 ) == LOW ) { SendIt(3); }
}

//****************************************************************************************
// Sendit Function to send keystrokes to KVM based which button is pushed
//****************************************************************************************
void SendIt(int Port) {
digitalWrite(ledPin, LOW);
Keyboard.press( MODIFIERKEY_CTRL ) ;
Keyboard.releaseAll() ;
delay(300);
Keyboard.press( MODIFIERKEY_CTRL ) ;
Keyboard.releaseAll() ;
delay(600);
Keyboard.print( Port ); // holds the value of the button that was pushed
delay(600);
Keyboard.press( KEY_ENTER ) ;
Keyboard.releaseAll() ;
digitalWrite(ledPin, HIGH);
}


Here is the unedited makefile from the teensy 3.1 install

# The name of your project (used to name the compiled .hex file)
TARGET = main

# Path to your arduino installation
ARDUINOPATH ?= ../../../../..
#ARDUINOPATH ?= ../../../..

# configurable options
OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE

# options needed by many Arduino libraries to configure for Teensy 3.0
OPTIONS += -D__MK20DX256__ -DARDUINO=10600 -DTEENSYDUINO=121


# Other Makefiles and project templates for Teensy 3.x:
#
# https://github.com/apmorton/teensy-template
# https://github.com/xxxajk/Arduino_Makefile_master
# https://github.com/JonHylands/uCee


#************************************************************************
# 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 = $(ARDUINOPATH)/hardware/tools # on Linux

# path location for Arduino libraries (currently not used)
LIBRARYPATH = $(ARDUINOPATH)/libraries

# path location for the arm-none-eabi compiler
COMPILERPATH = $(ARDUINOPATH)/hardware/tools/arm/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,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=cortex-m4 -mthumb -Tmk20dx256.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) mk20dx256.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
 
OK, finally arrived at home. Indeed one of my modications was to find the linkerscript.
Code:
LINKFILE ?= mk20dx256.ld
ifeq ($(wildcard $(LINKFILE)),)
        LINKSCRIPT ?= $(ARDUINOPATH)/hardware/teensy/avr/cores/teensy3/$(LINKFILE)
else
        LINKSCRIPT ?= $(LINKFILE)
endif

...

LDFLAGS = -O0 -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=cortex-m4 -mthumb -T$(LINKSCRIPT)

...

$(TARGET).elf: $(OBJS) $(LINKSCRIPT)
        $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
If not defined it will first try to find it in the local directory, otherwise, it will pick the global version.
 
Im not makefile say should I insert this into the linker section of the makefile. I assume the 3 dots do not get inserted.
 
These are small snippets. The LDFLAGS= and $TARGET is already in Pauls Makefile. Just put the LINKFILE and the ifeq part before these lines.
 
So added the lines and got the following error.

make: *** No rule to make target `mk20dx256.ld', needed by `Keybrd.elf'. Stop.

Here is the complete Makefile.

# The name of your project (used to name the compiled .hex file)
TARGET = Keybrd

# Path to your arduino installation
ARDUINOPATH = /Applications/Arduino163.app
#ARDUINOPATH ?= ../../../..

# configurable options
OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE

# options needed by many Arduino libraries to configure for Teensy 3.0
OPTIONS += -D__MK20DX256__ -DARDUINO=10600 -DTEENSYDUINO=121


# Other Makefiles and project templates for Teensy 3.x:
#
# https://github.com/apmorton/teensy-template
# https://github.com/xxxajk/Arduino_Makefile_master
# https://github.com/JonHylands/uCee


#************************************************************************
# 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 = $(ARDUINOPATH)/hardware/tools # on Linux

# path location for Arduino libraries (currently not used)
LIBRARYPATH = $(ARDUINOPATH)/libraries

# path location for the arm-none-eabi compiler
COMPILERPATH = $(ARDUINOPATH)/hardware/tools/arm/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
LINKFILE ?= mk20dx256.ld
ifeq ($(wildcard $(LINKFILE)),)
LINKSCRIPT ?= $(ARDUINOPATH)/hardware/teensy/avr/cores/teensy3/$(LINKFILE)
else
LINKSCRIPT ?= $(LINKFILE)
endif
LDFLAGS = -Os -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=cortex-m4 -mthumb -Tmk20dx256.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) mk20dx256.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
 
Opps didn't hit save first, made the changes.

Making progress I think. Got this error

make: *** No rule to make target `/Applications/Arduino163.app/hardware/teensy/avr/cores/teensy3/mk20dx256.ld', needed by `Keybrd.elf'. Stop.

Included the makefile to be sure I made the correct changes.


# The name of your project (used to name the compiled .hex file)
TARGET = Keybrd

# Path to your arduino installation
ARDUINOPATH = /Applications/Arduino163.app
#ARDUINOPATH ?= ../../../..

# configurable options
OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE

# options needed by many Arduino libraries to configure for Teensy 3.0
OPTIONS += -D__MK20DX256__ -DARDUINO=10600 -DTEENSYDUINO=121


# Other Makefiles and project templates for Teensy 3.x:
#
# https://github.com/apmorton/teensy-template
# https://github.com/xxxajk/Arduino_Makefile_master
# https://github.com/JonHylands/uCee


#************************************************************************
# 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 = $(ARDUINOPATH)/hardware/tools # on Linux

# path location for Arduino libraries (currently not used)
LIBRARYPATH = $(ARDUINOPATH)/libraries

# path location for the arm-none-eabi compiler
COMPILERPATH = $(ARDUINOPATH)/hardware/tools/arm/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
LINKFILE ?= mk20dx256.ld
ifeq ($(wildcard $(LINKFILE)),)
LINKSCRIPT ?= $(ARDUINOPATH)/hardware/teensy/avr/cores/teensy3/$(LINKFILE)
else
LINKSCRIPT ?= $(LINKFILE)
endif
LDFLAGS = -O0 -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=cortex-m4 -mthumb -T$(LINKSCRIPT)

# 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) $(LINKSCRIPT)
$(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
 
1.6.3 might have the file somewhere else, in a shell, cd to the arduino directory and perform:
Code:
find -name mk20dx256.ld
 
I found the following file "/Contents/Java/hardware/teensy/avr/cores/teensy3/mk20dx256.ld"

Change this line to reflect the addition Java folder ==> LINKSCRIPT ?= $(ARDUINOPATH)/Java/hardware/teensy/avr/cores/teensy3/$(LINKFILE)

Result was the same

make: *** No rule to make target `/Applications/Arduino163.app/Java/hardware/teensy/avr/cores/teensy3/mk20dx256.ld', needed by `Keybrd.elf'. Stop.
 
The error I get is:
make: *** No rule to make target `/Applications/Arduino163.app/Java/hardware/teensy/avr/cores/teensy3/mk20dx256.ld', needed by `Keybrd.elf'. Stop.

The location of that file is in
/Applications/Arduino163.app/Contents/Java/hardware/teensy/avr/cores/teensy3/mk20dx256.ld

Here is the Makefile from the last run that produced the error above. I highlighted the line that I changed to reflect the directory change.

# The name of your project (used to name the compiled .hex file)
TARGET = Keybrd

# Path to your arduino installation
ARDUINOPATH = /Applications/Arduino163.app
#ARDUINOPATH ?= ../../../..

# configurable options
OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE

# options needed by many Arduino libraries to configure for Teensy 3.0
OPTIONS += -D__MK20DX256__ -DARDUINO=10600 -DTEENSYDUINO=121


# Other Makefiles and project templates for Teensy 3.x:
#
# https://github.com/apmorton/teensy-template
# https://github.com/xxxajk/Arduino_Makefile_master
# https://github.com/JonHylands/uCee


#************************************************************************
# 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 = $(ARDUINOPATH)/hardware/tools # on Linux

# path location for Arduino libraries (currently not used)
LIBRARYPATH = $(ARDUINOPATH)/libraries

# path location for the arm-none-eabi compiler
COMPILERPATH = $(ARDUINOPATH)/hardware/tools/arm/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
LINKFILE ?= mk20dx256.ld
ifeq ($(wildcard $(LINKFILE)),)
LINKSCRIPT ?= $(ARDUINOPATH)/Java/hardware/teensy/avr/cores/teensy3/$(LINKFILE)
else
LINKSCRIPT ?= $(LINKFILE)
endif
LDFLAGS = -O0 -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=cortex-m4 -mthumb -T$(LINKSCRIPT)

# 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) $(LINKSCRIPT)
$(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
 
Disregard my last post I made progress. I went through and verified each directory to correct all the incorrect ones. It appears that setting the:
ARDUINOPATH = /Applications/Arduino163.app/Contents/Java

Corrected most of the issues, Arduino added "Java" to the path. After making that change I ran Make again with the current output. It looks as if it recompiled and tried to upload but the upload failed. see below.


beta:Keybrd kardacian$ make
/Applications/Arduino163.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-gcc -O0 -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=cortex-m4 -mthumb -T/Applications/Arduino163.app/Contents/Java/hardware/teensy/avr/cores/teensy3/mk20dx256.ld -o Keybrd.elf -lm
/Applications/Arduino163.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-size Keybrd.elf
text data bss dec hex filename
1124 0 28 1152 480 Keybrd.elf
/Applications/Arduino163.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-objcopy -O ihex -R .eeprom Keybrd.elf Keybrd.hex
/Applications/Arduino163.app/Contents/Java/hardware/tools/teensy_post_compile -file=Keybrd -path=/Volumes/Data/kardacian/Code/Arduino/328/Keybrd -tools=/Applications/Arduino163.app/Contents/Java/hardware/tools
/Applications/Arduino163.app/Contents/Java/hardware/tools/teensy_reboot
Teensy did not respond to a USB-based request to automatically reboot.
Please press the PROGRAM MODE BUTTON on your Teensy to upload your sketch.
beta:Keybrd kardacian$ ls -l
total 96
drwxr-xr-x 10 kardacian staff 340 May 16 07:14 Junk
-rwxr-xr-x 1 kardacian staff 35854 May 16 07:14 Keybrd.elf
-rw-r--r-- 1 kardacian staff 3184 May 16 07:14 Keybrd.hex
-rw-r--r--@ 1 kardacian staff 1599 May 15 09:59 Keybrd.ino
-rw-r--r--@ 1 kardacian staff 3150 May 16 07:04 Makefile
beta:Keybrd kardacian$



Here is the current Makefile

# The name of your project (used to name the compiled .hex file)
TARGET = Keybrd

# Path to your arduino installation
ARDUINOPATH = /Applications/Arduino163.app/Contents/Java
#ARDUINOPATH ?= ../../../..

# configurable options
OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE

# options needed by many Arduino libraries to configure for Teensy 3.0
OPTIONS += -D__MK20DX256__ -DARDUINO=10600 -DTEENSYDUINO=121


# Other Makefiles and project templates for Teensy 3.x:
#
# https://github.com/apmorton/teensy-template
# https://github.com/xxxajk/Arduino_Makefile_master
# https://github.com/JonHylands/uCee


#************************************************************************
# 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 = $(ARDUINOPATH)/hardware/tools # on Linux

# path location for Arduino libraries (currently not used)
LIBRARYPATH = $(ARDUINOPATH)/libraries

# path location for the arm-none-eabi compiler
COMPILERPATH = $(ARDUINOPATH)/hardware/tools/arm/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
LINKFILE ?= mk20dx256.ld
ifeq ($(wildcard $(LINKFILE)),)
LINKSCRIPT ?= $(ARDUINOPATH)/hardware/teensy/avr/cores/teensy3/$(LINKFILE)
else
LINKSCRIPT ?= $(LINKFILE)
endif
LDFLAGS = -O0 -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=cortex-m4 -mthumb -T$(LINKSCRIPT)

# 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) $(LINKSCRIPT)
$(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
 
Status
Not open for further replies.
Back
Top