diff --git a/drivers/espi/espi_it8xxx2.c b/drivers/espi/espi_it8xxx2.c index eafdca89b96..6694cf013ff 100644 --- a/drivers/espi/espi_it8xxx2.c +++ b/drivers/espi/espi_it8xxx2.c @@ -204,7 +204,7 @@ static const struct ec2i_t pmc2_settings[] = { * This feature allows host access EC's memory directly by eSPI I/O cycles. * Mapping range is 4K bytes and base address is adjustable. * Eg. the I/O cycle 800h~8ffh from host can be mapped to x800h~x8ffh. - * Linker script of h2ram.ld will make the pool 4K aligned. + * Linker script will make the pool 4K aligned. */ #define IT8XXX2_ESPI_H2RAM_POOL_SIZE_MAX 0x1000 #define IT8XXX2_ESPI_H2RAM_OFFSET_MASK GENMASK(5, 0) diff --git a/soc/riscv/riscv-ite/it8xxx2/CMakeLists.txt b/soc/riscv/riscv-ite/it8xxx2/CMakeLists.txt index 8de80be408c..b7eff43b096 100644 --- a/soc/riscv/riscv-ite/it8xxx2/CMakeLists.txt +++ b/soc/riscv/riscv-ite/it8xxx2/CMakeLists.txt @@ -3,10 +3,3 @@ zephyr_sources( ) zephyr_library_sources_ifndef(CONFIG_RISCV_ISA_EXT_M __arithmetic.S) zephyr_sources_ifdef(CONFIG_SOC_IT8XXX2_USE_ILM ilm.c) - -# IMPORTANT: -# The h2ram section must be first added to RAM_SECTIONS to avoid gap. -zephyr_linker_sources_ifdef(CONFIG_ESPI_IT8XXX2 - RAM_SECTIONS - h2ram.ld -) diff --git a/soc/riscv/riscv-ite/it8xxx2/h2ram.ld b/soc/riscv/riscv-ite/it8xxx2/h2ram.ld deleted file mode 100644 index d09396786b3..00000000000 --- a/soc/riscv/riscv-ite/it8xxx2/h2ram.ld +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2022 ITE Corporation. - * - * SPDX-License-Identifier: Apache-2.0 - */ - - SECTION_PROLOGUE(.h2ram_pool, (NOLOAD),) - { - /* - * Ensure this section is 4k-byte aligned. - * NOTE: This won't cause gap if this is included first inside - * the RAMABLE_REGION. Because RAM base is 4k-byte aligned. - */ - . = ALIGN(0x1000); - _h2ram_pool_start = .; - KEEP(*(.h2ram_pool)) - _h2ram_pool_end = .; - } GROUP_LINK_IN(RAMABLE_REGION) - _h2ram_pool_size = ABSOLUTE(_h2ram_pool_end - _h2ram_pool_start); diff --git a/soc/riscv/riscv-ite/it8xxx2/linker.ld b/soc/riscv/riscv-ite/it8xxx2/linker.ld index 798e1ae6dc3..e285147f690 100644 --- a/soc/riscv/riscv-ite/it8xxx2/linker.ld +++ b/soc/riscv/riscv-ite/it8xxx2/linker.ld @@ -356,6 +356,22 @@ SECTIONS __data_region_end = .; + SECTION_DATA_PROLOGUE(.h2ram_pool,(NOLOAD),) + { + /* + * Since __sha256_ram_block section must in the first 4KB, + * h2ram_pool section is no longer included first inside the + * RAMABLE_REGION. + * Append h2ram_pool section at the end of used memory, so gap + * due to alignment is still available for newly added variables + */ + . = ALIGN(0x1000); + _h2ram_pool_start = .; + KEEP(*(.h2ram_pool)) + _h2ram_pool_end = .; + } GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION) + _h2ram_pool_size = ABSOLUTE(_h2ram_pool_end - _h2ram_pool_start); + __kernel_ram_end = .; __kernel_ram_size = __kernel_ram_end - __kernel_ram_start;