PlatformIO Community

Build flugs in new version mbed

build_flags = -D MBED_BUILD_PROFILE_RELEASE
This flag does not reduce the size of the firmware in new version mbed (https://community.platformio.org/t/arm-mbed-os-5-13-4/9328)

@valeros please help

Hi @Nikantovik! What platform do you use? MBED_BUILD_PROFILE_RELEASE and MBED_BUILD_PROFILE_DEVELOP (used by default) are not so different in terms of optimization (especially for RAM). Could you please try -D MBED_BUILD_PROFILE_DEBUG does it affect memory size?

  #include <mbed.h>
  
  DigitalOut led (PC_13);
  
  int main() {
  
   // put your setup code here, to run once:
  
    while(1) {
    led=!led;
  wait_ms(1000);
  }
  }

[env:genericSTM32F103C8]
platform = stm32@5.5.0
board = genericSTM32F103C8
framework = mbed
build_flags = -D MBED_BUILD_PROFILE_RELEASE

DATA:    [          ]   1.8% (used 368 bytes from 20480 bytes)
PROGRAM: [=         ]  11.6% (used 7612 bytes from 65536 bytes)
build_flags = -D MBED_BUILD_PROFILE_DEBUG

DATA:    [==        ]  16.8% (used 3448 bytes from 20480 bytes)
PROGRAM: [======    ]  61.9% (used 40548 bytes from 65536 bytes)

[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = mbed
build_flags = -D MBED_BUILD_PROFILE_RELEASE

DATA:    [==        ]  17.3% (used 3536 bytes from 20480 bytes)
PROGRAM: [=====     ]  47.9% (used 31372 bytes from 65536 bytes)
build_flags = -D MBED_BUILD_PROFILE_DEBUG

DATA:    [==        ]  17.3% (used 3536 bytes from 20480 bytes)
PROGRAM: [======    ]  63.6% (used 41684 bytes from 65536 bytes)

Thanks for the info. I guess the problem is that in the new release they’ve moved code related to fault handling to the platform folder and now it’s compiled even in mbed 2 mode (that pulls in a bunch of heavy functions from libc). As a workaround you can try to add -DMBED_FAULT_HANDLER_DISABLED to your build_flags in platformio.ini

2 Likes

Thank you for help!!!