Can't program F401 after PA9 set as INPUT_PULLUP

Post here first, or if you can't find a relevant section!
Post Reply
Mikey
Posts: 5
Joined: Fri Jan 27, 2023 5:28 pm

Can't program F401 after PA9 set as INPUT_PULLUP

Post by Mikey »

First of all I'm fairly new to STM32, so please excuse my lack of knowledge here... :|

I accidentally set "PA9" as INPUT_PULLUP in a sketch and after uploading the sketch I can't seem to program my Black Pill F401 anymore using USB and DFU.
It says
Error: Target device not found
Establishing connection with the device failed

And Windows is throwing an error message regarding the usb device.

Is there any way I can get this back to working and undo my mistake?
Problem really is, that I can't even upload any correcting parameters, since the board is not recognized as a usb-device anymore.
Is there something I can do on the hardware level? Connect certain pins?
Or is there maybe even a factory reset for these boards?

Please note that before I set PA9 as INPUT_PULLUP everything was working absolutely fine and I've been uploading sketches for months without any issue at all.
by ag123 » Wed Apr 17, 2024 6:34 pm
I suppose you are using a stm32f401cxx blackpill (or some such variant?)
https://stm32-base.org/boards/STM32F401 ... -V1.2.html

the 'usual' thing is, keep your usb cable connected
  • press both boot0 and reset
  • hold boot0 and release reset
  • release boot0 1-2 secs later
you can check in 'device manager' if a usb DFU device is detected.

if that is there, you can try flashing e.g. using stm32cube programmer etc
https://www.st.com/en/development-tools ... eprog.html

if that didn't work, you may need
  • disconnect usb cable
  • press and both boot0 and reset and connect the cable (if you need 'extra hands', try to find out if those pins reset or boot0 can be connected to gnd (reset) or 3v3 (boot0) using jumper/dupont wires.
  • hold boot0 and release reset
  • release boot0 1-2 secs later
PA9 is the uart1 pin, putting it in input_pullup can cause the serial uart boot loader to take precedence over usb-dfu
Go to full post
ag123
Posts: 1657
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: Can't program F401 after PA9 set as INPUT_PULLUP

Post by ag123 »

I suppose you are using a stm32f401cxx blackpill (or some such variant?)
https://stm32-base.org/boards/STM32F401 ... -V1.2.html

the 'usual' thing is, keep your usb cable connected
  • press both boot0 and reset
  • hold boot0 and release reset
  • release boot0 1-2 secs later
you can check in 'device manager' if a usb DFU device is detected.

if that is there, you can try flashing e.g. using stm32cube programmer etc
https://www.st.com/en/development-tools ... eprog.html

if that didn't work, you may need
  • disconnect usb cable
  • press and both boot0 and reset and connect the cable (if you need 'extra hands', try to find out if those pins reset or boot0 can be connected to gnd (reset) or 3v3 (boot0) using jumper/dupont wires.
  • hold boot0 and release reset
  • release boot0 1-2 secs later
PA9 is the uart1 pin, putting it in input_pullup can cause the serial uart boot loader to take precedence over usb-dfu
Mikey
Posts: 5
Joined: Fri Jan 27, 2023 5:28 pm

Re: Can't program F401 after PA9 set as INPUT_PULLUP

Post by Mikey »

if that didn't work, you may need
disconnect usb cable
press and both boot0 and reset and connect the cable (if you need 'extra hands', try to find out if those pins reset or boot0 can be connected to gnd (reset) or 3v3 (boot0) using jumper/dupont wires.
hold boot0 and release reset
release boot0 1-2 secs later
That did the trick! It wouldn't work with the usb cable connected, I really had to hold down NRST and BOOT0 while connecting the cable for it to work.

@ag123 Thank you so much for your swift answer and extensive help, you're a life saver! :)
Post Reply

Return to “General discussion”