From c5cf53b690a40f3c92723c69acb18843371a567c Mon Sep 17 00:00:00 2001 From: Tim Lin Date: Mon, 24 Jun 2024 11:52:03 +0800 Subject: [PATCH] soc: it8xxx2: linker: Move serial library to RAM to enhance performance Place serial library in ILM. This can improve performance. test: Print the message 10000 times with 1ms sleep interval to compare the time difference before and after adding RAM code on the it82002bw evb. RAM code size save time original: 1954 bytes libdrivers__serial.a: +2282 bytes -226ms Signed-off-by: Tim Lin --- soc/ite/ec/it8xxx2/Kconfig | 14 ++++++++++++++ soc/ite/ec/it8xxx2/linker.ld | 32 +++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/soc/ite/ec/it8xxx2/Kconfig b/soc/ite/ec/it8xxx2/Kconfig index 38b92c9c6b8..2dfe2d5afc9 100644 --- a/soc/ite/ec/it8xxx2/Kconfig +++ b/soc/ite/ec/it8xxx2/Kconfig @@ -183,6 +183,20 @@ config SOC_IT8XXX2_EXCEPTIONS_IN_RAM Flash. This can significantly improve performance when under I-cache pressure. +config SOC_IT8XXX2_LIBRARY_TO_RAM + bool + help + If this is selected it means that there is a library that needs to be excluded + from the text section. + +config SOC_IT8XXX2_SERIAL_IN_RAM + bool "Place serial handling code in RAM" + select SOC_IT8XXX2_USE_ILM + select SOC_IT8XXX2_LIBRARY_TO_RAM + help + Place serial handling (Include uart_ns16550.c and uart_ite_it8xxx2.c) code + in ILM. This can improve performance. + config SOC_IT8XXX2_SHA256_HW_ACCELERATE bool "HW SHA256 calculation" help diff --git a/soc/ite/ec/it8xxx2/linker.ld b/soc/ite/ec/it8xxx2/linker.ld index a40c97dc3f2..0c4e3d483dd 100644 --- a/soc/ite/ec/it8xxx2/linker.ld +++ b/soc/ite/ec/it8xxx2/linker.ld @@ -165,9 +165,34 @@ SECTIONS KEEP(*(".openocd_debug.*")) __text_region_start = .; - +#ifndef CONFIG_SOC_IT8XXX2_LIBRARY_TO_RAM *(.text) *(".text.*") +#endif + +#ifdef CONFIG_SOC_IT8XXX2_LIBRARY_TO_RAM + *(EXCLUDE_FILE ( +#endif +#ifdef CONFIG_SOC_IT8XXX2_SERIAL_IN_RAM + *libdrivers__serial.a:* +#endif +#ifdef CONFIG_SOC_IT8XXX2_LIBRARY_TO_RAM + ) + .text + ) +#endif + +#ifdef CONFIG_SOC_IT8XXX2_LIBRARY_TO_RAM + *(EXCLUDE_FILE ( +#endif +#ifdef CONFIG_SOC_IT8XXX2_SERIAL_IN_RAM + *libdrivers__serial.a:* +#endif +#ifdef CONFIG_SOC_IT8XXX2_LIBRARY_TO_RAM + ) + .text.* + ) +#endif *(.gnu.linkonce.t.*) #include @@ -189,6 +214,11 @@ SECTIONS #ifdef CONFIG_SOC_IT8XXX2_EXCEPTIONS_IN_RAM KEEP(*(".exception.entry.*")) *(".exception.other.*") +#endif +#ifdef CONFIG_SOC_IT8XXX2_SERIAL_IN_RAM + *libdrivers__serial.a:*(.text .text.*) + *libdrivers__serial.a:*(.rodata .rodata.*) + *libdrivers__serial.a:*(.srodata .srodata.*) #endif __ilm_flash_end = .; /* ILM mapping is always a multiple of 4k size; ensure following