Why Does My Makefile Use More RAM Than PlatformIO When Compiling RTOS Project?

Hello everyone!
We are starting to work with RTOS using a Blue Pill and libopencm3 for our university project. Initially, we used PlatformIO for compiling and uploading to the board. However, we’ve been asked to work independently from the platform. We managed to set up the uploading process with OpenOCD, but we’re having trouble with the compilation.

To create the Makefile, I based it on Warren Gay’s project (GitHub - ve3wwg/stm32f103c8t6: libopencm3 and FreeRTOS projects using the STM32F103C8T6 MCU), specifically the blinky2 example (stm32f103c8t6/rtos/blinky2 at master · ve3wwg/stm32f103c8t6 · GitHub). I took the files Makefile.incl, Makefile.rtos, and the Makefile from blinky2, included only my .c files, and in the libopencm3 Makefile, I kept only the flags that referred to the STM32F1.

However, when I compile my project, it uses more RAM than when compiled with PlatformIO. I suspect this is because I’m including unnecessary files in the compilation process.

Is there a way to see the detailed compilation process of PlatformIO, beyond the .ini file?

Thanks in advance for any help!

PIO Core Cli

pio run -j1 -v

(Single threaded, verbose compilation includes all compile commands).

You would have to match the used compilers though too to get the same results as PlatformIO. Even using arm-none-eabi compilers that have the same version number (e.g. 10.3.1) can still produce different code, because e.g. the newlib library that that compiler uses was optimized for size (-Os) or for speed (-O2), or had different configurations activated etc. Other notable parts are:

  • is -ffunction-sections, -fdata-sections, -Wl,–gc-sections turned on to discard unused functions/data? Or is -flto turned on?
  • is the full (phat) C library used or the smaller newlib-nano one? (--specs=nano.specs in linker command)
  • same optimization level, same actiavted macros, same general settings
1 Like