cancel
Showing results for 
Search instead for 
Did you mean: 

FLASH Mem Error

bngstskn
Associate III

I use an STM32F030F4 chip. The code I wrote is quite short. But when I compile I get this error. And STM32F0 has 16 to 256 Kbytes of Flash memory. I don't understand why it is an error. Does anyone know why?

 

c:\st\stm32cubeide_1.10.1\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127\tools\arm-none-eabi\bin\ld.exe: STM32F0.elf section `.text' will not fit in region `FLASH'
c:\st\stm32cubeide_1.10.1\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127\tools\arm-none-eabi\bin\ld.exe: region `FLASH' overflowed by 952 byte
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_ADC_Init();
  MX_I2C1_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
	  if (HAL_ADC_Start(&hadc) != HAL_OK)
	      {
	        Error_Handler();
	      }

	      // ADC dönüşümünün tamamlanmasını bekle
	      if (HAL_ADC_PollForConversion(&hadc, HAL_MAX_DELAY) != HAL_OK)
	      {
	        Error_Handler();
	      }

	      // ADC değerini oku
	      uint16_t adcValue = HAL_ADC_GetValue(&hadc);

	      // ADC değerini sıcaklık değerine çevirin
	      float resistance, temperature;
	      resistance = 100000.0 / ((4095.0 / adcValue) - 1.0);
	      temperature = (1.0 / ((log(resistance / 100000.0) / 3950.0) + (1.0 / 298.15))) - 273.15;

	      // Dönüşüm sonuçlarını kullanın veya görüntüleyin
	      // temperature, sıcaklık değerini içerir

	      HAL_Delay(1000);
  }
  /* USER CODE END 3 */
}

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

> region `FLASH' overflowed by 952 byte

As the error message says, your code is too large for the flash you have available. Your chip only has 16 kB of FLASH, which is not much.

You can reduce the size of the code by changing optimization settings from Debug to Release.

Also, in particular, using doubles is increasing your code size a lot. Put "f" at the end of a number to make it a float instead. For example, use "1.0f" instead of "1.0". Your chip doesn't have an FPU so using floating point at all will increase size a fair amount. Sticking to integers would help with this.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
TDK
Guru

> region `FLASH' overflowed by 952 byte

As the error message says, your code is too large for the flash you have available. Your chip only has 16 kB of FLASH, which is not much.

You can reduce the size of the code by changing optimization settings from Debug to Release.

Also, in particular, using doubles is increasing your code size a lot. Put "f" at the end of a number to make it a float instead. For example, use "1.0f" instead of "1.0". Your chip doesn't have an FPU so using floating point at all will increase size a fair amount. Sticking to integers would help with this.

If you feel a post has answered your question, please click "Accept as Solution".

this was bad. Then would it be better if I use STM32F030RCT6? I need to use a very cheap chip. Do you have any suggestions on this matter?

I listed some suggestions above. I would suggest looking at those.

As for finding cheap chips, I would look at STM32 chips and sort by price and choose the cheapest one that fit my needs.

If you feel a post has answered your question, please click "Accept as Solution".

I searched carefully and found the STM32F030RCT6 chip. Thank you for helping me quickly with this issue. You saved me from big trouble. I had noticed that the previous chip had 16KBytes of memory. Thank you very much again.