11-26-2019, 12:16 PM
You are loading your code into a physical address that is not writable. If you want to run bare-metal applications you should fix your binary to start at 0x8000000 or higher (DRAM range). The easiest way to do that is by providing a linker file (linker.lds) to the linker:
The linker file could look like the file in fpga/src/bootrom/linker.lds:
Code:
riscv64-unknown-elf-gcc main.c -Tlinker.lds -o main.o
The linker file could look like the file in fpga/src/bootrom/linker.lds:
Code:
ENTRY(main)
SECTIONS
{
// I changed this to the DRAM start addr (0x80000000)
ROM_BASE = 0x80000000; /* ... but actually position independent */
. = ROM_BASE;
.text.init : { *(.text.init) }
.text : ALIGN(0x100) {
_TEXT_START_ = .;
*(.text)
_TEXT_END_ = .;
}
.data : ALIGN(0x100) {
_DATA_START_ = .;
*(.data)
_DATA_END_ = .;
}
PROVIDE(_data = ADDR(.data));
PROVIDE(_data_lma = LOADADDR(.data));
PROVIDE(_edata = .);
.bss : ALIGN(0x100) {
_BSS_START_ = .;
*(.bss)
_BSS_END_ = .;
}
.rodata : ALIGN(0x100) {
_RODATA_START_ = .;
*(.rodata)
*(.dtb*)
*(.rodata*)
_RODATA_END_ = .;
}
}