Using mbed with gcceclipse and CMSIS v2

<<info>>Regrettably, in doing this we lose access to all the nice libraries that mbed has been so kind in developing.===\\ Please note that this is not permanent. If you use the online compiler, you will still be able to use the libraries\\ As I develop the offline packages I will upload and link them for others to share.<</info>>

The online compiler is nice and all; but I much prefer using Eclipse and open source solutions wherever possible. This page is to document my successful attempt at using the platform with said environment. I'm writing these instructions for:

  • Ubuntu 11.10
  • Eclipse Indigo
  • Sourcery G++ Lite 2011.03-42 for ARM EABI

If you use other versions YMMV

  1. Download the required files
  2. Extract and retrieve the required files.
    • Extract eclipse (I extracted it to '/mbed')
    • Extract GCC (I extracted it to '/mbed' also)
    • Extract CMSIS (I extracted it to '/mbed' too)
    • Your directory now probably looks like this:

`ls ~/mbed`
arm-2011.03  CMSIS  Device  eclipse  Version 2.10
  1. Configure Eclipse and your first project
    • So we have a nice place to put it all, and to do the initial setup and configuration we are going to create a "hello world" project in eclipse
      • Start Eclipse (it may ask where you want to load the workspace, If it does and you want to follow my steps exactly, tell it to use '/mbed/workspace' as the workspace)
      • Now we do a little preconfiguration
        • Goto Help->Install New Software...
        • Click Add...
        • Click Archive...
        • Browse to the GNU ARM downloaded zip file
        • Give it a name in the upper box (I used "GNU ARM" but anything works, but I do recommend a descriptive name)
        • Click OK
        • In the center box you should now see 'CDT GNU Cross Development Tools' Check it and click Next >
        • Click through the wizard.
        • Ignore the security warning and continue anyways
        • Choose Restart Now
        • Choose Window->Preferences
        • Goto C/C++ -> Build -> Environment click Select... Choose PATH click OK
        • Edit PATH and add '/home/dejagerd/mbed/arm-2011.03/bin:' to the BEGINNING of the line
        • Click OK
          You now have a cross compiling eclipse setup!
      • Now we create the project
        • Goto File -> New... -> C++ Project
        • Give it a name (I'm gonna call mine "HelloWorldProject")
        • Under Project Type choose ARM Cross Target Application -> Empty Project
          Under Toolchains choose ARM Linux GCC (Sourcery G++ Lite)
        • Click Finish
          Woo! Getting there!
      • Time to configure the project.
        While this may seem like a lot of effort to go through, it is worth it; also once done, you can just copy HelloWorldProject to get a new project with the same settings.
        • Right click your project and select Properties...
        • Goto C/C++ Build -> Discovery Options
        • Click Manage Configurations...
        • Delete Debug and click OK
        • Change Discovery Profiles Scope to Configuration Wide
        • Switch to C/C++ Build -> Settings
        • For each compiler (C and C++) I like to change the optimization to none, and the language standard(under miscellaneous) to the newest version with GNU extensions (my rationale is that it causes the compiler to be the most forgiving)
        • Goto the linker settings and then the general section. make sure to check Do not use standard start files (we will be supplying our own)
        • Change the flash image tool to binary, and check both boxes on the sections page.
        • Click OK
      • Let's make the project!
        Remember the CMSIS folder? You will need several files out of it.
        • copy:
          All the files *.c, *.h, *.s, and *.ld to /mbed/HelloWorldProject/
          1. rename startup_LPC17xx.s to startup_LPC17xx.S (Capitol S) Quirky I know, but it's needed...
        • Go back into the project properties, and under C/C++ Build -> Settings and ARM Linux GCC C++ Linker -> General Browse for the Linker Script ldscript_rom_gnu.ld
        • Go to C/C++ General->Paths and Symbols->Symbols (tab) add two new symbols to the definitions on all compilers: RAM_MODE and RAM_MODE (Setting both to zero (0))
      • Save all the files
    • Build the project!
      • Click the hammer icon on the toolbar. If I wrote these instructions correctly, you should have a .hex file in HelloWorldProject/Release
    • Upload to mbed.
      You will need to rename the file to end with ".bin" to get the mbed to recognize it. It is in the proper format, however it just has the wrong extension.
    • If all is well, you should have all the LEDs flashing at 5 hz

This info was the final bit that I needed to be able to put this guide together:

If you include the following files in you compilation and include the call SerialInit(UART0,9600); in your main function, you *should* be able to use uart_putchar(char,NULL) to output individual characters to the USB UART, and use putst(const char * s); to output a whole string.

All wikipages