Programming interface progress: SWD JTAG command sequences

Published by Stijn Kuipers on

Since the last post I spent quite some time with my new tool to dump sequences from my commercial debugger. After comparing these dumps to various codebases I found online (libswd, cmsis-dap, mchck) and comparing them to the various manuals on the subject, I managed to extract the command sets for a set of essential functions:

1) Peek/Poke (universal to all ARM cores)
2) Halt/Continue (universal to all ARM cores)
3) Reset (Freescale specific)
4) Mass erase (Freescale specific)

With these command sets figured out, I was able to recreate them on a standard Arduino and trigger them with a simple serial remote control application. I also managed to figure out how, when and why all the various types of registers are available to read/write over the debug lines. In the case of the Freescale chips I’m targeting, some features are only available after setting certain bits somewhere else. Others only work when the system resetpin is activated. Joy.

Example: reading the identification register to see if the chip has powered up correctly. The magic value here is the 0x04770031 at the end.

Figuring all this out has brought me much further along the path – I am now almost ready to start executing flash commands on the target device. When the system can flash the MKL26 and MKL02 chips I am planning to move the codebase from the Arduino it lives on now to a set of dedicated small/cheap boards. One of these will be another USB-stick type PCB (plugs straight in to a USB port) with a simple row of programming pins meant to program microgameboys – possibly pogopin holder.

Still to be continued…