[英]stm32 arm gcc compile with wrong libraries or specs
當從 STM32CubeIDE 構建時,一切都很好(顯然)當在 IDE 之外構建時,但使用完全相同的工具鏈(ST)和相同的編譯器和鏈接標志,我得到了一些 HardwareFault 處理程序:((
所以基本上,一些標志/規格對我來說並不好。
現在,在稍微(-verbose)調查之后,我注意到 IDE 的工具鏈庫與我的相比有所不同(在編譯和鏈接文件中)
這是鏈接示例日志
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
它正在選擇../lib/gcc/arm-none-eabi/10.3.1/thumb/v6-m/nofp/crti.o
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
我選擇的是thumb/nofp/crti.o
出於某種原因,在我身邊似乎沒有選擇 NANO。 而且,首先選擇了libgcc!
./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
./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
這些是我的鏈接標志
`-O0`,
`-Wl,-verbose`,
`--specs=nosys.specs`,
`--specs=nano.specs`,
`-static`,
`-Xlinker --gc-sections`,
`-Xlinker --print-memory-usage`,
`-mfloat-abi=soft`,
`-mthumb`,
這些是 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
有什么問題?
在此先感謝,
我本來希望這是顯而易見的,但你需要-mcpu=cortex-m0plus
(或-march=armv6-m
)。
很抱歉作為答案,感謝@Tom V 的線索,你就是那個人:)我只是愚蠢地忘記了為我的 linker 指定 -mcpu=cortex-m0plus !!!
是的,我喜歡 VSCode 作為 IDE 並使用我自己的腳本在外部構建。 只是厭倦了 ST 的隱藏參數和使舊項目崩潰的更新。
但我仍然必須使用 STM32Cube 進行目標調試、進入運行代碼、查看寄存器和外圍定義等。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.