From 227f61ac1ccaa88a9fa4e61a43f3d542ce003807 Mon Sep 17 00:00:00 2001 From: YuzukiTsuru Date: Sat, 23 Dec 2023 00:21:49 +0800 Subject: [PATCH] [feat] merge link ld to one file and add arch --- CMakeLists.txt | 22 ++++++++-- link/{link_bin.ld => arm32/link.ld} | 2 +- link/link_elf.ld | 62 ----------------------------- src/drivers/CMakeLists.txt | 4 +- src/drivers/sun8iw20/CMakeLists.txt | 2 + 5 files changed, 25 insertions(+), 67 deletions(-) rename link/{link_bin.ld => arm32/link.ld} (90%) delete mode 100644 link/link_elf.ld create mode 100644 src/drivers/sun8iw20/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c361b52..cff08a17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,9 +84,8 @@ set(CMAKE_SIZE "${CROSS_COMPILE}size") set(CMAKE_MKSUNXI "${PROJECT_SOURCE_DIR}/tools/mksunxi") -set(LINK_SCRIPT_FEL ${CMAKE_SOURCE_DIR}/link/link_elf.ld) -set(LINK_SCRIPT_BIN ${CMAKE_SOURCE_DIR}/link/link_bin.ld) - +set(LINK_SCRIPT_FEL ${PROJECT_BINARY_DIR}/link_elf.ld) +set(LINK_SCRIPT_BIN ${PROJECT_BINARY_DIR}/link_bin.ld) set(CONFIG_ARCH_ARM32 True) set(CONFIG_CHIP_SUN8IW21 True) @@ -95,6 +94,23 @@ add_definitions(-DCONFIG_CHIP_SUN8IW21) if (CONFIG_ARCH_ARM32) set(ARCH_INCLUDE include/arch/arm32) + +set(ARCH_START_ADDRESS "0x00020000") +set(ARCH_SRAM_LENGTH "128K") + +configure_file( + "${PROJECT_SOURCE_DIR}/link/arm32/link.ld" + "${PROJECT_BINARY_DIR}/link_bin.ld" +) + +set(ARCH_START_ADDRESS "0x00028000") +set(ARCH_SRAM_LENGTH "100K") + +configure_file( + "${PROJECT_SOURCE_DIR}/link/arm32/link.ld" + "${PROJECT_BINARY_DIR}/link_elf.ld" +) + endif() include_directories( diff --git a/link/link_bin.ld b/link/arm32/link.ld similarity index 90% rename from link/link_bin.ld rename to link/arm32/link.ld index 713b3026..5f9b22a3 100644 --- a/link/link_bin.ld +++ b/link/arm32/link.ld @@ -7,7 +7,7 @@ SEARCH_DIR(.) /* Memory Spaces Definitions */ MEMORY { - ram (rwx) : ORIGIN = 0x00020000, LENGTH = 128K /* SRAMC. 132K on boot mode, 100K on FEL mode */ + ram (rwx) : ORIGIN = @ARCH_START_ADDRESS@, LENGTH = @ARCH_SRAM_LENGTH@ /* SRAMC. 132K on boot mode, 100K on FEL mode */ } /* The stack size used by the application. NOTE: you need to adjust according to your application. */ diff --git a/link/link_elf.ld b/link/link_elf.ld deleted file mode 100644 index c0d3e1ee..00000000 --- a/link/link_elf.ld +++ /dev/null @@ -1,62 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ - -OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") -OUTPUT_ARCH(arm) -SEARCH_DIR(.) - -/* Memory Spaces Definitions */ -MEMORY -{ - ram (rwx) : ORIGIN = 0x00028000, LENGTH = 100K /* SRAMC. 132K on boot mode, 100K on FEL mode */ -} - -/* The stack size used by the application. NOTE: you need to adjust according to your application. */ -STACK_SIZE = 0x1000; /* 4KB */ - -/* Section Definitions */ -SECTIONS -{ - - .text : - { - . = ALIGN(4); - PROVIDE(__spl_start = .); - *(.text .text.*) - KEEP(*(.note.gnu.build-id)) - . = ALIGN(4); - } > ram - - . = ALIGN(4); - - .ARM.exidx : { - __exidx_start = .; - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - __exidx_end = .; - } > ram - - PROVIDE(__spl_end = .); - PROVIDE(__spl_size = __spl_end - __spl_start); - - /* .bss section which is used for uninitialized data */ - .bss (NOLOAD) : - { - . = ALIGN(4); - _sbss = . ; - *(.bss .bss.*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } > ram - - .stack (NOLOAD): - { - . = ALIGN(8); - /* SRV stack section */ - __stack_srv_start = .; - . += STACK_SIZE; - __stack_srv_end = .; - } > ram - - . = ALIGN(4); - _end = . ; -} diff --git a/src/drivers/CMakeLists.txt b/src/drivers/CMakeLists.txt index 2ea3d3fb..09e014e4 100644 --- a/src/drivers/CMakeLists.txt +++ b/src/drivers/CMakeLists.txt @@ -1,5 +1,7 @@ if (CONFIG_CHIP_SUN8IW21) -add_subdirectory(sun8iw21) + add_subdirectory(sun8iw21) +elseif(CONFIG_CHIP_SUN8IW20) + add_subdirectory(sun8iw20) endif() add_library(drivers-obj OBJECT diff --git a/src/drivers/sun8iw20/CMakeLists.txt b/src/drivers/sun8iw20/CMakeLists.txt new file mode 100644 index 00000000..af38aa76 --- /dev/null +++ b/src/drivers/sun8iw20/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(chip_drivers-obj OBJECT +) \ No newline at end of file