I'm trying to get my program building via Makefile. I've stripped it down to this amalgamation of modified sample code.#include <unistd.h>
Makefile
Which results in:
I'm assuming mk20dx128.ld to be a library build from hardware/tools/teensy3 source, and that it shouldn't be recompiled each and every time I build my project. Is that accurate? I've been able (after ripping out more of the windows make kludges) to get it to compile, but it doesn't run anything, and the hex filie is way smaller in relation to the elf file than I would normally expect. Anyone have Teensy3 stuff building for Linux/Makefile setup?
Code:
#include "mk20dx128.h"
#include "usb_serial.h"
#include "core_pins.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);
}
}
Makefile
Code:
TARGET = main
OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH
ARDUINO_SDK = /usr/local/arduino/
PLATFORM = $(ARDUINO_SDK)/hardware/teensy/cores/teensy3
TOOLSPATH = $(ARDUINO_SDK)/hardware/tools
LIBRARYPATH = $(ARDUINO_SDK)/libraries
COMPILERPATH = $(TOOLSPATH)/arm-none-eabi/bin
CPPFLAGS = -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD $(OPTIONS) -I. -I$(PLATFORM)
CXXFLAGS = -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti
CFLAGS =
LDFLAGS = -Os -Wl,--gc-sections -mcpu=cortex-m4 -mthumb -T$(PLATFORM)/mk20dx128.ld
LIBS = -lm
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
C_FILES := $(wildcard *.c)
CPP_FILES := $(wildcard *.cpp)
OBJS := $(C_FILES:.c=.o) $(CPP_FILES:.cpp=.o)
all: $(TARGET).hex
$(TARGET).elf: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(PLATFORM)/mk20dx128.ld
%.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
-include $(OBJS:.o=.d)
clean:
rm -f *.o *.d $(TARGET).elf $(TARGET).hex
Which results in:
Code:
/usr/local/arduino/hardware/tools/arm-none-eabi/bin/arm-none-eabi-gcc -Os -Wl,--gc-sections -mcpu=cortex-m4 -mthumb -T/usr/local/arduino//hardware/teensy/cores/teensy3/mk20dx128.ld -o main.elf main.o /usr/local/arduino//hardware/teensy/cores/teensy3/mk20dx128.ld
/usr/local/arduino-1.0.4/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.7.2/../../../../arm-none-eabi/bin/ld:/usr/local/arduino//hardware/teensy/cores/teensy3/mk20dx128.ld:3: warning: redeclaration of memory region `FLASH'
/usr/local/arduino-1.0.4/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.7.2/../../../../arm-none-eabi/bin/ld:/usr/local/arduino//hardware/teensy/cores/teensy3/mk20dx128.ld:4: warning: redeclaration of memory region `RAM'
/usr/local/arduino//hardware/teensy/cores/teensy3/mk20dx128.ld:11 cannot move location counter backwards (from 000004d8 to 00000000)
collect2: error: ld returned 1 exit status
make: *** [main.elf] Error 1
I'm assuming mk20dx128.ld to be a library build from hardware/tools/teensy3 source, and that it shouldn't be recompiled each and every time I build my project. Is that accurate? I've been able (after ripping out more of the windows make kludges) to get it to compile, but it doesn't run anything, and the hex filie is way smaller in relation to the elf file than I would normally expect. Anyone have Teensy3 stuff building for Linux/Makefile setup?