I am trying to program STM32F042K6 nucleo using CubeIDE and STM32 HAL but the compiler throws an error:
region `FLASH' overflowed by 1212 bytes.
Here is the exact console output:
09:55:03 **** Incremental Build of configuration Debug for project Virtual Com Port ****
make -j16 all
arm-none-eabi-gcc -o "Virtual Com Port.elf" @"objects.list" -mcpu=cortex-m0 -T"C:\Users\EE Engineering\Documents\Projects\Firmware\Virtual Comm Port\STM32F042K6TX_FLASH.ld" --specs=nosys.specs -Wl,-Map="Virtual Com Port.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
c:\st\stm32cubeide_1.7.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: Virtual Com Port.elf section `.text' will not fit in region `FLASH'
c:\st\stm32cubeide_1.7.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: region `FLASH' overflowed by 1212 bytes
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:69: Virtual Com Port.elf] Error 1
"make -j16 all" terminated with exit code 2. Build might be incomplete.
09:55:04 Build Failed. 3 errors, 0 warnings. (took 340ms).
However, when I look at the memory regions in the build analyzer, it shows 16.58 KB free out of 32KB size for a usage of 48.19%. If only 48% of the flash storage is used, then how is the flash overflowing by 1212 bytes and what can I do to fix this?