cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to run program using VSCode on the STM32F401RET6. "RAMCode did not respond in time"

masoncc
Associate

OS: `Linux Mint 22`
Kernel Version: `6.8.0-48-generic`
STM32CubeMX version: `6.14.1`
STM32 Chip: `STM32F401RET6`

I'm trying to just run a simple light blink script for testing. I'm using a Segger J-Link EDU Mini and programming over SWD using a 10-Pin connection. I'm using a CMake project generated by STM32CubeMX and I am debugging from VSCode (which is launching `JLinkGDBServerCLExe`).

If I run `Start debugging` I get this output (and it just stops there indefinitely):
```
/opt/SEGGER/JLink/JLinkGDBServerCLExe -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device STM32F401RE
SEGGER J-Link GDB Server V8.38 Command Line Version

JLinkARM.dll V8.38 (DLL compiled May 28 2025 12:45:51)

Command line: -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device STM32F401RE
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 50000
SWO raw output listening port: 50001
Terminal I/O port: 50002
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: off
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: STM32F401RE
Target device parameters: none
Target interface: SWD
Target interface speed: 4000kHz
Target endian: little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link EDU Mini V2 compiled Apr 1 2025 10:05:18
Hardware: V2.00
S/N: 802001278
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.31 V
Listening on TCP/IP port 50000
Connecting to target...
Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
GDB client (conn. 10) requested target.xml from GDB Server
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x00000000
Read register 'r1' (4 bytes) from hardware: 0x00000000
Read register 'r2' (4 bytes) from hardware: 0x00000000
Read register 'r3' (4 bytes) from hardware: 0x00000000
Read register 'r4' (4 bytes) from hardware: 0x00000000
Read register 'r5' (4 bytes) from hardware: 0x00000000
Read register 'r6' (4 bytes) from hardware: 0x00000000
Read register 'r7' (4 bytes) from hardware: 0x00000000
Read register 'r8' (4 bytes) from hardware: 0x00000000
Read register 'r9' (4 bytes) from hardware: 0x00000000
Read register 'r10' (4 bytes) from hardware: 0x00000000
Read register 'r11' (4 bytes) from hardware: 0x00000000
Read register 'r12' (4 bytes) from hardware: 0x00000000
Read register 'sp' (4 bytes) from hardware: 0xD8FFFFFF
Read register 'lr' (4 bytes) from hardware: 0xF9FFFFFF
Read register 'pc' (4 bytes) from hardware: 0xFEFFFFFF
Read register 'xpsr' (4 bytes) from hardware: 0x03000001
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0xFFFFFFFE)
Received monitor command: reset
Resetting target
Downloading 404 bytes @ address 0x08000000
Downloading 4640 bytes @ address 0x08000194
Downloading 368 bytes @ address 0x080013B4
Downloading 8 bytes @ address 0x08001524
Downloading 4 bytes @ address 0x0800152C
Downloading 4 bytes @ address 0x08001530
Downloading 12 bytes @ address 0x08001534
Writing register 'pc' = 0x08001348
ERROR: Timeout while preparing target, RAMCode did not respond in time (PC = 0xFFFFFFFE, XPSR = 0x01000003, SP = 0x20000610)!
Failed to prepare RAMCode using RAM
Received monitor command: reset
Resetting target
Reading 64 bytes @ address 0x08001240
Read 2 bytes @ address 0x08001250 (Data = 0xB508)
Setting breakpoint @ address 0x08001250, Kind = 2, Type = THUMB, BPHandle = 0x0001
Starting target CPU...
...Target halted (DBGRQ, PC = 0xFFFFFFFE)
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x00000000
Read register 'r1' (4 bytes) from hardware: 0x00000000
Read register 'r2' (4 bytes) from hardware: 0x00000000
Read register 'r3' (4 bytes) from hardware: 0x00000000
Read register 'r4' (4 bytes) from hardware: 0x00000000
Read register 'r5' (4 bytes) from hardware: 0x00000000
Read register 'r6' (4 bytes) from hardware: 0x00000000
Read register 'r7' (4 bytes) from hardware: 0x00000000
Read register 'r8' (4 bytes) from hardware: 0x00000000
Read register 'r9' (4 bytes) from hardware: 0x00000000
Read register 'r10' (4 bytes) from hardware: 0x00000000
Read register 'r11' (4 bytes) from hardware: 0x00000000
Read register 'r12' (4 bytes) from hardware: 0x00000000
Read register 'sp' (4 bytes) from hardware: 0xD8FFFFFF
Read register 'lr' (4 bytes) from hardware: 0xF9FFFFFF
Read register 'pc' (4 bytes) from hardware: 0xFEFFFFFF
Read register 'xpsr' (4 bytes) from hardware: 0x03000001
Removing breakpoint @ address 0x08001250, Size = 2
Reading register 'msp' = 0xFFFFFFD8
Reading register 'psp' = 0x00000000
```

If I run `Run without Debugging` I get this output:

```
/opt/SEGGER/JLink/JLinkGDBServerCLExe -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device STM32F401RE
SEGGER J-Link GDB Server V8.38 Command Line Version

JLinkARM.dll V8.38 (DLL compiled May 28 2025 12:45:51)

Command line: -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device STM32F401RE
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 50000
SWO raw output listening port: 50001
Terminal I/O port: 50002
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: off
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: STM32F401RE
Target device parameters: none
Target interface: SWD
Target interface speed: 4000kHz
Target endian: little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link EDU Mini V2 compiled Apr 1 2025 10:05:18
Hardware: V2.00
S/N: 802001278
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.31 V
Listening on TCP/IP port 50000
Connecting to target...
Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
GDB client (conn. 9) requested target.xml from GDB Server
Reading common registers: Read register 'r0' (4 bytes) from hardware: 0x00000000
Read register 'r1' (4 bytes) from hardware: 0x00000000
Read register 'r2' (4 bytes) from hardware: 0x00000000
Read register 'r3' (4 bytes) from hardware: 0x00000000
Read register 'r4' (4 bytes) from hardware: 0x00000000
Read register 'r5' (4 bytes) from hardware: 0x00000000
Read register 'r6' (4 bytes) from hardware: 0x00000000
Read register 'r7' (4 bytes) from hardware: 0x00000000
Read register 'r8' (4 bytes) from hardware: 0x00000000
Read register 'r9' (4 bytes) from hardware: 0x00000000
Read register 'r10' (4 bytes) from hardware: 0x00000000
Read register 'r11' (4 bytes) from hardware: 0x00000000
Read register 'r12' (4 bytes) from hardware: 0x00000000
Read register 'sp' (4 bytes) from hardware: 0xD8FFFFFF
Read register 'lr' (4 bytes) from hardware: 0xF9FFFFFF
Read register 'pc' (4 bytes) from hardware: 0xFEFFFFFF
Read register 'xpsr' (4 bytes) from hardware: 0x03000001
Received monitor command: halt
Halting target CPU...
...Target halted (PC = 0xFFFFFFFE)
Received monitor command: reset
Resetting target
Downloading 404 bytes @ address 0x08000000
Downloading 4640 bytes @ address 0x08000194
Downloading 368 bytes @ address 0x080013B4
Downloading 8 bytes @ address 0x08001524
Downloading 4 bytes @ address 0x0800152C
Downloading 4 bytes @ address 0x08001530
Downloading 12 bytes @ address 0x08001534
Writing register 'pc' = 0x08001348
ERROR: Timeout while preparing target, RAMCode did not respond in time (PC = 0xFFFFFFFE, XPSR = 0x61000003, SP = 0x20000610)!
Failed to prepare RAMCode using RAM
Received monitor command: reset
Resetting target
```

According to google that PC value of `0xFFFFFFFE` indicates "core lock-up".

Hopefully this isn't a hardware issue (this is a custom board), but I've been probing with a multimeter and haven't seen anything unexpected so far. There isn't a whole lot going on on the board. `BOOT0` is tied to ground through a 10k resistor.

I made it so that `SystemInit` in `system_stm32f4xx.c` explicitly sets: `SCB->VTOR = FLASH_BASE`, but that didn't seem to change anything.

I saw this post: https://forum.segger.com/index.php/Thread/2635-SOLVED-STM32F746-Failed-to-execute-RAMCode-for-RAM-check-after-upgrade-to-jlink/?postID=9015#post9015 where for them `WWDG_SW` was unset, maybe that is what is happening? I can't say I fully understand that.

As a bit of a side note, at one point I tried setting `WWDG_SW` to 1 using `STM32_Programmer_CLI` using:
```
STM32_Programmer_CLI -c port=SWD -ob WWDG_SW=1
```
And I got back: `Error: No debug probe detected.` Even though `STM32_Programmer_CLI -l` shows:
```
===== J-Link Interface =====

-------- Connected J-Link Probes List --------

J-Link Probe 0 :
J-Link SN : 802001278
-----------------------------------------------
```

Additional information:

My launch configuration:

```
{
"type": "cortex-debug",
"request": "launch",
"name": "Debug J-Link",
"cwd": "${workspaceRoot}",
"executable": "${command:cmake.launchTargetPath}",
"serverpath": "/opt/SEGGER/JLink/JLinkGDBServerCLExe",
"serverArgs": [],
"servertype": "jlink",
"device": "STM32F401RE",
"interface": "swd",
"serialNumber": "",
"runToEntryPoint": "main",
"stm32cubeprogrammer": "${config:STM32VSCodeExtension.cubeCLT.path}/STM32CubeProgrammer/bin",
"armToolchainPath": "${config:STM32VSCodeExtension.cubeCLT.path}/GNU-tools-for-STM32/bin",
"svdFile": "${config:STM32VSCodeExtension.cubeCLT.path}/STMicroelectronics_CMSIS_SVD/STM32F401.svd",
}
```

Thank you for any help, I feel extremely stuck.

1 REPLY 1
masoncc
Associate

With some more sleep, I reviewed the circuit again and noticed that there is nothing connected to the VCAP1 pin. Clearly an error, but would the resulting power instability cause an error like this?