“This tutorial was extracted from Erich Styger blog https://community.freescale.com/docs/DOC-101792 with his agreement.”
This document explains how you can debug the FRDM-K22FFRDM-K22F board with the P&E OpenSDAv2.1 Firmware and the Kinetis Design Studio V1.1.0.
Applicable to:
- OpenSDAv2.1 boards (FRDM-K22FFRDM-K22F for now)
- Kinetis Design Studio V1.1.0
(Download link: http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KDS_IDE&fpsp=1&tab=Design_Tools_Tab)
Outline
The FRDM-K22FFRDM-K22F board (FRDM-K22F|Freedom Development Board|Kinetis|Freescale) comes with OpenSDAv2.1 programmed on it, and has the CMSIS-DAP debug firmware on it by default.(see 'Technical Details' at the end about the OpenSDA differences)
OpenOCD with CMSIS-DAP for FRDM-K22F is not supported in KDS V1.1.0. Trying to debug the FRDM-K22F board with KDS V1.1.0 and OpenOCD/CMSIS-DAP results in an error in the Console View and is currently not possible, until OpenSDA gets updated (see Kinetis Design Studio V1.1.0: Release Notes and News).
One solution is to use the P&E OpenSDAv2.1 firmware to debug the board.(Another solution is to use the Segger J-Link OpenSDAv2.1 firmware, see
[FRDM-K22F - KDS - OpenSDAv2.1] Tutorial: Set-up the debug interface with Segger J-Link OpenSDAv2.1 Firmware]
Update KDS from P&E Update Web Site
For KDS V1.1.0, you need to install an update throught an Eclipse update. The update is from www.pemicro.com/eclipse/updates within the Install New Updates dialog under the Eclipse Help menu.
!!!! Please note that there is a known issue in KDS V1.1.0 which requires to remove and add a link to P&E's update site in order for installation procedure to work in KDS v1.02. Please see description below:
Issue: The default P&E update site included in KDS v1.02 (PEMicro - http://www.pemicro.com/eclipse/updates) will not allow a user to properly update the P&E plugin on a freshly installed KDS 1.02 layout.
Workaround:
a. Remove the PEMicro - http://www.pemicro.com/eclipse/updates update site from the list of available update sites. Use the menu Help > Perferences > Install/Updates > Available Software Sites and Remove the PEMicro entry:
b. Exit the KDS Eclipse IDE and restart it from the command line with the -clean parameter. On Windows start Eclipes from the cmd.exe (DOS shell) with the -clean parameter:
c. In Eclipse, add the PEMicro - http://www.pemicro.com/eclipse/updates update site. Use the menu Help > Install New Software and press the Add button:
d) Enter http://www.pemicro.com/eclipse/updates as update Location and press OK:
e) Then update from P&E's website:
Installation of P&E OpenSDA V2.1 Firmware
You need to install the P&E OpenSDAv2.1 firmware on the board, and you only need to do this once (unless you change the firmware again).
- Go to http://www.pemicro.com/opensda/ and download the OpenSDA Firmware Apps file (zip file) (requires registration at P&E)
- Unzip the firmware files to a folder on your harddisk.
- Power the board/Plug in the USB cable with the OpenSDA USB port, while having the Reset/SW1 pressed.
1. The device should enumerate BOOTLOADER: device on your host. You are now in bootloader mode.
2. Copy the the correct firmware file (DEBUG-FRDM-K22F_Pemicro_v108b_for_OpenSDA_v2.1.bin) to the BOOTLOADER device. Wait a few seconds to complete the operation.
3. Unplug the board, and now power it normally (without SW1 pressed)
4. The board should now show up as OpenSDA device, a virtual COM port and as PEMicro OpenSDA Debug Driver:
5. You are ready to use to debug the FRDM-K22F as if you would use a P&E Multilink
Debugging with P&E OpenSDAv2.1
Create a new debug/launch configuration: Select your project, then use the menu Run > Debug Configurations.Use the 'new' Icon to create a new configuration for your application and project (Main tab):
In the Debugger tab, specify OpenSDA Embedded Debug as Interface, select the OpenSDA device as Port, and select the K22FN512M12 as device, and make sure 'SWD' is selected:
That's it. Now you can debug your application with P&E OpenSDA V2.1 firmware on the board . You can use the 'Debug' button in the launch configuration:
Or use the debug icon drop-down list:
And then I'm debugging the FRDM-K22 with the P&E OpenSDAv2.1:
Technical Details
There are so far three versions of the OpenSDA available:
- OpenSDAv1.0: this one is on all the FRDM boards like FRDM-KL25Z, FRDM-KL26Z, FRDM-KL46Z, FRDM-K20, ... (prior FRDM-K64F). The bootloader on these boards is protected and cannot be erased and supports P&E, Segger and CMSIS-DAP debug applications (*.sda).
- OpenSDAv2.0: This version was released at FTF 2014 with the FRDM-K64F board. This is an open source bootloader, and the bootloader can be replaced by the user. It supports *.bin files and P&E, Segger and CMSIS-DAP debug applications.
- OpenSDAv2.1: This version is released with the FRDM-K22F board. It is the same as
The debug circuit on the board is the same for all OpenSDA versions (Kinetis K20 microcontroller): the difference is what bootloader is programmed on the K20: the bootloader on the OpenSDAv1.0 cannot be erased/changed. The bootloader on OpenSDAv2.x can be
erased/changed, and the difference between the OpenSDAv2.0 and v2.1 is the address where the debug application starts: for OpenSDAv2.0 it expects the application at address 0x5000, while OpenSDAv2.1 expects the application to start at address 0x8000.