How to program blank STM32F1 with STLINK V2 firmware

Today I found out how to “flash” blank STM32F103xC to make STLINK V2 debugger interface.

So, instead of desoldering from Discovery board to make miniture STLINK debug interface:

a09 - stlink v2 brain desoldered                  a0a - stlink v2 finally assembled usb mini dongle

it’s possible to solder blank (or any) STM32F10x with USB and at least 64k flash + 20k RAM, program it with STLINK V2 Firmware and use your new USB dongle for debugging STM32 or STM8 devices.

First make single sided PCB as described here.

What you will need is a copy of STLINK V2 HEX (available in this keil uVision project in the folder ./Objects) or Binary image of the STLinkV2.J16.S4 image for writing in the microcontroller. Here is is the complete project in keil uVision. Just install free evaluation copy of Keil tools or free version for STM, open the project, connect the debug interface to the pads iC (SCLK) and iD (SDIO) and program the STM32F10x.

After writing the flash it is possible to upgrade to newest version of STLINK V2. Just install STLINK firmware upgrade, e.g. stlink-V2.J21.S4 and perform the update:

pre-upgrade            upgrade-OK

 

9 Comments

  1. Mare says:

    Here is excellent article on using STM32 GNU ARM GCC Toolchain with Eclipse, STLink and OpenOCD Debugger:
    http://eraycanli.com/2015/08/19/stm32-gnu-arm-gcc-toolchain-with-eclipse-stlink-and-openocd-debugger/

  2. Mare says:

    Here are some other options for writing the flash image to STM32F103:
    http://jeelabs.org/book/1546c/

  3. Sherlock says:

    Hi my dear!

    I need an firmware to ST-Link-V2/1 and I just found a firmware to ST-Link-V2.

    Do you have any ST_Link_V2/1 firmware too? Like V2J28M16.

    • Mare says:

      Once you have up and running STLINK you can just run any firmware “upgrade” app at the desired level / version.

      • Sherlock says:

        I have the “STSW-LINK007 Upgrade” and I just can up to V2J28S6 (to ST-LINK/V2), so I don’t have Virtual COM Port acess…
        Do you know how can I resolve it?
        Thanks for your help!

      • Peter says:

        Unfortunately, ST-Link V2-1 have different bootloader and ST-Link V2 can not be simple upgraded to ST-Link V2-1.
        ST-Link V2-1 is composite device (debugger, Virtual COM, mass storage).

  4. Danny Leach says:

    Please help
    I flashed my on board STM32F103CBT6 (see below) but it appears I don’t have a USB transceiver when complete. No USB com’s, the ST-LINK utility gives me Error No ST-LINK detected.
    I also probed it wit an O’Scope and se no traffic.

    14:20:18 : ST-LINK SN : 49FF72064982565449261787
    14:20:18 : ST-LINK Firmware version : V2J27S6
    14:20:18 : Connected via SWD.
    14:20:18 : SWD Frequency = 4,0 MHz.
    14:20:18 : Connection mode : Normal.
    14:20:18 : Debug in Low Power mode enabled.
    14:20:18 : Device ID:0x410
    14:20:18 : Device family :STM32F10xx Medium-density
    14:20:18 : Can not read memory!
    Disable Read Out Protection and retry.
    14:20:36 : Could not set Option bytes!
    Please reset the target and retry.
    14:21:08 : Disconnected from device.
    14:21:08 : Connection to device is lost: check power supply and debug connection.
    14:21:08 : If the target is in low power mode, please enable “Debug in Low Power mode” option from Target->settings menu.
    14:21:14 : ST-LINK SN : 49FF72064982565449261787
    14:21:14 : ST-LINK Firmware version : V2J27S6
    14:21:14 : Connected via SWD.
    14:21:14 : SWD Frequency = 4,0 MHz.
    14:21:14 : Connection mode : Normal.
    14:21:14 : Debug in Low Power mode enabled.
    14:21:14 : Device ID:0x410
    14:21:14 : Device flash Size : 128KBytes
    14:21:14 : Device family :STM32F10xx Medium-density
    14:21:57 : Memory programmed in 15s and 116ms.
    14:21:57 : Verification…OK
    14:21:59 : Flash memory [0x08000000:0x08020000] Checksum: 0x01901941

    • Mare says:

      It seems the statement “any” STM32F10x will do is not correct. Originally the microcontroller on STLINK is STM32F103C8T6 and the binary image works with this size only. Sorry, I didn’t tested on other F10x types.

  5. Danny Leach says:

    Mare,

    Please note: I am using the STM32F103CBT6 I’m not sure why ST-LINK displays what it does.
    05:19:26 : Flash memory erased.
    05:20:39 : [stlink_00.hex] opened successfully.
    05:20:39 : [stlink_00.hex] checksum : 0x00911941
    05:21:11 : Memory programmed in 12s and 12ms.
    05:21:13 : Flash memory [0x08000000:0x08020000] Checksum: 0x01901941