简体   繁体   English

stm32 arm gcc 使用错误的库或规范编译

[英]stm32 arm gcc compile with wrong libraries or specs

When building from STM32CubeIDE, all good (obviously) When building outside IDE, but using exactly the same toolchain (ST's) and the same compiler & link flags, I got some HardwareFault handler:((当从 STM32CubeIDE 构建时,一切都很好(显然)当在 IDE 之外构建时,但使用完全相同的工具链(ST)和相同的编译器和链接标志,我得到了一些 HardwareFault 处理程序:((

So basically, some flags/specs are not good on my side.所以基本上,一些标志/规格对我来说并不好。

Now after investigating a little (-verbose) I noticed there is a difference in IDE's toolchain libraries compared to mine (both at compile & link files)现在,在稍微(-verbose)调查之后,我注意到 IDE 的工具链库与我的相比有所不同(在编译和链接文件中)

This is a link example log这是链接示例日志

IDE's集成开发环境

c:\st\stm32cubeide_1.11.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.100.202210260954\tools\arm-none-eabi\bin\ld.exe: mode armelf
                                                                                                                        
attempt to open c:/st/stm32cubeide_1.11.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.100.202210260954/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/thumb/v6-m/nofp/crti.o succeeded

It is choosing ../lib/gcc/arm-none-eabi/10.3.1/thumb/v6-m/nofp/crti.o它正在选择../lib/gcc/arm-none-eabi/10.3.1/thumb/v6-m/nofp/crti.o

Mine

c:\st\stm32cubeide_1.11.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.100.202210260954\tools\arm-none-eabi\bin\ld.exe: mode armelf
attempt to open c:/st/stm32cubeide_1.11.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm3
2.10.3-2021.10.win32_1.0.100.202210260954/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/thumb/nofp/crti.o succeeded

And mine is choosing thumb/nofp/crti.o我选择的是thumb/nofp/crti.o

For some reason, at my side appears that NANO is not choosen.出于某种原因,在我身边似乎没有选择 NANO。 Moreover, libgcc is choosen in the first place!而且,首先选择了libgcc!

This is mine这是我的

./Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rcc.o
attempt to open ../../../test1\libgcc.a failed
attempt to open c:/st/stm32cubeide_1.11.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm3
2.10.3-2021.10.win32_1.0.100.202210260954/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/thumb/nofp\libgcc.a succeeded

This is IDE's这是IDE的

./Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rcc.o
attempt to open c:/st/stm32cubeide_1.11.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.100.202210260954/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/thumb/v6-m/nofp\libc_nano.a failed
attempt to open c:/st/stm32cubeide_1.11.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.100.202210260954/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libc_nano.a succeeded

These are my link flags这些是我的链接标志

`-O0`,
`-Wl,-verbose`,
`--specs=nosys.specs`,
`--specs=nano.specs`,
`-static`,
`-Xlinker --gc-sections`,
`-Xlinker --print-memory-usage`,
`-mfloat-abi=soft`,
`-mthumb`,

And these are IDE's这些是 IDE 的

-mcpu=cortex-m0plus -T"STM32G0B1RETX_FLASH.ld" --specs=nosys.specs -Wl,-Map="${BuildArtifactFileBaseName}.map" -Wl,--gc-sections -Wl,--verbose -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group

What can be wrong?有什么问题?

Thanks in advace,在此先感谢,

I would have hoped this was obvious, but you need -mcpu=cortex-m0plus (or -march=armv6-m ).我本来希望这是显而易见的,但你需要-mcpu=cortex-m0plus (或-march=armv6-m )。

Sorry to put as answer, thanks @Tom V for clue, you're the man:) I just silly forgot to specify -mcpu=cortex-m0plus to my linker too !!!很抱歉作为答案,感谢@Tom V 的线索,你就是那个人:)我只是愚蠢地忘记了为我的 linker 指定 -mcpu=cortex-m0plus !!!

And yes, I preffer VSCode as IDE and build externally with my own scripts.是的,我喜欢 VSCode 作为 IDE 并使用我自己的脚本在外部构建。 Just tired of ST's hidden params & updates that crashes old projects.只是厌倦了 ST 的隐藏参数和使旧项目崩溃的更新。

But I still have to use STM32Cube for debug on-target purposes, step into running code, view registers & periheral definitions, etc.但我仍然必须使用 STM32Cube 进行目标调试、进入运行代码、查看寄存器和外围定义等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM