FRDM-K22F: Debugging with Segger J-Link OpenSDAv2.1 Firmware

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDM-K22F: Debugging with Segger J-Link OpenSDAv2.1 Firmware

FRDM-K22F: Debugging with Segger J-Link OpenSDAv2.1 Firmware

This document explains how you can debug the FRDM-K22F board with the Segger J-Link OpenSDAv2.1 Firmware and the Kinetis Design Studio V1.1.0.

 

Applicable to:

  • OpenSDAv2.1 boards (FRDM-K22F for now)
  • Kinetis Design Studio V1.1.0

 

13826_13826.pngpastedImage_0.png

 

Outline

The FRDM-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 Segger J-Link OpenSDAv2.1 firmware to debug the board.

(Another solution is to use the P&E Multilink OpenSDAv2.1 firmware, see FRDM-K22F: Debugging with P&E OpenSDAv2.1 Firmware)

 

Installation of Segger J-Link OpenSDA V2.1 Firmware

You need to install the Segger J-Link OpenSDAv2.1 firmware on the board, and you only need to do this once (unless you change the firmware again).

 

  1. Go to SEGGER - The Embedded Experts - OpenSDA / OpenSDA V2 and download the OpenSDA V2.1 firmware (zip file)
  2. Unzip the firmware file (JLink-OpenSDA_v2_1.bin) in the zip file to your harddisk.
  3. Power the board/Plug in the USB cable with the OpenSDA USB port, while having the Reset/SW1 pressed.
    13827_13827.pngpastedImage_6.png
  4. The device should enumerate BOOTLOADER: device on your host. You are now in bootloader mode.
    13829_13829.pngpastedImage_8.png
  5. Copy the Segger .bin file to that BOOTLOADER device. Wait a few seconds to complete the operation.
  6. Unplug the board, and now power it normally (without SW1 pressed)
  7. The board should now show up as J-Link device and with a virtual COM port:
    13831_13831.pngpastedImage_10.png
    13832_13832.pngpastedImage_11.png
  8. You are ready to use to debug the FRDM-K22F as if you would do with a Segger J-Link :-)

 

Debugging with Segger J-Link 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):

13833_13833.pngpastedImage_2.png

 

Specify MK22FN512xxx12 as your device name, and make sure 'SWD' is selected:

13835_13835.pngpastedImage_4.png

 

Have SWO disabled:

13836_13836.pngpastedImage_5.png

 

That's it. Now you can debug your application with Segger J-Link OpenSDA V2.1 firmware on the board :-).

You can use the 'Debug' button in the launch configuration:

13838_13838.pngpastedImage_1.png

Or use the debug icon drop-down list:

13837_13837.pngpastedImage_0.png

 

Happy Debugging :-)

Technical Details

There are so far three versions of the OpenSDA available:

  1. 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).
  2. 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.
  3. 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.

 

See also: OpenSDAv2

Labels (1)
Comments

Thanks for your information.

I have compared the differences between V1 and V2 of OpenSDA. I found its hardware is different at following points:

Changes from V1 to V2

  • VBAT to P3V3, minor change
  • all SDA IO, including DIO/CLK/RST/RX/TX are buffered via NXP level shifter
  • SDA_SWD_EN & SDA_SWD_OE are active high, instead of active low in V1
  • P5V_USB_SENSE moved to P30/PTD5
  • add POWER_ON and FAULT_B on P31/P32 to control external LDO MIC2005

Therefore, the biggest difference is control logic of SDA_SWD_EN and SDA_SWD_OE from P16/P20.

Please kindly correct me if I am wrong.

I can find the schematics documents in K22F package at FRDM-K22F|Freedom Development Board|Kinetis|Freescale

The FRDMK22FUG.pdf has part of the schematics. But it isn't complete.

Thanks for the information.  I upgraded to Segger J-Link OpenSDAv2.1 Firmware but when the program starts it seems sort of like the base addresses of the program are off.  Could KDS with its toolchain be making the executable for the incorrect base address?  Is there a setting somewhere I should check?  Or is the the code relocatable and this just a loader detail thing?

readelf -h -l mbed_22blinky.elf (output below)

I think this, particularly the .isr_vector being at 0x8000, tells me this elf file is incompatible with OpenSDA 2.1 (should be 0x5000 as I read the original post).  Now to find where to tweak that setting.  Thinking it might be buried in mbed somewhere since I can't find it in the kds settings anywhere.  Will import mbed from source rather than a .o export (would be good to do for other reasons).

ELF Header:

  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00

  Class:                             ELF32

  Data:                              2's complement, little endian

  Version:                           1 (current)

  OS/ABI:                            UNIX - System V

  ABI Version:                       0

  Type:                              EXEC (Executable file)

  Machine:                           ARM

  Version:                           0x1

  Entry point address:               0x199

  Start of program headers:          52 (bytes into file)

  Start of section headers:          142632 (bytes into file)

  Flags:                             0x5000002, has entry point, Version5 EABI

  Size of this header:               52 (bytes)

  Size of program headers:           32 (bytes)

  Number of program headers:         5

  Size of section headers:           40 (bytes)

  Number of section headers:         22

  Section header string table index: 19

Program Headers:

  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align

  EXIDX          0x011b80 0x00009b80 0x00009b80 0x00390 0x00390 R   0x4

  LOAD           0x008000 0x00000000 0x00000000 0x001f0 0x001f0 R E 0x8000

  LOAD           0x008400 0x00000400 0x00000400 0x00010 0x00010 R   0x8000

  LOAD           0x008410 0x00000410 0x00000410 0x09b00 0x09b00 R E 0x8000

  LOAD           0x018400 0x1fff0400 0x00009f10 0x002c8 0x00cac RW  0x8000

Section to Segment mapping:

  Segment Sections...

   00     .ARM.exidx

   01     .isr_vector

   02     .flash_protect

   03     .text .ARM.extab .ARM.exidx

   04     .data .bss

My bad.  My issues were some combination of getting the wrong segger boot loader and not noticing the pin names changed between a FRDM-K64F and FRDM-K22F.  Fixed those things and now everything is working.

OpenSDA 2.1 start address is 0x8000 which is reflected in the ELF headers (although I am curious where the build gets this value from).

No ratings
Version history
Last update:
‎08-07-2014 02:37 AM
Updated by: