Compiling mbed library from source files

05 Dec 2018

Hi all,

I was facing an issue of SPI and PWM not working together in some specific cases on Nucleo F103RB board. To debug further, I downloaded mbed source files and used those instead of the compiled library in my project.

Surprisingly, the issue was not present when using source files. So, my guess is that something is going wrong in the way they have compiled the mbed library from source files.

To verify if that is the case, I tried compiling the source files into a static library. I did the following steps:

1. Installed mbed CLI tool.

2. Used this command to create the library:

mbed compile -target NUCLEO_F103RB -toolchain GCC_ARM -library -build ..\output

Then I used the created library (.a file) in my project instead of the pre-compiled one from mbed but now it’s not working at all. Even if I download a simple PWM program, I cannot see the pulses on hardware.

Please let me know what are the steps required to compile mbed library from source files on my end?

06 Dec 2018

Hi,

I am also interested to know how to make used of static library in a mbed project with mbed-cli. However for debug purpose, why dont you just add the library source files together with your project. Another thing to try is that you can export to IDE and use IDE to put the MCU in debug mode. It will shows the mcu peripheral registers and you can check if the timer registers are set correctly.

06 Dec 2018

Hi Khiem,

I did try adding the source files with my project instead of using the compiled library as mentioned above. However, the issue was not present while doing that. I also verified this with IDE approach. While using the compiled library, one of the SPI functions was overwriting in the PWM module's memory range, thus causing the issue. This behavior was not present while using source files. So the only way to verify that the issue is arising because of faulty library compilation process is to do the same on my end from the source files and reproduce the issue.

Thanks.

07 Dec 2018

The required steps are decide the libraries to build, build libraries, and integrate into project. I agree that it can be faulty in compilation but please dont exclude the possibility that you didnot make use of the lib correctly.

From the mbed-cli doc, building library is very straight forward. You also can export and use the 3rd party ide to make library. If both way can not make the mcu work, im doubt that there is still another hidden problem.

You may try pwm lib and spi separately, see if each lib works correctly. If it is, it is possible that the linkage process has problem in the project which contains the 2 libs together. Moreover, you need to give more info about how you build your libraries. For example, which source files go to which library, how many libs that your project depends on. It helps others assist you better.

Please log in to post a reply.