mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 13:44:32 +02:00
Merge branch 'feature/esp_system_common_ld_settings' into 'master'
esp_system: create ld template to abstract few common settings Closes IDF-3624 See merge request espressif/esp-idf!14700
This commit is contained in:
@@ -113,9 +113,15 @@ menu "ESP System Settings"
|
|||||||
|
|
||||||
menu "Memory protection"
|
menu "Memory protection"
|
||||||
|
|
||||||
|
config ESP_SYSTEM_MEMPROT_DEPCHECK
|
||||||
|
bool
|
||||||
|
default y if IDF_TARGET_ESP32S2
|
||||||
|
default y if IDF_TARGET_ESP32C3
|
||||||
|
default y if IDF_TARGET_ESP32H2
|
||||||
|
|
||||||
config ESP_SYSTEM_MEMPROT_FEATURE
|
config ESP_SYSTEM_MEMPROT_FEATURE
|
||||||
bool "Enable memory protection"
|
bool "Enable memory protection"
|
||||||
depends on IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32H2
|
depends on ESP_SYSTEM_MEMPROT_DEPCHECK
|
||||||
default "y"
|
default "y"
|
||||||
help
|
help
|
||||||
If enabled, the permission control module watches all the memory access and fires the panic handler
|
If enabled, the permission control module watches all the memory access and fires the panic handler
|
||||||
@@ -133,6 +139,20 @@ menu "ESP System Settings"
|
|||||||
Once locked, memory protection settings cannot be changed anymore.
|
Once locked, memory protection settings cannot be changed anymore.
|
||||||
The lock is reset only on the chip startup.
|
The lock is reset only on the chip startup.
|
||||||
|
|
||||||
|
config ESP_SYSTEM_MEMPROT_CPU_PREFETCH_PAD_SIZE
|
||||||
|
# Hidden option for linker script usage
|
||||||
|
int
|
||||||
|
depends on ESP_SYSTEM_MEMPROT_DEPCHECK
|
||||||
|
default 16
|
||||||
|
|
||||||
|
config ESP_SYSTEM_MEMPROT_MEM_ALIGN_SIZE
|
||||||
|
# Hidden option for linker script usage
|
||||||
|
int
|
||||||
|
depends on ESP_SYSTEM_MEMPROT_DEPCHECK
|
||||||
|
default 4 if IDF_TARGET_ESP32S2
|
||||||
|
default 256 if IDF_TARGET_ESP32S3
|
||||||
|
default 512
|
||||||
|
|
||||||
endmenu # Memory protection
|
endmenu # Memory protection
|
||||||
|
|
||||||
config ESP_SYSTEM_EVENT_QUEUE_SIZE
|
config ESP_SYSTEM_EVENT_QUEUE_SIZE
|
||||||
|
@@ -53,7 +53,7 @@ $(COMPONENT_LIBRARY): $(ld_output)
|
|||||||
|
|
||||||
$(ld_output): $(ld_input) ../include/sdkconfig.h
|
$(ld_output): $(ld_input) ../include/sdkconfig.h
|
||||||
mkdir -p $(COMPONENT_BUILD_DIR)/ld
|
mkdir -p $(COMPONENT_BUILD_DIR)/ld
|
||||||
$(CC) -I ../include -C -P -x c -E $< -o $@
|
$(CC) -I ../include -I $(COMPONENT_PATH)/ld -C -P -x c -E $< -o $@
|
||||||
|
|
||||||
COMPONENT_EXTRA_CLEAN := $(ld_output) $(sections_ld)
|
COMPONENT_EXTRA_CLEAN := $(ld_output) $(sections_ld)
|
||||||
endif
|
endif
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
to simple macros with numeric values, and/or #if/#endif blocks.
|
to simple macros with numeric values, and/or #if/#endif blocks.
|
||||||
*/
|
*/
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
#include "ld.common"
|
||||||
|
|
||||||
/* If BT is not built at all */
|
/* If BT is not built at all */
|
||||||
#ifndef CONFIG_BT_RESERVE_DRAM
|
#ifndef CONFIG_BT_RESERVE_DRAM
|
||||||
|
@@ -349,7 +349,7 @@ SECTIONS
|
|||||||
* safe access to up to 16 bytes after the last real instruction, add
|
* safe access to up to 16 bytes after the last real instruction, add
|
||||||
* dummy bytes to ensure this
|
* dummy bytes to ensure this
|
||||||
*/
|
*/
|
||||||
. += 16;
|
. += _esp_flash_mmap_prefetch_pad_size;
|
||||||
|
|
||||||
_text_end = ABSOLUTE(.);
|
_text_end = ABSOLUTE(.);
|
||||||
_etext = .;
|
_etext = .;
|
||||||
|
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ESP32-C3 Linker Script Memory Layout
|
* ESP32-C3 Linker Script Memory Layout
|
||||||
* This file describes the memory layout (memory blocks) by virtual memory addresses.
|
* This file describes the memory layout (memory blocks) by virtual memory addresses.
|
||||||
@@ -7,6 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
#include "ld.common"
|
||||||
|
|
||||||
#ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
|
#ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
|
||||||
#define ESP_BOOTLOADER_RESERVE_RTC (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE + CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE)
|
#define ESP_BOOTLOADER_RESERVE_RTC (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE + CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE)
|
||||||
|
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
/* Default entry point */
|
/* Default entry point */
|
||||||
ENTRY(call_start_cpu0);
|
ENTRY(call_start_cpu0);
|
||||||
|
|
||||||
@@ -228,7 +234,7 @@ SECTIONS
|
|||||||
* safe access to up to 16 bytes after the last real instruction, add
|
* safe access to up to 16 bytes after the last real instruction, add
|
||||||
* dummy bytes to ensure this
|
* dummy bytes to ensure this
|
||||||
*/
|
*/
|
||||||
. += 16;
|
. += _esp_flash_mmap_prefetch_pad_size;
|
||||||
|
|
||||||
_text_end = ABSOLUTE(.);
|
_text_end = ABSOLUTE(.);
|
||||||
_instruction_reserved_end = ABSOLUTE(.);
|
_instruction_reserved_end = ABSOLUTE(.);
|
||||||
@@ -368,9 +374,9 @@ SECTIONS
|
|||||||
/* Marks the end of IRAM code segment */
|
/* Marks the end of IRAM code segment */
|
||||||
.iram0.text_end (NOLOAD) :
|
.iram0.text_end (NOLOAD) :
|
||||||
{
|
{
|
||||||
/* C3 memprot requires 16B padding for possible CPU prefetch and 512B alignment for PMS split lines */
|
/* ESP32-C3 memprot requires 16B padding for possible CPU prefetch and 512B alignment for PMS split lines */
|
||||||
. += 16;
|
. += _esp_memprot_prefetch_pad_size;
|
||||||
. = ALIGN (0x200);
|
. = ALIGN(_esp_memprot_align_size);
|
||||||
/* iram_end_test section exists for use by memprot unit tests only */
|
/* iram_end_test section exists for use by memprot unit tests only */
|
||||||
*(.iram_end_test)
|
*(.iram_end_test)
|
||||||
_iram_text_end = ABSOLUTE(.);
|
_iram_text_end = ABSOLUTE(.);
|
||||||
|
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ESP32-H2 Linker Script Memory Layout
|
* ESP32-H2 Linker Script Memory Layout
|
||||||
* This file describes the memory layout (memory blocks) by virtual memory addresses.
|
* This file describes the memory layout (memory blocks) by virtual memory addresses.
|
||||||
@@ -7,6 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
#include "ld.common"
|
||||||
|
|
||||||
#ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
|
#ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
|
||||||
#define ESP_BOOTLOADER_RESERVE_RTC (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE + CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE)
|
#define ESP_BOOTLOADER_RESERVE_RTC (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE + CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE)
|
||||||
|
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
/* Default entry point */
|
/* Default entry point */
|
||||||
ENTRY(call_start_cpu0);
|
ENTRY(call_start_cpu0);
|
||||||
|
|
||||||
@@ -365,8 +371,9 @@ SECTIONS
|
|||||||
/* Marks the end of IRAM code segment */
|
/* Marks the end of IRAM code segment */
|
||||||
.iram0.text_end (NOLOAD) :
|
.iram0.text_end (NOLOAD) :
|
||||||
{
|
{
|
||||||
/* C3 memprot requires 512 B alignment for split lines */
|
/* ESP32-H2 memprot requires 16B padding for possible CPU prefetch and 512B alignment for PMS split lines */
|
||||||
. = ALIGN (0x200);
|
. += _esp_memprot_prefetch_pad_size;
|
||||||
|
. = ALIGN(_esp_memprot_align_size);
|
||||||
/* iram_end_test section exists for use by memprot unit tests only */
|
/* iram_end_test section exists for use by memprot unit tests only */
|
||||||
*(.iram_end_test)
|
*(.iram_end_test)
|
||||||
_iram_text_end = ABSOLUTE(.);
|
_iram_text_end = ABSOLUTE(.);
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
Restrict to simple macros with numeric values, and/or #if/#endif blocks.
|
Restrict to simple macros with numeric values, and/or #if/#endif blocks.
|
||||||
*/
|
*/
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
#include "ld.common"
|
||||||
|
|
||||||
#ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
|
#ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
|
||||||
#define ESP_BOOTLOADER_RESERVE_RTC (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE + CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE)
|
#define ESP_BOOTLOADER_RESERVE_RTC (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE + CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE)
|
||||||
|
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
/* Default entry point: */
|
/* Default entry point: */
|
||||||
ENTRY(call_start_cpu0);
|
ENTRY(call_start_cpu0);
|
||||||
|
|
||||||
@@ -177,7 +183,7 @@ SECTIONS
|
|||||||
_coredump_iram_end = 0;
|
_coredump_iram_end = 0;
|
||||||
|
|
||||||
/* align + add 16B for CPU dummy speculative instr. fetch */
|
/* align + add 16B for CPU dummy speculative instr. fetch */
|
||||||
. = ALIGN(4) + 16;
|
. = ALIGN(_esp_memprot_align_size) + _esp_memprot_prefetch_pad_size;
|
||||||
/* iram_end_test section exists for use by memprot unit tests only */
|
/* iram_end_test section exists for use by memprot unit tests only */
|
||||||
*(.iram_end_test)
|
*(.iram_end_test)
|
||||||
_iram_text_end = ABSOLUTE(.);
|
_iram_text_end = ABSOLUTE(.);
|
||||||
@@ -363,7 +369,7 @@ SECTIONS
|
|||||||
* safe access to up to 16 bytes after the last real instruction, add
|
* safe access to up to 16 bytes after the last real instruction, add
|
||||||
* dummy bytes to ensure this
|
* dummy bytes to ensure this
|
||||||
*/
|
*/
|
||||||
. += 16;
|
. += _esp_flash_mmap_prefetch_pad_size;
|
||||||
|
|
||||||
_text_end = ABSOLUTE(.);
|
_text_end = ABSOLUTE(.);
|
||||||
_instruction_reserved_end = ABSOLUTE(.);
|
_instruction_reserved_end = ABSOLUTE(.);
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
#include "ld.common"
|
||||||
|
|
||||||
#ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
|
#ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
|
||||||
#define ESP_BOOTLOADER_RESERVE_RTC (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE + CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE)
|
#define ESP_BOOTLOADER_RESERVE_RTC (CONFIG_BOOTLOADER_RESERVE_RTC_SIZE + CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE)
|
||||||
|
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
/* Default entry point */
|
/* Default entry point */
|
||||||
ENTRY(call_start_cpu0);
|
ENTRY(call_start_cpu0);
|
||||||
|
|
||||||
@@ -264,7 +270,7 @@ SECTIONS
|
|||||||
* safe access to up to 16 bytes after the last real instruction, add
|
* safe access to up to 16 bytes after the last real instruction, add
|
||||||
* dummy bytes to ensure this
|
* dummy bytes to ensure this
|
||||||
*/
|
*/
|
||||||
. += 16;
|
. += _esp_flash_mmap_prefetch_pad_size;
|
||||||
|
|
||||||
_text_end = ABSOLUTE(.);
|
_text_end = ABSOLUTE(.);
|
||||||
_instruction_reserved_end = ABSOLUTE(.);
|
_instruction_reserved_end = ABSOLUTE(.);
|
||||||
@@ -376,7 +382,11 @@ SECTIONS
|
|||||||
/* Marks the end of IRAM code segment */
|
/* Marks the end of IRAM code segment */
|
||||||
.iram0.text_end (NOLOAD) :
|
.iram0.text_end (NOLOAD) :
|
||||||
{
|
{
|
||||||
. = ALIGN (4);
|
/* ESP32-S3 memprot requires 16B padding for possible CPU prefetch and 256B alignment for PMS split lines */
|
||||||
|
. += _esp_memprot_prefetch_pad_size;
|
||||||
|
. = ALIGN(_esp_memprot_align_size);
|
||||||
|
/* iram_end_test section exists for use by memprot unit tests only */
|
||||||
|
*(.iram_end_test)
|
||||||
_iram_text_end = ABSOLUTE(.);
|
_iram_text_end = ABSOLUTE(.);
|
||||||
} > iram0_0_seg
|
} > iram0_0_seg
|
||||||
|
|
||||||
|
@@ -22,7 +22,8 @@ idf_build_get_property(config_dir CONFIG_DIR)
|
|||||||
# Preprocess memory.ld.in linker script to include configuration, becomes memory.ld
|
# Preprocess memory.ld.in linker script to include configuration, becomes memory.ld
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${ld_output}
|
OUTPUT ${ld_output}
|
||||||
COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o ${ld_output} -I ${config_dir} ${ld_input}
|
COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o ${ld_output} -I ${config_dir}
|
||||||
|
-I "${CMAKE_CURRENT_LIST_DIR}" ${ld_input}
|
||||||
MAIN_DEPENDENCY ${ld_input}
|
MAIN_DEPENDENCY ${ld_input}
|
||||||
DEPENDS ${sdkconfig_header}
|
DEPENDS ${sdkconfig_header}
|
||||||
COMMENT "Generating memory.ld linker script..."
|
COMMENT "Generating memory.ld linker script..."
|
||||||
|
24
components/esp_system/ld/ld.common
Normal file
24
components/esp_system/ld/ld.common
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
/* CPU instruction prefetch padding size for flash mmap scenario */
|
||||||
|
_esp_flash_mmap_prefetch_pad_size = 16;
|
||||||
|
|
||||||
|
/* CPU instruction prefetch padding size for memory protection scenario */
|
||||||
|
#ifdef CONFIG_ESP_SYSTEM_MEMPROT_CPU_PREFETCH_PAD_SIZE
|
||||||
|
_esp_memprot_prefetch_pad_size = CONFIG_ESP_SYSTEM_MEMPROT_CPU_PREFETCH_PAD_SIZE;
|
||||||
|
#else
|
||||||
|
_esp_memprot_prefetch_pad_size = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Memory alignment size for PMS */
|
||||||
|
#ifdef CONFIG_ESP_SYSTEM_MEMPROT_MEM_ALIGN_SIZE
|
||||||
|
_esp_memprot_align_size = CONFIG_ESP_SYSTEM_MEMPROT_MEM_ALIGN_SIZE;
|
||||||
|
#else
|
||||||
|
_esp_memprot_align_size = 0;
|
||||||
|
#endif
|
Reference in New Issue
Block a user