[STM32F4] f429i测试示例出错

[复制链接]
406|12
lilaiju 发表于 2025-9-5 12:29 | 显示全部楼层 |阅读模式
测试, ST, se, rc, pi, ni

STMCubeIDE 提示“Break at address "0x1fff5162" with no debug information available, or outside of program code.”。
在 CubeIDE 1.9.0 中使用 stm32f429i-disco 开发板时遇到了这个问题,问题涉及固件和调试。


我用了一个简单的示例进行测试,在调试过程中执行 HAL_Delay(第 95 行)时出现了异常行为:
当单步跳过(Step Over)该行时,调试当前指令指针仍停留在同一行。
如果在该行设置断点并继续执行(Resume),每次迭代后 LED 会重置为初始状态(熄灭),尽管它们本应每 250 毫秒改变一次状态。
之前我在这块板上使用过引导程序(bootloader)。
还注意到,即使在微控制器内存中没有固件的情况下,上电时用户 USB 指示灯也会亮起。
在 Keil 中也遇到了上述相同的问题。
请问,这可能是开发板机械损坏导致的结果吗?还是其他原因?该如何解决?



/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2022 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
          HAL_Delay(250);
          HAL_GPIO_TogglePin(GPIOG, LED_1_Pin);
          HAL_GPIO_TogglePin(GPIOG, LED_2_Pin);
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Configure the main internal regulator output voltage
  */
  __HAL_RCC_PWR_CLK_ENABLE();
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
  RCC_OscInitStruct.PLL.PLLM = 8;
  RCC_OscInitStruct.PLL.PLLN = 180;
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  RCC_OscInitStruct.PLL.PLLQ = 4;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Activate the Over-Drive mode
  */
  if (HAL_PWREx_EnableOverDrive() != HAL_OK)
  {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
  {
    Error_Handler();
  }
}

/**
  * @brief GPIO Initialization Function
  * @param None
  * @retval None
  */
static void MX_GPIO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOH_CLK_ENABLE();
  __HAL_RCC_GPIOG_CLK_ENABLE();

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOG, LED_2_Pin|LED_1_Pin, GPIO_PIN_RESET);

  /*Configure GPIO pins : LED_2_Pin LED_1_Pin */
  GPIO_InitStruct.Pin = LED_2_Pin|LED_1_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  __disable_irq();
  while (1)
  {
  }
  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */


classroom 发表于 2025-9-5 15:19 | 显示全部楼层
启动模式配置错误?
cr315 发表于 2025-9-5 19:20 | 显示全部楼层
检查开发板BOOT0引脚状态,或通过CubeIDE的Debug配置查看“Startup Mode”是否为“Flash Boot”。
duo点 发表于 2025-9-5 16:20 | 显示全部楼层
可能是时钟配置错误吧。。
elephant00 发表于 2025-9-5 15:21 | 显示全部楼层
SWD接口引脚配置可能存在错误。
flycamelaaa 发表于 2025-9-5 17:22 | 显示全部楼层
看看调试器供电是否稳定?
jcky001 发表于 2025-9-5 18:33 | 显示全部楼层
引导程序可能未正确跳转到用户程序,或残留配置干扰了主程序运行。
onlycook 发表于 2025-9-5 19:03 | 显示全部楼层
全片擦除芯片,重新下载用户程序试试。
powerantone 发表于 2025-9-5 19:24 | 显示全部楼层
检查并修正启动模式。
probedog 发表于 2025-9-5 20:25 | 显示全部楼层
检查SystemClock_Config()函数,时钟源是否已启用,且PLL配置是否正确。
stormwind123 发表于 2025-9-5 21:26 | 显示全部楼层
断开ST-Link的VCC连接,仅保留GND、SWDIO、SWCLK,优化调试器连接。
七毛钱 发表于 2025-9-5 22:26 | 显示全部楼层
全片擦除并重新编程。
内政奇才 发表于 2025-9-5 21:17 | 显示全部楼层
检查硬件连接,可以换ST-Link或USB线缆,排除硬件故障。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

51

主题

51

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部