STM32F3xx problem with debugging with Eclipse IDE, hangs at "Starting target CPU..."

0

First I want to say that I am a newbie in this field. I am trying to upload and debug a code on a custom-made board based on STM32F303CB chip through a NUCLEO-F446RE board. I am using Eclipse IDE (2019-12), a GNU toolchain and a SEGGER J-Link debugging software.

The code builds successfully with no errors, anyway when starting to debug, a HardFault_handler is called. The code was not written by me. I doubt that the problem is in the code itself (it builds) and rather think that some setting of the tools is not right (correct me if I am wrong). I also tried the same procedure on several boards, so I would exclude a hardware issue as well.

The debugger hangs when initializing the USB in the function MX_USB_Init(), leading to a HardFault_handler. When debugging in single-step mode, most funcitons within MX_USB_init() execute successfully, except USBD_Start(&hUsbDeviceFS). When stepping into USBD_Start(...), it arrives in the while(1) loop of the HardFault_handler. When debugging in resume mode (no single step), debugger would also hang at previous functions which work properly in single-step mode such as HAL_PCD_Init(&hpcd_USB_FS), HAL_PCDEx_PMAConfig, USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC), USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) and again USBD_Start(&hUsbDeviceFS).

Here is the SEGGER J-Link Log for this case if no single-step debugging used:

SEGGER J-Link GDB Server V6.60f Command Line Version

JLinkARM.dll V6.60f (DLL compiled Jan 20 2020 16:15:17)

Command line: -if swd -device STM32F303CB -endian little -speed 1000 -port 2331 -swoport 2332 -telnetport 2333 -vd -ir -localhostonly 1 -singlerun -strict -timeout 0 -nogui
-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     2331
SWO raw output listening port: 2332
Terminal I/O port:             2333
Accept remote connection:      localhost only
Generate logfile:              off
Verify download:               on
Init regs on start:            on
Silent mode:                   off
Single run mode:               on
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 STM32F303CB
Target interface:              SWD
Target interface speed:        1000kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link STLink V21 compiled Jun 26 2017 10:35:16
Hardware: V1.00
S/N: 774801057
Checking target voltage...
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target...
Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x00000000 (Data = 0x2000A000)
Read 2 bytes @ address 0x00000000 (Data = 0xA000)
Received monitor command: speed 1000
Target interface speed set to 1000 kHz
Received monitor command: clrbp
Received monitor command: reset
Resetting target
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0x00000158)
Received monitor command: regs
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 2000A000, MSP= 2000A000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 00000158
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Received monitor command: speed auto
Select auto target interface speed (2000 kHz)
Received monitor command: flash breakpoints 0
Flash breakpoints disabled
Received monitor command: semihosting enable
Semi-hosting enabled (Handle on BKPT)
Received monitor command: semihosting IOClient 1
Semihosting I/O set to TELNET Client
Read 4 bytes @ address 0x00000158 (Data = 0xF7FFB508)
Downloading 646 bytes @ address 0x00000000 - Verified OK
Downloading 40 bytes @ address 0x00000288 - Verified OK
Downloading 15936 bytes @ address 0x000002B0 - Verified OK
Downloading 10808 bytes @ address 0x000040F0 - Verified OK
Downloading 8 bytes @ address 0x00006B28 - Verified OK
Downloading 544 bytes @ address 0x00006B30 - Verified OK
Comparing flash   [....................] Done.
Writing register (PC = 0x      44)
Read 4 bytes @ address 0x00000044 (Data = 0xB083B500)
Reading 64 bytes @ address 0x00001180
Read 2 bytes @ address 0x0000118E (Data = 0xF7FF)
Reading 64 bytes @ address 0x00002700
Read 2 bytes @ address 0x00002780 (Data = 0x6822)
Received monitor command: clrbp
Received monitor command: reset
Resetting target
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0x00000158)
Read 2 bytes @ address 0x0000118E (Data = 0xF7FF)
Received monitor command: regs
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 2000A000, MSP= 2000A000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 00000158
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Setting breakpoint @ address 0x0000118E, Size = 2, BPHandle = 0x0001
Setting breakpoint @ address 0x00002780, Size = 2, BPHandle = 0x0002
Starting target CPU...
...Breakpoint reached @ address 0x0000118E
Reading all registers
Removing breakpoint @ address 0x0000118E, Size = 2
Removing breakpoint @ address 0x00002780, Size = 2
Read 4 bytes @ address 0x0000118E (Data = 0xFEFFF7FF)
Setting breakpoint @ address 0x00002780, Size = 2, BPHandle = 0x0003
Starting target CPU...
...Breakpoint reached @ address 0x00002780
Reading all registers
Removing breakpoint @ address 0x00002780, Size = 2
Read 4 bytes @ address 0x00002780 (Data = 0x23016822)
Reading 64 bytes @ address 0x20009F80
Read 4 bytes @ address 0x0000158C (Data = 0x2318BB30)
Reading 64 bytes @ address 0x20009FC0
Read 4 bytes @ address 0x00001792 (Data = 0xBD082000)
Read 4 bytes @ address 0x0000143E (Data = 0x46204908)
Read 4 bytes @ address 0x00000FB2 (Data = 0xFC8FF7FF)
Read 4 bytes @ address 0x00001192 (Data = 0x781B4B0A)
Performing single step...
...Breakpoint reached @ address 0x00002782
Reading all registers
Setting breakpoint @ address 0x00002780, Size = 2, BPHandle = 0x0004
Starting target CPU...

I spent more than 3 days googling and trying different solutions but nothing worked for me. So any help would be appreciated. Please tell me if you need any additional information, screenshots, logs etc.

Thanks in advance!

debugging
gdb
eclipse-cdt
jlink
stm32f3
asked on Stack Overflow Feb 4, 2020 by s7iVuR • edited Feb 4, 2020 by s7iVuR

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0