Not a lot of documentation was found for the SparkFun RED-V board about a good working linker file but this one works great.
Took a lot of trial and error to get it functioning,
/* Specify the architecture */
OUTPUT_ARCH("riscv")
/* Define memory regions */
MEMORY
{
FLASH (rx) : ORIGIN = 0x20010000, LENGTH = 16K
RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 16K
}
/* Entry point of the program */
ENTRY(_start)
/* Define sections */
SECTIONS
{
/* Code and read-only data goes into FLASH */
.text : {
_stext = .;
KEEP(*(.text))
KEEP(*(.text.*))
KEEP(*(.rodata))
KEEP(*(.rodata.*))
_etext = .;
} > FLASH
.gnu_build_id : {
*(.note.gnu.build-id)
} > FLASH
/* Read-write data goes into RAM */
.data : {
_sdata = .;
_data_flash = LOADADDR(.data);
KEEP(*(.data))
KEEP(*(.data.*))
_edata = .;
} > RAM AT> FLASH
/* Uninitialized data goes into RAM */
.bss : {
_sbss = .;
KEEP(*(.bss))
KEEP(*(.bss.*))
KEEP(*(.noinit))
_ebss = .;
} > RAM
/* The stack also goes into RAM */
.stack ORIGIN(RAM) + LENGTH(RAM) - 0x1000 : {
. = . + 0x1000;
_estack = .;
} > RAM
/* Define symbols for the memory boundaries */
_sflash = ORIGIN(FLASH);
_eflash = ORIGIN(FLASH) + LENGTH(FLASH);
_sram = ORIGIN(RAM);
_eram = ORIGIN(RAM) + LENGTH(RAM);
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.