• MDK报错:Undefined symbol assert_failed报错解决策略


    MDK报错:Undefined symbol assert_failed报错解决策略


    • 🎯🪕在全网搜索相关MDK编译报错:Error: L6218E: Undefined symbol assert_param (referred from xxx.o).

    ✨有些问题看似很简单,可能产生的问题是由于不经意的细节原因导致。引起报错的问题有很多种可能,没有放之四海皆准的解决方案。

    • 🌿提供的解决问题的可能方案一:添加宏定义USE_STDPERIPH_DRIVER
      在这里插入图片描述
    • 🌿提供的解决问题的可能方案二:没有将相对应的驱动头文件(.h)路径包含进来或者是源文件(.c)添加到工程中。
    • 🔖这里针对的是具体的驱动文件或驱动头文件。
      在这里插入图片描述
      在这里插入图片描述
    • 🌿提供的解决问题的可能方案三:在main.c文件中,补充下面的void assert_failed()断言报错函数:
    #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,
           tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
        /* USER CODE END 6 */
    }
    #endif /* USE_FULL_ASSERT */
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    ✨很多外部导入的工程源码,添加完标准库文件后,编译报此错误,往往可能是忽略标准库驱动文件中定义了此断言assert_failed函数,却没有写实现的地方,才会出现有调用assert_param宏的驱动文件中报错。

    、

    /* Exported macro ------------------------------------------------------------*/
    #define USE_FULL_ASSERT
    
    #ifdef  USE_FULL_ASSERT
        /**
        * @brief  The assert_param macro is used for function's parameters check.
        * @param  expr If expr is false, it calls assert_failed function
        *         which reports the name of the source file and the source
        *         line number of the call that failed.
        *         If expr is true, it returns no value.
        * @retval None
        */
        #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
        /* Exported functions ------------------------------------------------------- */
        void assert_failed(uint8_t *file, uint32_t line);
    #else
        #define assert_param(expr) ((void)0U)
    #endif /* USE_FULL_ASSERT */
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
  • 相关阅读:
    YOLOv5量化调优
    二维码生成和解析工具包-zxing
    redis群集有三种模式(主从同步/复制、哨兵模式、Cluster)
    Unity 之利用Audio Source(音频源)组件用于播放声音
    HSN:微调预训练ViT用于目标检测和语义分割,华南理工和阿里巴巴联合提出
    什么是 Spring, IoC 和 DI 的区别是什么?
    排队算法的matlab仿真,带GUI界面
    SQL必需掌握的100个重要知识点:使用游标
    啥是各向同性、各向异性GNN:
    前端开发核心知识进阶 —— 宏任务和微任务
  • 原文地址:https://blog.csdn.net/weixin_42880082/article/details/133432370