How to run baremetal code in RocketChip

160 views
Skip to first unread message

Gabriel Lima Luz

unread,
Feb 29, 2024, 8:30:42 AM2/29/24
to Chipyard
Hi.
I'm trying to run a basic hello world program in The RocketChip.
I have successfully ran the code in the spike simulator but when I run it on the
verilator simulation for the RocketChip nothing seems to happen.
here is the code:
.global _start
.section .text.bios

_start:
addi a0, x0, 0x68
li a1, 0x10000000

sb a0, (a1) # 'h'

addi a0, x0, 0x65
sb a0, (a1) # 'e'

addi a0, x0, 0x6C
sb a0, (a1) # 'l'

addi a0, x0, 0x6C
sb a0, (a1) # 'l'

addi a0, x0, 0x6F
sb a0, (a1) # 'o'

and the .ld file:
MEMORY {
  dram_space (rwx) : ORIGIN = 0x80000000, LENGTH = 128
}

SECTIONS {
  .text : {
    hello.o(.text.bios)
  } > dram_space
}

my goal is to be able to run code in machine mode and access the mhpeventX register and mhpcounters to evaluate branch misdirections and cache misses. if you guys have any orientation on how to do that i would appreciate it

Manchem Chandana Sai Sri ee19b093

unread,
Mar 1, 2024, 1:10:10 AM3/1/24
to Chipyard
Compile your code with the linker file and generate the elf for your baremetal program.
Then you can use this command to run binary on the rocket chip. Do it in the sims/verilator/ folder.
make  CONFIG=RocketConfig run-binary BINARY="path to elf file", you can also get gtkwave dump from using run-binary-debug instead of run-binary.
Reply all
Reply to author
Forward
0 new messages