cancel
Showing results for 
Search instead for 
Did you mean: 

Compiling STM32 with clang and cmake

azer asd
Associate II

Hello,

I am trying to setup clang (and later clang-tidy) in a project. To test clang integration with STM32F4 board I did several steps :

1. I created a default NUCLEO413 project,

2. I compiled it using the default generated Makefile

3. I created a CMake file configured with the linaro toolchain

All these steps works fine.

 

so I began switching to clang toolchain. But now I do have issues, Compilation raises warnings about unused flags :

clang: warning: argument unused during compilation: '-D STM32F413xx=1' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-D USE_HAL_DRIVER=1' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-fdata-sections' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-ffunction-sections' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '--gcc-toolchain=~/.local/bin/gcc-arm-none-eabi-10.3-2021.10/bin/' [-Wunused-command-line-argument]

 

I don't know why I do have all these flag, it's like clang raises warnings at each file being compiled.

I don't figure out why clang raises --gcc-toolchain warning. It seems clang needs compilation information and so the gcc-toolchain can be passed to clang to help him find the compiled libs. but no matter the path I set to --gcc-toolchain, I cannot clear this warning.

 

Plus the link finishes with an error :

ld.lld: error: /home/toto/STM32Cube/test/test/STM32F413ZHTx_FLASH.ld:56: memory region not defined: RAM
>>> _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of RAM */
>>> ^
clang: error: ld.lld command failed with exit code 1 (use -v to see invocation)

 

I add the CMakeLists and the compilation results.

 

I don't find any information about these kind of errors. Do you have any idea or any clue to help me ?

 

Thank you

0 REPLIES 0