Skip to content

Commit

Permalink
cpu/riscv_common: Jump to rom start on boot
Browse files Browse the repository at this point in the history
With this the riscv start code jumps to the ROM start on boot when the
ROM area doesn't start at address 0x0.
  • Loading branch information
bergzand committed Aug 24, 2021
1 parent 285d20b commit c1d81cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cpu/riscv_common/Makefile.include
Expand Up @@ -21,6 +21,8 @@ ifneq (,$(ITIM_START_ADDR))
LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_itim_length=$(ITIM_LEN)
endif

CFLAGS += -DROM_START_ADDR=$(ROM_START_ADDR)

LINKER_SCRIPT ?= riscv.ld

include $(RIOTMAKE)/arch/riscv.inc.mk
14 changes: 13 additions & 1 deletion cpu/riscv_common/start.S
Expand Up @@ -5,7 +5,10 @@
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
.section .init
#include "vendor/riscv_csr.h"

.section .init

.globl _start
.type _start,@function

Expand All @@ -14,6 +17,15 @@ _start:
.cfi_undefined ra
.option push
.option norelax
csrc CSR_MSTATUS, MSTATUS_MIE
la a0, _start
li a1, ROM_START_ADDR
bleu a1, a0, _start_real
la a0, _start_real
add a0, a0, a1
jr a0

_start_real:
la gp, __global_pointer$
.option pop
la sp, _sp
Expand Down

0 comments on commit c1d81cf

Please sign in to comment.