Failed to read ROM table via AP 3 - Failed to start GDB server

I've seen this issue in a few places. Some with solutions, none of which have worked for me. I am programming the Portenta H7 via a Portenta Breakout board with an ST Link v2 using STM32CubeIDE.

UPDATE 05/01/24:

I no longer believe this is a debugger only problem. CM7 is always successful in flashing and debugging or running. The CM4 never gets successfully flashed so the debugger never runs.

CM7 Debug Configuration
image
image
image

CM4 Debug Configuration
image
image
image

The ST Link GDB Server cannot flash the CM4 in either debug or Release mode.

The debug configurations are setup the same for each as described in AN5361 Section 3 (see screen shots above).

I can start the CM7 debugger with no problems. When I start the CM4 debugger, I get this error:

COM frequency = 4000 kHz
Target connection mode: Attach Failed to read ROM table via AP 3

Error in initializing ST-LINK device.
Reason: Unknown. Please check power and cabling to target.

With this dialog popup:

Error in final launch sequence:

Failed to start GDB server
Failed to start GDB server
Error in initializing ST-LINK device.
Reason: (255) Unknown. Please check power and cabling to target.

ST Link connections are fine as I can download the Bootloader, CM7 and CM4 .elf files from STMCubeProgrammer.

  • The Bootloader (portentah7_bootloader_mbed_hs_v2.bin)
  • CM7 address 0x08040000
  • CM4 address 0x08100000
  • My linker file for both CM7 and CM4 FLASH entry are set accordingly
  • Debugger configurations for both CM7 and CM4 Startup->Set program counter (hex): are set accordingly

The power mode for CM4, as suggested in this post, is generated correctly with my version of STM32CubeIDE (1.15.1)

HAL_PWREx_ClearPendingEvent(); 
HAL_PWREx_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFE, PWR_D2_DOMAIN);

This post on GitHub follows the same debugger setup as AN5361 Section 3 with one exception: in the CM7 configuration, it shows 'Halt all cores' as checked which contradicts AN5361 . Which one is correct or does it matter? I have also implemented this suggestion from that post:

while(__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) != RESET) { asm("NOP"); }

Also, these OB settings are checked:

NRST_STOP_D2
NRST_STBY_D2

If more details are needed, please don't hesitate to ask.

Of course, all help/suggestions are greatly appreciated!

Using STM32CubeProgrammer, make sure the BCM4 Option Byte (OB -> User Configuration->BCM4) is checked. This enables CM4 Boot.

Credit for this fix goes to @RomainR. from ST Microelectronics. Thank you Romain!