4 years, 8 months ago.

Error: code size too large for linker when adding new target board to mbed-os


I have been very busy trying to add a new target board (Nucleo-F413ZH) to mbed-os. I have been following the instructions here:


However, I get the following error on running mbed test or mbed compile:

"Fatal error: L6047U: The size of this image (35416 bytes) exceeds the maximum allowed for this version of the linker"

note: the image size varies depending on the test from around 35k to 40k bytes).

I am using the ARM compiler which I have installed with Keil uVision. The strange thing is if I compile this library in Keil I do not get this error and it compiles fine with no errors.

Please can someone help me, because I believe I am on the verge of adding a new target board here :)

1 Answer

4 years, 8 months ago.

Guessing here based on symptoms. Your Keil uVision license is code limited to 32K? I suspect your settings for optimization are higher (O3?) than what the mbed settings are (O0,O1). Poke around in your uVision and see if you can turn down optimization and see if it results in the same error message. Somewhere in the Python scripts I bet they are calling uVision with a list of external flags - one of which is optimization...

Accepted Answer

I think you are right, so I've switched to GCC_ARM instead as its free. Thanks for the info, I had assumed that my uVision didn't have a limit, but at some point I ended up getting the same error when compiling in uVision. I now have a working version of the mbed source for my stm32f413zh board :)

posted by James Elder 16 May 2017

You might also try the STM System Workbench for STM32 if you're focused on STM products. Well integrated GCC environment. The generic GCC is great as well if you're up to speed on all the gotchas for integrating a compiler and debugger on your own.

posted by Bill Bellis 17 May 2017