Skip to main content
Associate
February 5, 2026
Solved

Tests with GCC vs Arm Clang for several projects & MCU's - mixed results

  • February 5, 2026
  • 1 reply
  • 647 views

I have four quite mature projects which I have developed with STM32CubeIDE 1.19.0 so far. Now I tested these projects with STM32Cube for VS Code using both toolchains.

My environment:

  • Debian Trixie
  • VS Code 1.108.2  
  • STM32CubeMX 6.16.1
  • STM32CubeIDE for Visual Studio Code 3.7.0 fresh installed with all STM-Extension Packs and the following bundles in the project (from .settings/bundles.store.json):
     "name": "cmake", "version": "4.0.1+st.3"
     "name": "ninja", "version": "1.13.1+st.1"
     "name": "gnu-tools-for-stm32", "version": "14.3.1+st.2"
     "name": "st-arm-clangd", "version": "19.1.2+st.3"
     "name": "programmer", "version": "2.21.0"
     "name": "stlink-gdbserver", "version": "7.12.0+st.2"
     "name": "st-arm-clang", "version": "19.1.6+st.10"
     "name": "st-arm-clang-hybrid", "version": "19.1.6+st.3" 

I only used the release configuration and flashed the devices either with ST-Link or USB using the bundled programmer.
I set up the project as follows:

  • Generate a clean project with CubeMX from existing ioc files for the CMAKE toolchain.
  • Add  application sources of the STM32CubeIDE projects (*.cpp *.c *.h files) which were not generated by CubrM.
  • Carefully add user code to the CubeMX generated files.
  • Do always a clean reconfigure and clean rebuild from the CMakeLists.txt context menu after the toolchains or toolchain configuration had been changed.
  • Flash processor using the bundled programmer using ST-Link (STM32G031xx) or USB (all other MCU's).

I got the following results from "smoke tests":

Project # 1 2 3 4
MCU STM32G031F6 STM32G031F6 STM32G0B1CB STM32G474CE STM32H750VB
GCC o.k. o.k. o.k. o.k. 1)
CLANG-Hybrid o.k. o.k. o.k. o.k. 1)
CLANG-Newlib - - - o.k. -
CLANG-Picolibc o.k. o.k. o.k. 2) 3)

Diagnostics:

  1. Program does not work correctly. A DMA transfer from memory to peripheral fails.  I do a SCB_CleanDCache_by_Addr before starting the DMA transfer. I noticed, that in addition to STM32H750XX_FLASH.ld a STM32H750VBTX_FLASH.ld file was generated by CubeMX in the workspace directory. If I use this file instead of the STM32H750XX_FLASH.ld in the CMAKE_EXE_LINKER_FLAGS, then the program works as expected!

  2. Flash fails:
USB speed : Full Speed (12MBit/s)
Manuf. ID : STMicroelectronics
Product ID : DFU in FS Mode
SN : 206D36A14632
DFU protocol: 1.1
Board : --
Device ID : 0x469
Device name : STM32G47x/G48x/G414
Flash size : 512 KBytes
Device type : MCU
Revision ID : --
Device CPU : Cortex-M4

Opening and parsing file: stm32g474ce.elf

Memory Programming ...
 File : stm32g474ce.elf
 Size : 40.74 KB
 Address : 0x08000000
File segment @0x200001D4 is not 8-bytes aligned. It will be aligned to @0x200001D0
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 20]
Erasing memory corresponding to segment 1:
Not flash Memory : No erase done
Download in Progress:
[==================================================] 100%

Error: failed to download Sector[0]
Error: failed to download the File
  • Linking with STM32H750XX_FLASH.ld flashing fails:

USB speed : Full Speed (12MBit/s)
Manuf. ID : STMicroelectronics
Product ID : DFU in FS Mode
SN : 200364500000
DFU protocol: 1.1
Board : --
Device ID : 0x450
Device name : STM32H7xx
Flash size : 2 MBytes (default)
Device type : MCU
Revision ID : --
Device CPU : Cortex-M7


Opening and parsing file: stm32h750vb.elf


Memory Programming ...
 File : stm32h750vb.elf
 Size : 53.16 KB
 Address : 0x08000000


Erasing memory corresponding to segment 0:
Erasing internal memory sector 0
Erasing memory corresponding to segment 1:
Not flash Memory : No erase done
Download in Progress:
[==================================================] 100%

Error: failed to download Sector[0]
Error: failed to download the File
​

Linking with STM32H750VBTX_FLASH.ld fails:

[build] ld.lld: error: /home/xxx/yyyy/zzz/stm32h750vb/STM32H750VBTX_FLASH.ld:38: memory region not defined: RAM_D1
[build] >>> _estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* end of RAM */
[build] >>>

 

Best answer by TDK

> Program does not work correctly. A DMA transfer from memory to peripheral fails.  I do a SCB_InvalidateDCache_by_Addr before starting the DMA transfer.

Wrong one. You should be using SCB_CleanDCache_by_Addr before a memory -> peripheral transfer starts.

1 reply

TDK
TDKBest answer
Super User
February 5, 2026

> Program does not work correctly. A DMA transfer from memory to peripheral fails.  I do a SCB_InvalidateDCache_by_Addr before starting the DMA transfer.

Wrong one. You should be using SCB_CleanDCache_by_Addr before a memory -> peripheral transfer starts.

"If you feel a post has answered your question, please click ""Accept as Solution""."
jsi1Author
Associate
February 5, 2026

Sorry for mixing up the function names in the post. I use SCB_CleanDCache_by_Addr in the program (just verified). The initial post was updated.