Post navigation

Using the Freedom Board as SWD Programmer

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 SWD debugging probe. Why not using the Freedom board to program 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 SWD 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 SWD cable to a microcontroller on another board.

For this I need:

The OpenSDA Firmware with Bootloader.

A 10pin ARM Cortex JTAG SWD debug header to populate the one on the Freedom board.

To cut J11 trace on the Freedom board to isolate the microcontroller from OpenSDA.

A 10pin ARM Cortex JTAG SWD 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

Required Hardware Changes

The Freedom board needs a 10pin JTAG SWD debug header, and both boards needs to be connected by a 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

:!: 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 (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

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

Cut J11 Trace

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

: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:

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

:-)

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:

Added the JTAG SWD header:

Added SWD Header

And then I hooked up the two boards:

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.

: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

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.

Not sure about this. Yes, I have seen this as well, but was not able to get it working. I posted a question on the forum too, and have not seen an answer. Or do you have a description how to get it working with CodeWarrior and the Freedom board? I have USBDM recognized as device in Windows, but not by CodeWarrior. If you have the solution and steps, please contact me under the email address I have on the About page of this blog.

These are the instructions that I prepared for my team:
Step 1: make sure the SWD header is populated on the KL25 board, and make sure you have a debug cable to connect the headers.
Step 2: make sure you have cut the J11 trace on the KL25 and added a jumper header. The header must be open to program external boards, and connected to program the on-board KL25.
Step 3: install USBM_4_10_4a_Win.msi
Step 4: install the x64 drivers package for Windows 7 x64, or the x32 drivers package for Windows XP.
Step 5: follow the instructions in USBDM_OpenSDA to install the USBDM opensda firmware onto the KL25 board that will be used for programming.

Configuring Codewarrior

This is the basic set of steps for configuring code warrior.

1. Run->Debug Configurations…
2. Select the Launch configuration in the Tree control on the left
3. Click the Edit button next to the Connection drop-down box
4. Change the connection type to USBDM ARM Interface
5. Change the connection frequency to 12 MHz.

The USBDM debug configuration is created by Codewarrior when a new project is created.
If the USBDM ARM Interface does not exist, follow these steps:

1. File | New | Bareboard Project
2. This project will be used only to create debug interfaces, so call it whatever you like. “Debug Interfaces” is good.
3. Choose the KL25 processor, then hit next
4. Check USBM, Open Source SDA, and any other interfaces you might be using.
5. Hit Finish

6. Go back to Run->Debug Configurations…
7. Select the Launch configuration in the Tree control on the left (the one for your project, not “Debug Interfaces”)
8. Click the Edit button next to the Connection drop-down box
9. Change the connection type to “Debug Interfaces_FLASH_USBDM” (It is ok to use a connection configuration from a different project)
10. Change the connection frequency to 12 MHz.

Hi Brian,
thanks for the information. While writing that article, I was trying to get USBDM working. I was not getting it to the point that it is recognized by CodeWarrior for MCU10.3. I have the drivers installed, with the USBDM firmware on the Freedom board, but there is no ‘USBDM ARM’ interface visible. I don’t know how to connect to it in the launch configuration. It seems many other users (looking at the threads in the forum) have a similar issue. I tried to setup a GDI connection (as described in other posts), to no success. I had big hopes in USBDM, but I have not found the documentation of steps which allow me to get it properly installed, and recognized so I can use it. Or do you have any other pointers of information for me?
Thanks!

=FIRST=
some clarifications to my instructions above :
In step 3 and 4 (under Configuring Codewarrior), I should have said –
3. Choose the Connection drop down
4. Select the [project]_FLASH_USBDM connection

In step 8 (under USBDM configuration creation), I should have said –
8. Choose the Connection drop down

That is – you shouldn’t need to press the “Edit…” button.

You won’t see USBDM Arm Interface unless you hit the “Edit…” button next to connection, but you shouldn’t need to do this if you follow the steps under USBDM configuration creation.

=SECOND=
verify that you have the plugin installed properly:
I can verify that USBDM is installed by choosing Help|About – then choosing the “Installation Details” button from the aboiut dialog. This opens another dialog. Choosing the “Plug-ins” tab and sorting by “Plug-in Name” (the default for me), I scroll down to USBDM Debug Connections Plug-in. The version reported for me is 4.10.3.v201210231727

If you don’t have this plugin, I believe you want to run the installer USBDM_4_10_4a_Win.msi. I don’t know if you need to close Codewarrior before doing that.

=THIRD=
since it sounds like you do not see the “[project]_FLASH_USBDM” connection configuration, follow the steps under “USBDM debug configuration” creation above to create a USBDM connection configuration.

After that, do the following:

1. choose Run | Debug Configurations …
2. Choose an existing [project]_FLASH_OpenSDA debug configuration in the left pane
3. right click the configuration and choose Duplicate, which will create a duplicate
4. Choose the duplicate configuration in the left pane.
4a. change the name to [project_FLASH_USBDM]
4b. Choose the Connection dropdown and select “Debug Interfaces_FLASH_USBDM”

Let me know how that works. I can also email you some pictures or a flash video if you would like.

I’m not sure, as I have overwritten my firmware. Debugging is still locked to the device on the board. But what works is to use the MSD bootloader on OpenSDA to program another device, but only of the same type.

Have you had success designing another board and programming it using the Freedom board? I ask because the part number on the MCU on the Freedom Board ends with FRDM unlike the parts I could order from Digikey. I wonder if this method of reprogramming only works for Freedom boards.

Hi Christopher,
yes, I had success to program a custom board with the KL25Z on it. I don’t know why they have FRDM on the parts on the FRDM board. I assume because they are matching the KL25Z on the FRDM board to the K20 (OpenSDA) one.

Hi Erich,
I made a custom board and I haven’t had any luck programming it with another FRDM board. I am using mbed (for now, to keep things simple and straight foward) and I have been able to program another FRDM board using the jumper cable but not my custom board. If you can provide me with some additional details specifically regarding how you programed a custom board, it’d be much appreciated.
Thanks!

I have not done anything special, except that the circuit (clock/etc) was matching the FRDM board one. I was able to program that board with a P&E Multilink too. It could be that the circuit of your board is not ok? I have seen several posts in the Freescale forum where people reported that their custom boards did not work, and looks this was mainly due the clock circuits. I know that we programmed the custom boards first with the P&E Multilink, I believe we have not tried it with another FRDM first. It could be that using the Multilink have put the boards into a ‘known good state’? At least this would be something you could try (e.g. with a Segger or P&E unit)?

@christopher: the community’s best understanding is that the frdm parts are used to lock the opensda on the k20 chip to the kl25 chip, as Erich says. When you replace opensda with usbdm, you can program other chips.

@harsh: I program my custom boards using this technique. I do not use a pe multilink at all. The programming interface for the kl25 chips is a defined SWD protocol, which the usbdm software speaks. If you can program another freedom board with the usbdm, then your programming setup is all set. There is probably a problem on your custom board – check standard things like power to the kl25, power-up state problem on your inputs, clock signal to the SWD, bad clock to the kl25.

@Erich & @Brion: Thanks a lot for the help, it’s much appreciated. I triple checked my circuit after Erich’s reply yesterday but didnt find any faults there. However since Erich mentioned that the clock circuits are usually at fault, I rechecked the crystal. Turns out the data sheet was incorrect – pin 1 of the crystal wasn’t pin 1. The datasheet said the pad with a slight chamfer is pin 1 but in reality there is a pad with a small dot beside it and that’s actually pin 1. After making a simple crossover jumper and flipping the crystal I was able to program it using mbed without a hitch. Thanks for all the help!

Victor, I used a slightly larger 8MHz crystal for my own board (http://www.abracon.com/Resonators/ABMM.pdf) the datasheet seems to have been updated – but the crystal I used only had one chamfered edge, which was indicated as pin 1. In reality, pin 1 of the crystal was actually the pad below it (which had a small yellow dot beside it).

I have used an FRDM-KL05Z board as a programmer to flash another FRDM-KL05Z board.
I have cut the trace on J6 in a programmer board, but don’t works.
The SWD_CLK/PTA0 signal with the trace on J6 cutted is however connected to the microcontroller in the programmer board.
Thanks for the help.

Thank you, i’m still new to the FRDM Board and I also learned about MBED just now. I’ve read the comments and also about the USBDM updates so that answers my question.

Does this hold true for MBED? I have a couple of KL25Z mc but I only have FRDM Kl46Z. And will my FRDM board still work as a prototyping platform after I cut the connections for programming other boards? :D

mbed is not really an option for me, as it does not allow me to debug my board. There is a new CMSIS-DAP firmware based on mbed, so this might be interesting for you. I’m using mostly Segger and P&E firmware, with some USBDMD. If you cut the connections, make sure you put jumpers on it so you can revert what you did. At least this worked for me, so I can use the board to program off-board targets and still use the onboard processor.

If you get this error then put the jumper between the pins before you go crazy thinking you have a problem with your drivers! There’s a lot of people with this problem in the Freescale Community forums.

Hi Carlos,
yes, that trace (J11, name depends on the board used) is only to isolate OpenSDA in order to program another board. If using OpenSDA to debug the onboard processor or to use the onboard SWD connector with an external programmer, the connection needs to be in place.

My question today is about the degree to which the MCU must fit with the on-board programmer.
I understand that you cannot program a KL MCU custom board with the FRDM-K20D50M because of the UID check, but do you need to stick with the MK20DX128VLH5 to make it work? Is it possible to change the package, the frequency or the model? Is a MK20 at 100 MHz programmable with the FRDM-K20D50M.
Similarly, the FRDM-K64F page says that it is a development platform for K63, K64 and K24 MCUs. Does it mean that you can program any K24 with the onboard programmer.

hello eric
I wonder if there is the possibility of using the freedom KL25Z as an external microcontroller programmer soldier in a generic home plate circuit such as a MKL46Z256VLL4 in which acquired as free sample page from freescale??
the idea is to make a PCB with MKL46Z256VLL4 soldier and attach my freedom to program it.
I hope you understand what I’m asking. Greetings.