2023-08-16 12:56 AM - edited 2023-08-16 12:57 AM
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
2023-08-16 01:11 AM
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.:
Hope that helps?
Regards
/Peter
2023-08-16 02:43 AM
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
2023-08-16 07:04 AM
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
2023-08-16 11:48 PM
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 ?
2023-08-17 01:05 AM
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.