OpenOCD is the PC host application that is used by OpenSDAv2 (CMSIS-DAP application) for debugging. The standard installation of KDS does not include support for debugging the K22FN512 & K24FN256 device families via OpenOCD. This document will guide a KDS user through updating OpenOCD, bundled in KDS, to provide support for the K22FN512 & K24FN256 device families. In addition, we will show the user how to re-configure a KDS project to use OpenOCD to debug with CMSIS-DAP on a FRDM-K22F development board.
The following CMSIS-DAP versions are required for this version of OpenOCD:
|Development Board||CMSIS-DAP Version|
First the user must locate their installation of KDS. On Windows machines, the default installation directory is “C:\Freescale\KDS_1.1.1”. For Linux users, the default installation folder is “opt/Freescale/KDS_1.1.1”. Inside this installation, you should see the same directories and files as seen in the figure below.
Note: before continuing you must stop any debugging sessions and shutdown KDS.
Figure 1: Default KDS_1.1.1 installation directory.
In Figure 1, you can see the folder named “openocd”. This contains all the files necessary for OpenOCD to run in KDS. Before we install the updated version of OpenOCD we must rename the “openocd” folder. This way we have the old version of OpenOCD, should you feel the need to return.
Figure 2: Renamed "openocd" folder.
Once the “openocd” folder is renamed, as in Figure 2, we then need to download the “kds-openocd-update-09-04-14.zip” file attached to this document. Save this file into the KDS installation directory, as in Figure 3.
Figure 3: KDS OpenOCD update in KDS installation.
Once downloaded, extract the “openocd” folder for your operating system into the KDS installation directory. Figure 4 shows where the updated “openocd” folder is located for Windows users.
Figure 4: Location of updated OpenOCD folder for Windows.
Once the new “openocd” folder is copied to your KDS installation the update process is complete. OpenOCD in KDS now supports the K22F family of devices. It is now possible for FRDM-K22F users to debug their KDS projects with CMSIS-DAP via OpenOCD. Figure 5 shows the KDS installation folder after successfully updating OpenOCD.
Figure 5: Updated KDS installation.
Now a quick walkthrough on how to configure KDS projects to debug using OpenOCD. We will assume that the user already has a project in their workspace.
The first step is to highlight the desired project, and then select “Debug Configurations…” from the Debug drop down.
Figure 6: Open "Debug Configurations..."
Once the “Debug Configurations” menu pops up on your screen, select “GDB OpenOCD Debugging”, then click on the “New Launch configuration” button in the upper left of the window. Figure 7 shows where these items are located.
Figure 7: Create a new GDB OpenOCD Debugging configuration.
The new debug configuration should automatically pull in information from the selected project. If an .elf file exists for the project, then the “C/C++ Application” and “Project” fields will be populated as in Figure 8.
Figure 8: These fields should be generated automatically if the project has already been built.
If the “C/C++ Application” field is not populated, you can search your project for an .elf file using the “Search Project…” button below the “C/C++ Application” field. If no .elf exists, then it is necessary for the user to build the project to generate the .elf file.
Once the “Main” tab has been completed, it is time to move onto the “Debugger” tab. In the “Debugger” tab, it is necessary for the user to define the configuration file in the “Config options” field. For debugging in KDS, OpenOCD will need a configuration file, and the default configuration file is “kinetis.cfg”. Enter “-f kinetis.cfg” into the “Config options” field. Figure 9 shows the correct input for the “Config options” field. After populating the field, the user can now press the “Debug” button to begin debugging.
Figure 9: User must enter “Config options”.
If this is the first time debugging in the current workspace, a dialog box will appear prompting you to open the “Debug” perspective. You should check the “Remember my decision” box, and press the “Yes” button. This will allow KDS to switch to the “Debug” perspective, for you whenever you begin to debug an application. See Figure 10 for more detail.
Figure 10: Select to automatically change perspective when debugging.
Figure 11, below, shows a successful debug connection to the target device using OpenOCD. The application has run to “main” and is waiting for the user to interact with the debug session.
Figure 11: Once debugger has connected and run to main.
After completing the steps in the sections above, a KDS user should be able to debug applications using OpenOCD and CMSIS-DAP with K22FN512 & K24FN256 device families. For more information on KSDK and KDS please consult the documentation located in C:\Freescale\KSDK_1.0.0\doc and C:\Freescale\KDS_1.1.1\doc\pdf, respectively.
 For directions on importing an existing KSDK demo to KDS please consult the device family specific user’s guides in “C:\Freescale\KSDK_1.0.0\doc”, and on creating new KDS projects consult the “kds_user_guide” in “C:\Freescale\KDS_1.1.1\doc\pdf”.
Original Attachment has been moved to: kds-openocd-update-09-04-14.zip