I'm interested in creating simple interface to SWD to be able to write flash memory of ARM chips. I.e. to create a make-shift programming device - more for sake of exercise.
I started reading the documentation and searching for examples (for I think people already tried this). Currently I have a few questions, for which I would be thankful for guidance:
- I'm going to configure SWDCLK as normal output, and SWDIO as an open-drain (acting as input when it is in high-Z, see below) - I suspect that it is also open-drain on the side of the target device, so with the help of pull-up I will never have a short-circuit by mistake - is this correct?
- is there minimum allowed clock period? or anything will do, even just a few Hertz? Or perhaps this is dependent on target device?
- is it correct that in waiting mode both lines are driven HIGH on the host side, and when the communication begins, the first edge on SWDCLK is falling?
- HOST should change SWDIO on falling edge of SWCLK - and sample data from target (when needed) on falling edge of SWCLK either - right?
I think currently that's enough (though I would be also thankful for short sample of commands sequence to read / write the flash - but I believe I'll find it out anyway soon) - thank you in advance!
Currently I'm trying to use Arduino to create a basic prototype, though I can switch to plain Atmega or LPC111x with FTDI cable at any time... Though I believe this is not important.
P.S. to explain better about SWDIO - with AVR's for example I put the pin to LOW state and then if it is switched to output, it produces 0. However if it is switched to input, it is in high-Z state and really works as input. I.e. I manipulate not PORTx bit, but DDRx instead (while PORTx is permanent 0 and PINx is used for reading).