Performance Zone is brought to you in partnership with:

Erich is Professor at Lucerne University of Applied Sciences and Arts and Distinguished Member of Technical Staff at Freescale Semiconductor. Erich has a MsCS degree and 18+ years of experience in the embedded software and tools world. He created many embedded cross C/C++ compilers and debuggers. Additionally he is researching in the domain of programming languages, real time and mechatronic systems. Erich is a DZone MVB and is not an employee of DZone and has posted 129 posts at DZone. You can read more from them at their website. View Full User Profile

Using the Freedom Board as JTAG Programmer

04.23.2013
| 4098 views |
  • submit to reddit

I love the Freescale Freedom boards because they are low-cost, and I do not need a special debug device, as they have the on-board OpenSDA. It is using a small Kinetis-K20 which acts as JTAG debugging probe. Why not using the Freedom board to program another board?

FRDM-KL25Z board programs another board

FRDM-KL25Z board programs another board

OpenSDA features a MSD (Mass Storage Device) Bootloader application. With this I can copy a S19 file to the ‘programmer’ and program another board. The Freedom boards come with an unpopluated JTAG header which can be used to debug the processor with a Multilink or J-Link debug probe. The idea is to disconnect the processor on the board from OpenSDA, and connect it instead with a JTAG cable to a microcontroller on another board.

For this I need:

    1. The OpenSDA Firmware with Bootloader.
    2. A 10pin ARM  Cortex JTAG debug header to populate the one on the Freedom board.
    3. To cut J11 trace on the Freedom board to isolate the microcontroller from OpenSDA.
    4. A 10pin ARM Cortex JTAG debug cable to connect the two boards.

OpenSDA Firmware

P&E has recently (17th April 2013) updated the firmware. That package has the latest firmware files and supports the new FRDM-K20D50M which I’m using here. The firmware is available from http://www.pemicro.com/opensda.

OpenSDA 17th April 2013 Firmware

OpenSDA 17th April 2013 Firmware

Required Hardware Changes

The Freedom board needs a 10pin JTAG debug header, and both boards needs to be connected by a 10pin ARM Cortex Debug cable.

:idea: See Completing the FRDM-KL25Z Board for part numbers for the header and mating cables.

10pin ARM Cortex Debug Cable

10pin ARM Cortex Debug Cable

By default, the Freedom boards come without the 10pin ARM Cortex debug header populated. So I need to add and solder such a header on J6:

SWD J6 Populated on the FRDM-KL25Z

SWD J6 Populated on the FRDM-KL25Z

:!: Use a good and fine soldering tip. The pads are very close to each other, so if using too much solder or not carefully solder the connector, there can be shortcuts between the pins. I recommend to carefully inspect the soldered pins.

Next step is to cut the J11 trace on the board. J11 needs to be used to remove the SWD clock to the target microcontroller on ‘programmer’ Freedom board. With this I cut off the resident microcontroller from OpenSDA on the same board:

J11 to isolate SWD Clock

J11 to isolate SWD Clock (Source: Freescale FRDM-KL25Z schematic)

So I need to cut the connection between J11 on the backside of the board:

J11 on the board backside

J11 on the board backside

I recommend to cut the trace and install a dual-pin header/jumper:

Cut J11 Trace

Cut J11 Trace

J11 Header populated

J11 Header populated

:idea: Cutting the J11 trace is only needed for the Freedom ‘programmer’ board. If I want to program another Freedom board with the programmer, the ‘target’ board only needs the 10pin ARM Cortex Header populated. I have not modified the target board otherwise. If using a custom target board, then all what it needs is that ARM Cortex header for the connection.

Connecting the Boards

I connect the two boards with the 10pin flat cable, making sure pin 1 connects to pin 1:

Connected Boards

Connected Boards

:idea: The debug cable provides 3.3V for the target board. In the case of the Freedom board, that’s sufficient to power the target board. Otherwise make sure you power properly the target board.

Programming with MSD

The ‘programmer’ boards needs to have the MSD (Mass Storage Device) Bootloader loaded:

  1. Power the board with reset button pressed
  2. Wait until it enumerates as ‘Bootloader’ device
  3. Copy the MSD-FRDM-KL25Z_Pemicro_v109.SDA to it
  4. Re-power the board (without reset button pressed)

The MSD Bootloader accepts S19 files (see S-Record Generation with gcc for ARM/Kinetis how to create S19 files with ARM GNU gcc).

Now I can drag&drop or copy files to the bootloader device, and it will program the target board microcontroller (instead the resident microprocessor):

S-Record Generation with gcc for ARM/Kinetis

S-Record Generation with gcc for ARM/Kinetis

:-)

Programming a different Freedom Board

So far I have programmed with a KL25Z board another KL25Z Freedom board. But what about a programming a different ARM microcontroller, e.g. the K20 on the FRDM-K20D50M? This board has an SWD connector too: FRDM-K20D50M SWD Connector

Added the JTAG header:

Added JTAG Header

Added JTAG Header

And then I hooked up the two boards:

FRM-KL25Z and FRDM-K20D50M

FRM-KL25Z and FRDM-K20D50M

Unfortunately, that did not work :-( . The OpenSDA green LED was flashing an error code, and failed to program the K20 on the other board.

I tried the same thing, this time with my FRDM-KL05Z:

FRDM-KL25Z trying to program the FRDM-KL05Z

FRDM-KL25Z trying to program the FRDM-KL05Z

Result is the same: this combination does not work.

:idea: It seems that OpenSDA is checking the target processor, and only allows to program the same processor as on the Freedom board. I only have one FRDM-K20D50M and one FRDM-KL05Z, so I cannot check if it is possible to program the same device. Given what works with the FRDM-KL25Z, I would think that it is possible to program the same microcontroller from the FRDM-K20D50M, and same for the FRDM-KL05Z.

Debugging

So far I have used the MSD Bootloader to program the other board. What about using the debugger? The result is the Error 17926 which tells that I only can debug the processor on the board:

Error 17926

Error 17926

To bad :-(

Summary

With the Freedom board and OpenSDA, I have an inexpensive programmer for my boards. Programmer in the sense of programming a device, but not debugging it. It does not replace a P&E Multilink and it is not as fast as a Multilink, but for hobby projects it is a viable alternative or add-on value of the Freedom Board. Using the Freedom board as programmer seems only to allow to program the same microcontroller. To me, this limitation is in place not to cannibalize programming probe vendors like P&E Multilink or Segger J-Link. On the other end: as it is now, the Freedom board enables me to evaluate the microcontroller, and if I’m going to create my board with that microcontroller, I can program it with the Freedom board too. Debugging and developing things on the Freedom board, and then program a mini-batch of boards with it too. But I better have a Multilink or J-Link at hand when there is a problem I have to debug on that other board. Having the ability to use the Freedom board as a mini-series programmer is a plus in any case.

Happy Programming :-)



Published at DZone with permission of Erich Styger, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)