cancel
Showing results for 
Search instead for 
Did you mean: 

Create empty project -> Does not compile

ganzziani
Associate

I installed VS Code and the STM32 extension. Compiling a project imported from STM32CUBEMX works.

But creating an empty project from VS Code (target is: stm32g474retx) gives me this error when building:

 

 

[main] Building folder: D:/Projects/tmp/firmware2/build/debug
[build] Starting build
[proc] Executing command: C:\ST\STM32CubeCLT_1.16.0\CMake\bin\cmake.EXE --build D:/Projects/tmp/firmware2/build/debug --
[build] [1/1] Linking C executable firmware2.elf
[build] FAILED: firmware2.elf
[build] C:\Windows\system32\cmd.exe /C "cd . && C:\ST\STM32CubeCLT_1.16.0\GNU-tools-for-STM32\bin\arm-none-eabi-gcc.exe -fdata-sections -ffunction-sections -Wl,--gc-sections -g -TD:/Projects/tmp/firmware2/stm32g474retx_FLASH.ld -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Wl,-Map=firmware2.map -u _printf_float --specs=nosys.specs -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group -Wl,-z,max-page-size=8 -Wl,--print-memory-usage CMakeFiles/firmware2.dir/Src/main.c.obj CMakeFiles/firmware2.dir/Src/syscall.c.obj CMakeFiles/firmware2.dir/Src/sysmem.c.obj CMakeFiles/firmware2.dir/Startup/startup_stm32g474retx.s.obj -o firmware2.elf -LD:/Projects/tmp/firmware2/firmware2  && C:\Windows\system32\cmd.exe /C "cd /D D:\Projects\tmp\firmware2\build\debug && arm-none-eabi-size D:/Projects/tmp/firmware2/build/debug/firmware2.elf && arm-none-eabi-objcopy -O ihex D:/Projects/tmp/firmware2/build/debug/firmware2.elf firmware2.hex && arm-none-eabi-objcopy -O binary D:/Projects/tmp/firmware2/build/debug/firmware2.elf firmware2.bin""
[build] C:/ST/STM32CubeCLT_1.16.0/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe:D:/Projects/tmp/firmware2/stm32g474retx_FLASH.ld:173: nonconstant expression for fill value
[build] collect2.exe: error: ld returned 1 exit status
[build] ninja: build stopped: subcommand failed.
[proc] The command: C:\ST\STM32CubeCLT_1.16.0\CMake\bin\cmake.EXE --build D:/Projects/tmp/firmware2/build/debug -- exited with code: 1
[driver] Build completed: 00:00:00.203
[build] Build finished with exit code 1
1 ACCEPTED SOLUTION

Accepted Solutions
ganzziani
Associate

I created an empty project in STM32CubeIDE and compared the files from VS Code. There is a difference in the stm32g474retx_FLASH.ld file, a missing word in the VS Code version, at line 170: FLASH.

I copied this line into the VS Code and now the code does compile.

The output from each build is different thou, STM32 outputs:

text data bss dec hex filename

732 0 1568 2300 8fc firmware.elf

And VS Code outputs:

[build]    text    data     bss     dec     hex filename
[build]     936       4    1972    2912     b60 D:/Projects/tmp/firmware-vscode/build/debug/firmware2.elf
Despite having the same source code and in debug. There might be some different settings somewhere but I guess this is not too important, something to look at another day.

View solution in original post

2 REPLIES 2
ganzziani
Associate

I created an empty project in STM32CubeIDE and compared the files from VS Code. There is a difference in the stm32g474retx_FLASH.ld file, a missing word in the VS Code version, at line 170: FLASH.

I copied this line into the VS Code and now the code does compile.

The output from each build is different thou, STM32 outputs:

text data bss dec hex filename

732 0 1568 2300 8fc firmware.elf

And VS Code outputs:

[build]    text    data     bss     dec     hex filename
[build]     936       4    1972    2912     b60 D:/Projects/tmp/firmware-vscode/build/debug/firmware2.elf
Despite having the same source code and in debug. There might be some different settings somewhere but I guess this is not too important, something to look at another day.

Thanks, you probably saved me a day or two of head scratching!