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](http://eugenesia.co.uk/wp-content/uploads/2019/07/Cs32_blue_pill_clone-1024x505.jpg)
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](http://eugenesia.co.uk/wp-content/uploads/2019/07/ST-Link_V2_programmer-1024x407.jpg)
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.
![](http://eugenesia.co.uk/wp-content/uploads/2019/07/Cs32_reset_button-1024x426.jpg)
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](http://eugenesia.co.uk/wp-content/uploads/2019/07/STLink_Win_cannot_connect-1024x637.jpg)
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](http://eugenesia.co.uk/wp-content/uploads/2019/07/STLink_Win_Target_Connect-1024x635.jpg)
- 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](http://eugenesia.co.uk/wp-content/uploads/2019/07/STLink_Win_connect_success-1024x647.jpg)
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?
Interesting…. I’m running Ubuntu 19.10, and have the issue you show here, but holding the reset button does not solve it for me.
I’m on Mac OS X Catalina at the moment, so I have no experience using the Blue Pill with Ubuntu. You may have to experiment and find out your own solution by trial and error. Frustrating but that’s how I arrived at my solution!
I had the same connection issue with my Blue Pill. This one helped:
stackoverflow.com/questions/56673154/stm32-cube-ide-true-studio-connect-under-reset
Did you get USB to work with the clone? I got scammed and because of corona situation (deliveries stuck) I’m trying to use clone with relativty/Relativ VR glasses but can’t get USB to work (seems to have problem with USB ID).
Yes I used the ST-Link v2 programmer to connect it to my laptop just fine. Make sure you get an original ST-Link v2 from a reputable seller though. If you’re referring to the USB/Micro-USB port on the board, I got that to work fine too.
Thank you! The button reset trick with ST Link fixed my problem connecting to the device 🙂
You’re welcome and good luck with your hardware adventure!