Blue Pill and ST-LINK V2

Generic boards that are not Maple or Maple mini clones, and don't contain the additional USB reset hardware
Post Reply
Chuck(G)
Posts: 9
Joined: Sat Jun 18, 2016 10:42 pm
Location: Oregon, USA

Blue Pill and ST-LINK V2

Post by Chuck(G) » Sat Jun 18, 2016 11:18 pm

I'm obviously missing something important trying to get a Blue Pill board (same as that shown on Roger Clarke's Github page.

I've got the ST-LINK V2 programmer shown here and am running Ubuntu AMD64 14.04.4 LTS using the latest openocd (0.9.0). I'm unable to connect--running openocd -d, I get the message:

Code: Select all

Debug: 251 34 stlink_usb.c:777 stlink_usb_init_mode(): MODE: 0x01
Debug: 252 38 stlink_usb.c:402 stlink_usb_error_check(): unknown/unexpected STLINK status code 0x9
Error: 253 38 stlink_usb.c:1739 stlink_usb_open(): init mode failed (unable to connect to the target)
I've up- and down-graded the STLINK firmware with identical results. The Blue Pill is being powered by the USB connector; the 3.3V from the STLINK is NC.

I've tried exactly the same setup on Windows 7 (x32) and also gotten a "failure to connect". The pins on the Blue Pill STLINK connector are, top to bottom, GND, SWCLK, SWDIO, 3.3. These are connected to the corresponding STLINK pins 6 (GND) 2 (SWCLK) and 4 (SWDIO).

I'm able to access the MCU using the ST serial flash loader, but no soap with the ST LINK widget.

Can anyone offer a suggestion or two?

TIA, Chuck

simonf
Posts: 180
Joined: Sun Jul 26, 2015 4:03 pm

Re: Blue Pill and ST-LINK V2

Post by simonf » Sat Jun 18, 2016 11:38 pm

Chuck(G) wrote: I've got the ST-LINK V2 programmer shown here and am running Ubuntu AMD64 14.04.4 LTS using the latest openocd (0.9.0). I'm unable to connect--running openocd -d,
OK they work with the blue pill on windows 10.. BUT I have two of those and they have different pinouts. I made up a cable for one and then swapped to a different stlink then found it didn't work. Just check the pin outs.

Some are

RST . .SWDIO
GND. .GND
SWIM .SWCLK
3.3v 3.3v
5.0v 5.0v

0r

RST . SWCLK
SWIM. SWDIO
GND . GND
3.3V . 3.3V
5.0 V. 5.0V

There may be other varieties. I bought some pre made cables but they weren't set up correctly for my stlink v2

Chuck(G)
Posts: 9
Joined: Sat Jun 18, 2016 10:42 pm
Location: Oregon, USA

Re: Blue Pill and ST-LINK V2

Post by Chuck(G) » Sun Jun 19, 2016 4:39 am

Hmm, on a hunch, I used the pinout of Roger's STLINK V2 shown here. That is, instead of what's on the red case, I used pin 2 = SWDIO, pin 4 = GND, pin 6 = SWCLK--and whaddya know, it connected right up!

So, something to know about the fake STLINK V2s, Evidently, the case needn't match the contents. The Chinese vendors may simply grab whatever case is to hand, regardless of the board inside.

FWIW, how does one get to the innards to actually see the hookup?

FWIW, the easy way to see what's what, is to check the continuity between the GND pins (or what you may suspect to be the GND pins) and the shell of the USB connector.

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

Re: Blue Pill and ST-LINK V2

Post by RogerClark » Sun Jun 19, 2016 6:24 am

Chuck(G) wrote: FWIW, how does one get to the innards to actually see the hookup?
Hold the metal case, and pull on the socket connector (the opposite end from the USB),

The whole circuit board including the USB plug will pull out as one piece (as the USB plug is soldered to the PCB),

The USB end has a plastic insert, with the cutout for the USB.
You can try levering that plastic insert out first, but normally its not necessary and can be counter productive.

However to put the PCB back in the metal housing, its best to remove that plastic insert, then put the PCB + plug back in the housing, and then fit that plastic insert piece over the USB plug.



BTW. One other thing about using STLink, by default, the sketch turns off the SWD pins (reallocates them as GPIO), so the STLink will not connect.

There are 2 ways to get it to connect. Easiest is to set Boot0. Alternatively there is a STLink mode called "Connect under reset" where you put the board into reset, tell the STLink to connect. The STLink spots the board is in reset, and waits until you release the board from reset, at which point it connects.
However I don't know if OpenOCD etc support connect under reset (though ST's Windows STLink program does)

Chuck(G)
Posts: 9
Joined: Sat Jun 18, 2016 10:42 pm
Location: Oregon, USA

Re: Blue Pill and ST-LINK V2

Post by Chuck(G) » Sun Jun 19, 2016 3:50 pm

Thanks, Roger.

Upon removal from the (red) case, the STLINK PCB is identical to that shown on your page cited above. So, the red case with its pinout is definitely a blunder. Let this be a warning to others.

I kind of figured that BOOT0 was the way to go, since that's what you have to use when programming via serial adapter. Have you tried tying the RST pin to the STLINK to the "R" pin (adjacent to B11) on the Blue Pill board? I wonder if that might also be a way to go without resorting to BOOT0 or manually resetting. Just a thought...

While I've got your attention, I have a decision to make about using the Maple IDE with the Blue Pill.

How compatible is the Maple toolchain with the STM STM3210x standard peripheral library? (STSW-STM32054) Completely different with different libraries?

TIA, Chuck

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

Re: Blue Pill and ST-LINK V2

Post by RogerClark » Sun Jun 19, 2016 9:49 pm

The core does not use the Standard Peripheral Library.

The core (libmaple), was originally written by Leaflabs, from scratch, only using a small amount of STM code.

The reason for this is the license on this code, which makes it impossible to distribute, and hence its not compatible with open source products.


Things have changed a bit with the STM Cube, as the license on the HAL has been relaxed and can be distributed.

So @sheepdoll and @vassiliis have been writing a core based on the HAL. However its only at Alpha stage development, and is missing a lot of functionality

You could download this core from my repo, just look for the HAL MX repo.

Alternatively, It may be possible to use the HAL as an external library.
I have not tried this, but the idea came to me when I saw what Francesco at Arduino.org had done for the core for the Arduino STAR OTTO board ( see that thread for details)


BTW.
Re: STLINK reset pin.
I have not looked at it using a scope, bit it didn't seem to get used by ST's Windows utility.

Chuck(G)
Posts: 9
Joined: Sat Jun 18, 2016 10:42 pm
Location: Oregon, USA

Re: Blue Pill and ST-LINK V2

Post by Chuck(G) » Mon Jun 20, 2016 4:28 pm

Okay, thanks for the tip on the alternate core work.

This stuff with the ARM core platforms is a little confusing; I'd previously used the Digilent Uno32 (PIC32 based) boards and found that much simpler and easy to get into. Sadly, there are no $4 PIC32 boards as far as I can determine. :cry:

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

Re: Blue Pill and ST-LINK V2

Post by mrburnette » Mon Jun 20, 2016 8:47 pm

previously used the Digilent Uno32 (PIC32 based) boards and found that much simpler and easy to get into.
This forum inherited a product that was manufacturer discontinued and the compiler and custom GUI and core structure wete not Arduino 1.5x compatible. In fact, the GUI was a pre-0022 snapshot. Everything we have today came from cycles stolen after the day job ended.

Evolution is somewhat slow but the end product is pretty good; and it will get better. The biggest issue I see now is a large amount of noise in the forum as word gets around about the STM32 value proposition. Everyone has their own priorities and are rather vocal... like a wild herd or horses galloping - a lots of dust is being stired and it is easy to become disoriented.

Ray

Post Reply