cancel
Showing results for 
Search instead for 
Did you mean: 

Build error related to TrustZone

zsigmons
Associate II

Hey!

I tried migrating a project from CubeIDE to VSCode, and I can't get rid of a build error related to the TrustZone feature. I'm using a Nucleo N657X0-Q card. This error occurs when trying to build the project:
C:/Users/[redacted]/AppData/Local/stm32cube/bundles/gnu-tools-for-stm32/13.3.1+st.9/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: address 0x34000060 of robonaut-firmware_Appli.elf section `.gnu.sgstubs' is not within region `ROM'
C:/Users/[redacted]/AppData/Local/stm32cube/bundles/gnu-tools-for-stm32/13.3.1+st.9/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: address 0x34000060 of robonaut-firmware_Appli.elf section `.gnu.sgstubs' is not within region `ROM'
C:/Users/[redacted]/AppData/Local/stm32cube/bundles/gnu-tools-for-stm32/13.3.1+st.9/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ERROR: CMSE stub (.gnu.sgstubs section) too far (0x34000040) from destination (0x70100f64)

The project works fine in CubeIDE, this error only appears in VSCode.

Thanks in advance!

5 REPLIES 5
LaurentL
ST Employee

Hi zsigmons,

Check the linker script ld files and compare with your STM32CubeIDE project.

Seems that the destination address is in external memory (70 million) and the address 34 million is in Ram.

Is your STM32CubeIDE project an empty project or a cube project ?

If it is a cube project, you can generate the cmake files in STM32CubeIDE to migrate to STM32CubeIDE for Visual Studio Code project.

If it is an empty project and you migrated yourself the project then check the linker files as stated previously.

Rgds,

Laurent

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
zsigmons
Associate II

Thank you for your reply!

This project is a cube project provided to me by a professor for a university project. For now it's only blinking a led and checking some sensors. I imported it to CubeMX, changed the toolchain to cMake and regenerated the code. CubeMX generated twice the amount of linker files, it generated the ones I've already had in CubeIDE, and the same files with some changes and a different filename (screenshot attached). 

zsigmons_0-1760515938019.png

Where in CubeIDE can I generate the cmake files? If I open the .ioc file in CubeIDE, the option to change the toolchain is greyed out.

Thanks in advance!

Hi LaurentL,

The project I received from my professor was created in CubeIDE, and is executed in place. When I tried migrating I loaded the project into CubeMX, and changed the toolchain to cMake, then loaded the project in VSCode.

I've checked the linker scripts, and there seems to be some errors in the linker files generated by CubeMX.

While the original project has a ROM size of 2048K, the CubeMX generated file only has 511K. I've attached both of them.

When changing toolchains, should I change any other setting in CubeMX, or did I do something else wrong?
Thanks in advance!

* IIRC this is a well known issue. Link script for CMake is generated in a different way than for CubeIDE. So it is still not fixed.

* CubeIDE can generate projects only for itself. To generate for CMake you need CubeMX. 

Oh, okay, thanks for the info. So CubeIDE can only generate linker files for itself, and CubeMX generates linker files incorrectly?