1. Download the mbed github repository
If you are familiar with git, just clone repository using git clone command. For those who don't use git, download the repository as archive (zip).
Link mbed src ZIP archive (~5MB) [github.com/mbedmicro/mbed]
After downloading is completed, unzip the archive.
2. Set your toolchain paths
There few toolchains which can be used, I'll present ARM GCC and ARMCC (uVision). Create a new file named private_settings.py in the workspace_tools directory. This private settings file defines settings which overrides default settings.
from os.path import join
#KEIL
ARM_PATH = "C:/Keil/ARM"
ARM_BIN = join(ARM_PATH,"ARMCC","bin")
ARM_INC = join(ARM_PATH,"RV31","INC")
ARM_LIB = join(ARM_PATH,"ARMCC","lib")
ARM_CPPLIB = join(ARM_PATH, "ARMCC","lib","cpplib")
#GCC ARM
GCC_ARM_PATH = "C:/Program Files/GNU Tools ARM Embedded/4.7 2013q3/bin"
BUILD_OPTIONS = ["debug-info"]
ARM_ paths are used for ARMCC (uVision IDE, paths for each folders might vary, as I had problems with previous versions, because they changed the folder structure), GCC_ARM_ path for ARM GCC toolchain path. Set those according your installation folder.
I use debug-info build-option, to include debug symbols.
3. Build sources for your target
To build mbed sources for TARGET and TOOLCHAIN, use command:
python build.py -m TARGET -t TOOLCHAIN
The list of supported targets is quite long, to check if your TARGET is supported TARGETS array [github.com/mbedmicro/mbed].
Each TARGET defines supported TOOLCHAIN. For example, K20D5M has ARM and GCC_ARM.
To build for ARM (that's ARMCC used in uVision for example)
python build.py -m K20D5M -t ARM
To build for GCC ARM
python build.py -m K20D5M -t GCC_ARM
If you just invoke command without -t, the target will be built for all supported toolchains.
4. Using exporters
As soon as you have built mbed sources for your target, go to my previous tutorial about using exporters. There is just shown to export Hello world example.
How to use mbed exporters
5. Build an application
Using ARM GCC, use makefile to build an application. If uVision is used, build the application in the uVision IDE. No matter what toolchain you use, they should generate a binary file, which can be copied to mbed msd drive. Same procedure as it's used by the mbed online compiler.