cancel
Showing results for 
Search instead for 
Did you mean: 

new to STM32 black pill - SWD programming issue possibly due to overvoltage on 3v3

bp787
Visitor

First time working with an STM32 black pill.  I have a circuit that connects a Raspberry PI (3b) to the STM32.  I am getting errors when attempting to program it using openocd via the SWD lines.  I suspect it is a voltage issue, but I don't know how to verify.

The STM32 is supplied 5v from a mini buck converter.  I measured 5v on the STM32 pins.

On initial bootup, it comes up at 3.3v, and then rises to 4.2v.   This seems bad.   The rPI's 5v and 3.3v lines measure correctly.  There are no additional power sources other than the main 12v input on the PCB.

Upon booting of the pi, an initial openocd command is issued to query the device.  this partially works:

Open On-Chip Debugger 0.10.0+dev-01141-gc33d9efa (2024-12-11-17:24)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
none separate
Info : BCM2835 SPI SWD driver
Info : SWD only mode enabled
Info : clock speed 31200 kHz
Info : SWD DPIDR 0x2ba01477
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Error: stm32f4x.cpu -- clearing lockup after double fault
Polling target stm32f4x.cpu failed, trying to reexamine
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
Info : device id = 0x10006431
Warn : STM32 flash size failed, probe inaccurate - assuming 512k flash
Info : flash size = 512 kbytes
Error: stm32x device protected
Error: failed erasing sectors 0 to 0
** Programming Failed **
shutdown command invoked

After the initial communication, the output becomes limited:

 Open On-Chip Debugger 0.10.0+dev-01141-gc33d9efa (2024-12-11-17:24)
Licensed under GNU GPL v2
For bug reports, read
 http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
none separate
Info : BCM2835 SPI SWD driver
Info : SWD only mode enabled
 Info : clock speed 31200 kHz
 Info : SWD DPIDR 0x76ee37ac
: in procedure 'program'
 ** OpenOCD init failed **

 
I also enabled debug level 3, and noted the follwoing:
arm_adi_v5.h:514 dap_dp_poll_register(): DAP: poll 4 timeout
Debug: 364 132 command.c:628 run_command(): Command 'dap init' failed with error code -5
User : 365 132 command.c:694 command_run_line():
Debug: 366 132 command.c:628 run_command(): Command 'init' failed with error code -4
User : 367 132 command.c:694 command_run_line():

and:
Debug: 283 28 bitbang.c:504 bitbang_swd_read_reg(): bitbang_swd_read_reg
Debug: 284 28 bitbang.c:426 bitbang_exchange(): bitbang_exchange
Debug: 285 28 bitbang.c:426 bitbang_exchange(): bitbang_exchange
Debug: 286 28 bitbang.c:526 bitbang_swd_read_reg(): JUNK DP read reg 4 = 00000000
Debug: 287 28 bitbang.c:554 bitbang_swd_read_reg(): No valid acknowledge: ack=0
Debug: 288 28 bitbang.c:615 bitbang_swd_run_queue(): bitbang_swd_run_queue
Debug: 289 28 bitbang.c:426 bitbang_exchange(): bitbang_exchange
Debug: 290 28 bitbang.c:622 bitbang_swd_run_queue(): SWD queue return value: 00
Debug: 291 39 bitbang.c:504 bitbang_swd_read_reg(): bitbang_swd_read_reg
Debug: 292 39 bitbang.c:426 bitbang_exchange(): bitbang_exchange
Debug: 293 39 bitbang.c:426 bitbang_exchange(): bitbang_exchange
Debug: 294 39 bitbang.c:526 bitbang_swd_read_reg(): JUNK DP read reg 4 = 00000000
Debug: 295 39 bitbang.c:554 bitbang_swd_read_reg(): No valid acknowledge: ack=0
Debug: 296 39 bitbang.c:615 bitbang_swd_run_queue(): bitbang_swd_run_queue
Debug: 297 39 bitbang.c:426 bitbang_exchange(): bitbang_exchange

I don't know much about the stm32, but I've been reading quite a bit about how to program, etc...  I assume that during assembly I did something wrong and damaged the STM32.  

I'd appreciate any suggestions/feedback on whether I just need to replace the current stm or not, as well as other debugging options.

2 REPLIES 2

0x2ba01477 so probably fake MCU

The MCU shouldn't be powered directly by 5V. You should have regulator on board getting you to 3.3V. This should be powered via the USB connector.

Excessive voltages can permanently damage the devices.

You should only need to connect SWDIO, SWCLK and GND.

You definitely need a common ground with the RPi.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi and Thank you for the quick reply.  I have no idea where the STM32 came from.  It was part of a kit i ordered.

the PCB design is to take an external 12v input, which then hits the 5v DC/DC buck converter.  The limited schematics I have suggest that the STM32 is drawing 5v from the buck convertor so that the USBC 5v wouldn't be necessary.  The STM32 is soldered directly to the board ( I should have used a header... ).

The assembly instructions stated that the four pins:  3v3, SWDIO SWCLK, and GND needed soldered to the PCB.

I'm assuming the board dev used the 5v buck converter output to provide power to the MCU in lieu of making another power connection via USBC.  

I certainly could remove the 5v and use a USB-C, and then disconnect the 3v3 pin if that's the better direction.

I do have a common ground with the pi.

So at a minimum it seems that the device is likely damaged due to the 4.2v.  I guess one way to validate would be to remove it from the PCB and power via USBC, then measure voltage on 3v3?



   image.pngimage.png