Home

Awesome

SWDscan

This Arduino-based Platformio project allows quick identification of SWD ports.

How does it work?

The app iterates through microcontroller gpio pins following the definition specified using PIN_MASK to find SWD clock and io lines. Pins are enabled by setting corresponding bits of PIN_MASK, i.e. pins 2-8 are enabled for PIN_MASK of 0b111111100 or 0x1fc.

Besides PIN_MASK predefined at build time you can also set the pin mask at runtime using the m command. Entering 508 or 0x1fc will result in pin_mask set to 0b111111100 so you can update the configuration without the need to rebuild the project.

How to use it?

How to configure it?

What is test mode for?

Test mode allows to check if target SWD IO and CLK lines are connected to specified pins.

How does it look like?

> h
+-------------------------------------------+
|                   SWDScan                 |
+-------------------------------------------+
 e - enumerate swd lines
 m - set pin mask, current: 0x1C
 t - test pin pair for swd
 b - break on hit, current: 1
 d - set debug level, current: 1
 h - this help
+-------------------------------------------+
> d
Choose debug level 0-2 1
Debug set to 1
> e
+-------------------------------------------+
| CLK PIN | IO PIN | ACK | PART NO | MAN ID |
+-------------------------------------------+
|    2    |    3   |  7  |   ffff  |   7ff  |
|    2    |    4   |  7  |   ffff  |   7ff  |
|    3    |    2   |  1  |   ba01  |   23b  |
|    3    |    4   |  7  |   ffff  |   7ff  |
|    4    |    2   |  7  |   ffff  |   7ff  |
|    4    |    3   |  7  |   ffff  |   7ff  |
+----------------- SUCCESS -----------------+
> m
Enter pin mask 0xfc
Pin mask set to 11111100
> b
Break work on hit? 1/0 1
> d
Choose debug level 0-2 1
Debug set to 1
> e
+-------------------------------------------+
| CLK PIN | IO PIN | ACK | PART NO | MAN ID |
+-------------------------------------------+
|    2    |    3   |  7  |   ffff  |   7ff  |
|    2    |    4   |  7  |   ffff  |   7ff  |
|    2    |    5   |  7  |   ffff  |   7ff  |
|    2    |    6   |  7  |   ffff  |   7ff  |
|    2    |    7   |  7  |   ffff  |   7ff  |
|    3    |    2   |  1  |   ba01  |   23b  |
+----------------- SUCCESS -----------------+
> t
Enter SWD CLK PIN NO 3
Enter SWD IO PIN NO 2
+-------------------------------------------+
| CLK PIN | IO PIN | ACK | PART NO | MAN ID |
+-------------------------------------------+
|    3    |    2   |  1  |   ba01  |   23b  |
+----------------- SUCCESS -----------------+
> t
Enter SWD CLK PIN NO 2
Enter SWD IO PIN NO 3
+-------------------------------------------+
| CLK PIN | IO PIN | ACK | PART NO | MAN ID |
+-------------------------------------------+
|    2    |    3   |  7  |   ffff  |   7ff  |
+----------------- FAILURE -----------------+

Nothing found?

In case the target fails to switch to SWD mode:

No Platformio?

No problem, just copy the contents of src/main.cpp to a new Arduino project, remove the Arduino.h import from the first line and you're ready to go.

Need JTAG?

Check JTAGscan to identify JTAG TMS, TCK, TDO and TDI pins.