Forgot to add SWCLK and SWDIO to pin layout on STM32 - Page 1
Forum section: electronics / beginners

author: D4no0
author_rank: Contributor
timestamp: June 06, 2019, 10:03:52 am
content: Hello,So I wanted to start developing on STM32.I am using STM32CubeIDE that uses STM32CubeMX as layout by default.The development board is a generic blue pill STM32F103C8T6.The problem appeared when I tried to make a blink sketch and upload it to the device using ST-LINK V2. It uploaded, however after that I was unable to upload anymore. Later I found out that you need to specifically set the SWCLK and SWDIO in MX. My BOOT0 mode is still working so I tried to upload STMduino to it, however from what I've read this dev board has an wrong value resistor that needs to be replaced (I don't really want to solder a smd resistor with soldering iron), so I'm stuck here. I wanted to know if there is a way to flash a new firmware?

author: capt bullshot
author_rank: Super Contributor
timestamp: June 06, 2019, 10:06:20 am
content: Quote from: D4no0 on June 06, 2019, 10:03:52 amConnect the STM32 reset input to the ST-Link reset output, and use "connect under reset" with the ST-Link tool.

author: ogden
author_rank: Super Contributor
timestamp: June 06, 2019, 10:08:33 am
content: Quote from: capt bullshot on June 06, 2019, 10:06:20 amRight. Other way around:1. Press & hold reset button on the pill.2. Start programming (it will seemingly hung while reset pushed).3. Release reset button (programming supposedly will commence).

author: D4no0
author_rank: Contributor
timestamp: June 06, 2019, 10:34:37 am
content: I suppose you are using the ST-Link utility from windows? I am currently on linux with a limited version of this tool and it shows an error when I release the reset button.

author: capt bullshot
author_rank: Super Contributor
timestamp: June 06, 2019, 10:48:13 am
content: Usually I'm using linux and openocd with an ST-Link, and have the reset line connected to the target.Using openocd and ST-Link, the "hold the reset button" works for me, if you release the button at the right moment.But as you've pointed out, I've mentioned the windows ST-Link utility and it's "connect under reset" setting as the last resort.Never tried the Linux version of that utility, but afaik it provides the same functionality.

author: ogden
author_rank: Super Contributor
timestamp: June 06, 2019, 12:24:00 pm
content: Quote from: D4no0 on June 06, 2019, 10:34:37 amTry minimizing delay between program start and reset release. Do it close to "same time". Also check timeout settings for debug hardware, increase if needed

author: DDunfield
author_rank: Regular Contributor
timestamp: June 06, 2019, 12:47:57 pm
content: As others have said, "Connect under reset" works for cases where you've used the debug pins for other purposes.The "wrong value resistor" on the Blue-Pill is for the USB port, and it may work "as is" with some systems, however the point is a bit moot because IIRC the STM32F103C8T bootloader doesn't support USB.Do you have a USB serial adapter providing RxD, TxD at 3v levels? If so, you can use that to access the on-board bootloader and it works fine on the Blue-Pill (done it many times!). If you don't already have such an adapter you probably want one, because using an on-chip USART is the simplest way to implement a debug console (very little code to talk to it).Dave

author: DDunfield
author_rank: Regular Contributor
timestamp: June 06, 2019, 01:06:27 pm
content: Another thing you could try:Set the Boot0/Boot1 pins to activate the on-chip bootloader out of reset.This should prevent your code from running and re-configuring the debug pins.Then try programming with SWDDon't forget to re-configure boot to flash afterward.Dave