7 years, 3 months ago.

beginner questions: mbed environment, device configuration

Hi all, I'm totally new to a development environment like mbed. Most of what I do is either with C in a proprietary RTOS environment, or low-level assembler with no library support at all.

So I have a few really basic newbie questions. For reference, I'm running on a Nucleo -F303RE: - Where can I find the code that configures the device options, such as for the watchdog, oscillator, bootloader, etc.?

- Is there an underlying RTOS that's included in the build? If so, where can I find documentation on it? If it's optional, how can I tell if I have it?

It's insane that the stater program I picked (which drives a pwm at a fixed freq/duty cycle, blinks an led, and "prints" a message to some mysterious destination) takes over 25k of flash and 1.3k of ram. Is there such a thing as a starter program that really does nothing other than configure the device to not reset and blink an led, without all the library bloat?

Thanks!

-Eric

1 Answer

7 years, 3 months ago.

1. Complete mbed source code can be found here: https://github.com/ARMmbed/mbed-os or here https://developer.mbed.org/users/mbed_official/code/mbed-dev/. Watchdog isn't initialized normally, oscillators are (for yours: https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/device/system_stm32f3xx.c). Bootloader is in a seperate IC, which for STMs is as far as I am aware not open source.

2. If you are using mbed-os in the compiler: Yes. If you are using regular mbed, no. You can then import mbed-rtos to get the RTOS added if you want (same one as in mbed-os as far as I am aware), see for example: https://docs.mbed.com/docs/mbed-os-api-reference/en/latest/APIs/tasks/rtos/

3. No, because it is the mbed lib :). If you modify it yourself (if you use mbed-dev it should be possible in the online compiler, should have a look at it myself soon, good to figure it out) you can get it lower, I wouldn't know how much exactly. A major one is that if you try to make for example an SPI object on pins which do not support it, it is checked at runtime. And for this runtime check, printf is called. So always the complete printf C library is included, which is simply large. The good part: If you are going to use printf it will barely increase in size. The bad news: if you are not going to use printf it is a waste of memory.

Now since that example prints a message to a mysterious destination (hint: It is the USB COM port created by the STLink drivers via a UART of the device), you cannot disable printf since you need it for that. Obviously you can have that alot smaller if you just want to push some characters, but that is the downside that it is based on the C stdio lib.