From 1f0cc62a8dddc9217c3b0d515f3c234ac127cb9b Mon Sep 17 00:00:00 2001 From: wangming9 Date: Fri, 5 Jan 2024 21:28:35 +0800 Subject: [PATCH] board/arm/qemu: Adjust the address mapping in the LD script Summary: 1. The start location of FLASH reserves the extended bootloader 2. DTB data is reserved at the start location of RAM Signed-off-by: wangming9 Signed-off-by: lipengfei28 --- .../qemu/qemu-armv7a/configs/knsh/defconfig | 12 +- .../qemu/qemu-armv7a/configs/nsh/defconfig | 12 +- .../qemu/qemu-armv7a/configs/smp/defconfig | 12 +- .../arm/qemu/qemu-armv7a/scripts/dramboot.ld | 125 ++++++++++-------- 4 files changed, 85 insertions(+), 76 deletions(-) diff --git a/boards/arm/qemu/qemu-armv7a/configs/knsh/defconfig b/boards/arm/qemu/qemu-armv7a/configs/knsh/defconfig index 47b8d560c1..b509078d68 100644 --- a/boards/arm/qemu/qemu-armv7a/configs/knsh/defconfig +++ b/boards/arm/qemu/qemu-armv7a/configs/knsh/defconfig @@ -40,9 +40,9 @@ CONFIG_DEV_ZERO=y CONFIG_ELF=y CONFIG_EXAMPLES_HELLO=m CONFIG_EXPERIMENTAL=y -CONFIG_FLASH_SIZE=134217728 -CONFIG_FLASH_START=0 -CONFIG_FLASH_VSTART=0 +CONFIG_FLASH_SIZE=127926272 +CONFIG_FLASH_START=0x00600000 +CONFIG_FLASH_VSTART=0x00600000 CONFIG_FS_HOSTFS=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y @@ -67,9 +67,9 @@ CONFIG_NSH_READLINE=y CONFIG_ONESHOT=y CONFIG_PATH_INITIAL="/system/bin" CONFIG_PREALLOC_TIMERS=4 -CONFIG_RAM_SIZE=536870912 -CONFIG_RAM_START=0x40000000 -CONFIG_RAM_VSTART=0x40000000 +CONFIG_RAM_SIZE=132120576 +CONFIG_RAM_START=0x40200000 +CONFIG_RAM_VSTART=0x40200000 CONFIG_RAW_BINARY=y CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 diff --git a/boards/arm/qemu/qemu-armv7a/configs/nsh/defconfig b/boards/arm/qemu/qemu-armv7a/configs/nsh/defconfig index d88aa91e6c..af9356b454 100644 --- a/boards/arm/qemu/qemu-armv7a/configs/nsh/defconfig +++ b/boards/arm/qemu/qemu-armv7a/configs/nsh/defconfig @@ -27,9 +27,9 @@ CONFIG_DEFAULT_TASK_STACKSIZE=4096 CONFIG_DEV_ZERO=y CONFIG_EXAMPLES_HELLO=y CONFIG_EXPERIMENTAL=y -CONFIG_FLASH_SIZE=134217728 -CONFIG_FLASH_START=0 -CONFIG_FLASH_VSTART=0 +CONFIG_FLASH_SIZE=127926272 +CONFIG_FLASH_START=0x00600000 +CONFIG_FLASH_VSTART=0x00600000 CONFIG_FS_PROCFS=y CONFIG_FS_ROMFS=y CONFIG_HAVE_CXX=y @@ -47,9 +47,9 @@ CONFIG_NSH_READLINE=y CONFIG_ONESHOT=y CONFIG_PREALLOC_TIMERS=4 CONFIG_RAMLOG=y -CONFIG_RAM_SIZE=134217728 -CONFIG_RAM_START=0x40000000 -CONFIG_RAM_VSTART=0x40000000 +CONFIG_RAM_SIZE=132120576 +CONFIG_RAM_START=0x40200000 +CONFIG_RAM_VSTART=0x40200000 CONFIG_RAW_BINARY=y CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 diff --git a/boards/arm/qemu/qemu-armv7a/configs/smp/defconfig b/boards/arm/qemu/qemu-armv7a/configs/smp/defconfig index 0cea4e227e..972ba3ed57 100644 --- a/boards/arm/qemu/qemu-armv7a/configs/smp/defconfig +++ b/boards/arm/qemu/qemu-armv7a/configs/smp/defconfig @@ -24,9 +24,9 @@ CONFIG_DEFAULT_TASK_STACKSIZE=4096 CONFIG_DEV_ZERO=y CONFIG_EXAMPLES_HELLO=y CONFIG_EXPERIMENTAL=y -CONFIG_FLASH_SIZE=134217728 -CONFIG_FLASH_START=0 -CONFIG_FLASH_VSTART=0 +CONFIG_FLASH_SIZE=127926272 +CONFIG_FLASH_START=0x00600000 +CONFIG_FLASH_VSTART=0x00600000 CONFIG_FS_PROCFS=y CONFIG_FS_ROMFS=y CONFIG_HAVE_CXX=y @@ -44,9 +44,9 @@ CONFIG_NSH_READLINE=y CONFIG_ONESHOT=y CONFIG_PREALLOC_TIMERS=4 CONFIG_RAMLOG=y -CONFIG_RAM_SIZE=134217728 -CONFIG_RAM_START=0x40000000 -CONFIG_RAM_VSTART=0x40000000 +CONFIG_RAM_SIZE=132120576 +CONFIG_RAM_START=0x40200000 +CONFIG_RAM_VSTART=0x40200000 CONFIG_RAW_BINARY=y CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 diff --git a/boards/arm/qemu/qemu-armv7a/scripts/dramboot.ld b/boards/arm/qemu/qemu-armv7a/scripts/dramboot.ld index 06079d999b..87cdef71f6 100644 --- a/boards/arm/qemu/qemu-armv7a/scripts/dramboot.ld +++ b/boards/arm/qemu/qemu-armv7a/scripts/dramboot.ld @@ -17,15 +17,20 @@ * under the License. * ****************************************************************************/ + +#include + OUTPUT_ARCH(arm) ENTRY(__start) -PHDRS + +MEMORY { - text PT_LOAD ; + ROM (rx) : ORIGIN = CONFIG_FLASH_START, LENGTH = CONFIG_FLASH_SIZE + RAM (rwx): ORIGIN = CONFIG_RAM_START, LENGTH = CONFIG_RAM_SIZE } + SECTIONS { - . = 0x40101000; /* where the global variable out-of-bounds detection information located */ @@ -43,73 +48,77 @@ SECTIONS #endif .text : { - _stext = .; /* Text section */ - *(.vectors) - *(.text) - *(.text.cold) - *(.text.unlikely) - *(.fixup) - *(.gnu.warning) - } :text + _stext = .; /* Text section */ + __text_start = .; + *(.vectors) + *(.text*) + *(.fixup) + *(.gnu.warning) + } > ROM + . = ALIGN(4096); + .init_section : { - _sinit = ABSOLUTE(.); - KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) - KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o) .ctors)) - _einit = ABSOLUTE(.); - } :text - . = ALIGN(4096); - _etext = .; /* End_1 of .text */ - _sztext = _etext - _stext; + _sinit = ABSOLUTE(.); + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o) .ctors)) + _einit = ABSOLUTE(.); + . = ALIGN(4096); + _etext = .; /* End_1 of .text */ + _sztext = _etext - _stext; + } > ROM + + .ARM.extab : + { + *(.ARM.extab*) + } > ROM + + /* .ARM.exidx is sorted, so has to go in its own output section. */ + + PROVIDE_HIDDEN (__exidx_start = .); + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > ROM + PROVIDE_HIDDEN (__exidx_end = .); + .rodata : { - _srodata = .; /* Read-only data */ - *(.rodata) - *(.rodata.*) - *(.data.rel.ro) - *(.data.rel.ro.*) - } :text - . = ALIGN(4096); - _erodata = .; /* End of read-only data */ - _szrodata = _erodata - _srodata; - _eronly = .; /* End of read-only data */ + _srodata = .; /* Read-only data */ + *(.rodata*) + *(.data.rel.ro*) + KEEP(*(SORT(.scattered_array*))); + . = ALIGN(4096); + _erodata = .; + } > ROM + + _eronly = LOADADDR(.data); .data : { /* Data */ - _sdata = .; - *(.data.page_aligned) - *(.data) - . = ALIGN(8); - __start_impls = .; - *(.impls) - KEEP(*(.impls)) - . = ALIGN(4); - __stop_impls = .; - *(.data.rel) - *(.data.rel.*) - CONSTRUCTORS - } :text - _edata = .; /* End+1 of .data */ + _sdata = .; + *(.data*) + . = ALIGN(8); + _edata = .; + } > RAM AT > ROM + + .noinit : { + _snoinit = ABSOLUTE(.); + *(.noinit*) + _enoinit = ABSOLUTE(.); + } > RAM + .bss : { /* BSS */ _sbss = .; - *(.bss) - . = ALIGN(1 << 3); - } :text - . = ALIGN(4096); - _ebss = .; - _szbss = _ebss - _sbss; - .initstack : { /* INIT STACK */ - _s_initstack = .; - *(.initstack) - . = ALIGN(16); - } :text - . = ALIGN(4096); - _e_initstack = . ; - _szdata = _e_initstack - _sdata; + *(.bss*) + . = ALIGN(4096); + _ebss = .; + } > RAM + /* Sections to be discarded */ /DISCARD/ : { *(.exit.text) *(.exit.data) *(.exitcall.exit) - *(.eh_frame) } + /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) }