Offline toolchain (Eclipse IDE and CodeSourcery G++) in Windows 7 with support to mBed APIs
1. Install the Eclipse and Code Sourcery G++ Lite (ARM EABI version)
Download the free cross toolchain Sourcery CodeBench Lite (used to be CodeSourcery G++ Lite) ARM-EABI IA32 windows version, one ARM compiler designed for Windows without cygwin. Please note, it is the ARM-EABI version, not the GNU/Linux version. The ARM-EABI version is for bare board (without Linux OS), which applies to mBed.
Following the instruction at 'Getting Started' of Sourcery BodeBench Lite to install the cross compiler. After installation, it is worthy checking if the path and compiler are installed successfully by run the command in windows cmd window:
>arm-none-eabi-g++ -v
and verify you get some like: gcc version 4.6.3 (Sourcery CodeBench Lite 2012.03-56)
And also try
>arm-none-eabi-gcc -v
2. Export the mBed online program to a local file
Make sure you have the latest version of mbed library (see the note below). Right click the program and select 'Export Program". In the new dialog, select "Export to" as "GCC (Code Sourcery)" and the "Export target" as "mbed NXP LPC1768". Then click 'Export' and save the zip file (for example, assume the program is progname in the mbed online IDE, the exported program will be saved as 'progname_gcc_lpc1768.zip). More details see
http://mbed.org/handbook/Exporting-to-CodeSourcery
Unzip the zip file progname_gcc_lpc1769.zip to a directory and the unziped progname folder will contains our source code (main.cpp) and all the head files/library needed for compiler
Note: In the old version of mBed library, we need an mbed-export library when we export our program to offline toolchain. The mBed-export library not only contains the mBed.h file, but also other head files we need in compiling, e.g. cmsis.h. The mbed-export library can be found at
http://mbed.org/users/mbed_official/code/mbed-export/file/
However, in the latest version of mbed library, it seem that we do not need the mbed-export library. A single mbed library is enough. See
http://mbed.org/forum/mbed/topic/4014/?page=1#comment-19892
Where steve suggested: "make sure the mbed library is the latest version in your project it will allow the export to work without the need for mbed-export. To update your mbed library click on mbed with the cog icon on the right of the compiler you may see a message saying "A new version is available", if that is the case clicking update will update you to the latest version."
3. Create an empty makefile project in Eclipse
In Eclipse, select File->Makefile Project with Existing code.
In the new dialog window, set 'Project Name' as 'progname_offline' and set the 'Existing Code Location' to the location of unziped folder 'progname' (e.g., H:\progname) by clicking the 'Browse' button.
Click finish and a new project 'progname_offline' with the mbed library, main.cpp and makefile will appear in the Eclipse's Project Explorer tab.
Right click the project 'progname_offline' and select 'Build'. You will have the output at the Console tab as follows:
And you will find three new files created as the output of the building:
progname_offline
| ... ...
|- main.o
|- progname.elf
|- progname.bin
5. Copy the bin file to mBed drive and run the program at mBed
Enjoy.
6. Advanced tricks and tips: makefile
Created
with Microsoft OneNote 2010
One place for all your notes and
information