teensy-template icon indicating copy to clipboard operation
teensy-template copied to clipboard

LDFlags

Open dderiso opened this issue 8 years ago • 0 comments

Great project, thanks!

When enabling arduino (ie setting ARDUINO = 10600), make sure the LDFlags have rtc_localtime set (see line 73 of https://github.com/PaulStoffregen/cores/blob/master/teensy3/Makefile );

# linker options
LDFLAGS = -Os -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mthumb -mcpu=cortex-m4

This will let the main.cpp work using standard Arduino code, for example:

#include "WProgram.h"

void setup(void){
    pinMode(13, OUTPUT);
}

void loop(void){
    digitalWrite(13, HIGH);
    delay(50);
    digitalWrite(13, LOW);
    delay(50);
}

extern "C" int main(void){
    setup();
    while (1) {
        loop();
        yield();
    }
}

Standard C++ code (thank you so much for this part!) will also work:

#include "WProgram.h"

extern "C" int main(void)
{
    pinMode(13, OUTPUT);
    while (1) {
        digitalWriteFast(13, HIGH);
        delay(50);
        digitalWriteFast(13, LOW);
        delay(50);
    }
}

Also, here are my options (based on yours and PJRC's):

# configurable options
OPTIONS = -DF_CPU=$(TEENSY_CORE_SPEED) -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE -ffunction-sections -fdata-sections

# options needed by many Arduino libraries to configure for Teensy 3.0
OPTIONS += -DARDUINO=$(ARDUINO) -DTEENSYDUINO=141

where disabling the bottom line will disable arduino. I like this better than the choice between DUSING_MAKEFILE or arduino, since both (arduino and no arduino) can be built with the makefile. Of course the best part about this is moving away from arduino but using the open source build engine. Thanks again for this!

dderiso avatar Mar 16 '16 20:03 dderiso