Skip to content

sketches use surprisingly large amounts of RAM #15

Closed
@jerabaul29

Description

@jerabaul29

I am playing around with some small Artemis + MbedOS recipes. I have a small recipe I wanted to try (available at https://github.com/jerabaul29/Artemis_MbedOS_recipes/tree/main/recipes/recipe_RTC if you want to reproduce).

I am able to compile it with the Arduino IDE (well, not with the latest Sparkfun release, see issue sparkfun/Arduino_Apollo3#330 , but with the previous release from a few weeks ago it works fine), in which case the sketch uses a few percents of the RAM available.

But when I compile this exact sketch with the platformio extension, I get:

Processing SparkFun_RedBoard_Artemis (platform: apollo3blue; board: SparkFun_RedBoard_Artemis; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/apollo3blue/SparkFun_RedBoard_Artemis.html
PLATFORM: Apollo 3 Blue (0.0.2) > SparkFun RedBoard Artemis
HARDWARE: AMA3B1KK 48MHz, 384KB RAM, 960KB Flash
PACKAGES: 
 - framework-arduinoapollo3 2.0.2 
 - toolchain-gccarmnoneeabi 1.70201.0 (7.2.1)
-------------------> /home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/arduino/mbed-bridge
-------------------> <SCons.Script.SConscript.SConsEnvironment object at 0x7fc005b98520>
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/SparkFun_RedBoard_Artemis/src/main.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/varient/config/pins.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/varient/variant.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/bridge/pins.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-api/api/Common.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-api/api/IPAddress.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-api/api/PluggableUSB.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-api/api/Print.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-api/api/Stream.cpp.o
src/main.cpp: In function 'int main()':
src/main.cpp:13:37: warning: 'void rtos::ThisThread::sleep_for(uint32_t)' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
     rtos::ThisThread::sleep_for(1000);
                                     ^
In file included from /home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/mbed-os/rtos/rtos.h:30:0,
                 from /home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/mbed-os/mbed.h:22,
                 from /home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/arduino/mbed-bridge/Arduino.h:11,
                 from /home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/arduino/sdk/ArduinoSDK.h:9,
                 from <command-line>:0:
/home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/mbed-os/rtos/ThisThread.h:216:6: note: declared here
 void sleep_for(uint32_t millisec);
      ^~~~~~~~~
src/main.cpp:115:41: warning: 'void rtos::ThisThread::sleep_for(uint32_t)' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
         rtos::ThisThread::sleep_for(1000);
                                         ^
In file included from /home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/mbed-os/rtos/rtos.h:30:0,
                 from /home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/mbed-os/mbed.h:22,
                 from /home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/arduino/mbed-bridge/Arduino.h:11,
                 from /home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/arduino/sdk/ArduinoSDK.h:9,
                 from <command-line>:0:
/home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/mbed-os/rtos/ThisThread.h:216:6: note: declared here
 void sleep_for(uint32_t millisec);
      ^~~~~~~~~
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-api/api/String.cpp.o
Archiving .pio/build/SparkFun_RedBoard_Artemis/libvarient.a
Indexing .pio/build/SparkFun_RedBoard_Artemis/libvarient.a
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-implement/CommonAnalog.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-implement/CommonDigital.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-implement/CommonInit.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-implement/CommonInterrupt.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-implement/CommonMath.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-implement/CommonPulse.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-implement/CommonTiming.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-implement/HardwareSerial.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/core-implement/Yield.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/mbed_bridge/main.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/PDM/PDM.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/RTC/RTC.cpp.o
Compiling .pio/build/SparkFun_RedBoard_Artemis/Servo/Servo.cpp.o
Archiving .pio/build/SparkFun_RedBoard_Artemis/libSoftwareSerial.a
Indexing .pio/build/SparkFun_RedBoard_Artemis/libSoftwareSerial.a
Compiling .pio/build/SparkFun_RedBoard_Artemis/SPI/SPI.cpp.o
In file included from /home/jrmet/.platformio/packages/framework-arduinoapollo3/libraries/PDM/src/PDM.cpp:22:0:
/home/jrmet/.platformio/packages/framework-arduinoapollo3/libraries/PDM/src/PDM.h:32:2: warning: #warning "Mic DATA pin not defined in variant. Using default." [-Wcpp]
 #warning "Mic DATA pin not defined in variant. Using default."
  ^~~~~~~
/home/jrmet/.platformio/packages/framework-arduinoapollo3/libraries/PDM/src/PDM.h:37:2: warning: #warning "Mic CLOCK pin not defined in variant. Using default." [-Wcpp]
 #warning "Mic CLOCK pin not defined in variant. Using default."
  ^~~~~~~
Compiling .pio/build/SparkFun_RedBoard_Artemis/Wire/Wire.cpp.o
/home/jrmet/.platformio/packages/framework-arduinoapollo3/libraries/PDM/src/PDM.cpp: In member function 'uint32_t AP3_PDM::getData(uint16_t*, uint32_t)':
/home/jrmet/.platformio/packages/framework-arduinoapollo3/libraries/PDM/src/PDM.cpp:301:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int x = 0; x < externalBufferSize; x++)
                         ~~^~~~~~~~~~~~~~~~~~~~
/home/jrmet/.platformio/packages/framework-arduinoapollo3/libraries/PDM/src/PDM.cpp:309:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int x = 0; x < externalBufferSize; x++)
                         ~~^~~~~~~~~~~~~~~~~~~~
/home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/arduino/mbed-bridge/core-implement/HardwareSerial.cpp: In member function 'int UART::printf(const char*, ...)':
/home/jrmet/.platformio/packages/framework-arduinoapollo3/cores/arduino/mbed-bridge/core-implement/HardwareSerial.cpp:153:19: warning: variable length array 'buf' is used [-Wvla]
     char buf[space];
                   ^
/home/jrmet/.platformio/packages/framework-arduinoapollo3/libraries/PDM/src/PDM.cpp: In member function 'void AP3_PDM::pdm_isr()':
/home/jrmet/.platformio/packages/framework-arduinoapollo3/libraries/PDM/src/PDM.cpp:335:18: warning: unused variable 'tempReadAmt' [-Wunused-variable]
         uint32_t tempReadAmt = _pdmBufferSize;
                  ^~~~~~~~~~~
/home/jrmet/.platformio/packages/framework-arduinoapollo3/libraries/RTC/src/RTC.cpp: In member function 'void Apollo3RTC::setEpoch(uint32_t)':
/home/jrmet/.platformio/packages/framework-arduinoapollo3/libraries/RTC/src/RTC.cpp:94:15: warning: unused variable 'tm' [-Wunused-variable]
     struct tm tm;
               ^~
Archiving .pio/build/SparkFun_RedBoard_Artemis/libServo.a
Indexing .pio/build/SparkFun_RedBoard_Artemis/libServo.a
Archiving .pio/build/SparkFun_RedBoard_Artemis/libPDM.a
Indexing .pio/build/SparkFun_RedBoard_Artemis/libPDM.a
Archiving .pio/build/SparkFun_RedBoard_Artemis/libmbed_bridge.a
Indexing .pio/build/SparkFun_RedBoard_Artemis/libmbed_bridge.a
Archiving .pio/build/SparkFun_RedBoard_Artemis/libRTC.a
Indexing .pio/build/SparkFun_RedBoard_Artemis/libRTC.a
Archiving .pio/build/SparkFun_RedBoard_Artemis/libSPI.a
Indexing .pio/build/SparkFun_RedBoard_Artemis/libSPI.a
Archiving .pio/build/SparkFun_RedBoard_Artemis/libWire.a
Indexing .pio/build/SparkFun_RedBoard_Artemis/libWire.a
Linking .pio/build/SparkFun_RedBoard_Artemis/program
Checking size .pio/build/SparkFun_RedBoard_Artemis/program
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==========]  99.7% (used 391928 bytes from 393216 bytes)
arm-none-eabi-objcopy -O binary .pio/build/SparkFun_RedBoard_Artemis/program .pio/build/SparkFun_RedBoard_Artemis/firmware.bin
Flash: [=         ]  12.8% (used 125592 bytes from 983040 bytes)
=========================================================================================== [SUCCESS] Took 10.83 seconds ===========================================================================================

And here the RAM use shocks me: 99.7 percents.

Any idea if there is a problem / why / how to solve?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions