…Huh? O_O
The size of all the source files (as text) does not equal the size of the compiled program. This is not web development. A single line of C/C++ code can cause basically arbitrary usage of flash and RAM (think: (const) byte hugeArray[2*1024*1024];
, 2 Megabytes of flash/ram usage in one line ).
So what matters is the size of the compiled functions, classes and global variables / objects make it in the final build. You should do a test build where you hack the flash size to be very large so that the firmware builds, then throw it in an analyzer like mbed-os-linker-report or PlatformIO’s built-in analyzer.
As a first step for that, you have to modify the referenced linker file mk20dx256.ld
. That file should be in C:\Users\<user>\.platformio\packages\framework-arduinoteensy\cores\teensy3
. Bump up
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (rwx) : ORIGIN = 0x1FFF8000, LENGTH = 64K
}
to
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K
RAM (rwx) : ORIGIN = 0x1FFF8000, LENGTH = 64K
}
and build the binary. It should go through. Then use on of the analyzing tools above, or send the .elf
here.
You might want to read up on related cases like [ESP32] ld: region `dram0_0_seg' overflowed by 156768 bytes.