feat: modify flash xip lds and add sram and psram lds scripts

This commit is contained in:
maksyuki committed 2025-03-18 16:15:56 +08:00
1 parent 0d85265f0c
commit e33847de6d
4 files changed
+136 -3

No files matched your search

File renamed without changes.
+66
View File
@@ -0,0 +1,66 @@
MEMORY
{
FLASH (rx) : ORIGIN = 0x30000000, LENGTH = 0x1000000 /* entire flash, 16 MiB */
/*FLASH (rx) : ORIGIN = 0x00100000, LENGTH = 0x400000 entire flash, 4 MiB*/
/*RAM (xrw) : ORIGIN = 0x00000000, LENGTH = 0x20000 /* 128KB */
RAM (xrw) : ORIGIN = 0x04000000, LENGTH = 0x800000 /* 8MB */
}
SECTIONS {
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
*(.srodata) /* .rodata sections (constants, strings, etc.) */
*(.srodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
_etext = .; /* define a global symbol at end of code */
_sidata = _etext; /* This is used by the startup in order to initialize the .data secion */
} >FLASH
/* This is the initialized data section
The program executes knowing that the data is in the RAM
but the loader puts the initial values in the FLASH (inidata).
It is one task of the startup to copy the initial values from FLASH to RAM. */
.data : AT ( _sidata )
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
_ram_start = .; /* create a global symbol at ram start for garbage collector */
. = ALIGN(4);
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.sdata) /* .sdata sections */
*(.sdata*) /* .sdata* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
} >RAM
/* Uninitialized data section */
.bss :
{
. = ALIGN(4);
_sbss = .; /* define a global symbol at bss start; used by startup code */
*(.bss)
*(.bss*)
*(.sbss)
*(.sbss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end; used by startup code */
} >RAM
/* this is to define the start of the heap, and make sure we have a minimum size */
.heap :
{
. = ALIGN(4);
_heap_start = .; /* define a global symbol at heap start */
} >RAM
}
+66
View File
@@ -0,0 +1,66 @@
MEMORY
{
FLASH (rx) : ORIGIN = 0x30000000, LENGTH = 0x1000000 /* entire flash, 16 MiB */
/*FLASH (rx) : ORIGIN = 0x00100000, LENGTH = 0x400000 entire flash, 4 MiB*/
/*RAM (xrw) : ORIGIN = 0x00000000, LENGTH = 0x20000 /* 128KB */
RAM (xrw) : ORIGIN = 0x04000000, LENGTH = 0x800000 /* 8MB */
}
SECTIONS {
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
*(.srodata) /* .rodata sections (constants, strings, etc.) */
*(.srodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
_etext = .; /* define a global symbol at end of code */
_sidata = _etext; /* This is used by the startup in order to initialize the .data secion */
} >FLASH
/* This is the initialized data section
The program executes knowing that the data is in the RAM
but the loader puts the initial values in the FLASH (inidata).
It is one task of the startup to copy the initial values from FLASH to RAM. */
.data : AT ( _sidata )
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
_ram_start = .; /* create a global symbol at ram start for garbage collector */
. = ALIGN(4);
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.sdata) /* .sdata sections */
*(.sdata*) /* .sdata* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
} >RAM
/* Uninitialized data section */
.bss :
{
. = ALIGN(4);
_sbss = .; /* define a global symbol at bss start; used by startup code */
*(.bss)
*(.bss*)
*(.sbss)
*(.sbss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end; used by startup code */
} >RAM
/* this is to define the start of the heap, and make sure we have a minimum size */
.heap :
{
. = ALIGN(4);
_heap_start = .; /* define a global symbol at heap start */
} >RAM
}
+4 -3
View File
@@ -1,5 +1,6 @@
# software
FIRMWARE_NAME := retrosoc_fw
EXEC_TYPE := xip
CROSS=riscv32-unknown-elf-
@@ -10,7 +11,7 @@ DUMP = $(CROSS)objdump
CFLAGS := -mabi=ilp32 \
-march=rv32im \
-Wl,-Bstatic,-T,retrosoc_sections.lds,--strip-debug \
-Wl,-Bstatic,-T,flash_$(EXEC_TYPE).lds,--strip-debug \
-ffreestanding \
-nostdlib
@@ -34,14 +35,14 @@ SRC_PATH := $(PRJ_ROOT_PATH)/crt/start.s \
$(PRJ_ROOT_PATH)/crt/src/tinysh.c \
$(PRJ_ROOT_PATH)/crt/src/firmware.c
LDS_PATH := $(PRJ_ROOT_PATH)/crt/sections.lds
LDS_PATH := $(PRJ_ROOT_PATH)/crt/flash_$(EXEC_TYPE).lds
# %.o: %.c %.h $(DEPS)
# $(CROSS)
$(FIRMWARE_NAME).elf:
@mkdir -p .sw_build
cd .sw_build && ($(CP) -P -o retrosoc_sections.lds $(LDS_PATH))
cd .sw_build && ($(CP) -P -o flash_$(EXEC_TYPE).lds $(LDS_PATH))
cd .sw_build && ($(CC) $(CFLAGS) -I$(PRJ_ROOT_PATH)/crt/inc -o $@ $(SRC_PATH))
cd .sw_build && ($(OBJC) -O verilog $@ $(FIRMWARE_NAME).hex)
cd .sw_build && (sed -i 's/@30000000/@00000000/g' $(FIRMWARE_NAME).hex)