Skip to content

Commit

Permalink
stm32/boards: Enable LTO by default on boards with smaller flash size.
Browse files Browse the repository at this point in the history
Signed-off-by: Angus Gratton <gus@projectgus.com>
  • Loading branch information
projectgus authored and dpgeorge committed Jun 28, 2022
1 parent 5568c32 commit dd77dbd
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ports/stm32/README.md
Expand Up @@ -68,6 +68,23 @@ can be built via:

For more information about mboot see mboot/README.md.

### Link Time Optimization

Link Time Optimization (LTO) reduces the firmware binary size when enabled
(typically 2-3% smaller). However it may make build time longer, particularly on
older GCC versions.

Currently LTO is enabled by default for some smaller STM32 boards with less
flash, but disabled on other boards.

To enable LTO, pass `LTO=1` on the command line:

$ make BOARD=boardname LTO=1

To disable LTO, pass `LTO=0` in the same way.

Note that `make clean BOARD=boardname` will be needed before changing the `LTO`
setting of a firmware that is already built.

### Flashing the Firmware using DFU mode

Expand Down
3 changes: 3 additions & 0 deletions ports/stm32/boards/B_L072Z_LRWAN1/mpconfigboard.mk
Expand Up @@ -9,3 +9,6 @@ MICROPY_VFS_FAT = 0

# Don't include default frozen modules because MCU is tight on flash space
FROZEN_MANIFEST ?=

# LTO reduces final binary size, may be slower to build depending on gcc version and hardware
LTO ?= 1
3 changes: 3 additions & 0 deletions ports/stm32/boards/NUCLEO_F091RC/mpconfigboard.mk
Expand Up @@ -9,3 +9,6 @@ MICROPY_VFS_LFS1 ?= 1

# Don't include default frozen modules because MCU is tight on flash space
FROZEN_MANIFEST ?=

# LTO reduces final binary size, may be slower to build depending on gcc version and hardware
LTO ?= 1
3 changes: 3 additions & 0 deletions ports/stm32/boards/NUCLEO_G0B1RE/mpconfigboard.mk
Expand Up @@ -2,3 +2,6 @@ MCU_SERIES = g0
CMSIS_MCU = STM32G0B1xx
AF_FILE = boards/stm32g0b1_af.csv
LD_FILES = boards/stm32g0b1xe.ld boards/common_basic.ld

# LTO reduces final binary size, may be slower to build depending on gcc version and hardware
LTO ?= 1
3 changes: 3 additions & 0 deletions ports/stm32/boards/NUCLEO_L073RZ/mpconfigboard.mk
Expand Up @@ -8,3 +8,6 @@ MICROPY_VFS_FAT = 0

# Don't include default frozen modules because MCU is tight on flash space
FROZEN_MANIFEST ?=

# LTO reduces final binary size, may be slower to build depending on gcc version and hardware
LTO ?= 1
3 changes: 3 additions & 0 deletions ports/stm32/boards/NUCLEO_L432KC/mpconfigboard.mk
Expand Up @@ -10,3 +10,6 @@ MICROPY_VFS_LFS1 ?= 1

# Don't include default frozen modules because MCU is tight on flash space
FROZEN_MANIFEST ?=

# LTO reduces final binary size, may be slower to build depending on gcc version and hardware
LTO ?= 1

0 comments on commit dd77dbd

Please sign in to comment.