Using mbed with Kinetis Design Studio

A brief overview of the process for building mbed projects with Kinetis Design Studio

  1. Install the necessary tools
  2. Modify the mbed toolchain to support KDS
    2a) Modify the mbed source code to be more KDS/K64F friendly
  3. Build the mbed core library
  4. Build a sample mbed project
  5. Import the mbed project into KDS
  6. Program & Play


Install Kinetis Design Studio

Obviously, to get started working working with the K64F and the Kinetis Design Studio, it is necessary to install KDS. At the time of writing, the current version is 3.0.0 and can be downloaded directly from Freescale. Downloading requires registration, but so far I have not received any unsolicited e-mails from Freescale.

Install Python

mbed will be built using the ARM GCC compiler included with Kinetis Design Studio. However, the build scripts that rely on the ARM GCC compiler are written in Python. I have only tested the mbed build scripts with Python 2.7, however, the scripts may work with the 3.x branch of Python.

Install a git client (optional)

I prefer using the git command line, however, Github provides a git GUI.

Clone mbed repository

If you installed a git client, clone the git repository for mbed

git clone

If you did not install a git client, download and extract the zip file of the mbed repo.

Modifying the mbed source

Add the KDS compiler

Open the file


Modify Line 57 to point to the /bin folder in the KDS install directory:

GCC_ARM_PATH = "C:/Freescale/KDS_3.0.0/toolchain/bin"
Change pins for K64F Rev E (optional)

Edit the pin definitions file for the K64F. More information about why this necessary is in this post.


Modify the line specifying the definition of D8 from PTA0 to PTC12

D8 = PTC12,
Add gdb support for the mbed core (optional)

Occasionally, we want to debug something happening in the mbed libraries themselves. To do that with KDS, we need to build the mbed libraries with gdb support.

Modify the file specifying gcc command line options


Change Line 73 to include gdb debug symbols:

        if "debug-info" in self.options:

### Build mbed

It is useful to run the build script with the help output to see what sort of options can be used

    python workspace_tools/ --help

Knowing the expected parameters, run the following command

    python workspace_tools/ - m K64F -t GCC_ARM -o debug-info

If you plan on using rtos, ethernet, DSP, the SD card, or any USB functionality, add their respective flags to the `` command. Additionally, if you have multiple cores use `-j <number of cores - 1>`, for example, `-j 7` if you have 8 cores. 

    python workspace_tools/ - m K64F -t GCC_ARM -o debug-info -r -e -F -j 7

After running the command, the mbed directory should have a `build` folder containing at a minimum `mbed` as well as any other libraries specified by the additional flags.

### Create the sample project

With the mbed libraries built locally, we can create a sample project to import into KDS.

   python workspace_tools/ -m K64F -i kds -b -p 4

The `-p 4` flag tells `` to build the 4th test program. A complete list of test programs can be seen by running `python -L`

If everything was successful, there should be a `` file in `/path/to/mbed/build/export/`

### Import into KDS

Extract the *.zip file that was created in the previous step. 

Open KDS, `File\Import`. In the dialog box, select `General\Existing Projects Into Workspace`. Navigate to the extracted *.zip file and import it. 

Press the 'hammer' aka 'build' icon in the KDS toolbar. The output in the debug menu should indicate that the build was successful. 

### Run code on K64F

_Note:_ I use the [Segger J-Link OpenSDA]( application for debugging. The K64F by default uses OpenOCD. I believe just pressing the 'Debug' icon while the K64F is plugged in should debug the application. I recommend using the Segger J-Link debugging interface. A post will follow on how to do this.

Was this information useful? Please consider using my [Amazon Affilliate URL]( as a way of saying thanks.