Using Mbed with Visual Studio

26 Oct 2015

I know there has been talk about this historically and even some cookbook pages written about it (with dead links!). Is it possible to get full build functionality, and is there anyone who has done it? Do people have any guides or tips?

18 Nov 2015

Dear George Edwards,

Please take a look at PlatformIO. It has support for mbed framework and can be integrated to Visual Studio. See http://docs.platformio.org/en/latest/ide/visualstudio.html

How does it look? See example of Arduino framework + Visual Studio. The same result can be achieved for mbed framework too. http://docs.platformio.org/en/latest/_static/ide-vs-platformio-newproject-8.png

Regards, Ivan.

22 Dec 2015

Are there any tutorials on how to setup platformio and Visual Studio to do this for mbed platforms? It's quite hard to set this up right :S

22 Dec 2015

Dear Bas Priest,

Did you visit our documentation http://docs.platformio.org/en/latest/ide/visualstudio.html ? Follow the steps from "Project Generator" section.

Regards, Ivan.

22 Dec 2015

Dear Ivan Kravets,

Wow that was a quick reply! Yes I followed this documentation, but I used the manual integration, this caused some errors like "cannot open source file mbed.h". I don't know if this is supposed to happen or that I am just doing something wrong in the settings(most probably) I'll immediately go and try the project generator, I don't know how I missed this on the page. If this doesn't work I'll post again.

Thanks for the help :D!

Greetings, Bas

22 Dec 2015

Dear Ivan Kravets,

I have succesfully build the project with the Project Generator now, but after opening the project in Visual Studio 2010 a mass on errors appeared. /media/uploads/Bazzlo/capture.png

Is this happening because I am working with an older Visual Studio (I believe 2010 does include uint32_t declarations) or is this some other issue?

Regards, Bas Priest

22 Dec 2015

Hi Bas Priest, These errors don't affect PlatformIO code builder. You can disable IntelliSense error informing by disabling "Show IntelliSense Errors” checkbox (right-click on any error).

22 Dec 2015

I have Visual Studio 2015 and wanted to try this, but I'm not so sure platformio actually works very well Bas.

After spending a lot of time setting up platformio (the instructions are dreadful), I tried to run using the board disco_f429zi using this code:

https://github.com/papadkostas/RDA5807M

Does get quite a way through then loads of 'RED' ending in error. Various errors like 'can't find .h file', but it is in the SRC folder.

This is before I tried to set it up in Visual Studio.

Program compiles fine on CooCox

Pity really, it did look a good offline option.

22 Dec 2015

Dear Paul Staron,

Quote:

After spending a lot of time setting up platformio (the instructions are dreadful)

What is unclear in PlatformIO documentation? We are ready to fix it.

Thanks!

Regards, Ivan.

22 Dec 2015

Hi Ivan, Python is very similar to DOS (they should have named it DOSthon) that I was using 25 years ago so forgotten a lot, Windows lazy:)

So its probably okay for you guys that are using it all the time. Some things that are probably assumed, which version of python to use for instance. The natural choice would be to go for the latest, Python 3. Reading, it appears some functions are not compatible, so I used the latest Python 2. But nothing is mentioned in the instructions. Does this work on Python 3, we don't know.

Quote: To install or upgrade PlatformIO paste command at a Terminal prompt and run using pip (MAY require administrator access sudo):

Well pip is already there in the latest version, I spent a long time looking to download and install it, I should have looked.

But anyway that's just my fault for not being up to speed with this.

The problem is I have tried to run a couple of exported programs from mbed and the one I mentioned above. I'm probably doing this wrong or thinking it works in a different way, but I have used Python before to build KL05 libraries for Keil that worked fine.

Okay so lets try an example, bottom of the web page there is a "Blink" project example. Great I'll download that and test. Lets try Teensy3.1, I know something about this one. Click on Teensy3.1, I get 'Embedded boards' page, then click on the Teensy3.1 here and get PJRC website, not sure why I need that, go back and try something else, click on Teensy, takes me to 'Development Platforms' page. By this time I don't know whether I'm coming or going so gave up.

I have placed all my source files into the 'SRC' folder, these are split in different directories, I assume this is correct.

Would like to be able to use this Ivan, providing I can export my mbed programs, convert and load them in Visual Studio. Not entirely sure if platformio actually does it in this way.

Many thanks, Paul.

edit...

Used these instructions:

http://docs.platformio.org/en/latest/installation.html

Followed this:

http://docs.platformio.org/en/latest/ide/visualstudio.html

and its working !!!

This confused me:

http://platformio.org/#!/get-started

Having problems with the mbed STM export, exporting to GCC-ARM, I assume this is the correct export?

Paul

Edit.....

No luck I'm afraid, I can't get Visual Studio (2015) working on anything I export from Mbed. Tried various platforms and export types. The Nucleo STM-L476RG came close but had Vargs errors.

Ivan perhaps you could try, I don't think blinking an led will be much of a test, you need something a bit more 'beefy'

26 Dec 2015

Paul Staron wrote:

Hi Ivan, Python is very similar to DOS (they should have named it DOSthon) that I was using 25 years ago so forgotten a lot, Windows lazy:)

So its probably okay for you guys that are using it all the time. Some things that are probably assumed, which version of python to use for instance. The natural choice would be to go for the latest, Python 3. Reading, it appears some functions are not compatible, so I used the latest Python 2. But nothing is mentioned in the instructions. Does this work on Python 3, we don't know.

Hi Paul!

Thanks! I added to home page that PlatformIO requires Python 2.6/2.7. Also, PlatformIO 2.7.0 will show error message when user tries to run from Python 3. See commit.

Paul Staron wrote:

Okay so lets try an example, bottom of the web page there is a "Blink" project example. Great I'll download that and test. Lets try Teensy3.1, I know something about this one. Click on Teensy3.1, I get 'Embedded boards' page, then click on the Teensy3.1 here and get PJRC website, not sure why I need that, go back and try something else, click on Teensy, takes me to 'Development Platforms' page. By this time I don't know whether I'm coming or going so gave up.

Thanks. The links have been removed from http://platformio.org/#!/get-started for "Blink" project example.

Paul Staron wrote:

Having problems with the mbed STM export, exporting to GCC-ARM, I assume this is the correct export?

No luck I'm afraid, I can't get Visual Studio (2015) working on anything I export from Mbed. Tried various platforms and export types. The Nucleo STM-L476RG came close but had Vargs errors.

Ivan perhaps you could try, I don't think blinking an led will be much of a test, you need something a bit more 'beefy'

I understand you. Does it work from command line using ``platformio run`` command (without Visual Studio)?

Merry Christmas and Happy Holidays!

Regards Ivan.

26 Dec 2015

Hi Ivan,

Merry Christmas and Happy Holidays to you too!

Well I have some results, I have exported Si-Labs EFM32WG and FRDM-KL25Z projects that did not build in platformio command line mode, this was the result (EFM32):

.pioenvs\efm32wg_stk3800\libFrameworkMbed.a(retarget.o): In function `_exit': retarget.cpp:(.text._exit+0x0): multiple definition of `_exit' c:/users/paul/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-n one-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m/softfp\libnosys.a(_exit.o) :_exit.c:(.text._exit+0x0): first defined here .pioenvs\efm32wg_stk3800\libFrameworkMbed.a(retarget.o): In function `wrap_mai n': retarget.cpp:(.text.wrap_main+0xe): undefined reference to `main' collect2.exe: error: ld returned 1 exit status scons: * [.pioenvs\efm32wg_stk3800\firmware.elf] Error 1

But both would build in Visual Studio 2015. So a good result there.

I'm exporting a program from mbed as 'GCC Arm Embedded', I assume this is the correct format?

Not too sure that mbed is exporting STM properly, still playing around with that.

Something I noticed, I couldn't try the Teensy3.1, it sets Arduino framework. Could you add 'Teensy31mbed' with the mbed framework? Or is there a 'framework' switch in the command line init function that can be used.

Regards

Paul

27 Dec 2015

Hi Paul,

But both would build in Visual Studio 2015. So a good result there.

Could you share somewhere this project to test it? You can mail me@ikravets.com privately.

I'm exporting a program from mbed as 'GCC Arm Embedded', I assume this is the correct format?

The format doesn't matter for PlatformIO. PlatformIO has own code builder, build scripts and etc. The only one requirement is to place source code to `src` directory.

Something I noticed, I couldn't try the Teensy3.1, it sets Arduino framework. Could you add 'Teensy31mbed' with the mbed framework?

Please set `framework = mbed` for Teensy environment. Like, https://github.com/platformio/platformio/blob/develop/examples/mbed/mbed-blink/platformio.ini#L46:L49

Regards Ivan.

29 Dec 2015

me@ikravets.com appears to be undeliverable.

29 Dec 2015

Paul Staron wrote:

me@ikravets.com

Hi Paul,

Did you receive letter from me?

29 Dec 2015

Yes I did Ivan, replied to that but came back undeliverable.

02 Jan 2016

Hi Paul,

I've not received an answer yet. Please contact me directly in the chat https://gitter.im/ikravets or https://gitter.im/platformio/platformio

Regards Ivan.

06 Jan 2016

Hi,

i have also a multiple definition problem but with method remove

.pioenvs/nucleo_f103rb/libFrameworkMbed.a(retarget.o): In function `remove': retarget.cpp:(.text.remove+0x0): multiple definition of `remove' /Users/caliqi/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7-m/libc_s.a(lib_a-remove.o):remove.c:(.text.remove+0x0): first defined here collect2: error: ld returned 1 exit status scons: * [.pioenvs/nucleo_f103rb/firmware.elf] Error 1

when i try to compile this example https://developer.mbed.org/teams/Freescale/code/FRDMK64_SDCard/ with platformio in eclipse. The error is caused because of the function "remove" being defined in stdio.h and retarget.o.

you had Paul the same problem with _exit. Did you managed to solve it?

06 Jan 2016

No, I have not, put this aside for bit, but did appear to work on Visual Studio which is what I wanted. Not too sure if some of the Mbed platform exports are working very well particularly ST. Could you send Ivan your code example, I'm having trouble sending him emails for some reason. I'm sure he can resolve it. Paul

06 Jan 2016

Thanks for your fast reply Paul,

i did not export anything from the mbed compiler i just copied the code i needed from the main.cpp and pasted it in my project. I am working with eclipse and generated a fresh project with platformio (for eclipse) and worked on that. Everything has worked fine until this moment :(

But as you said i will try to email Ivan about that.

Thanks

11 Jan 2016

Dear Paul Staron and Anteo,

I've just made some changes to mbed build script https://github.com/platformio/platformio/commit/fa51860268b3e1e4dd31d5bb60a06a47f002bbd1

Could you try the latest development version http://docs.platformio.org/en/latest/installation.html#d-development-version ?

Regards, Ivan Kravets.

16 Jan 2016

Hi Ivan,

i tried with the development version and everything works fine.

Here for documentation purposes if also someone else steps upon this problem:

The problem i had: platformio version 2.7.1

downloaded this project as zip: https://developer.mbed.org/teams/Freescale/code/FRDMK64_SDCard/

i than did:

mkdir platformio_test01
cd platformio_test01/
platformio init --ide eclipse --board=nucleo_f103rb

i put the .cpp and .lib file of the project above in src folder of platformio_test01 and updated the pins of the SD in the .cpp file. i also updated platformio.ini and had as a result

[env:nucleo_f103rb]
platform = ststm32
framework = mbed
board = nucleo_f103rb
build_flags = -g

than i did:

platformio run

Problem i got was: .pioenvs/nucleo_f103rb/libFrameworkMbed.a(retarget.o): In function `remove': retarget.cpp:(.text.remove+0x0): multiple definition of `remove' /Users/caliqi/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7-m/libc_s.a(lib_a-remove.o):remove.c:(.text.remove+0x0): first defined here collect2: error: ld returned 1 exit status scons: * [.pioenvs/nucleo_f103rb/firmware.elf] Error 1

Solved: i repeated the same steps with the development version as @Ivan wrote above and everything works fine.

Thanks Ivan

30 Sep 2019

Hi, I find that there are links which illustrates VisualGDB can be integrated with visual studio to develop mbed program: https://visualgdb.com/tutorials/arm/mbed/ https://visualgdb.com/tutorials/arm/mbed/mbed-cli/ And the free extension of vscode, PlatformIO, also mbed supported. It's easy to use.