5 years, 4 months ago.

How to compile mbed library from source files?

I was facing an issue on STM Nucleo F103RB board with combination of SPI and PWM not working together in a specific case. To debug the issue, I decided to download the source files and compile those instead of using the pre-compiled mbed library. Surprisingly, the issue was not present when using the source files.

So, my guess is that something is going wrong in the way the mbed library is being compiled. To reproduce that on my end, I installed the mbed CLI tool and used the following command:

mbed compile -target NUCLEO_F103RB -toolchain GCC_ARM -v -library -build ..\mbed-rev144-lib

But when I use the generated '.a' file, nothing is working at all. Even a simple GPIO toggle program is not giving any output on the hardware.

Can anyone tell what is the correct way of compiling mbed library from source files?

2 Answers

5 years, 4 months ago.

Hello, You're missing a few "-"s but since you were able to generate the .a file, you might have dropped those when you typed the question.

Any way, this is how I do it:

mbed compile target NUCLEO_F103RB toolchain GCC_ARM -v library build ../mbed-rev144-lib

If you use this command, the library generated from the latest source code will be Mbed OS 5 release. Are you expecting Mbed OS 2? It probably won't work if the rest of your code is compatible with OS 2.

Also, it should be easier to debug if you build your code and Mbed OS source code together.

mbed compile -m NUCLEO_F103RB -t GCC_ARM

Thanks, Lin

Hi Lin,

Yes I removed the double hyphen in my question as it was creating a stikethrough.

Thanks for pointing out the fact about mbed OS 5 library. My code was using Mbed 2 library when the issue was arising. Specifically, release 144: '0f02307a0877 ' mentioned here:

https://os.mbed.com/users/mbed_official/code/mbed/graph/

Do you know how can I compile this version of library from the source files?

Thanks, Manan

posted by Manan Mishra 07 Dec 2018

Hi Manan,

Please refer to "Removing the RTOS" section in this blog: https://os.mbed.com/blog/entry/Reducing-memory-usage-by-tuning-RTOS-con/

Once you created .mbedignore with all the entries listed, you've effectively turned Mbed OS 5 to Mbed OS 2.

Thanks, Lin

posted by Lin Gao 10 Dec 2018
5 years, 4 months ago.

I want to see more quality posts in your blog so please keep updating your blog. ThankConcrete Sealing Smyrna, Tennessee