Skip to content

Commit

Permalink
xtensa/esp32s3: Simplify board linker script selection
Browse files Browse the repository at this point in the history
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
  • Loading branch information
gustavonihei authored and xiaoxiang781216 committed Dec 8, 2022
1 parent afd9505 commit ca16e9b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 43 deletions.
31 changes: 26 additions & 5 deletions boards/xtensa/esp32s3/common/scripts/protected_memory.ld
@@ -1,12 +1,32 @@
/****************************************************************************
* boards/xtensa/esp32s3/common/scripts/protected_memory.ld
* ESP32-S3 Linker Script Memory Layout
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

/****************************************************************************
* ESP32-S3 Linker Script Memory Layout for Protected Mode
*
* This file describes the memory layout (memory blocks) as virtual
* memory addresses.
*
* kernel-space.ld contains output sections to link compiler output
* into these memory blocks.
* kernel-space.ld and user-space.ld contain output sections to link compiler
* output into these memory blocks for the Kernel and User images,
* respectively.
*
****************************************************************************/

Expand Down Expand Up @@ -52,7 +72,8 @@
MEMORY
{
metadata (RX) : org = 0x0, len = 0x30
ROM (RX) : org = 0x30, len = 0x100000
ROM (RX) : org = ORIGIN(metadata) + LENGTH(metadata),
len = 0x100000 - ORIGIN(ROM)

/* Instruction RAM */

Expand Down Expand Up @@ -89,6 +110,6 @@ MEMORY
*/

KDROM (R) : org = 0x3c000020, len = 0x80000 - 0x20
UDROM (R) : org = 0x3c080030, len = 0x180000 - 0x30
UDROM (R) : org = 0x3c080030, len = 0x180000 - ORIGIN(ROM)
}

26 changes: 7 additions & 19 deletions boards/xtensa/esp32s3/esp32s3-devkit/scripts/Make.defs
Expand Up @@ -23,30 +23,18 @@ include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/tools/esp32s3/Config.mk
include $(TOPDIR)/arch/xtensa/src/lx7/Toolchain.defs

# Pick the linker scripts from the board level if they exist, if not
# pick the common linker scripts.

ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s3_peripherals.ld
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s3_rom.ld

ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s3_memory.ld),)
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s3_memory.ld
else
ifeq ($(CONFIG_BUILD_PROTECTED),y)
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)protected_memory.ld
else
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)flat_memory.ld
endif
endif
# Pick the linker scripts from the board level if they exist, if not
# pick the common linker scripts.

ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s3_sections.ld),)
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s3_sections.ld
ifeq ($(CONFIG_BUILD_PROTECTED),y)
ARCHSCRIPT += $(call FINDSCRIPT,protected_memory.ld)
ARCHSCRIPT += $(call FINDSCRIPT,kernel-space.ld)
else
ifeq ($(CONFIG_BUILD_PROTECTED),y)
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld
else
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s3_sections.ld
endif
ARCHSCRIPT += $(call FINDSCRIPT,flat_memory.ld)
ARCHSCRIPT += $(call FINDSCRIPT,esp32s3_sections.ld)
endif

ifneq ($(CONFIG_DEBUG_NOOPT),y)
Expand Down
26 changes: 7 additions & 19 deletions boards/xtensa/esp32s3/esp32s3-eye/scripts/Make.defs
Expand Up @@ -23,30 +23,18 @@ include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/tools/esp32s3/Config.mk
include $(TOPDIR)/arch/xtensa/src/lx7/Toolchain.defs

# Pick the linker scripts from the board level if they exist, if not
# pick the common linker scripts.

ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s3_peripherals.ld
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s3_rom.ld

ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s3_memory.ld),)
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s3_memory.ld
else
ifeq ($(CONFIG_BUILD_PROTECTED),y)
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)protected_memory.ld
else
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)flat_memory.ld
endif
endif
# Pick the linker scripts from the board level if they exist, if not
# pick the common linker scripts.

ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s3_sections.ld),)
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s3_sections.ld
ifeq ($(CONFIG_BUILD_PROTECTED),y)
ARCHSCRIPT += $(call FINDSCRIPT,protected_memory.ld)
ARCHSCRIPT += $(call FINDSCRIPT,kernel-space.ld)
else
ifeq ($(CONFIG_BUILD_PROTECTED),y)
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld
else
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s3_sections.ld
endif
ARCHSCRIPT += $(call FINDSCRIPT,flat_memory.ld)
ARCHSCRIPT += $(call FINDSCRIPT,esp32s3_sections.ld)
endif

ifneq ($(CONFIG_DEBUG_NOOPT),y)
Expand Down

0 comments on commit ca16e9b

Please sign in to comment.