Minimum pin access to program via STLink

If you made your own board, post here, unless you built a Maple or Maple mini clone etc
michaeliv
Posts: 15
Joined: Tue Apr 12, 2016 4:55 am

Minimum pin access to program via STLink

Post by michaeliv » Sun Apr 24, 2016 8:10 pm

Hello,

I'm making my own mini-board and I was wondering what would be the minimum number of pins that have to be interfaced with in order to always be able to program the chip, no matter the current state of the chip. This assumes that the chip is connected to a crystal and power is supplied.

SWCLK / SWIO / GND would definitely be included in the required pins.
How about:
RESET: In which cases a reset of the chip would be necessary, also would power-cycle instead of reset work ?
BOOT0: I'm thinking of having BOOT0 always tied to ground, what scenario would make the chip unaccessible via STLink if BOOT0 was always connected to ground ?
BOOT1: Same as BOOT0.

I remember reading that the SWCLK & SWIO pins can or might sometimes be configured as GPIO so the chip can't be accessed any more via these pins. I don't remember where I read this, does anyone have a link with more info about this, and how to get SWCLK & SWIO back to being STLink-able ?

Thanks!

User avatar
mrburnette
Posts: 1788
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Minimum pin access to program via STLink

Post by mrburnette » Sun Apr 24, 2016 8:23 pm

michaeliv wrote:Hello,

I'm making my own mini-board and I was wondering what would be the minimum number of pins that have to be interfaced with in order to always be able to program the chip, no matter the current state of the chip. This assumes that the chip is connected to a crystal and power is supplied.
<...>
https://github.com/leaflabs/maple/blob/ ... ematic.pdf

The above link has the Maple board schematic... you should be able to answer your own question by eliminating what you do not desire to utilize.

IF you do not wish to use a bootloader, or do not wish to use ST-Link, there is a native ssrial loader, discussed here: https://www.sparkfun.com/products/retired/10664


Ray
Last edited by mrburnette on Sun Apr 24, 2016 11:47 pm, edited 1 time in total.

zmemw16
Posts: 1263
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Minimum pin access to program via STLink

Post by zmemw16 » Sun Apr 24, 2016 9:36 pm

@michaeliv

googling 'connect under reset stlink' gives the st manual pdf

http://www.google.co.uk/url?sa=t&rct=j& ... ArLDuhWwLQ

i seem to have acquired a copy by following the above :D

it'll explain the effect if any of boot0/boot1?

stephen

User avatar
RogerClark
Posts: 6130
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Minimum pin access to program via STLink

Post by RogerClark » Sun Apr 24, 2016 9:40 pm

AFIK.

If you always intend to program via STLink,you can pull Boot0 and Boot1 low all the time.

At a pinch, you could also hard wire the reset line, and just power cycle the board instead.

You only need to connect the 2 SWD lines to program via STLink

stevech
Posts: 442
Joined: Thu Aug 27, 2015 6:32 am

Re: Minimum pin access to program via STLink

Post by stevech » Mon Apr 25, 2016 4:46 am

and SWD needs a connection to card's 3.3V Vcc as VTref, and GND of course.
Card's nRESET is a practical must-have for the SWD interface.

SWD and CLK, optional is the trace pin... very handy for logging and and profiling in the debugger.

User avatar
RogerClark
Posts: 6130
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Minimum pin access to program via STLink

Post by RogerClark » Mon Apr 25, 2016 7:02 am

@stevech

Are you sure STLink needs to be connected to Vcc.

I sometimes power a board via USB, and its onboard 3.3V reg, and then only connect the STLink via SDIO SCLK and Gnd.

If the processor has the SWD pins enabled, there should be no need to connect under reset. But for safety I would have the reset pin available to the STLink

User avatar
WereCatf
Posts: 167
Joined: Sat Apr 16, 2016 5:30 pm

Re: Minimum pin access to program via STLink

Post by WereCatf » Mon Apr 25, 2016 7:09 am

RogerClark wrote:Are you sure STLink needs to be connected to Vcc.

I sometimes power a board via USB, and its onboard 3.3V reg, and then only connect the STLink via SDIO SCLK and Gnd.
I think the VCC-pin is there only for when you want to power the board from your ST-Link itself. My device powers up and works happily if I power it from ST-Link, ie. there is no USB-cable or anything else connected providing power to it, but when I power it from somewhere else I never connect the VCC pin.

michaeliv
Posts: 15
Joined: Tue Apr 12, 2016 4:55 am

Re: Minimum pin access to program via STLink

Post by michaeliv » Mon Apr 25, 2016 8:13 am

Thanks all for your answers, I'm getting a better idea about what is involved.
Can anyone tell me how the MCU can get it's SWD pins disabled ( configured as GPIO ) ? Is there an stm32duino function to do this ?
If it reaches that state, what is the correct way to program it via STLink ? Hold down reset and access via STLink ?

Also if I intend to also program via USB, will this change anything for this particular case, will I need more pins exposed to program ?

Thanks!

User avatar
RogerClark
Posts: 6130
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Minimum pin access to program via STLink

Post by RogerClark » Mon Apr 25, 2016 8:37 am

SDW pins can be disabled if they are configured as GPIO in the firmware.

For boards like the Maple mini, the SWD pins are configured as GPIO, which means if you try to program over STLink after running a sketch, the STlink will not connect to the STM32 (this is part of the initialisation)

So you have to select "Connect under reset" in the STLink program, then hold the stm32 in reset, and then tell the STLink to connect, and then take the STM32 out of reset.


If you want USB you need 2 usb pins connected to the USB i.e USB D+ and USB D-.

To enumerate USB ideally you need an external PNP transistor or PChannel FET, but it is also possible just via a 1.5k pullup on one of the USB lines as we have a hacky way to switch one USB pin to GPIO and then back to USB which causes the USB re-enumeration - but we only to this to support boards without the proper usb reset electronics

But like Ray has said, Look at the Maple mini schematic, it has a complex USB reset system of 2 x NPN transistors (which I think can be replaced by one PNP), it also has the nesessary USB series resistors (22 ohm I think), and some boards also have USB protection devices as well.


BTW. I'm not sure what you are building, but I have been tempted for some time to design a DIgiStump style USB board based on the STM32, using the PCB as the USB edge connector.

michaeliv
Posts: 15
Joined: Tue Apr 12, 2016 4:55 am

Re: Minimum pin access to program via STLink

Post by michaeliv » Mon Apr 25, 2016 5:31 pm

I'm trying to design an arduino pro micro -style board (http://artofcircuits.com/wp-content/upl ... icro-1.jpg) based on STM32F103T8U6(qfn/36). It's just a standard board, but with a more compact format for easier breadboarding.
That's why I was wondering what I need to expose for programing. I'm thinking that I won't be exposing the reset pin for programing.

So, which firmware / what should i avoid flashing in order to not configure the SWD pins as GPIO and therefore "Brick" my mini-board.
Also, I'm guessing that by default, chips that ship from the factory / DigiKey can be programmed without reset access, right ?
I'm planning on using a 1.5k resistor for reset. If I want to use the transistor reset mechanism then I would need a custom bootloader and would also have 1 less GPIO to use for general purpose, right ?

Funny enough, for my blue pill-board reset/re-enumerating via usb works on the ports on the left side of my laptop, but doesn't work with the ports on the right side of my laptop. However it works with right side ports + USB hub. I'm under Windows 8.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests