How do I flash a Kinetis KL25 using SWD from another micro?

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

How do I flash a Kinetis KL25 using SWD from another micro?

3,361 Views
mstreet
Contributor I

I need to be able to upgrade the firmware in a Kinetis KL25 in the field from another microcontroller.  Where can I find the SWD commands to unlock, write, and verify the Kinetis' onboard flash?

Labels (1)
0 Kudos
11 Replies

1,410 Views
Paul_Tian
NXP Employee
NXP Employee

Hi, Mstreet

If you want to use another MCU to program KL25, I think you have to use GPIO to simulate SWD protocol. For protocol, you can find from ARM site. Resourcing is opened.

Hope my reply can help you.

Best Regards

Paul

1,410 Views
mstreet
Contributor I

Hi Paul,

I was planning to use GPIO as you suggested and have downloaded the ARM Debug Interface specification.  Is all of the information needed to write the Kinetis flash memory included in this document, or are there Kenetis specific commands or debug memory interfaces that I need to know about? 

0 Kudos

1,410 Views
Paul_Tian
NXP Employee
NXP Employee

Hi, Mstreet

Kinetis SWD has no special requirement. You can use ARM opening protocol and GPIO to simulate.

Hope my reply can help you.

Best Regards

Paul

0 Kudos

1,410 Views
John16
Contributor I

Hi Paul,

i also have similar requirement to program the flash memory through SWD. I found a document from Freescale AN4835 which talking about how to connect to the SWD. But after I connect, how to do the erase, program section, read operations? How to send all those flash commands through SWD?

Thank you in advance.

0 Kudos

1,410 Views
BlackNight
NXP Employee
NXP Employee

Another solution for that field upgrade would be to use a FRDM board with the MSD bootloader. This works out of the box, see Using the Freedom Board as SWD Programmer | MCU on Eclipse

Erich

0 Kudos

1,409 Views
EricNelson
Senior Contributor II

Thanks Zhe,

While looking for how to do this, I found libSWD, which appears to support such bit-banging:

     LibSWD - Serial Wire Debug Open Library

0 Kudos

1,409 Views
mstreet
Contributor I

Pgo and Paul,

So, it sounds like I can access the Kinetis flash memory module using SWD to reprogram the flash.  Thanks for your answers!

0 Kudos

1,409 Views
mircopizzichini
Contributor III

Hi mstreet

You've been able to emulate SWD commands?

Did you use libSWD?

Thanks

0 Kudos

1,410 Views
pgo
Senior Contributor V

Hi Paul,

Missed that - I'm used to the other Kinetis devices.

bye

0 Kudos

1,410 Views
pgo
Senior Contributor V

Hi Paul,

The SWD protocol is more easily simulated with the SPI interface on the Kinetis devices,  in particular the K20 devices are convenient because they allow variable-length transactions.  You can refer to the source for USBDM firmware for example code.

The programming of the Flash is described in the Device Manual and has nothing to do with the SWD protocol.  You should  also consider using the EZPORT protocol which does not require target code execution. This is also described in the Device manual.

bye

Message was edited by: Peter O Donoghue

As has been pointed out by Paul - The KL series devices don't have EZPORT.

bye

1,410 Views
Paul_Tian
NXP Employee
NXP Employee


Hi, Pgo

KL25 has not EZPORT in it. So we cannot use such SPI way.

Hope my reply can help you.

Best Regards

Paul

0 Kudos