mbed for the Freedom Board

I knew about mbed already for some time: watching students using it for an NXP enabled board. Pretty cool stuff: mbed is an online IDE and compiler with tons of software libraries for the supported platform. So I was dreaming to have something like this for my own boards like the Freedom board. But because mbed only supported two dedicated NXP boards, that was a road block.

But then mbed announced recently that the mbed SDK is open source. Wow, that is interesting! And finally the announcement last week: mbed supports the KL25Z Freedom Board. Now they have my attention :-).

In a few words: mbed is a ‘cloud’ implementation of development tools and software libraries. As with any ‘cloud’ application, there are pros and cons:

  1. This is a online IDE with compiler: so no long download and installation needed :-).
  2. Everything is online, as well the provided libraries/SDK: so if there is a bug fix or update, it is there already there, no need to download and update software tools :-).
  3. The IDE runs in a web browser (so I need access to the internet, ok, that’s something to consider as I’m travelling a lot)
  4. It comes for free πŸ™‚
  5. It has a version control system integrated πŸ™‚

So this sounds really exciting. Well, as with anything, there are pros and cons. I come to the cons at the end. The good thing is: it is really, really easy to use. I wish all other tool chains I use would be so easy. I explain this with the steps to create and download a program to the FRDM-KL25Z board with mbed.

Getting Started

Getting started only takes a few minutes, and registration is free of charge.

  1. Signup for an account at mbed.org.
  2. Read the KL25Z Getting Started guide here.

Programming the mbed Firmware

In order to download (not debug!) a program to the KL25Z board, the mbed S19 application needs to be programmed to the board using the OpenSDA bootloader. The detailed steps are explained in the Getting Started Guide here. Freedom Board users are familiar with the bootloader steps:

  1. Enter Bootloader mode
  2. Copy the mbed firmware file to the board
  3. Re-Power the board. Now it should enumerate as ‘MBED’ device

πŸ’‘ If using a file manager/extension under Windows, or if there are troubles to get the firmware file copied to the Freedom board: use the DOS shell/cmd to copy the file to the device.

Downloading an mbed Program

On http://mbed.org/handbook/mbed-FRDM-KL25Z-Downloading there is already a .bin file available to download with the steps how to do this. Basically it works the same as programming S19 files with the normal OpenSDA bootloader:

  1. Download the file
  2. copy it to the MBED device
  3. Reset/repower the board

Creating a Program

The page atΒ http://mbed.org/handbook/Creating-a-program explains how to create a program. First I click on the ‘Compiler’ button (top right corner of the web page):

mbed Compiler

mbed Compiler

πŸ’‘ With ‘compiler’ mbed means the IDE+compiler+linker. Everything I need to build my application.

With ‘New Program’ I create a new one:

New mbed Program

New mbed Program

Next, I provide a name:

Create new program

Create new program

This creates my project files:

mbed Project Files

mbed Project Files

Double clicking on main.cpp opens the main() routine which toggles the RGB LED on the Freedom board:

Toggling LED Code

Toggling LED Code

With the ‘Compile’ button I build my application:

Compile the project

Compile the project

Similar to Eclipse, an output pane at the bottom of the window shows errors or if I was able to successfully build it:

Compiler/Build Output Pane

Compiler/Build Output Pane

On the right side the Program Details inform about the code/data size:

Program Details

Program Details

After building, opens a dialog from my web browser to download the program:

Download dialog

Download dialog

After downloading it, I can copy the file the MBED Freedom device.

Importing

The cool thing with a web based IDE like mbed is that you can share and use code and libraries. To import an existing program, I use the Import button:

Import

Import

Then I can filter and search for programs I’m interested in:

Importing a Program

Importing a Program

The easiest way to import it then is to drag&drop it the program workspace on the left hand side.

The really cool feature of mbed is that it comes with libraries and class description:

Class Reference

Class Reference

Exporting

It is possible to Export a program. This functionality is somewhat hidden behind a context menu:

Exporting

Exporting

This opens an Export Dialog:

Export Dialog

Export Dialog

I clicked the drop down:

Exporting Program IDE Selection

Exporting Program IDE Selection

And here the first disappointment: no CodeWarrior support :-(.

But what about the ARM Embedded one, as CodeWarrior supports this? But this does not work neither:

No ARM Gcc

No ARM Gcc

I tried Code_Red, as this is Eclipse based and I have it on my machine installed. But it gave me:

sorry, no Code_Red

sorry, no Code_Red

Ok, but I do have IAR for Kinetis-L, so hopefully I’m lucky here. But again:

Sorry, no IAR

Sorry, no IAR

Same for CodeSourcery gcc 😦

What worked was to export to Keil (but here my Keil IDE expired :-().

What worked was exporting as zip file:

Exporting as Zip file

Exporting as Zip file

That’s at least something. But it had only my source file in it, and not all the other libraries.

Freedom Board Examples

The mbed Freedom support and community is growing, and there are already multiple Freedom board examples available with this link.

Summary

With mbed, it is possible to build and download a program to my Freedom board in a few minutes. Installing a typically IDE takes longer than this :-). The great part with mbed is that it has a big community (at least for the other platforms), with a rich software library behind it.

But it is not possible to debug the application on the board, at least I have not found a way to do it. This makes mbed limited a not very well suited for a typical embedded programming process in my view. Great for exploring things, but not for doing a real project? I have seen that there is a beta CMSIS-DAP mbed debug connection available for the NXP board, so hopefully this will exist for the Freedom board too?

That would be mitigated if it would be possible to export the projects to other IDE’s. I think CodeWarrior support or at least IAR would be needed. Otherwise I feel mbed is like a ‘golden jail’. And it is unclear to me how I could use mbed for a different Kinetis than the KL25Z board or for my custom board (as it requires a special bootloader).

But it is a great thing to start with a new board and to explore things, without investing into a tool chain. As for everything, there is a learning curve, and I just started exploring things. So if you know how to debug with mbed, or how to export things to Eclipse/CodeWarrior, post a comment!

Happy mbeding πŸ™‚

Advertisements

15 thoughts on “mbed for the Freedom Board

  1. Hi! When write the mbed firmware you can still have open sda function working or you lost it? You can also reverse the changes

    Like

  2. Hello Erich!

    Thanks much for your great blog.

    CMSIS-DAP is available on FRDM board, but you can use it only with Keil, it seems that online IDE don’t support debugging at all 😦

    But I have a good news: you can easily port projects to Keil, IAR and maybe GCC.

    MBED also have great version control system and collaboration support.

    Like

    • Hello Alexander,
      Yes, I have seen CMSIS-DAP, but not sure how it is usable with mbed. At least on the NXP side I see activities around it to hopefully make mbed even more useful. And you are correct: the built-in version control of mbed is one of the big advantages in my view, and of course the mbed community.

      Like

  3. Hi Eric,

    The CMSIS-DAP connectivity is available on the FRDM board, the same as it is for the NXP board, and so any offline tool that supports CMSIS-DAP can target the FRDM board. The online tools do not support debug (as a definite choice not to), but the ability to export projects to offline tool chains means you have full professional development if you need it.

    Code Warrior support is on its way! πŸ™‚

    Hope this helps!

    Thanks,
    Chris

    Like

    • The applicable webpage is: http://mbed.org/handbook/CMSIS-DAP-MDK
      Keil MDK free eval license is good for up to 32KB of program code, but limitations of the “Lite Edition” license should be noted: http://www.keil.com/demo/limits.asp

      MDK-ARM Lite Edition
      – Programs that generate more than 32 KB of code and data will not compile, assemble, or link.
      – The debugger supports programs that are 32 KB or smaller.
      – The compiler does not generate a disassembly listing of the machine code generated. The -S, –asm, and –interleave compiler command-line options are disabled. Projects will not compile with Target -> Listing -> C Compiler Listing enabled.
      – The compiler and assembler do not generate position-independent code or data. The –apcs /ropi /rwpi /pic/ pid compiler and assembler command line options are disabled.
      – The assembler and linker create Symbolic Output Format objects which cannot be linked with 3rd-party linker utilities. (Fully licensed tools generate standard ELF/DWARF files which may be used with third-party utilities).
      – The linker does not accept scatter-loading description files for sophisticated memory layouts. The –scatter command line option is disabled”

      Like

  4. Hi! I tried to test mbed and i copied the mbed firmware to the board. After that my board is recognised only as Bootloader(E:). The green status led blinks. I can’t re-program it back with the MSD bootloader. After I copy the MSD-FRDM-KL25Z_Pemicro_v107.SDA file and repower the board it is still appearing as Bootloader(E:).
    Is my board bricked?

    Thank you, Alex

    Like

    • Hi Alexandru,
      the fact that it still says ‘Bootloader’ and that the green LED blinks tells me that it is stil running the micro-boot kernel, and was not able to flash your new file. How did you copy the file? I know that sometimes using Explorer or a Explorer shell might interfer. So try to copy the file using the DOS cmd prompt (on Windows, press Windows+R, then execute ‘cmd’, and then use the copy command to copy the file.

      Like

  5. Hallo,

    Have you seen the the CoIDE from CooCox?
    It’s some free IDE / debugger that can use also the CMSIS-DAP.
    I did not had the time to try to export from MBED the project and to debug it with CoIDE but I hope I’ll have some time in the near future. Maybe it works. I like the MBED firmware as it is all in one (MSD, CMSIS-DAP and COM Port for printf :)))

    Best wishes.

    Like

    • Hi Dan,
      yes, I have seen it, but have not had a chance to try it out. I was not aware that this firmware is an all-in-one solution: that’s definitely what came to my mind when I had to switch between MSD and debug applications all the time. Such a ‘multiple endpoint’ solution for sure would be a big plus, so now CoIDE moves up in my wish list πŸ™‚
      Thanks for that information!

      Like

  6. good day sir.. I would like to follow-up on what particular tool-chain would be applicable for the freedom boards? It’s already 2015, do they have code warrior support?

    Like

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.