mbed + PlatformIO = too long compilation

17 Sep 2019

Hi anybody!

I have a trouble that prevents me from switching from Arduino to mbed under PlatformIO IDE. The problem is that any simple code compiles with mbed ten times longer than similar Arduino code.

For example the simplest code with 'Hello World'. It takes 5 seconds with Arduino and 40 seconds with mbed. If I enable RTOS with -D PIO_FRAMEWORK_MBED_RTOS_PRESENT macros then compilation takes even longer.

It seems that the compiler builds all the core mbed libraries anytime and with RTOS enabled it compiles also all the features.

I use Ryzen 7 with super fast PCIe SSD and 32Gb RAM and it is not possible to work with mbed. The same situation repeats with other computers I have (simple compilation at my laptop takes 20 minutes).

Here is the output of ordinary, not clean build:

Processing nucleo_f103rb (platform: ststm32; board: nucleo_f103rb; framework: mbed) Verbose mode can be enabled via `-v, verbose` option CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_f103rb.html PLATFORM: ST STM32 5.6.0 > ST Nucleo F103RB HARDWARE: STM32F103RBT6 72MHz, 20KB RAM, 128KB Flash DEBUG: Current (stlink) On-board (stlink) External (blackmagic, jlink) PACKAGES: toolchain-gccarmnoneeabi 1.70201.0 (7.2.1), framework-mbed 5.51304.190826 (5.13.4) Collecting mbed sources... LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf LDF Modes: Finder ~ chain, Compatibility ~ soft Found 0 compatible libraries Scanning dependencies... No dependencies Checking size .pio\build\nucleo_f103rb\firmware.elf Memory Usage -> http://bit.ly/pio-memory-usage DATA: [===== ] 49.3% (used 10088 bytes from 20480 bytes) PROGRAM: [===== ] 48.2% (used 63168 bytes from 131072 bytes) [SUCCESS] Took 39.78 seconds

Everything looks fine except the compilation time.

18 Sep 2019

Hi Vladislav, Unfortunately on the first time compiler builds everything (all libraries). After the first time or if you have not done changes for mbed_app.json only application will be compiled and the time is very short compared to full library compilation.

Regards, Pekka

18 Sep 2019

Platformio+mbed+LINUX=fast compilation

21 Sep 2019

Pekka Saavalainen wrote:

Hi Vladislav, Unfortunately on the first time compiler builds everything (all libraries). After the first time or if you have not done changes for mbed_app.json only application will be compiled and the time is very short compared to full library compilation.

Regards, Pekka

Yes, it it. But even repeated compilation takes too long: 1. Compile after clean Took 143.71 seconds 2. Repeat compile Took 39.91 seconds

That is with RTOS enabled via PIO_FRAMEWORK_MBED_RTOS_PRESENT macro and at a superfast computer. i7 or i3 takes much longer for compilation.

The problem is that if I include a new lib or a new include it recompiles again. If I try to debug - the same, full recompilation.

I think that the problem is in enabled features like:

Compiling .pio\build\nucleo_f103rb\FrameworkMbed\features\nfc\stack\transceiver\transceiver.o
Compiling .pio\build\nucleo_f103rb\FrameworkMbed\features\storage\blockdevice\BufferedBlockDevice.o

So it includes everything that bmed has. The final firmware takes also too much:

Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [=====     ]  49.3% (used 10088 bytes from 20480 bytes)
PROGRAM: [=====     ]  48.2% (used 63168 bytes from 131072 bytes)
21 Sep 2019

Nik Fedorov wrote:

Platformio+mbed+LINUX=fast compilation

What board do you use?

21 Sep 2019

Hello Vladislav,

To reduce the amount of files to be compiled you can try to exclude some unneeded components and features from your project using a .mbedignore file.

For example:

  • Create a simple "blinky" project for"mbed-os".
  • Create a .mbedignore file in the mbed-os folder of your project and include it to the project files.
  • Add the following lines to the .mbedignore file and save it:

.mbedignore

components/802.15.4_RF/*
components/storage/*
components/wifi/*
features/cellular/*
features/frameworks/*
features/lorawan/*
features/lwipstack/*
features/mbedtls/*
features/nanostack/*
features/netsocket/*
features/nfc/*
features/storage/*
usb/*

Compilation of such project should be much faster. However, as you will gradually extend your project by additional features some of those lines have to be deleted and the compilation will take more and more time :-(

21 Sep 2019

Zoltan Hudak wrote:

Hello Vladislav,

To reduce the amount of files to be compiled you can try to exclude some unneeded components and features from your project using a .mbedignore file.

For example:

  • Create a simple "blinky" project for"mbed-os".
  • Create a .mbedignore file in the mbed-os folder of your project and include it to the project files.
  • Add the following lines to the .mbedignore file and save it:

.mbedignore

components/802.15.4_RF/*
components/storage/*
components/wifi/*
features/cellular/*
features/frameworks/*
features/lorawan/*
features/lwipstack/*
features/mbedtls/*
features/nanostack/*
features/netsocket/*
features/nfc/*
features/storage/*
usb/*

Compilation of such project should be much faster. However, as you will gradually extend your project by additional features some of those lines have to be deleted and the compilation will take more and more time :-(

It looks like a solution but it doesn't work at my installation (I think that there is something wrong with my file position).

I did the following: 1. Created .mbedignore at the root folder of my project in VSCode + Platfromio. 2. Inserted there features/* and also features\* 3. Clean 4. Compile

Unfortunately there is no result. I think that the file is located not at the appropriate place.

It will be great to keep the file here because at that place (and all subdirs of my project) are under git synchronization and I'd like to keep it the same at all my computers. I also tried to put this file into src and include of my project - not success.

May be it is possible to pass this file to the compiler via .platformio?

PS. I also found this manual according to this file https://github.com/bravegnu/Handbook/blob/master/docs/advanced/mbedignore.md

/media/uploads/kvv213/annotation_2019-09-21_212023.png

22 Sep 2019

Vladislav Kravchenko wrote:

Nik Fedorov wrote:

Platformio+mbed+LINUX=fast compilation

What board do you use?

Any. Platformio on Linux is much faster than on Windows

22 Sep 2019

Nik Fedorov wrote:

Vladislav Kravchenko wrote:

Nik Fedorov wrote:

Platformio+mbed+LINUX=fast compilation

What board do you use?

Any. Platformio on Linux is much faster than on Windows

I'm not sure that just usage of Linux can give speed up of compilations of thousands of sources. The problem is in that when RTOS feature for mbed is enabled via PIO_FRAMEWORK_MBED_RTOS_PRESENT macro then it compiles the whole set of all libraries, features and drivers it has.

Could you try to put 'build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT' into your platformio.ini and do clean build?

PS. I've installed Mbed studio and it doesn't compile everything and .mbedignore works there also + I can set up a breakpoint at any line. PSS. PIO is alittle bit more useful in terms of multipads etc.

22 Sep 2019

Vladislav Kravchenko wrote:

Nik Fedorov wrote:

Vladislav Kravchenko wrote:

Nik Fedorov wrote:

Platformio+mbed+LINUX=fast compilation

What board do you use?

Any. Platformio on Linux is much faster than on Windows

I'm not sure that just usage of Linux can give speed up of compilations of thousands of sources. The problem is in that when RTOS feature for mbed is enabled via PIO_FRAMEWORK_MBED_RTOS_PRESENT macro then it compiles the whole set of all libraries, features and drivers it has.

Could you try to put 'build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT' into your platformio.ini and do clean build?

PS. I've installed Mbed studio and it doesn't compile everything and .mbedignore works there also + I can set up a breakpoint at any line. PSS. PIO is alittle bit more useful in terms of multipads etc.

I have an old laptop Lenovo Z575 AMD A4-3300M APU with Radeon(tm) HD Graphics, Memory : 3497 Mb, Linux Mint 19.2 Tina

[env:nucleo_f103rb]
platform = ststm32
board = nucleo_f103rb
framework = mbed
build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT

The first compilation was 493.13 seconds, the next 42.92seconds

22 Sep 2019

I have an old laptop

Quote:

Lenovo Z575 AMD A4-3300M APU with Radeon(tm) HD Graphics, Memory : 3497 Mb, Linux Mint 19.2 Tina

[env:nucleo_f103rb]
platform = ststm32
board = nucleo_f103rb
framework = mbed
build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT

The first compilation was 493.13 seconds, the next 42.92seconds

That I'm exactly speaking about. So the first complation takes toooo much resources. The second one is shorter. But if yuo add some "include" or try to debug - you receive the same trial of compilation as the first time.

23 Sep 2019

Vladislav Kravchenko wrote:

I have an old laptop

Quote:

Lenovo Z575 AMD A4-3300M APU with Radeon(tm) HD Graphics, Memory : 3497 Mb, Linux Mint 19.2 Tina

[env:nucleo_f103rb]
platform = ststm32
board = nucleo_f103rb
framework = mbed
build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT

The first compilation was 493.13 seconds, the next 42.92seconds

That I'm exactly speaking about. So the first complation takes toooo much resources. The second one is shorter. But if yuo add some "include" or try to debug - you receive the same trial of compilation as the first time.

This is true. But on Linux, everything is exactly faster.

Intel (R) Core(TM) i5-3337U CPU 1.80GHz 1.80GHz, Memory 4.00 Gb

Compilation time on Windows 10 pro - 1139.39 seconds

Compilation time on Linux Mint - 314.58 seconds

09 Oct 2019

I have absolutely the same issue. Any compilation (of course the second is a bit faster) is soo slow that I consider trying linux in a dual boot mode.