Skip to content

Alignof/carron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

carron

Rust riscv_tests
RV64IMAC emulator in rust

Feature

Carron can run Linux and self-hosted binaries of cc_sakura my handmade C compiler.
This emulator parses an ELF file that supports rv32imac/rv64imac and emulate execution environment of it.

The emulator passed riscv-tests shown below.

  • rv32mi-p
  • rv32si-p
  • rv32ui-p
  • rv32ui-v
  • rv32um-p
  • rv32um-v
  • rv32ua-p
  • rv32ua-v
  • rv32uc-p
  • rv32uc-v
  • rv64mi-p
  • rv64si-p
  • rv64ui-p
  • rv64ui-v
  • rv64um-p
  • rv64um-v
  • rv64ua-p
  • rv64ua-v
  • rv64uc-p
  • rv64uc-v

Install

git clone https://github.com/Alignof/carron.git
cd carron
cargo build --release

Usage

$ ./carron --help
carron 1.1.1
n.takana <Alignof@outlook.com>
RV64IMAC emulator

USAGE:
    carron [OPTIONS] <filename> [main_args]...

ARGS:
    <filename>        ELF file path
    <main_args>...

OPTIONS:
    -e, --elfhead                         Show ELF header
    -p, --program                         Show all segments
    -s, --section                         Show all sections
    -d, --disasem                         Disassemble ELF
    -a, --all                             Show all ELF data
        --pk <proxy_kernel>               Run with proxy kernel
        --pc <init_pc>                    Set entry address as hex
        --break_point <address>           Set break point as hex
        --result_reg <register_number>    Set result register
        --loglv <log_level>               Set log level
    -h, --help                            Print help information
    -V, --version                         Print version information

Hello World

$ ./carron --pk $RISCV/riscv32-unknown-elf/bin/pk ./HelloWorld

In file HelloWorld
elfcheck: OK

bbl loader
hello world!

boot Linux

$ git clone https://github.com/buildroot/buildroot
$ cd buildroot
$ git checkout 9b911c8
$ make spike_riscv64_defconfig
$ make menuconfig # disable F extension
$ make -j $(nproc)
$ ./carron --release -- --kernel /path/to/Image --initrd /path/to/rootfs.cpio /path/to/fw_jump.elf
In file /home/takana/riscv-toolchain/buildroot/output/images/fw_jump.elf
elfcheck: OK


OpenSBI v1.2
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

......

[    0.091080] Freeing unused kernel image (initmem) memory: 2144K
[    0.097300] Run /init as init process
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Saving 256 bits of non-creditable seed for next boot
Starting network: OK

Welcome to Buildroot
buildroot login: