在Vscode中使用Cmake C/C++混合编程开发STM32

本文介绍了在VisualStudioCode中使用Cmake进行C/C++混合编程开发STM32的经验,探讨了C++特性如iostream和异常机制在嵌入式开发中的应用,以及bin包大小的影响。作者强调了使用更便捷的开发工具加快嵌入式软件开发的重要性。

在Vscode中使用Cmake C/C++混合编程开发STM32

  • 背景

    在之前的一个项目总结中:嵌入式日志系统设计,曾提到使用C语言面向对象的方式来开发STM32,最后也提出了在开发体验上并不友好,虽然最后的功能也全都实现了,但是C语言毕竟不是为面向对象设计的语言,在这一层上有着先天的劣势,想着以后是否可以使用C++来开发这样类似的项目,或者采用C/C++混合编程,这让我想起了几个月前曾搞过两个这样的试验,使用Make体系来完成的,后面也迁移到了Cmake体系,可惜时间拉的比较长了,找不到当初所参考的文章的。近来又把当时搞的Cmake编译STM32的工程翻了出来,尝试用C/C++混合编程来开发STM32,并且成功在板子上跑起来。

1. 使用C/C++混合编程

从汇编层面来看,C和C++的没有什么不同,最后都是编译称为arm的机器指令,但是C语言和C++却有非常大的不同,C++有众多大量的特性可以使用,并且对面向对象的支持也非常友好,有STL标准模板库,有着强大的泛型编程,并且还有像智能指针这样非常好用的工具,从开发角度来讲,C++有更强大的能力,虽然在速度上而言有些许的损失,但是在代码开发上,在架构设计上,以及在移植上,都更有优势,当然在移植系统上,也需要支持C/C++混合编程。

在我使用混合编程中发现一个问题,就是C++的部分库使得编译后的bin包非常大,这个库就是<iostream>,本来只有不到10K的bin包增加到了一百多K,这在部分嵌入开发平台上是不能忍受的,所以就做了一个试验,看看C和C++的几个常用库会给编译后的bin增加多大,其数据如下。

在这里插入图片描述

在测试过程中编译优化等级为Og,开启gdb调试选项,链接选项添加-specs=nano.specs -specs=nosys.specs,编译选项添加-ffunction-sections -fdata-sections -fno-exceptions,测试平台为stm32f103c6t6,不含fpu和dsp,编译工具为arm-none-eabi-gcc 10.3.1,表格中开启异常会关掉编译选项-fno-exceptions。

可以看出只有引入iostream头文件时,使得编译后的bin文件增加到一个很离谱的大小,其他头文件增加的大小都还在接受范围之内,可以预料到的是使用STL对bin包大小并没有太大的影响,因为STL模板库是以纯头文件的形式存在,并不会引入太多要编译的内容,而iostrem大概是由于stdin,stdout,stderr的问题,需要对输入和输出设备处理,使得编译的bin达到了160K,同时也可以看出stdio.h,也会增加不少文件大小,大概在3K左右,使用cstdio和stdio.h相差不大,在开启异常机制后增加了4K左右,不过在测试过程中发现,虽然开启了异常,但是catch语句无法捕捉异常,很遗憾无法在stm32上使用C++的异常机制,这也可能和链接编译选项的设置有关。

2. 总结

不管怎样瑕不掩瑜,不能使用iostream,可以使用C语言的stdio,不能使用异常机制,但是又大量的stl标准模板库的类型可以使用,可以使用C++的类来设计架构。所以在硬件快速发展的今天,使用更方便的开发语言和开发工具,可以加快我们对嵌入式软件的开发和部署。相信在使用C/C++混合编程后,项目团队的能力也可以进一步释放,虽然这对开发人员的要求也进一步提升,从简洁的C语言中,到特性繁多复杂的C++,从面向过程的开发理念到面向对象的开发架构设计,一切也都是挑战。又有时在感叹,其他平台的软件开发思想,一直向前推进,在嵌入式领域,居然还有这么多的软件开发人员,使用基础编程思想,维护复杂庞大的底层驱动软件,结果导致软件开发变成固件开发,换个平台,软件就要重新编写,希望在不久的未来,这一切可以发生改变。

目前我的编译系统也从make迁移到了cmake体系,也是为了更方便地扩展各种插件平台,这套项目代码和cmake编译体系,同时也保留了make编译系统,可以在我的仓库master分支上找到:STM32F103: stm32 personal code repository (gitee.com)

PS E:\stm\tim_servo> ninja -C build ninja: Entering directory `build' [1/6] Building C object CMakeFiles/tim_servo.dir/Core/Src/syscalls.c.obj FAILED: [code=1] CMakeFiles/tim_servo.dir/Core/Src/syscalls.c.obj C:\msys64\ucrt64\bin\gcc.exe -DDEBUG -DSTM32F103xB -DUSE_HAL_DRIVER -IE:/stm/tim_servo/cmake/stm32cubemx/../../Core/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Device/ST/STM32F1xx/Include -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Include -std=gnu11 -MD -MT CMakeFiles/tim_servo.dir/Core/Src/syscalls.c.obj -MF CMakeFiles\tim_servo.dir\Core\Src\syscalls.c.obj.d -o CMakeFiles/tim_servo.dir/Core/Src/syscalls.c.obj -c E:/stm/tim_servo/Core/Src/syscalls.c E:/stm/tim_servo/Core/Src/syscalls.c:31:10: fatal error: sys/times.h: No such file or directory 31 | #include <sys/times.h> | ^~~~~~~~~~~~~ compilation terminated. [2/6] Building ASM object CMakeFiles/tim_servo.dir/startup_stm32f103xb.s.obj FAILED: [code=1] CMakeFiles/tim_servo.dir/startup_stm32f103xb.s.obj C:\msys64\ucrt64\bin\gcc.exe -DDEBUG -DSTM32F103xB -DUSE_HAL_DRIVER -IE:/stm/tim_servo/cmake/stm32cubemx/../../Core/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Device/ST/STM32F1xx/Include -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Include -g -MD -MT CMakeFiles/tim_servo.dir/startup_stm32f103xb.s.obj -MF CMakeFiles\tim_servo.dir\startup_stm32f103xb.s.obj.d -o CMakeFiles/tim_servo.dir/startup_stm32f103xb.s.obj -c E:/stm/tim_servo/startup_stm32f103xb.s E:/stm/tim_servo/startup_stm32f103xb.s: Assembler messages: E:/stm/tim_servo/startup_stm32f103xb.s:28: Error: unknown pseudo-op: `.syntax' E:/stm/tim_servo/startup_stm32f103xb.s:29: Error: unknown pseudo-op: `.cpu' E:/stm/tim_servo/startup_stm32f103xb.s:30: Error: unknown pseudo-op: `.fpu' E:/stm/tim_servo/startup_stm32f103xb.s:31: Error: unknown pseudo-op: `.thumb' E:/stm/tim_servo/startup_stm32f103xb.s:59: Warning: .type pseudo-op used outside of .def/.endef: ignored. E:/stm/tim_servo/startup_stm32f103xb.s:59: Error: junk at end of line, first unrecognized character is `R' E:/stm/tim_servo/startup_stm32f103xb.s:63: Error: no such instruction: `bl SystemInit' E:/stm/tim_servo/startup_stm32f103xb.s:66: Error: no such instruction: `ldr r0,=_sdata' E:/stm/tim_servo/startup_stm32f103xb.s:67: Error: no such instruction: `ldr r1,=_edata' E:/stm/tim_servo/startup_stm32f103xb.s:68: Error: no such instruction: `ldr r2,=_sidata' E:/stm/tim_servo/startup_stm32f103xb.s:69: Warning: `r3' is not valid here (expected `(%rsi)') E:/stm/tim_servo/startup_stm32f103xb.s:69: Error: expecting operand after ','; got nothing E:/stm/tim_servo/startup_stm32f103xb.s:70: Error: no such instruction: `b LoopCopyDataInit' E:/stm/tim_servo/startup_stm32f103xb.s:73: Error: no such instruction: `ldr r4,[r2,r3]' E:/stm/tim_servo/startup_stm32f103xb.s:74: Error: missing ']' E:/stm/tim_servo/startup_stm32f103xb.s:74: Error: too many memory references for `str' E:/stm/tim_servo/startup_stm32f103xb.s:75: Error: expecting operand after ','; got nothing E:/stm/tim_servo/startup_stm32f103xb.s:78: Error: too many memory references for `add' E:/stm/tim_servo/startup_stm32f103xb.s:79: Error: operand type mismatch for `cmp' E:/stm/tim_servo/startup_stm32f103xb.s:80: Error: no such instruction: `bcc CopyDataInit' E:/stm/tim_servo/startup_stm32f103xb.s:83: Error: no such instruction: `ldr r2,=_sbss' E:/stm/tim_servo/startup_stm32f103xb.s:84: Error: no such instruction: `ldr r4,=_ebss' E:/stm/tim_servo/startup_stm32f103xb.s:85: Warning: `r3' is not valid here (expected `(%rsi)') E:/stm/tim_servo/startup_stm32f103xb.s:85: Error: expecting operand after ','; got nothing E:/stm/tim_servo/startup_stm32f103xb.s:86: Error: no such instruction: `b LoopFillZerobss' E:/stm/tim_servo/startup_stm32f103xb.s:89: Error: number of operands mismatch for `str' E:/stm/tim_servo/startup_stm32f103xb.s:90: Error: expecting operand after ','; got nothing E:/stm/tim_servo/startup_stm32f103xb.s:93: Error: operand type mismatch for `cmp' E:/stm/tim_servo/startup_stm32f103xb.s:94: Error: no such instruction: `bcc FillZerobss' E:/stm/tim_servo/startup_stm32f103xb.s:97: Error: no such instruction: `bl __libc_init_array' E:/stm/tim_servo/startup_stm32f103xb.s:99: Error: no such instruction: `bl main' E:/stm/tim_servo/startup_stm32f103xb.s:100: Error: no such instruction: `bx lr' E:/stm/tim_servo/startup_stm32f103xb.s:101: Warning: .size pseudo-op used outside of .def/.endef: ignored. E:/stm/tim_servo/startup_stm32f103xb.s:101: Error: junk at end of line, first unrecognized character is `R' E:/stm/tim_servo/startup_stm32f103xb.s:111: Error: junk at end of line, first unrecognized character is `,' E:/stm/tim_servo/startup_stm32f103xb.s:114: Error: no such instruction: `b Infinite_Loop' E:/stm/tim_servo/startup_stm32f103xb.s:115: Warning: .size pseudo-op used outside of .def/.endef: ignored. E:/stm/tim_servo/startup_stm32f103xb.s:115: Error: junk at end of line, first unrecognized character is `D' E:/stm/tim_servo/startup_stm32f103xb.s:123: Error: junk at end of line, first unrecognized character is `,' E:/stm/tim_servo/startup_stm32f103xb.s:124: Warning: .type pseudo-op used outside of .def/.endef: ignored. E:/stm/tim_servo/startup_stm32f103xb.s:124: Error: junk at end of line, first unrecognized character is `g' E:/stm/tim_servo/startup_stm32f103xb.s:125: Warning: .size pseudo-op used outside of .def/.endef: ignored. E:/stm/tim_servo/startup_stm32f103xb.s:125: Error: junk at end of line, first unrecognized character is `g' E:/stm/tim_servo/startup_stm32f103xb.s:196: Warning: value 0xf108f85f truncated to 0xf85f E:/stm/tim_servo/startup_stm32f103xb.s:207: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:209: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:211: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:213: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:215: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:217: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:219: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:221: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:223: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:225: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:227: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:229: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:231: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:233: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:235: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:237: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:239: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:241: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:243: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:245: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:247: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:249: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:251: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:253: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:255: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:257: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:259: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:261: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:263: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:265: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:267: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:269: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:271: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:273: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:275: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:277: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:279: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:281: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:283: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:285: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:287: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:289: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:291: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:293: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:295: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:297: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:299: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:301: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:303: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:305: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:307: Error: unknown pseudo-op: `.thumb_set' E:/stm/tim_servo/startup_stm32f103xb.s:309: Error: unknown pseudo-op: `.thumb_set' [3/6] Building C object CMakeFiles/tim_servo.dir/Core/Src/main.c.obj FAILED: [code=1] CMakeFiles/tim_servo.dir/Core/Src/main.c.obj C:\msys64\ucrt64\bin\gcc.exe -DDEBUG -DSTM32F103xB -DUSE_HAL_DRIVER -IE:/stm/tim_servo/cmake/stm32cubemx/../../Core/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Device/ST/STM32F1xx/Include -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Include -std=gnu11 -MD -MT CMakeFiles/tim_servo.dir/Core/Src/main.c.obj -MF CMakeFiles\tim_servo.dir\Core\Src\main.c.obj.d -o CMakeFiles/tim_servo.dir/Core/Src/main.c.obj -c E:/stm/tim_servo/Core/Src/main.c In file included from E:/stm/tim_servo/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h:131, from E:/stm/tim_servo/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h:130, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h:29, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h:27, from E:/stm/tim_servo/Core/Inc/stm32f1xx_hal_conf.h:238, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h:29, from E:/stm/tim_servo/Core/Inc/main.h:30, from E:/stm/tim_servo/Core/Src/main.c:20: E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h: In function '__NVIC_SetVector': E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h:1738:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1738 | uint32_t *vectors = (uint32_t *)SCB->VTOR; | ^ E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h: In function '__NVIC_GetVector': E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h:1753:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1753 | uint32_t *vectors = (uint32_t *)SCB->VTOR; | ^ C:\Users\Yeah\AppData\Local\Temp\ccIGZrQh.s: Assembler messages: C:\Users\Yeah\AppData\Local\Temp\ccIGZrQh.s:139: Error: no such instruction: `cpsid i' [4/6] Building C object cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c.obj FAILED: [code=1] cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c.obj C:\msys64\ucrt64\bin\gcc.exe -DDEBUG -DSTM32F103xB -DUSE_HAL_DRIVER -IE:/stm/tim_servo/cmake/stm32cubemx/../../Core/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Device/ST/STM32F1xx/Include -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Include -std=gnu11 -MD -MT cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c.obj -MF cmake\stm32cubemx\CMakeFiles\STM32_Drivers.dir\__\__\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c.obj.d -o cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c.obj -c E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c In file included from E:/stm/tim_servo/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h:131, from E:/stm/tim_servo/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h:130, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h:29, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h:27, from E:/stm/tim_servo/Core/Inc/stm32f1xx_hal_conf.h:238, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h:29, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c:82: E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h: In function '__NVIC_SetVector': E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h:1738:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1738 | uint32_t *vectors = (uint32_t *)SCB->VTOR; | ^ E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h: In function '__NVIC_GetVector': E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h:1753:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1753 | uint32_t *vectors = (uint32_t *)SCB->VTOR; | ^ C:\Users\Yeah\AppData\Local\Temp\ccLF5hmc.s: Assembler messages: C:\Users\Yeah\AppData\Local\Temp\ccLF5hmc.s:105: Error: number of operands mismatch for `ds' C:\Users\Yeah\AppData\Local\Temp\ccLF5hmc.s:111: Error: no such instruction: `isb 0xF' C:\Users\Yeah\AppData\Local\Temp\ccLF5hmc.s:445: Error: number of operands mismatch for `ds' C:\Users\Yeah\AppData\Local\Temp\ccLF5hmc.s:458: Error: number of operands mismatch for `ds' [5/6] Building C object cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c.obj FAILED: [code=1] cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c.obj C:\msys64\ucrt64\bin\gcc.exe -DDEBUG -DSTM32F103xB -DUSE_HAL_DRIVER -IE:/stm/tim_servo/cmake/stm32cubemx/../../Core/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Device/ST/STM32F1xx/Include -IE:/stm/tim_servo/cmake/stm32cubemx/../../Drivers/CMSIS/Include -std=gnu11 -MD -MT cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c.obj -MF cmake\stm32cubemx\CMakeFiles\STM32_Drivers.dir\__\__\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c.obj.d -o cmake/stm32cubemx/CMakeFiles/STM32_Drivers.dir/__/__/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c.obj -c E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c In file included from E:/stm/tim_servo/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h:131, from E:/stm/tim_servo/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h:130, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h:29, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h:27, from E:/stm/tim_servo/Core/Inc/stm32f1xx_hal_conf.h:238, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h:29, from E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c:26: E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h: In function '__NVIC_SetVector': E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h:1738:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1738 | uint32_t *vectors = (uint32_t *)SCB->VTOR; | ^ E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h: In function '__NVIC_GetVector': E:/stm/tim_servo/Drivers/CMSIS/Include/core_cm3.h:1753:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 1753 | uint32_t *vectors = (uint32_t *)SCB->VTOR; | ^ E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c: In function 'HAL_PWR_EnableWakeUpPin': E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c:386:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 386 | *(__IO uint32_t *) CSR_EWUP_BB(WakeUpPinx) = (uint32_t)ENABLE; | ^ E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c: In function 'HAL_PWR_DisableWakeUpPin': E:/stm/tim_servo/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c:401:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] 401 | *(__IO uint32_t *) CSR_EWUP_BB(WakeUpPinx) = (uint32_t)DISABLE; | ^ C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s: Assembler messages: C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:13: Error: no such instruction: `wfe' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:304: Error: no such instruction: `wfi' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:311: Error: no such instruction: `sev' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:314: Error: no such instruction: `wfe' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:317: Error: no such instruction: `wfe' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:359: Error: no such instruction: `wfi' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:366: Error: no such instruction: `sev' C:\Users\Yeah\AppData\Local\Temp\ccnxrD4a.s:403: Error: no such instruction: `wfi' ninja: build stopped: subcommand failed.如何解决
11-15
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值