DIY ST-Link SWIM programmer for STM8S?

Kenjutsu
Mon Feb 29, 2016 9:26 am
Hello everyone,

A while back I ordered a few “STM8S103F3P6 Minimum System Development Board”s with a clone ST-Link programmer. The ST-Link programmer was DOA, and now I can not program the STM8S boards. Instead of buying a new clone (and waiting nearly 2 months for it to arrive), I was wondering if I can build my own ST-Link clone using a STM32 Blue Pill board?

Where should I start looking?

Thank you!


mrburnette
Mon Feb 29, 2016 1:30 pm
I was wondering if I can build my own ST-Link clone

I think a solution would be to build out a BMP which can provide the ST-Link functionality.

Ray


ahull
Mon Feb 29, 2016 1:43 pm
You may be able to reflash the dead STM adapter too, if you solder wires to the four solder pads on the board, you should be able to re-flash, but of course you will need a working ST-Link or BMP to do this.

RogerClark
Mon Feb 29, 2016 9:16 pm
If you are very good at soldering, there is nothing to stop you connecting a USB to serial adaptor to the dead STlink, and its possible that it is blank and just needs to be flashed.

I received a “CC Debugger” from an eBay supplier and found it was totally blank. Fortunately I knew someone with another one of these and we managed to flash my CC Debugger using his CC debugger.

So this sort of thing definitely happens.


ahull
Mon Feb 29, 2016 11:10 pm
I have done this in the past, I think the device in question is in my office, ‘cos I can’t find it here. I took a couple of pictures at the time, see below.

https://goo.gl/photos/bHJvb6caAPjTQW318

Image

If I had it to hand, I’d tell you which pins were which, but you can probably figure it out quite easily with a multimeter.


zoomx
Tue Mar 01, 2016 10:13 am
The BMP has a complete emulation of a STlinkv2?
Because STM8 uses SWIM instead STM32 uses SWD. STlinkv2 clones have two different ports, one SWIM and the other SWD.

Kenjutsu
Tue Mar 01, 2016 12:09 pm
Thank you for all the replies.

My progress so far:
– downloaded and flashed the blackmagic.bin file in bmp_j66_coreboard_20150524.zip to a Blue Pill
– connect the ST-Link clone to the BMP
– run dfu-util -l and get: Found Runtime: [1d50:6018] ver=0100, devnum=9, cfg=1, intf=4, alt=0, name=”Black Magic Firmware Upgrade (JC66CoreBoard)”, serial=”B6CBAEDB”
– run arm-none-eabi-gdb with target extended-remote /dev/cu.usbmodemB6CBAED1, followed by monitor swdp_scan and get
Target voltage: Not Implemented!
Available Targets:
No. Att Driver
1 STM32F1 medium density


ahull
Tue Mar 01, 2016 8:08 pm
Kenjutsu wrote:Thank you for all the replies.

My progress so far:
– downloaded and flashed the blackmagic.bin file in bmp_j66_coreboard_20150524.zip to a Blue Pill
– connect the ST-Link clone to the BMP
– run dfu-util -l and get: Found Runtime: [1d50:6018] ver=0100, devnum=9, cfg=1, intf=4, alt=0, name=”Black Magic Firmware Upgrade (JC66CoreBoard)”, serial=”B6CBAEDB”
– run arm-none-eabi-gdb with target extended-remote /dev/cu.usbmodemB6CBAED1, followed by monitor swdp_scan and get
Target voltage: Not Implemented!
Available Targets:
No. Att Driver
1 STM32F1 medium density


RogerClark
Tue Mar 01, 2016 8:33 pm
AFIK you can ignore the target voltage warning. Its just that its not implemented in that BMP code.

It looks like the BMP is seeing the STLink board.


Kenjutsu
Wed Mar 02, 2016 8:06 am
I connected another Blue Pill to my BMP and I can attach to it via gdb. I seems as if my clone STLink is dead. The power led also do not turn on when power is applied. I guess I will have to buy another clone from eBay :(

RogerClark
Wed Mar 02, 2016 10:56 am
The Blue Pill will work as a STLink, you just need to flash the STLink firmware to it.

There isn’t any special hardware on those STLink dongles.

I managed to flash the bootloader to one of those dongles and I think it worked fine, albeit they are of limited use, as they have hardly any gpio connections available.


Kenjutsu
Wed Mar 02, 2016 1:28 pm
Thanks to this great post by Roger, Arduino on the nRF51822 Bluetooth Low Energy microcontroller, I flashed one of my Maple Minis to a BMP, and tried to flash the STLink clone again, but stil no luck. The plus side is that I now have a fully working BMP running on a Maple Mini ;)

Kenjutsu
Wed Mar 09, 2016 6:21 pm
I wasn’t ready to give up just yet, so after some Google-Fu I found this Russian site: http://bovs.org/post/107/programmator-o … m8-i-stm32. I used one of my Blue Pill boards and wired up only what is needed to get SWIM going for the STM8S, and using stm8flash (https://github.com/vdudouyt/stm8flash), I got my 4 STM8S board flashing their green LEDs 8-)

ahull
Wed Mar 09, 2016 7:39 pm
Good stuff!

That Russian site is an interesting read. (English Translation)


zoomx
Thu Mar 10, 2016 10:06 am
The Swim line seems to be controlled by pins PB7,PB8,PB9,PB10 and PB11
The Swim_RST is controlled by PB5 and PB6.
To me seems a lot of pins. I wonder why.

@Kenjutsu
you wired only these pins, with resistors R7,R8,R10,R17,R18 and two zeners VD6 and VD7?


Kenjutsu
Thu Mar 10, 2016 1:48 pm
Here is what I connected:

  • R1, R2 and C1 to PA0
    R19 to LED1, LED2 to R20 for U1_BL_TX
    R8 to PB5 & PB6 for SWIM_RST
    PB7 to PB9 to PB10 to R7 for SWIM to R10 to 3V3
    PB8 to PB11 to SWIM

;)


urielka
Sat Jul 09, 2016 6:37 pm
I just made a guide (from zero to blinky STM8) based on this post and the original russian blog – http://www.stm32duino.com/viewtopic.php?f=35&t=1233

Including a minimal schematic (without leds) of the programmer board with STM32F103C8 minimum development board.


Leave a Reply

Your email address will not be published. Required fields are marked *