PlatformIO small build for Teensy LC

Status
Not open for further replies.

e3b0c442

New member
Hello all,

I have a project that I am building in PlatformIO for Teensy LC that has gone over the space limit. However, if I build the same code in Arduino/Teensyduino using the "smallest" optimization, everything fits fine.

I have looked up the specific build flags in the boards.txt file and tried to apply them in my platformio.ini file, but it doesn't seem to be having any effect. Anybody out there with an example of a platformio.ini config file that builds small code for Teensy LC?

Thanks!

edit: here's the source. Sorry for the delay, realized I should have added it when I posted and needed to clear out credentials.

In PlatformIO, I get this message:
Code:
Linking .pioenvs/teensylc/firmware.elf
/Users/nick/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: .pioenvs/teensylc/firmware.elf section `.text' will not fit in region `FLASH'
/Users/nick/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld: region `FLASH' overflowed by 1508 bytes
In Arduino:
Code:
Sketch uses 41240 bytes (64%) of program storage space. Maximum is 63488 bytes.
Global variables use 3452 bytes (42%) of dynamic memory, leaving 4740 bytes for local variables. Maximum is 8192 bytes.

Code:
#include <Arduino.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <HardwareSerial.h>
#include <U8g2lib.h>
#include <SPI.h>

#define ESP_ENABLE_PIN 2
#define ESP_BOOT_MODE_PIN 3
#define ESP_RST_PIN 4

U8G2_SSD1306_128X32_UNIVISION_1_4W_HW_SPI u8g2(U8G2_R0, 10, 5, 15);
unsigned long last = 0;
char auth[] = "redacted";
char ssid[] = "redacted";
char pass[] = "redacted";
char server[] = "redacted";
uint16_t port = 80;
ESP8266 wifi(&Serial1);

void setup() {
    u8g2.begin();
    pinMode(ESP_ENABLE_PIN, OUTPUT);
    pinMode(ESP_BOOT_MODE_PIN, OUTPUT);
    pinMode(ESP_RST_PIN, OUTPUT);
    digitalWrite(ESP_ENABLE_PIN, LOW);
    digitalWrite(ESP_RST_PIN, LOW);
    // Setup computer to Teensy serial
    Serial.begin(115200);
    // Setup Teensy to ESP8266 serial
    // Use baud rate 115200 during firmware update
    Serial1.begin(115200);
    Serial.println("Serial enabled");
    digitalWrite(ESP_BOOT_MODE_PIN, HIGH);
    digitalWrite(ESP_ENABLE_PIN, HIGH);
    delay(1000);
    digitalWrite(ESP_RST_PIN, HIGH);
    delay(1000);
    Blynk.begin(auth, wifi, ssid, pass, server, port);
    last = millis();
}

int offset = 0;
bool offset_dir = 1;
unsigned long last_offset = 0;
unsigned long offset_interval = 200;
bool dirty = true;

void loop() {
    Blynk.run();
    u8g2.setFont(u8g2_font_helvR10_tf);
    u8g2_uint_t w = u8g2.getStrWidth("Demo string");
    unsigned long ts = millis();
    if(w > 64) {
        if((long)ts - long(last_offset) > (long)offset_interval) {
            last_offset = ts;
            if(offset == 0 || offset == 64-w) {
                offset_dir = !offset_dir;
            }
            offset_dir ? offset++ : offset--;
            dirty = true;
        }
    } else {
        offset = 0;
    }
    if(dirty) {
        u8g2.setContrast(0);
        u8g2.firstPage();
        do {
            u8g2.setFont(u8g2_font_helvR10_tf);
            u8g2.setDrawColor(1);
            u8g2.setCursor(0 + offset, 16);
            u8g2.print("Demo string");
            u8g2.setFont(u8g2_font_helvB08_tf);
            u8g2.drawBox(0,20,32,12);
            u8g2.setDrawColor(0);
            u8g2.setCursor(2, 30);
            u8g2.print(F("L:000"));
            u8g2.setFont(u8g2_font_helvR08_tf);
            u8g2.setDrawColor(1);
            u8g2.setCursor(32, 30);
            u8g2.print(F("H:000"));
            u8g2.setFont(u8g2_font_logisoso28_tf);
            u8g2.setCursor(64, 32);
            u8g2.print(F("000\xb0"));
        } while (u8g2.nextPage() );
        if(w > 64 && (offset == 0 || offset == 64-w)) {
            last_offset += 1000;
        }
        dirty = false;
    }

}
 
Last edited:
Status
Not open for further replies.
Back
Top