• Keil转STM32CubeIDE工程移植问题记录


    Keil转STM32CubeIDE工程移植问题记录

    从Keil软件转战STM32CubeIDE,转换的过程中遇到了不少问题,在此记录一下,防止以后再踩坑.也给同样有转软件需求的朋友做个参考吧~

    1.编译报错问题处理

    • 1.大量编译报错显示重复 multiple definition
    c:\st\stm32cubeide_1.9.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127\tools\arm-none-eabi\bin\ld.exe: ./Library/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_msp_template.o: in function `HAL_MspInit':
    D:/workspace/MPT-I/Library/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_msp_template.c:52: multiple definition of `HAL_MspInit'; ./HardwareDriverLayer/stm32f4xx_hal_msp.o:D:/workspace/MPT-I/HardwareDriverLayer/stm32f4xx_hal_msp.c:65: first defined here
    c:\st\stm32cubeide_1.9.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127\tools\arm-none-eabi\bin\ld.exe: ./Library/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_timebase_rtc_alarm_template.o: in function `HAL_RTC_AlarmAEventCallback':
    D:/workspace/MPT-I/Library/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_timebase_rtc_alarm_template.c:252: multiple definition of `HAL_RTC_AlarmAEventCallback'; ./HardwareDriverLayer/HAL_Driver/drv_rtc.o:D:/workspace/MPT-I/HardwareDriverLayer/HAL_Driver/drv_rtc.c:219: first defined here
    
    • 1
    • 2
    • 3
    • 4

    HAL库提供的模板文件和我们的应用文件冲突导致重复定义
    在这里插入图片描述

    • 2.工程没有配置源文件路径导致大量undefined reference 编译错误

    在这里插入图片描述

    右击工程名->Properties->C/C++ General->Source Location处添加源文件路径(每次新增源文件文件夹需要在此处添加)
    在这里插入图片描述

    • 3.alignment of array elements is greater than element size

    原因在于:

    typedef  CPU_STK __attribute__((aligned(8)))        CPU_STK_8BYTE_ALIGNED;
    
    • 1

    Keil,VS Code等支持8字节对齐, #pragma pack(8),gcc 默认是4字节对齐,且只支持1,2,4字节对齐, #pragma pack(4).
    修改如下:

    typedef  CPU_STK __attribute__((aligned(4)))        CPU_STK_8BYTE_ALIGNED;
    
    • 1

    2.工程相关配置问题

    可以通过scanf和sprintf进行浮点数操作
    在这里插入图片描述

    选择编译器的语法标准,这里我们选用常用的C99标准
    在这里插入图片描述

    解决STMCube IDE 字母与汉字大小显示不一致的问题:
    在这里插入图片描述

    3.调试器配置

    …持续更新…

  • 相关阅读:
    定时器方案,红黑树,时间轮
    kobject 和 sysfs
    TypeScript 之 Hello World!
    微信小程序python+nodejs+php+springboot+vue 健身教练私教预约系统
    第4讲:vue内置命令(文本插值,属性绑定,v-text,v-html)
    unity VR Interaction Framework 创建新手势
    [git] git diff
    webgl 系列 —— 初识 WebGL
    单机/分布式限流-漏桶/令牌桶/滑动窗口/redis/nginx/sentinel
    Docker安装Rabbitmq
  • 原文地址:https://blog.csdn.net/qq_32969455/article/details/125395682