cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB05KZ Build FLASH overflow

Dadigno
Senior

Hi Community,

I'm trying to build the BLE_TransparentMode example for the NUCLEO-WB05KZ, but I'm getting the following build error:

region 'FLASH' overflowed by 93348 bytes

Dadigno_0-1764347585364.png

 


Steps to reproduce:

  • Open the BLE_TransparentMode example from the MX Example Selector for NUCLEO_WB05KZ.
  • Change the toolchain to CMake with GCC compiler.
  • Open the project and configure it using the STM32 VS Code extension.
  • Build the project → the error appears.

Environment:

STM32CubeMX: v6.16

STM32CubeIDE for VS Code: v3.6.4

Has anyone encountered this issue or knows what might be causing the FLASH overflow with the CMake/GCC configuration?
Thanks!

 

 

8 REPLIES 8
Andrew Neil
Super User

@Dadigno wrote:
  • Open the BLE_TransparentMode example from the MX Example Selector for NUCLEO_WB05KZ.
  • Change the toolchain to CMake with GCC compiler.

Are you sure that the optimisation level is the same in  your modified project?

What happens if you build the example as-is - without any modifications ?

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Hi,

build runs fine without any modifications, using stm32cubeide.

 


@Andrew Neil wrote:

Are you sure that the optimisation level is the same in  your modified project?

 


I think so, I didn’t change anything else except the compiler and toolchain settings from MX.

 


@Dadigno wrote:

I think so


But have you checked?

 


@Dadigno wrote:

I didn’t change anything else except the compiler and toolchain 


Well, the optimisation level is a compiler setting!

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

I found a difference in the optimization level: in the STM32CubeIDE project it's set to -Os, while in the CMake project it's -O0. However, after switching to -Os the flash overflow is now 100.2%. Maybe there's something else? What else can I check?

So what was the flash use percentage in the CubeIDE build ?

Have you done a thorough check of all the other settings; eg,

AndrewNeil_1-1764606813414.png

 

Do you get a map file from the CMake build?

Note that the full command line appears in the Console when you do the CubeIDE build.

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Other compilation flags are exactly the same; I can't find any differences.

CubeIDE reports 100% RAM usage and 99.35% flash usage, so it's very close to the memory limit. Comparing the map files, it seems that more code is being included in many sections.

But I don’t understand why, the project and the libraries should be the same. Why does it change when using the CMake toolchain?


@Dadigno wrote:

Comparing the map files, it seems that more code is being included in many sections.


Have you enabled ASSERTs, or some other debug/diagnostic/logging feature?

 


@Dadigno wrote:

Why does it change when using the CMake toolchain?


Are you sure your CMake toolchain is using the exact same GCC version as CubeIDE ?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.


@Dadigno wrote:

Why does it change when using the CMake toolchain?


Are you sure your CMake toolchain is using the exact same GCC version as CubeIDE ?


GCC versions is 13.3.1 for both env

 

The .cmake I'm using:

set(CMAKE_SYSTEM_NAME               Generic)
set(CMAKE_SYSTEM_PROCESSOR          arm)

set(CMAKE_C_COMPILER_ID GNU)
set(CMAKE_CXX_COMPILER_ID GNU)

# Some default GCC settings
# arm-none-eabi- must be part of path environment
set(TOOLCHAIN_PREFIX                arm-none-eabi-)

set(CMAKE_C_COMPILER                ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_ASM_COMPILER              ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER              ${TOOLCHAIN_PREFIX}g++)
set(CMAKE_LINKER                    ${TOOLCHAIN_PREFIX}g++)
set(CMAKE_OBJCOPY                   ${TOOLCHAIN_PREFIX}objcopy)
set(CMAKE_SIZE                      ${TOOLCHAIN_PREFIX}size)

set(CMAKE_EXECUTABLE_SUFFIX_ASM     ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_C       ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_CXX     ".elf")

set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

# MCU specific flags
set(TARGET_FLAGS "-mcpu=cortex-m0plus")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_FLAGS}")
set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -x assembler-with-cpp -MMD -MP")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -ffunction-sections -fdata-sections")

set(CMAKE_C_FLAGS_DEBUG "-Os -g3")
set(CMAKE_C_FLAGS_RELEASE "-Os -g0")
set(CMAKE_CXX_FLAGS_DEBUG "-Os -g3")
set(CMAKE_CXX_FLAGS_RELEASE "-Os -g0")

set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions -fno-threadsafe-statics")

set(CMAKE_EXE_LINKER_FLAGS "${TARGET_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T \"${CMAKE_SOURCE_DIR}/stm32wb05_flash.ld\"")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=nano.specs")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=${CMAKE_PROJECT_NAME}.map -Wl,--gc-sections")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--print-memory-usage")
set(TOOLCHAIN_LINK_LIBRARIES "m")