Flash size increase for different boards

If you made your own board, post here, unless you built a Maple or Maple mini clone etc
Post Reply
hetlelid
Posts: 3
Joined: Sat Aug 14, 2021 2:56 pm
Answers: 1

Flash size increase for different boards

Post by hetlelid »

Hi.

I have made a custom board using STM32L051K8U6 (64KB Flash), and configured the board variant myself. While compiling for Nucleo L432KC, the flash size is very different in size.

Nucleo L432KC: 54132 bytes
Custom STM32L051K8U6: 61796 bytes

The difference is 7664 bytes, for the exact same code. The result is that the final code will not fit the flash.

Do you have any idea what is causing this, and how i can start investigate to optimise the code for my custom board?

I'm using platformio for dev environment. This is the libraries in use:

olikraus/U8g2 @ ^2.28.8
adafruit/Adafruit BusIO @ ^1.7.2
adafruit/Adafruit DPS310 @ ^1.1.1
adafruit/Adafruit LSM303DLH Mag @ ^1.0.7
adafruit/Adafruit SHTC3 Library @ ^1.0.0
stm32duino/STM32duino Low Power @ ^1.1.0
stm32duino/STM32duino RTC @ ^1.1.0
adafruit/Adafruit MLX90393 @ ^2.0.1

Platformio config file:

Code: Select all

{
  "build": {
    "core": "stm32",
    "cpu": "cortex-m0plus",
    "extra_flags": "-DSTM32L051xx",
    "f_cpu": "32000000L",
    "mcu": "STM32L051K8U6",
    "product_line": "STM32L051xx",
    "variant": "STM32L0xx/L051K(6-8)U"
  },
  "debug": {
    "default_tools": [
      "stlink"
    ],
    "jlink_device": "STM32L051K8",
    "onboard_tools": [
      "stlink"
    ],
    "openocd_target": "stm32l0",
    "svd_path": "STM32L051.svd"
  },
  "frameworks": [
    "arduino"
  ],
  "name": "STM32L051K8 (8k RAM. 64k Flash)",
  "upload": {
    "maximum_ram_size": 8192,
    "maximum_size": 65536,
    "protocol": "serial",
    "protocols": [
      "blackmagic",
      "dfu",
      "jlink",
      "serial",
      "stlink"
    ]
  },
  "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32l051k8.html",
  "vendor": "Generic"
}
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Flash size increase for different boards

Post by ag123 »

first Nucleo L432KC is more 'advanced' than STM32L051K8U6, there may be optimizations that can save code size even if the flags used is seemingly similar. you can take a look at platforms.txt and boards.txt look at the flags used and try them out, some of them can reduce code sizes but may have side effects and possibly break the app.
Post Reply

Return to “Custom design boards”