CS32 Blue Pill clone connection problems

Recently I’ve been doing some experiments with the popular “Blue Pill” microcontroller model STM32F103C8T6, made by STMicroelectronics. The microcontroller (MCU) uses the ARM Cortex-M3 F103 chip, a low cost, low power but high capability chip, with a whole load of input/output pins.

Instead of using the original, I stupidly decided to get a much cheaper Chinese clone, with model number CS32F103C8T6 – note the difference in the first two letters. I ran into some weird connection issues, which did not appear with an original MCU.

CS32 Blue Pill clone
CS32 Blue Pill clone : Looks exactly like the original Blue Pill except for the model number on the core – the black square chip in the middle

After a few days of tearing my hair out, I managed to resolve them. I’m leaving some notes here on the interwebs just in case someone else has the same problems.

ST-LINK V2 hardware programmer

This is needed to connect to your MCU. Make sure to connect the correct pins, otherwise your MCU will just silently get bricked. I bricked one of the clone MCUs this way, and never knew until I gave up trying to connect after nothing worked.

ST-Link v2 hardware programmer
ST-Link v2 hardware programmer: USB connector on the left goes to your computer, while the pins on the right connect to the MCU via female-to-female Du Pont cables

Texane/Stlink open source tool

Texane/Stlink is an open source version of the STMicroelectronics STLink tools, used to program the MCU. I prefer this as it is more cross-platform and also runs on Mac and Linux, compared to the proprietary STMicroelectronics one which only runs on Windows.

After connecting the computer to the MCU, through the ST-Link v2 hardware programmer, running the st-info --probe command gives an “unknown device” error. Other Stlink commands don’t work.

$ st-info --probe
Found 1 stlink programmers
 serial: 563f6f06513f52481953253f
openocd: "\x56\x3f\x6f\x06\x51\x3f\x52\x48\x19\x53\x25\x3f"
  flash: 0 (pagesize: 0)
   sram: 0
 chipid: 0x0000
  descr: unknown device

The trick is to play around with the reset button on the MCU.

Do this:

  • Unplug the MCU from the programmer, or unplug the programmer from your computer’s USB port
  • Plug it back in
  • Before issuing another Stlink command, press and hold the reset button on the MCU
  • While holding the Reset button, issue the command st-info --probe
  • Connection succeeds and MCU info is shown – see below
$ st-info --probe
Found 1 stlink programmers
 serial: 563f6f06513f52481953253f
openocd: "\x56\x3f\x6f\x06\x51\x3f\x52\x48\x19\x53\x25\x3f"
  flash: 131072 (pagesize: 1024)
   sram: 20480
 chipid: 0x0410
  descr: F1 Medium-density device

Subsequent Stlink commands should work. If this issue re-appears, following the procedure above should resolve it.

ST-Link Utility on Windows

Using STMicroelectronics’s proprietary ST-Link Utility on Windows will also give you similar issues.

ST-Link Utility (Windows) cannot connect to MCU
ST-Link Utility (Windows) cannot connect to MCU

Again, this is resolved by playing around with the reset button:

  • Press and hold the reset button on the MCU
  • In the ST-Link Windows application, go to Menu: Target -> Connect
ST-Link (Windows) Target Connect
ST-Link (Windows) Target Connect
  • The app window will appear to freeze
    Release the reset button
    The app will now show data read from the MCU
ST-Link (Windows) successful connection to MCU
ST-Link (Windows) successful connection to MCU

Further thoughts

In both use cases above, use of the reset button needed to be combined with an unplug/re-plug process.

Maybe it has to do with the reset action needing to be accompanied by a power cycle?

Leave a Reply

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