Author Topic: Forgot to add SWCLK and SWDIO to pin layout on STM32  (Read 2013 times)

0 Members and 1 Guest are viewing this topic.

Offline D4no0Topic starter

  • Contributor
  • Posts: 19
  • Country: md
Forgot to add SWCLK and SWDIO to pin layout on STM32
« on: June 06, 2019, 10:03:52 am »
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?
 

Offline capt bullshot

  • Super Contributor
  • ***
  • Posts: 3033
  • Country: de
    • Mostly useless stuff, but nice to have: wunderkis.de
Re: Forgot to add SWCLK and SWDIO to pin layout on STM32
« Reply #1 on: June 06, 2019, 10:06:20 am »
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?

Connect the STM32 reset input to the ST-Link reset output, and use "connect under reset" with the ST-Link tool.
Safety devices hinder evolution
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Forgot to add SWCLK and SWDIO to pin layout on STM32
« Reply #2 on: June 06, 2019, 10:08:33 am »
Connect the STM32 reset input to the ST-Link reset output, and use "connect under reset" with the ST-Link tool.

Right. 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).
 

Offline D4no0Topic starter

  • Contributor
  • Posts: 19
  • Country: md
Re: Forgot to add SWCLK and SWDIO to pin layout on STM32
« Reply #3 on: June 06, 2019, 10:34:37 am »
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.
 

Offline capt bullshot

  • Super Contributor
  • ***
  • Posts: 3033
  • Country: de
    • Mostly useless stuff, but nice to have: wunderkis.de
Re: Forgot to add SWCLK and SWDIO to pin layout on STM32
« Reply #4 on: June 06, 2019, 10:48:13 am »
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.
Safety devices hinder evolution
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Forgot to add SWCLK and SWDIO to pin layout on STM32
« Reply #5 on: June 06, 2019, 12:24:00 pm »
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.

Try minimizing delay between program start and reset release. Do it close to "same time". Also check timeout settings for debug hardware, increase if needed
 

Offline DDunfield

  • Regular Contributor
  • *
  • Posts: 173
  • Country: ca
Re: Forgot to add SWCLK and SWDIO to pin layout on STM32
« Reply #6 on: June 06, 2019, 12:47:57 pm »
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
 

Offline DDunfield

  • Regular Contributor
  • *
  • Posts: 173
  • Country: ca
Re: Forgot to add SWCLK and SWDIO to pin layout on STM32
« Reply #7 on: June 06, 2019, 01:06:27 pm »
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 SWD

Don't forget to re-configure boot to flash afterward.

Dave
 
The following users thanked this post: ogden


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf