How to use the KL25Z Freedom Board as a cheaper SWD Programmer

20160426_155241Having to develop a project with the Freescale Kinetis series micro, I looked on the net for the most suitable programmers using the SWD protocol (Serial Wire Debug). I didn’t like the solution of expensive programmers such as P&E Micro one’s, so I preferred the classic solution for geeks: I have discovered that is possible to turn FRDM-KL25Z (a demo platform that costs less than 20 €!) In a fast and cheap programmer with OpenSDA.

I have ordered mine from rs-components (look at this link) that ships in 24h in Italy, so the next day I was able to try it immediately. Looking to the schematics, is obviusly necessary to cut the short connection under the jumper J11, just to separate the clock of the internal micro from the external one we want to program by SWD connection:

cut

I did it in a barbaric way, however by inserting a jumper in order to restore the connection if i need to update the on-board mcu.

20160426_152316

It is better to prepare some files: you need to download from the website P&E Micro (click here) drivers for OpenSDA and the firmware to upgrade your KL25Z. Installed first of all the P&E Micro drivers (if they are not already on your computer), then extract from the zip “firmware apps” the MSD-DEBUG firmware for the KL25z and keep it at hand!

download

It’s now time to connect the board to the computer with a USB cable, hold down the reset button a second or two, this make the board boot into bootloader mode and will appear as a USB mass storage device (Bootloader). If you have an internet connection working, opening “sda_info.htm” file you can check the bootloader versions currently loaded in the flash and also the firmware application. However, we‘re going to upgrade everything, to turn the board into a programmer.

20160426_152446

So you just need to upload the file “MDS-DEBUG-FRDM-KL25Z_Pemicro_v ***. SDA” in the mass storage device, wait a few seconds, then power cycle the device. At this point, as a confirmation of the successful firmware update, Windows will warn you that “new hardware is found and OpenSDA drivers will be automatically (probably) loaded, and the device will be recognized as a programmer from CodeWarrior.

Be careful: with Windows 7 and Windows 10 for still unknown reasons this process failed to update the firmware of the board as last step, however, I had here a computer with Windows XP and in that case it worked immediately. This step must be done only once, so I did not study in deep this strange problem.

The SWD connector used to program third-party mcu’s is the J6:

programming connector

error-17926

The annoying thing of this solution is the OpenSDA firmware, which verifies the CPU target every time: if you try to program a different mcu from KL25Z, CodeWarrior will return a nasty error message. However, having the need to program a different mcus, I still found a solution, even if it took me more time…. I will update with this new solution the next time!

Leave a Reply

Your email address will not be published. Required fields are marked *