Poor man's STM8 (STLinkV2 SWIM) programmer

urielka
Posts: 4
Joined: Mon Jul 04, 2016 2:44 pm

Poor man's STM8 (STLinkV2 SWIM) programmer

Postby urielka » Sat Jul 09, 2016 6:36 pm

Hi all,

I just built a simple STLink V2 programmer using a STM32F103C8 Minimum development board (those that cost 2$ at aliexpress).
It is nothing new but I had to gather information from several sources (one in russian :) ) and I think it will help others to have a complete guide on how to build one.

Next step is building a minimal arduino core :)

Comments, questions and fixes are welcomed!

BOM for the programmer:

2 x 220 Ohm resistors
2 x 4.7K Ohm resistors
1 x 680 Ohm resistor
1 x 0.1uf capacitor
1 x STM32F103C8 minimum development board ("Blue Pill")
1 x connector/socket for the board
1 x 4-pin socket/socket for the SWIM connector

Steps to flash STLinkV2 firmware to the STM32:

1. Make sure you got a 1.5K Ohm resistance between PA12 (A12 in my board) to 3.3V, if you don't you can fix it by putting a resistor in parallel - for example if you got a 10K ohm resistance (like mine did) you need to put a 1.8KOhm resistor between PA12 and 3.3V pin.
More info can be found here - http://wiki.stm32duino.com/index.php?title=Blue_Pill
2. Download this http://bovs.org/fileItem/go?id=23
3. From the archive you downloaded on step #2 install "Flash_Loader_Demonstrator_v2.4.0_Setup"
4. Set BOOT1 to 1 in the jumpers (the one closer to the pins)
5. Connect the board to your computer with a serial to usb adapter - https://www.youtube.com/watch?v=Ze6q6NidS5w
5. Open Flash Loader Demostrator
6. UART should be selected, choose the correct port for your device (you can see the com ports under windows device manager)
7. Click Next. If the UART is connected properly, powered up, then a window should with a green light and "Target is readable"
If an error occurs, check the physical contact.
8. Click Next twice. In the next window, specify the path to the firmware file found in the archive: "firmwareSTLinkV2.J16.S4.bin"
9. Again, Click Next and wait for the completion of the firmware upload. when it finish you should see a green bar with "Download operation finished..."
10. Disconnect the Serial to USB converter and power to the board.
11. Install STLinkV2 drivers from here: http://www.st.com/content/st_com/en/pro ... nk009.html
12. Connect the board with a USB( not converter!) directly to the computer, the cable has to be a data cable (not a charging cable!)
13. Windows should auto detect the board (now a programmer) and select the driver.
14. Run upgradeST-LinkUpgrade.exe (upgrade folder must be unpacked), Click connect and then upgrade.
If it doesn't connect, then disconnect the USB, reconnect it and click connect.

Congrats now you have a STLinkV2 programmer on hand! ok not so fast, while it does run the correct firmware some passive components are needed to connect it to an STM8 SWIM connector.

Schematics(this is the bare bare minimum):

Image

NOTE: 3V3 and GND for the SWIM connector in the STM8 board are provided by 3.3V and GND from the STM32 board.

This is my board:
Image

Steps for uploading code to STM8:

0. Build the board and put your STM32 in it.
1. Instal IAR STM8 Workbench, you need to register for a 8KB permanent license, just follow the instructions
2. Open an example like blink
3. Change to the correct board (in my case stm8s103f3) and use the attached code (main.c, the led is assumed to be connected to PB5)
4. Connect your STM8 board to the board you just built via the SWIM connector on the side of the board
4. Click on ST-LINK -> Options bytes, if a window opens then you are able to connect to the STM8!
5. Now you can do Debug -> Start debugging, it will upload (called download for some reason) the code to the STM8, start the program and break on the first statment.

Congrats now you can program and debug STM8 boards!!!

Improvments:

1. Add SWD connector
2. Add leds for TX/RX

Links:
Original work (all credits goes to him!) - http://bovs.org/post/107/programmator-o ... m8-i-stm32
Original post (this post is basically a summary of this) - viewtopic.php?f=45&t=949&p=11205&hilit=stm8#p11205
Original schematics - http://bovs.org/images/scheme.jpg
Flashing the STM8 in linux - http://www.cnx-software.com/2015/04/13/ ... -in-linux/
Attachments
main.c
(1.09 KiB) Downloaded 113 times

Return to “STLink”

Who is online

Users browsing this forum: No registered users and 1 guest