Skip to content

High flash memory usage on STM32F030F4P6 #2390

@SuppaTenko

Description

@SuppaTenko

So, I decided to make a new project with STM32F030F4P6.
The only things I have done so far are:

  • defined new pin names
  • added clock config from CubeMX
  • changed pin modes and defined default pin states in setup() section.
    I didn't add any libraries and didn't add any valuable code at all.
    And compilation gives me this error messages:

d:/arduino15/packages/stmicroelectronics/tools/xpack-arm-none-eabi-gcc/12.2.1-1.2/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Tenko-JobOmega\AppData\Local\Temp\arduino\sketches\4AC2DD8C349502A56E9A2F21471716DB/Firmware_Gauge.ino.elf section .text' will not fit in region FLASH'
d:/arduino15/packages/stmicroelectronics/tools/xpack-arm-none-eabi-gcc/12.2.1-1.2/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: region `FLASH' overflowed by 3296 bytes
collect2.exe: error: ld returned 1 exit status

It's totaly wrong. A year ago I wrote another project for this MCU without any serious issues.
And now I can't even compile core. I tried all optimization options, with and without LTO. And I also tried newlib standard instead nano etc. I rechecked MCU variant - flash and ram sizes are correct here.

What causes this problem? Is it toolchain issue or core issue? How can i fight it?
Do i need to have second downgraded STM32duino core version? If yes - which one?

My current code:

#define OUT_A 9
#define OUT_B 8
#define OUT_C 12
#define OUT_D 7
#define OUT_E 6
#define OUT_F 5

#define DBG_RX 3
#define DBG_TX 2

#define SENSE 0

extern "C" void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL4;
RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
| RCC_CLOCKTYPE_PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV4;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler();
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1;
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
Error_Handler();
}

HAL_RCC_EnableCSS();
}

void setup() {
pinMode(OUT_A, OUTPUT);
pinMode(OUT_B, OUTPUT);
pinMode(OUT_C, OUTPUT);
pinMode(OUT_D, OUTPUT);
pinMode(OUT_E, OUTPUT);
pinMode(OUT_F, OUTPUT);

digitalWrite(OUT_A, LOW);
digitalWrite(OUT_B, LOW);
digitalWrite(OUT_C, LOW);
digitalWrite(OUT_D, LOW);
digitalWrite(OUT_E, LOW);
digitalWrite(OUT_F, LOW);
}

void loop() {
// put your main code here, to run repeatedly:
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions