cancel
Showing results for 
Search instead for 
Did you mean: 

compiling error

Ranjeet Singh
Senior

i am getting below error

 

d:\software\stm32cubeide_1.11.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.100.202210260954\tools\arm-none-eabi\bin\ld.exe: EV_Charger_Latest.elf section `.text' will not fit in region `FLASH'
d:\software\stm32cubeide_1.11.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.100.202210260954\tools\arm-none-eabi\bin\ld.exe: region `FLASH' overflowed by 852 bytes

RanjeetSingh_0-1692172655984.png

 

5 REPLIES 5
Peter BENSCH
ST Employee

Well, the error message 'FLASH' overflowed by 852 bytes' actually means just that - the amount of data to be pushed into the flash is too large by that amount.

You have now several possibilities, e.g.:

  • reduce program and/or data
  • switch on compiler optimization
  • use STM32 with more flash

Hope that helps?

Regards
/Peter

In order 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.

i my code 2KB flash empty if i will comment this line  sprintf(msg, "%hu\r\n", raw);

but when i remove the comment then it show

region `FLASH' overflowed by 448 bytes

Peter BENSCH
ST Employee

If I understand correctly, the error only occurs if you have not commented out sprintf, i.e. you use sprintf, right?

As already mentioned, in this case you need to reduce the flash usage. printf and its variants like sprintf etc are known to use a lot of memory. You can now either look for alternatives that are better suited to embedded systems, or consider converting/formatting raw to msg in a different way, e.g. using your own converter. The latter is a bit of work, but you can save a lot of flash.

Regards
/Peter

In order 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.

yes ,you are right .

but when i use same line i.e sprintf then it use only 856 byte in another blank program ,however  in main program 2kb is free but it using more than 2KB .why so difference ?

Pavel A.
Evangelist III

You can find it yourself by comparing .map files. Add some memory in your link script to allow the program build with sprintf. Then compare the .map files with and without sprintf and find what else is added.