OpenSDA on the Freedom KL25Z Board

P&E has released information and firmware instructions for using the OpenSDA, see Future has posted a very useful article about using OpenSDA here. So time to upgrade OpenSDA bootloader and firmware v10.1. My FRDM-KL25Z board is a pre-production board, and I assume the production boards expected next week will have the new firmware on it. But it is always useful to know how to change/upgrade the firmware, as I expect there will be new versions of it in the future.

❗ Update: P&E has released a new firmware v114 which combines USB CDC, MSD bootloader and debug application.


In the Freedom board, there is a Kinetis K20 (K20DX) which runs OpenSDA:

Freedom Board

Freedom Board

The OpenSDA is a firmware running on the K20 which runs a bootloader:

OpenSDA Block Diagram

OpenSDA Block Diagram

The bootloader is pre-programmed on the board, and is entered if pressing the SW1/Reset button on the Freedom Board. The booloader enumerates as MSD (Mass Storage Device, like a USB Memory stick). Using that bootloader different applications are programmed on the board. These OpenSDA applications are files with *.SDA extension.

Note: I believe the only way to change the OpenSDA Bootloader itself is using the JTAG connector for the K20, although I have not seen the sources or project for it. According to the Freedom production board pictures on Element14, this JTAG header is *not* populated on the board. But adding that JTAG header should not be a big deal if needed.

The P&E firmware includes two different applications:

  • DEBUG_APP_*.SDA: this enables OpenSDA to act as a debugging interface (similar to what OSBDM does).
  • MSD-<board>*.SDA: Application which turns the board into an MSD (Mass Storage Device, like a USB memory stick). This MSD application can be used to program different application to the target chip, see here. With this bootloader loaded, it is possible to program S19 files to the target processor. Element14 has published a set of such files here.

Downloading the new firmware

Downloading the new OpenSDA firmware package from the P&E OpenSDA site gives me these files:

OpenSDA Firmware package

OpenSDA Firmware package

As explained above, there is one generic debug SDA application, plus three MSD applications which allow me to program the target processor with S19 applications. The MSD applications depend on the target processor to be programmed.

Programming OpenSDA firmware

To program an new OpenSDA *.SDA application is simple:

  1. press the reset/SW1 button on the Freedom board while powering the board (plugging in the K20 USB connector).
  2. The green LED near the K20 starts blinking
  3. The K20 enumerates as MSD device and is named ‘Bootloader’:

    Enumerated Bootloader

    Enumerated Bootloader

  4. Simply drag&drop or copy the *.SDA application file to the Bootloader device to program it to the board:

    drag and drop new SDA application file

    drag and drop new SDA application file

  5. Re-power the board, and now the new SDA application is running

OpenSDA Debug Application

In case of the DEBUG_APP_*.SDA, the OpenSDA acts as a debug interface for example supported in CodeWarrior for MCU10.3. The beta is expected to be out very soon.

This applications enumerates as debug interface and offers a USB CDC mode:

OpenSDA Debug Devices in Windows Device Manager

OpenSDA Debug Devices in Windows Device Manager

The OpenSDA Debug connection is offered as a choice in the CodeWarrior New Project wizard:

OpenSDA Debug Connection in CodeWarrior

OpenSDA Debug Connection in CodeWarrior

Using the OpenSDA connection in the debugger is very similar to any of the P&E run control devices:

OpenSDA in Eclipse Debug Launch Configuration

OpenSDA in Eclipse Debug Launch Configuration

OpenSDA Application Bootloader

If using the OpenSDA MSD (e.g. MSD-FRDM-KL25Z_v103_Pemicro.SDA for the Freedom Board), then I can simply program S19 files to the target board. Element14 already has such S19 files available here:

Element14 SREC files for OpenSDA

Element14 SREC files for OpenSDA

Like above: press SW1 while power-on, and then simply copy the SREC file to the bootloader and reset the board. Simple as that🙂.

I expect that there will be a growing community providing such SREC files. For sure I will offer my applications that way as well🙂.

Happy OpenSDAing🙂

76 thoughts on “OpenSDA on the Freedom KL25Z Board

  1. Hi Eric,
    I recently went through many of the FRDM-KL25Z articles. I wish to use MKL25Z128VLK4 in a project. In fact I got one FRDM-KL25Z board. I want to stick to “mbed” library. Using mbed online compiler, I could generate .bin file which can be easily flashed into the FRDM board. But since the online compiler generated .bin file disables any security and forces to use unsecured. So I modified the the .bin file at security fields at 0x0000040C so as to get it flashed with security on. However the on board flasher “20140530_k20dx128_kl25z_if_opensda” installation doesn’t allow such files to get flashed and throws failure “RESERVED BITS”. My questions are as stated below:
    1. Is it technically correct to modify the .bin file to overcome problem with the on-board flashing firmware?
    2. Want to use mbed library with the on-board programmer (w/o buying a commercial programmer) along with option for CRP (Code Read Protection). Is it possible to use OpenSDA V1?
    3. If answer to #2 is “Not possible”, would P&E programmer solve my problem?
    4. If P&E like commercial programmer is the only option, what is the cheapest P&E product do you recommend?
    5. In order to generate .bin with CRP included, I think I can use mbed library along with tool chain in my local setup. Is this possible so that I don’t have to modify .bin file?

    Thanks in advance.


    • Some correction in queston #1. Is it technically correct to modify the .bin file to overcome restriction with the online compiler?


    • Hi Hernant,
      1. The technical correct way is not to use mbed. I recommend to use normal tools like Kinetis Design Studio, IAR or Keil as they do not have these limitations. You still might use the mbed libraries, but Freescale comes with a powerful Kinetis SDK ( which is much better in my view. And best of all: Kinetis Design Studio is free, unlimited and Eclipse based🙂



  2. Hello and thanks for share all this useful information.

    I work teaching microcontrollers. Currently, I have a delopment system which you can change the microcontroller (S08 or CFv1), pretty similar to DemoJM board. I was thinking about make a new MCU board for KL25K, however I am worry about the programming interface, because i have read OpenSDA can not be used in a custom hardware design. ¿Do you now which alternatives do I have?. My idea is to have a programming/debugging interface for KL25Z similar to OpenBDM in S08.

    Thanks a lot Erich.


  3. Pingback: Proof of Concept: Open Source ARM SWD Debug and General Purpose Board | MCU on Eclipse

  4. Pingback: Tutorial: Adafruit WS2812B NeoPixels with the Freescale FRDM-K64F Board – Part 2: Software Tools | MCU on Eclipse

  5. Pingback: Debugging STM32F103RB NUCLEO Board with Segger J-Link | MCU on Eclipse

  6. Pingback: Going to Mars: Building a DIY Eclipse IDE for ARM Embedded Microcontrollers | MCU on Eclipse

  7. Pingback: SWD Debugging the FRDM-KL43Z | MCU on Eclipse

  8. Pingback: Playing Tetris with a FRDM-KL43Z Board | MCU on Eclipse

  9. Pingback: Debug Multiple Boards with GDB at the Same Time | MCU on Eclipse

  10. Pingback: First steps: ARM Cortex-M7 and FreeRTOS on NXP TWR-KV58F220M | MCU on Eclipse

  11. Pingback: How to Recover the OpenSDA V2.x Bootloader | MCU on Eclipse

  12. Pingback: Hexiwear: Teardown of the Hackable ‘Do-Anything’ Device | MCU on Eclipse

What do you think?

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s