Bluetooth: Controller: Support Link Time Optimizations (LTO)

Support for using Link Time Optimization (LTO) when
building application with open source Bluetooth Low
Energy Controller. This reduces code space usage.

Current Memory Usage at the time of this PR (hci_ipc):

BT_CTLR_OPTIMIZE_FOR_SPEED:
Memory region         Used Size  Region Size  %age Used
           FLASH:      260112 B       256 KB     99.22%
             RAM:       60136 B        64 KB     91.76%
           SRAM1:           0 B        64 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%

BT_CTLR_OPTIMIZE_FOR_SIZE:
Memory region         Used Size  Region Size  %age Used
           FLASH:      232292 B       256 KB     88.61%
             RAM:       60128 B        64 KB     91.75%
           SRAM1:           0 B        64 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%

BT_CTLR_OPTIMIZE_FOR_APP_DEFAULT:
Memory region         Used Size  Region Size  %age Used
           FLASH:      232292 B       256 KB     88.61%
             RAM:       60128 B        64 KB     91.75%
           SRAM1:           0 B        64 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%

BT_CTLR_LTO:
Memory region         Used Size  Region Size  %age Used
           FLASH:      221484 B       256 KB     84.49%
             RAM:       60120 B        64 KB     91.74%
           SRAM1:           0 B        64 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2024-03-14 21:04:04 +01:00 committed by David Leach
commit 1b7fe792e0
2 changed files with 32 additions and 5 deletions

View file

@ -212,6 +212,11 @@ add_subdirectory_ifdef(
ll_sw/openisa
)
zephyr_library_compile_options_ifdef(
CONFIG_BT_CTLR_OPTIMIZE_FOR_SIZE
${OPTIMIZE_FOR_SIZE_FLAG}
)
zephyr_library_compile_options_ifdef(
CONFIG_BT_CTLR_OPTIMIZE_FOR_SPEED
${OPTIMIZE_FOR_SPEED_FLAG}

View file

@ -598,12 +598,34 @@ config BT_CTLR_DYNAMIC_INTERRUPTS
permit use of SoC's peripheral for custom use when Bluetooth is not
enabled.
config BT_CTLR_OPTIMIZE_FOR_SPEED
prompt "Optimize for Speed"
bool
default y
choice
prompt "Optimization options"
depends on !LTO
default BT_CTLR_OPTIMIZE_FOR_SPEED
config BT_CTLR_OPTIMIZE_FOR_APP_DEFAULT
bool "Optimize for application defaults"
help
Optimize compilation of controller for execution speed.
Optimize compilation of Controller for application's default.
config BT_CTLR_OPTIMIZE_FOR_SIZE
bool "Optimize for space"
help
Optimize compilation of Controller for code size.
This is the Zephyr project default, but is overridden to use optimize
for speed when compiling the Controller to reduce application's ISR
and thread latencies.
config BT_CTLR_OPTIMIZE_FOR_SPEED
bool "Optimize for Speed"
help
Optimize compilation of Controller for execution speed. As the
Controller's Upper Link Layer and Lower Link Layer execute in ISRs,
use of speed optimizations reduces application's ISR and thread
latencies.
endchoice
config BT_CTLR_XTAL_ADVANCED
bool "Advanced event preparation"