ST意法半导体
直播中

吴湛

10年用户 1028经验值
擅长:可编程逻辑
私信 关注
[问答]

使用STM32CubeIDE对STM32H7进行开发和调试,CM4始终报\"Failed to read ROM table via AP 3\"错误怎么解决?

我正在使用STM32CubeIDE对STM32H7系列双核微控制器进行开发和调试,但遇到了一个顽固的问题,希望能得到社区的帮助和建议。

### 问题描述
我根据应用手册AN5361,使用内置示例项目GPIO进行测试使用。
我能够成功编译、烧录和调试Cortex-M7核心的程序,但当尝试调试Cortex-M4核心时,总是收到以下错误信息:

```
Error in final launch sequence:
Failed to start GDB server
Failed to start GDB server
ST-Link设备进行初始化时出错。
原因:(255) 未知原因。请检查连接到目标机的电源和电缆。
```

更具体地,调试控制台显示:

```
Failed to read ROM table via AP 3
Error in initializing ST-LINK device.
Reason: Unknown. Please check power and cabling to target.
```

### 我已尝试的解决方案

1. **检查并配置了选项字节** :
   * 通过STM32CubeProgrammer验证了BCM4(CM4启动选项)已被启用
   * NRST_STOP_D2和NRST_STBY_D2也都已正确启用
   * 引导地址也正确配置(CM7: 0x08000000, CM4: 0x08100000)
2. **调试器配置** :
   * CM7配置:Access port设为"0 - Cortex-M7",Reset behavior设为"Connect under reset"
   * CM4配置:Access port设为"3 - Cortex-M4",Reset behavior设为"None"
   * 两个配置都启用了"Enable shared ST-LINK"
   * CM4的端口号比CM7高3(CM7: 61234, CM4: 61237)
   * 在CM4的Startup选项卡中禁用了下载(因为CM7已负责下载)
3. **启动顺序** :
   * 先启动CM7调试会话并让其运行
   * 然后尝试启动CM4调试会话
   * 确保CM7代码中包含释放硬件信号量的代码,以唤醒CM4
4. **连接测试** :
   * 使用STM32CubeProgrammer能够成功连接到设备并读取内存
   * ST-LINK固件已更新到最新版本
   * 尝试了不同的USB电缆和端口

### 系统信息

* 开发板型号:[NUCLEO-H755ZI-Q]
* 芯片:STM32H755
* STM32CubeIDE版本:[1.18.0]
* ST-LINK版本:[STLINK-V3 V3J16M7]
* 操作系统:[Linux 22.04]

### 调试信息

当CM7调试成功启动后,程序陷入等待CM4启动的循环中:
执行GPIO_EXTI_CM7_Debug时,输出信息为:

STMicroelectronics ST-LINK GDB server. Version 7.10.0
Copyright (c) 2025, STMicroelectronics. All rights reserved.

Starting server with the following options:
        Persistent Mode            : Disabled
        Logging Level              : 1
        Listen Port Number         : 61234
        Status Refresh Delay       : 15s
        Verbose Mode               : Disabled
        SWD Debug                  : Enabled
        InitWhile                  : Enabled

Info : default port : 7184
Info : Remote address: 127.0.0.1
Info : stlinkserver already running, exit
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
      -------------------------------------------------------------------
                        STM32CubeProgrammer v2.19.0                  
      -------------------------------------------------------------------



Log output file:   /tmp/STM32CubeProgrammer_q3TuDb.log
ST-Link Server is running on port : 7184
Info : default port : 7184
Info : Remote address: 127.0.0.1
Info : stlinkserver already running, exit
ST-LINK SN  : 004400193433510A37363934
ST-LINK FW  : V3J16M7
Board       : NUCLEO-H755ZI-Q
Voltage     : 3,29V
Info : default port : 7184
Info : Remote address: 127.0.0.1
Info : stlinkserver already running, exit
SWD freq    : 8000 KHz
Connect mode: Under Reset
Reset mode  : Hardware reset
Device ID   : 0x450
Revision ID : Rev V
Device name : STM32H7xx
Flash size  : 2 MBytes
Device type : MCU
Device CPU  : Cortex-M7/M4
BL Version  : 0x91

Opening and parsing file: ST-LINK_GDB_server_dxfKHW.srec


Memory Programming ...
  File          : ST-LINK_GDB_server_dxfKHW.srec
  Size          : 4.59 KB
  Address       : 0x08100000

Erasing memory corresponding to sector 0:
Erasing internal memory sector 8
Download in Progress:

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

Verifying ...

Download verified successfully

Info : default port : 7184
Info : Remote address: 127.0.0.1
Info : stlinkserver already running, exit
      -------------------------------------------------------------------
                        STM32CubeProgrammer v2.19.0                  
      -------------------------------------------------------------------

Log output file:   /tmp/STM32CubeProgrammer_FY9gId.log
ST-Link Server is running on port : 7184
Info : default port : 7184
Info : Remote address: 127.0.0.1
Info : stlinkserver already running, exit
Info : default port : 7184
Info : Remote address: 127.0.0.1
Info : stlinkserver already running, exit
ST-LINK SN  : 004400193433510A37363934
ST-LINK FW  : V3J16M7
Board       : NUCLEO-H755ZI-Q
Voltage     : 3,29V
SWD freq    : 8000 KHz
Connect mode: Under Reset
Reset mode  : Hardware reset
Device ID   : 0x450
Revision ID : Rev V
Device name : STM32H7xx
Flash size  : 2 MBytes
Device type : MCU
Device CPU  : Cortex-M7/M4
BL Version  : 0x91

Opening and parsing file: ST-LINK_GDB_server_4APDtX.srec

Memory Programming ...
  File          : ST-LINK_GDB_server_4APDtX.srec
  Size          : 8.66 KB
  Address       : 0x08000000

Erasing memory corresponding to sector 0:
Erasing internal memory sector 0
Download in Progress:

File download complete
Time elapsed during download operation: 00:00:03.837
Verifying ...
Download verified successfully

Info : default port : 7184
Info : Remote address: 127.0.0.1
Info : stlinkserver already running, exit



执行GPIO_EXTI_CM4_Debug时,输出信息如下:

STMicroelectronics ST-LINK GDB server. Version 7.10.0
Copyright (c) 2025, STMicroelectronics. All rights reserved.

Starting server with the following options:
        Persistent Mode            : Disabled
        Logging Level              : 1
        Listen Port Number         : 61240
        Status Refresh Delay       : 15s
        Verbose Mode               : Disabled
        SWD Debug                  : Enabled

Info : default port : 7184
Info : Remote address: 127.0.0.1
Info : stlinkserver already running, exit
Failed to read ROM table via AP 3

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






### 我的疑问

1. 为什么尽管BCM4选项已启用,仍然无法通过AP 3访问CM4?
2. 是否有其他可能影响双核调试的配置或设置?
3. 有没有特定的调试命令或方法可以获取更详细的错误信息?
4. 这个问题是否与特定的STM32H7型号或开发板有关?

如果需要任何其他信息补充,请随时联系我!
非常感谢任何帮助或建议!
[/td]

回帖(1)

张亮

2025-5-20 18:12:42

针对STM32H7双核调试时CM4核报错“Failed to read ROM table via AP 3”的问题,以下是详细的解决方案:


分步解决方案




  1. 验证M4核的启动流程  



    • 确保M7主程序在初始化后正确启动M4核。例如,在M7代码中执行以下操作:  
      HAL_HSEM_Init(); // 初始化硬件信号量
      __HAL_RCC_HSEM_CLK_ENABLE(); // 启用HSEM时钟
      HAL_HSEM_Release(0, 0); // 释放信号量,通知M4启动
      HAL_HSEM_ActivateNotification(0); // 激活通知(可选)

    • 或通过RCC寄存器直接启动M4核:  
      __HAL_RCC_HSEM_CLK_ENABLE(); 
      __HAL_RCC_M4CORE_CLK_ENABLE();
      __HAL_RCC_BOOT_M4(SYSTEM_CLOCK_SOURCE); // 启动M4核




  2. 配置STM32CubeIDE调试选项  



    • 创建独立的M4调试配置:  

      1. 右键项目 → Debug AsDebug Configurations → 新建一个配置。  

      2. Debugger 选项卡中:  

        • 选择 Cortex-M4 作为目标核。  

        • ST-Link (SYS) Debugger Settings 中设置 AP=3(默认可能为AP1)。  

        • 调整 Reset ModeHardware ResetSystem Reset。  



    • 修改调试脚本

      Startup 选项卡中添加初始化脚本(如 stm32h7x_dualcore_stlink.cfg),确保正确初始化多核调试环境。




  3. 升级ST-Link固件  



    • 打开STM32CubeIDE → HelpST-Link Update → 按照提示升级到最新版本。




  4. 检查选项字节配置  



    • 使用 STM32CubeProgrammer 连接设备,进入 OB(Option Bytes) 页面,确保以下设置:  

      • DBG_CPU_STOP (Debug in Stop mode)Enabled  

      • DBG_CPU_STANDBY (Debug in Standby mode)Enabled  

      • DBG_AUTH (Debug Authentication)Enabled(根据需求)  





  5. 验证M4代码的加载地址  



    • 确保M4的固件被烧录到正确的内存区域(如 0x08100000,对应Flash Bank2)。  

    • 检查链接脚本(.ld 文件),确认M4代码的起始地址和内存分配正确。




  6. 调整SWD接口参数  



    • 在调试配置的 Debugger 选项卡中,降低 Clock Speed(如从4MHz降至1MHz),避免信号干扰。




  7. 硬件排查  



    • 检查SWD接口(SWCLK/SWDIO)的物理连接,确保接触良好。  

    • 使用示波器检查信号完整性,尤其是长线或未屏蔽线缆的情况。  

    • 尝试更换ST-Link调试器或目标板,排除硬件故障。




  8. 参考官方资源和社区  



    • 查阅 AN5361应用手册 的示例代码,对比工程配置差异。  

    • 访问ST社区(如ST官方论坛)搜索类似问题,例如关键词“AP3 error dual core”。






补充说明



  • 双核同步问题:M7和M4需通过共享内存(如HSEM、IPCC)通信,确保M4在收到启动信号后才开始执行代码。  

  • 复位策略:若使用 Software Reset 可能导致AP未正确初始化,优先选择 Hardware/System Reset。  

  • 代码分离:M7和M4的代码需分别编译为独立的二进制文件,或通过多核工程管理工具(如STM32CubeMX生成的Dual Core项目)整合。


通过以上步骤,应能解决CM4核的调试问题。若仍存在异常,建议提供完整的调试日志和工程配置,以便进一步分析。

举报

更多回帖

发帖
×
20
完善资料,
赚取积分