-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Hello,
I am experiencing an issue where builds for Teensy LC in PlatformIO are much larger than builds done in the Arduino IDE itself.
Some examples:
An empty sketch (default starting point for both Arduino and PlatformIO):
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Arduino:
Sketch uses 6044 bytes (9%) of program storage space. Maximum is 63488 bytes.
Global variables use 2088 bytes (25%) of dynamic memory, leaving 6104 bytes for local variables. Maximum is 8192 bytes.
PlatformIO:
DATA: [== ] 23.7% (used 1940 bytes from 8192 bytes)
PROGRAM: [= ] 11.7% (used 7420 bytes from 63488 bytes)
Bare program which loops and outputs "hello world" on Serial:
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("hello world");
delay(1000);
}Arduino:
Sketch uses 6964 bytes (10%) of program storage space. Maximum is 63488 bytes.
Global variables use 2104 bytes (25%) of dynamic memory, leaving 6088 bytes for local variables. Maximum is 8192 bytes.
PlatformIO:
DATA: [==== ] 37.3% (used 3056 bytes from 8192 bytes)
PROGRAM: [== ] 18.3% (used 11596 bytes from 63488 bytes)
Program using the Teensy ADC library which reads and then prints a value:
#include <Arduino.h>
#include <ADC.h>
ADC *adc = new ADC();
void setup()
{
// put your setup code here, to run once:
adc->setResolution(10);
adc->setAveraging(16);
adc->setConversionSpeed(ADC_CONVERSION_SPEED::VERY_LOW_SPEED);
adc->setSamplingSpeed(ADC_SAMPLING_SPEED::VERY_LOW_SPEED);
pinMode(A0, INPUT);
Serial.begin(115200);
}
void loop()
{
// put your main code here, to run repeatedly:
int val = adc->analogRead(A0);
Serial.printf("The ADC read %d\n", val);
delay(1000);
}Arduino:
Sketch uses 13636 bytes (21%) of program storage space. Maximum is 63488 bytes.
Global variables use 2224 bytes (27%) of dynamic memory, leaving 5968 bytes for local variables. Maximum is 8192 bytes.
PlatformIO:
DATA: [==== ] 41.8% (used 3424 bytes from 8192 bytes)
PROGRAM: [====== ] 60.8% (used 38608 bytes from 63488 bytes)
I am using the "Smallest Code" preset in the Arduino IDE, which per the board definition sets the following flags:
teensyLC.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib
teensyLC.build.flags.dep=-MMD
teensyLC.build.flags.cpu=-mthumb -mcpu=cortex-m0plus -fsingle-precision-constant
teensyLC.build.flags.defs=-D__MKL26Z64__ -DTEENSYDUINO=146
teensyLC.build.flags.cpp=-fno-exceptions -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
teensyLC.build.flags.c=
teensyLC.build.flags.S=-x assembler-with-cpp
teensyLC.build.flags.ld=-Wl,--gc-sections,--relax,--defsym=__rtc_localtime={extra.time.local} "-T{build.core.path}/mkl26z64.ld" -lstdc++
teensyLC.build.flags.libs=-larm_cortexM0l_math -lm
teensyLC.menu.opt.osstd.build.flags.optimize=-Os --specs=nano.specs
teensyLC.menu.opt.osstd.build.flags.ldspecs=
Looking at the build output from PlatformIO, it seems like most if not all of these flags are being set (I'm still trying to compare build outputs). The one I noticed missing was --specs=nano.specs; I tried setting that in the build_flags environment setting to no avail.