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 :((
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)
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
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
For some reason, at my side appears that NANO is not choosen. Moreover, libgcc is choosen in the first place!
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
./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
-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,
CodePudding user response:
I would have hoped this was obvious, but you need -mcpu=cortex-m0plus
(or -march=armv6-m
).
CodePudding user response:
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 !!!
And yes, I preffer VSCode as IDE and build externally with my own scripts. Just tired of ST's hidden params & updates that crashes old projects.
But I still have to use STM32Cube for debug on-target purposes, step into running code, view registers & periheral definitions, etc.