5 years, 5 months ago.

Does mbed-os-5 and mbed-os-2 use the same mbed.h?

Looks like it does. I'm surprised since the libraries themselves are different (mbed-os.lib vs. mbed.lib). One more thing: does the term "mbed-os" refer to "2", "5" or both?

I haven't used "5" yet but will switch to it because I think it's getting most development and support attention. The 200k runtime is a shock but if it works well do we really care?

Does "5" use some of the "2" source code. If so, when changes are made, are they made to both versions (or perhaps it's common source code).

Does the term "MBED-OS" refer to "5" only?

Generally yes, "mbed-os" term was introduced for mbed os 5 - one assumes due to the rtos now being integrated into the core library. My minimum compile size with mbed-os is about 36k vs 20k with mbed 2. I believe most of this is due to multithread support for newlib/microlib.

posted by Graham S. 19 Dec 2017

Thanks for the reply. Tell us about "2" and "5" both being able to use the same mbed.h. Also, sounds like mbed-os loads only components that are called for by the application program. Correct?

posted by Alfred Hume 19 Dec 2017

1 Answer

5 years, 5 months ago.

Hi Alfred,

Check out this blog post initially announcing the release of Mbed OS 5 - https://os.mbed.com/blog/entry/Introducing-mbed-OS-5/ . It explains how Mbed OS 2 and Mbed OS 5 are related.

In regards to how they use the same mbed.h file, inside the mbed.h file you can see if statements that look at MBED_CONF variables. These variables are defined in mbed_lib.json files located in their respective Mbed OS directory. For example, in mbed.h you will find the following lines:

#include "rtos/rtos.h"

Because RTOS is only present in Mbed OS 5, when this line is encountered by the compiler, and if you are using Mbed OS 5, it will find the following "present" value in the /mbed-os/rtos/ directory:

    "name": "rtos",
    "config": {
        "present": 1

So, the if statement in the mbed.h file is evaluated to True and the RTOS header file is included (i.e. it is present).

If you were running an Mbed OS 2 program, this if statement in mbed.h would evaluate to False, and thus RTOS is not present in your Mbed OS 2 program.

If you want to learn more about how these configuration files work, take a look at this documentation page: https://os.mbed.com/docs/v5.6/tools/configuring-tools.html

Please let me know if you have any questions!

- Jenny, team Mbed

Accepted Answer