5 years, 2 months ago.

mbed library questions

I am new to mbed, and most of my initial explorations have worked well. I am starting with OS/5 on a Nucleo-F070RB.

However my first attempt to use Mutex and ConditionVariable is failing on the declarations for "Mutex" and "ConditionVariable" with the online compiler telling me that "Identifier "Mutex" is undefined".

I started with an "empty program" and I have imported the library "mbed" dated November, 2018. I have also tried starting with the default blinky example, and as soon as I added "Mutex mutex;" I received the same error.

I can import "ConditionVariable_Example_1" which has the same declaration and it compiles cleanly.

This makes me think that there is something more to be imported. My questions are:

  • What should I import in addition to "mbed"?
  • Is there a better choice than "mbed" that I should be using?

Thank you for helping, Tim

1 Answer

5 years, 2 months ago.

Tim, OS5 is being heavily developed atm and as such I'm not yet comfortable to use it to any depth other than to play around with it, but does look good and will be great very soon. Others are using this and will have a different opinion.

Tbh your board is really at the limit of OS5 as this does need some grunt from the MCU to work well, lots of thread and RTOS going on, you'll end up with not much flash space to play with depending on what you want to do. Personal from experience I would recommend Mbed 2.

But that is the question, what do you want to do, is Mbed 2 enough for you now?

I've just run this on a STM32f767, works fine,

https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-blinky/

If you build this you will see around 47k of your flash being used to flash an led. However most of that is for system and peripheral set up and debug functions that only happens once, as you add more of your application code, will use the average amount as you go along.

(Definitely recommend the STM32f467, good price, I get mine from Mouser, has Ethernet connection built in and so on. I did actually get this board to play with OS5 but I'm now using it on Mbed 2, very quick!!)

Accepted Answer

I think some clarification is needed. This is not an IoT project. Rather it is a design for an embedded board that accepts SPI requests and controls a number of gpios. Yes, it does need to be fast, and I will look into OS/2 (I had the impression that OS/5 was going to replace it, but I'm new and that was just the impression that the website left).

The real question that I posted is that after including the mbed library, I don't seem to have any of the platform objects (e.g. Mutex, Thread, ConditionVariable) defined. Is there another library that I need to import?

posted by Tim Teague 17 Feb 2019

It's all built into OS5, Mutex information is here along with Tread and ConditionVariable:

https://os.mbed.com/docs/mbed-os/v5.11/apis/mutex.html

So should be nothing else to import.

OS2 is more hard coded with limited RTOS that is essential for targets up to 128k flash and will need to be there for some time if not indefinitely until those MCU's become obsolete. That normally takes many years.

posted by Paul Staron 17 Feb 2019

Hello Tim, the mbed library imported into your project depends on the template selected when you create a new project. If you see mbed in your project folder that means you have Mbed OS2. To have Mbed OS5 (indicated as mbed-os in project's folder) try to select the Blinky example for the mbed OS 5.0 clone of https://github.com template when creating a new project.

posted by Zoltan Hudak 18 Feb 2019

Zoltan Hudak has provided the information that I needed. I'm back to making progress.

Thank you

posted by Tim Teague 19 Feb 2019