cancel
Showing results for 
Search instead for 
Did you mean: 

Target doesn't properly reset on custom board with STM32cubeIDE

DRicc.2
Associate III

I am using the STM32F030F4P6 MCU and ST-Link V2 with tag connect (6- pin for SWD) and am having trouble bootloading the board. I have tried multiple configurations, with this one being ST-LINK GDB server:

STM32CubeProgrammer v2.12.0                  
      -------------------------------------------------------------------



Log output file:   C:\Users\ricci\AppData\Local\Temp\STM32CubeProgrammer_a19324.log
ST-LINK SN  : 38FF6A06304E4B3031321143
ST-LINK FW  : V2J40S7
Board       : --
Voltage     : 3.25V
SWD freq    : 950 KHz
Connect mode: Under Reset
Reset mode  : Hardware reset
Device ID   : 0x444
Revision ID : Rev 1.0
Device name : STM32F03x
Flash size  : 16 KBytes
Device type : MCU
Device CPU  : Cortex-M0
BL Version  : 0x10



Memory Programming ...
Opening and parsing file: ST-LINK_GDB_server_a19324.srec
  File          : ST-LINK_GDB_server_a19324.srec
  Size          : 6.30 KB 
  Address       : 0x08000000 


Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 6]
Download in Progress:


File download complete
Time elapsed during download operation: 00:00:00.945



Verifying ...




Download verified successfully 

And have seen the results above however the ST-Link V2 LED is still flashing even when the program claims it "download verified successfully"

I tried ST-Link with OpenOCD in the debugger menu and got this as a result: 

Open On-Chip Debugger 0.12.0-00029-gf77e7cb03 (2023-12-15-13:25) [https://github.com/STMicroelectronics/OpenOCD]
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J45S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.213158
Info : clock speed 1800 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x0bb11477
Info : [STM32F030F4Px.cpu] Cortex-M0 r0p0 processor detected
Info : [STM32F030F4Px.cpu] target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for STM32F030F4Px.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0x10006444
Info : flash size = 16 KiB
Warn : GDB connection 1 on target STM32F030F4Px.cpu not halted
undefined debug reason 8 - target needs reset
Info : accepting 'gdb' connection on tcp/3333
Warn : GDB connection 2 on target STM32F030F4Px.cpu not halted
undefined debug reason 8 - target needs reset
[STM32F030F4Px.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x0800060c msp: 0x20001000
[STM32F030F4Px.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x0800060c msp: 0x20001000
Info : [STM32F030F4Px.cpu] external reset detected
Info : [STM32F030F4Px.cpu] external reset detected
shutdown command invoked
shutdown command invoked



(Note: Shutdown command invoked was when I stopped the program)

It seems that for whatever reason the ST-Link cannot reset properly, and I am unsure as to how to fix this.

Here is the schematic portion of the MCU: 

 
 

DRicc2_2-1715860512693.jpeg

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

I found the solution, 

the board uploads when I have the crystal set internal instead of the external setup I have but I'm not entirely sure why. I chose the ECS-80-12-30-JGN-TR with two 20pF caps at CL1 & CL2, and have Rext at 0 ohm acting as a jumper for now. 

 

I'm not entirely sure what's causing the bootloader to essentially get stuck at the end of the cycle when uploading it, but I'm assuming its something to do with the way I set up the crystal.

Heres is the layout on the board: 

DRicc2_0-1716426016817.png

And the ide setup: 

nSDEBjDP.png\

 

But at least now I can upload code to it and the ADC channel is working, albeit not accurately but it is reading values. 

 

View solution in original post

4 REPLIES 4
AScha.3
Chief III

Hi,

1. on nrst /reset put a cer.cap , typ. 100nF , to gnd.

2. in IDE set debug -->

AScha3_0-1715866975326.png

 

Try...

If you feel a post has answered your question, please click "Accept as Solution".

This is what I get as a result of that

Open On-Chip Debugger 0.12.0-00029-gf77e7cb03 (2023-12-15-13:25) [https://github.com/STMicroelectronics/OpenOCD]
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J45S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.230526
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : clock speed 4000 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x0bb11477
Info : [STM32L476RGTx.cpu] Cortex-M0 r0p0 processor detected
Info : [STM32L476RGTx.cpu] target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for STM32L476RGTx.cpu on 3333
Info : Listening on port 3333 for gdb connections
Error: [STM32L476RGTx.cpu] clearing lockup after double fault
Polling target STM32L476RGTx.cpu failed, trying to reexamine
Info : [STM32L476RGTx.cpu] Cortex-M0 r0p0 processor detected
Info : [STM32L476RGTx.cpu] target has 4 breakpoints, 2 watchpoints
Info : [STM32L476RGTx.cpu] external reset detected
Error: [STM32L476RGTx.cpu] clearing lockup after double fault
[STM32L476RGTx.cpu] halted due to debug-request, current mode: Handler HardFault
xPSR: 0xc1000003 pc: 0xfffffffe msp: 0x20017fe0
Info : accepting 'gdb' connection on tcp/3333
Warn : Cannot identify target as an STM32C0/G0/G4/L4/L4+/L5/U0/U5/WB/WL family device.
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
shutdown command invoked

:

 

I also get this:

 

Open On-Chip Debugger 0.12.0-00029-gf77e7cb03 (2023-12-15-13:25) [https://github.com/STMicroelectronics/OpenOCD]
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : STLINK V2J45S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.238421
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : clock speed 4000 kHz
Info : stlink_dap_op_connect(connect)
Info : SWD DPIDR 0x0bb11477
Info : [STM32F030F4Px.cpu] Cortex-M0 r0p0 processor detected
Info : [STM32F030F4Px.cpu] target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for STM32F030F4Px.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0x10006444
Info : flash size = 16 KiB
Warn : GDB connection 1 on target STM32F030F4Px.cpu not halted
undefined debug reason 8 - target needs reset
Info : accepting 'gdb' connection on tcp/3333
Warn : GDB connection 2 on target STM32F030F4Px.cpu not halted
undefined debug reason 8 - target needs reset
[STM32F030F4Px.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x080005f0 msp: 0x20001000
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
Info : Unable to match requested speed 8000 kHz, using 4000 kHz
[STM32F030F4Px.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x080005f0 msp: 0x20001000

 

 and there's a line at HAL_Init();

 

I seem to get this output far more, I think it was just something with my debugger but the orange LED on the ST-LinkV2 is flashing and doesn't stop.

 

Heres is also a screenshot of the IDE:

DRicc2_0-1715909770775.png

 

I found the solution, 

the board uploads when I have the crystal set internal instead of the external setup I have but I'm not entirely sure why. I chose the ECS-80-12-30-JGN-TR with two 20pF caps at CL1 & CL2, and have Rext at 0 ohm acting as a jumper for now. 

 

I'm not entirely sure what's causing the bootloader to essentially get stuck at the end of the cycle when uploading it, but I'm assuming its something to do with the way I set up the crystal.

Heres is the layout on the board: 

DRicc2_0-1716426016817.png

And the ide setup: 

nSDEBjDP.png\

 

But at least now I can upload code to it and the ADC channel is working, albeit not accurately but it is reading values.