sergeykhbr / riscv_vhdl

Portable RISC-V System-on-Chip implementation: RTL, debugger and simulators
http://sergeykhbr.github.io/riscv_vhdl/
Apache License 2.0
618 stars 102 forks source link

Bare-metal Rocket Chip #1

Closed pbn4 closed 8 years ago

pbn4 commented 8 years ago

Hello,

I was wondering if it is possible to run bare-metal applications with rocketchip? I wanted to simply flash a program written in C without using bootloader and flashing linux image to ROM. If it is not possible please point me to some details (docs, readings etc.) about it.

sergeykhbr commented 8 years ago

Hi, It is possible and that's we're doing with our firmware for Satellite Navigation receiver.

In our case it is a bit simpler to support hardware features because we're writing our FW from the scratch. In a case of linux there're some modifications in kernel will require to support internal timers and interrupts and most probably modes of processors (up to 4 privilege levels: machine ->..-> user). Linux port from the original riscv.org site should simplify this work, I think. The second problem - available memory size to run linux. It can be easily solved on fpga platforms using appropriate ddr phy with AMBA axi controller but it out of my project for now (maybe later).

You need some initial bootup code in any case to reset registers, invalidate caches and initialize stack pointer. After that you can copy your linux image into SRAM or jump to some entry point at once. That's we are actually doing with our firmware before we call main() function placed exactly at 0x10000000 address. See example of our our boot loader in 'fw' folder.