I was doing my hardware hack project on an air quality monitoring device which uses STM32L476 processor.

Airbox pins My only experiences with hardware hacking are IPcams or wifi routers with UART consoles available. But, after some probing and trying, I was not able to find a way to interact with my air box.
(The USART pins just print out a UUID on boot and then nothing more happens.)

So I reckon my next best bet is those SWD pins. I then proceed to get the datasheet of STM32L476 and encountered this problem.

According to the datasheet, SWDIO and SWCLK corresponds to pin PA13 and PA14 and no other pins has alternative functions to work as SWDIO or SWCLK. STM32L476 pinout STM32L476 pin definition

But looking carefully, PA13 and PA14 aren't even connected to those pins marked SWD1 on board. enter image description here
SWD1 and USART are the only ones that has pinouts so I think they have very high probabilities to be used by developers as debugging ports. But as far as I know, STM32 chips only need two pins to debug with SWD, and there are 8 pins on board! This circuit just makes no sense to me :((

I'm very new to hardware so I'm not familiar with what hardware developers usually do. Is it common for some pins on board to be marked as A but really worked as B ? Or was it just me making some very stupid mistakes when doing my research ?


So after reading all of the comments and answers, I did some test and listed some characteristics of those pins: enter image description here
I guess I'm good to go and proceed to next step? There's just so much to learn while waiting for my ST link V2 to arrive. Thanks a lot to every one who provided me with utmost kind and help😊😊

  • 2
    \$\begingroup\$ Have you measured that there is no connection from any of those header pins to the SWD pins or are you doing that just by following the trace optically? \$\endgroup\$ – Arsenal Apr 24 '18 at 9:56
  • 1
    \$\begingroup\$ @Arsenal Well... after reading your comment, I tried to do continuity test on those pins with my multimeter and really got two pins in SWD1 that are continuous with PA13 and PA14. How stupid am I to judge a circuit by its appearance D: .... Anyways, I'm really grateful for your kind and quick comment! \$\endgroup\$ – Jimmy.D Apr 24 '18 at 10:07
  • 1
    \$\begingroup\$ They would have to be connected or they couldn't program it, you can use 8 wire JTAG or SWD in the same connector. SWD uses two wires and you'll also need ground (it also helps to have VCC) \$\endgroup\$ – Voltage Spike Apr 24 '18 at 16:13
  • \$\begingroup\$ @laptop2d The two wires you mentioned are SWDIO and SWCLK, am I understanding it correctly? I managed to find GND but not quite sure which one is Vcc. My only knowledge is that Vcc is used as level shifter in SWD but don't know how to make sure which one is it..... There is a 5v pin though (That pin on buttom-right corner which is connected to a very thick wire) is it safe to suppose it is SWD Vcc pin? \$\endgroup\$ – Jimmy.D Apr 25 '18 at 2:34
  • \$\begingroup\$ @Jimmy.D There is no way of knowing without a schematic of your board, if you don't have a schematic then you'll have to reverse engineer one from your PCB. \$\endgroup\$ – Voltage Spike Apr 25 '18 at 5:28

Use a multimeter. You will probably find that those pins are connected to the SWD pins. Note that PA14 clearly goes to a via, which will then run along the bottom side of the PCB.

PA13 most likely runs underneath the micro, and into a via, and runs to the SWD header through the bottom layer too.

Just because you look at something from the top and cannot see a connection, does not mean that it is not there. Look at PA14. Can you see a logical way of running a track to the SWD header pins on the top layer? No, you would have to cross a lot of traces which you just can not do. This is why vias are used, so the track can continue on the other side of the PCB.

You should never look at a PCB and assume because you can't see a trace all the way along the top side of a board, that it is not connected. Get a multimeter and check for continuity. I suspect you will find there is a connection there.

There are actually 6 SWD pins used for programming (if you program via SWD) which are V+, GND, RST, SWIO, SWCLK and SWO. If this board was programmed via SWD, there are lots of pre-made flat cables used for programming, such as this one:

enter image description here

And the programmer will have a pre-made pinout that the designer needs to follow. That is the likely explanation for the extra pins on the header. It usually depends on the programmer being used as to which header is used in the design.

  • \$\begingroup\$ Thank you for your detailed answer! After reading your answer and Arsenal's comment, I do used my multimeter and find out continuity of those pins. Also your insight on SWD programming really shed light on my confusion! Thank you so much! \$\endgroup\$ – Jimmy.D Apr 24 '18 at 10:16
  • 1
    \$\begingroup\$ Glad to help. Although the answer by @jeroen3 has a better description of the SWD programming side of things than mine. \$\endgroup\$ – MCG Apr 24 '18 at 10:32

You research is correct. SWD cannot be remapped, but the pins can be used otherwise.

The connector is non-standard. Typically people use the 10 pin SWD connector (often with 1.27mm pitch) for ARM JTAG/SWD.

To communicate with the chip you need 4 pins.
Target gnd and vcc, and SWDIO, SWDCLK. The programmers use target Vcc for their level shifters. Since many ARM targets can run voltage from 1.8 to 5 Volt.

The reset pin is not required, unless the pins are used otherwise in user code. As in internally disconnected from the debug peripheral.

Popular programmers are the ST Link for STM32 and STM8 chips. Or Segger for various brands.

  • \$\begingroup\$ Appreciate your additional information about SWD!😄😄 I'd like to up vote all of you guys but my rep isn't enough😢 Looks like all those boasting about the ability to use SWD with only two pins in the datasheet blinded me. I shall do my research more thoroughly in future works🤦 \$\endgroup\$ – Jimmy.D Apr 24 '18 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.