Making your own ST-LINK V2 from STM32 Blue-Pill or STM32 Black-Pill

In this article I will explain how to create your own ST-LINK V2 with cheap board from China (Blue Pill).

Well we also need USB to Serial converter and some software. First we will look at software. We need so called “Flash Loader Demonstrator“, you can get it at the bottom of this page, or for your convenience on this link, because getting it from ST can be quite a challenge. We need ST-LINK Utility, which contains drivers we will need later, you can get it here on the bottom of the page or again for convenience here on my page. We also need .hex file for uploading into microcontroller, you can find it here. I got .hex file from Mare & Gal’s web page.

Now let’s prepare the hardware. We need to set jumper BOOT0 to 1. We also need to connect our USB to serial adapter as the diagram below:

Be careful to set adapter voltage to 3.3V!!!

Now we run Flash Loader Demo, which I won’t explain how to install, because it is very straightforward. You are presented with this window:

Here we select proper COM port and click Next. You are presented with this window, if not, maybe you connected RX and TX wrong or the BOOT jumpers are at the wrong position:If you programmed this board before, you might have to remove protection. Click Next and you are here, just click Next:Here you click on the icon marked green and browse to your stlink.hex file and click Open:
 And then click Next and the Loader will start to download program the microcontroller:

Adn then it will also start to verify it:And finally it will say it is done:But we are not done yet. Now we disconnect everything and connect our board to computer with micro USB cable and also move the BOOT0 jumper back to 0. Now we start ST-LINK Utility, select ST-LINK -> Firmware update:

New window opens and here we click on Device Connect and it will connect to our new ST-LINK:Now click on Yes and it will start to upgrade:When it’s done it will let us know:

Now all we need to do is test it. I am testing it according to diagram below with another Blue Pill (don’t miss that short connection between PB12 and PB14!!!):All we need to test if it works is to click on Target -> Connect:

Ifeverything is ok you should get target connected to your new ST-LINK:

 

Have fun with your new toy! Thank you for reading!

P.S.: In the title I mentioned Black Pill, it is same for it, just find the proper pins.

 

Slemi

8 thoughts on “Making your own ST-LINK V2 from STM32 Blue-Pill or STM32 Black-Pill

  1. Hello why can’t I use ST-link upgrade software in the first procedure instead of programming thru serial?

    • Because when microcontroller is new it does not contain ST-LINK software that would communicate with ST-LINK Utility.

      • I having problem with my STM32F429ZI-Discovery board.
        https://www.st.com/en/evaluation-tools/32f429idiscovery.html
        I has STM32F103C8T6 as ST-link/V2.
        Fw version is :
        V2.J16.S4 STM32+STM8 Debugger

        I cannot update to V2.J32.S7 or any other firmware.
        This is my first time to trying to update and havent updated before.

        I tried using this “Flash Loader Demonstrator“, tied Boot 0 to 3V by wire.
        1. It can detect by clicking next after I select the UART, but when I click back and next again, it wont connect anymore.
        I was able to remove protection.
        2. So I proceed and did not click back and was able to download but failed verification at around 17% and then error comes out “Data not matching at address : 0x8002C00”

        Do you think that this FW version is not capable to be erased and updated anymore?

        Anyway to update it?

        PS

        I tried different version of ST-LinkUpgrade.exe but also failed.
        I havent tried ST-LINK Utility to fully erase though.

        • This board should be updated from ST-LINK Utility. It might ask to reconnect it to get into DFU mode. I haven’t tried the Flash Loader Demonstrator for this purpose. Only for making clones. Try on ST forum if anyone knows the solution. Here is the link.

          • Hello Thank you very much for the help.
            One quick question.
            From ST-Link/v2-1 of STM32F3348Discovery I am trying to full chip erase the said ST-Link/V2 of STM32F429ZI-Discovery.
            So I connect the SWD from STM32F334 ST-link to the correct pins of ST-Link/V2 of STM32F429ZI-Discovery.
            I removed some jumpers (SB5 and SB10) and connect SB4 and SB9 of ST-Link/V2 of STM32F429ZI-Discovery (STM_JTMS and STMJTCK) and I solder wire to NRST.
            It can read the device model but shows error:
            Cannot read memory!
            Disable read protection and retry.

          • I believe you can solve this by using ST-LInk Utility. In there you go to menu Target -> Connect and then menu Target -> Option Bytes… (CTRL + B) and when new window opens select Disabled at the top of the window. But here is the catch, if you have resolution of screen smaller than around 1000 pixels vertical, you cannot see the apply button. You have two options: 1. rotate screen and select Apply or 2. you can keep pressing tab on the keyboard to move focus to apply button. You cannot see it but the order goes as folows: Disabled (start here) -> selecting option bytes checkmarks (one after another) -> Data 0 (H) -> Data 1 (H) -> Unselect All (button) -> Select All (button) -> Unselect All (yes this buton again -> Apply (button), now you hit enter to confirm. And now you should be able to program your chip again…

  2. Now I was able to erase it.
    Problem is when I upload the hex file and I cannot update to any new firmware.
    Your hex file is the same as mine V2.J16.S4 STM32+STM8 Debugger.
    I can confirm I successfully erased the chip because Win7 says USB cannot be recognized.
    When I update the FW to the said version (V2.J16.S4 STM32+STM8 Debugger), comes the same error (cannot update).
    When can I search for another newer hex file?
    BTW, there is no notification when there is a reply from here.

    • I tried the tutorial again to see if it still works. I had to erase complete chip before programming, because making ST-LINK disables write operations. After that I programmed and updated newly created ST-LINK. So I really wouldn’t know what to suggest to you to do…
      P.S. I also installed some plugin for notification on comment reply. Thank you for letting me know that it didn’t work.

Comments are closed.