This emulator parses an ELF file that supports rv32imac/rv64imac and emulate execution environment of it.
The emulator passed riscv-tests shown below.
This emulator can also run self-hosted binaries of cc_sakura, my handmade C compiler.
git clone https://github.com/Alignof/carron.git
cd carron
cargo build --release
$ ./carron --help
carron 1.1.0
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
$ ./carron --pk $RISCV/riscv32-unknown-elf/bin/pk ./HelloWorld
In file HelloWorld
elfcheck: OK
bbl loader
hello world!
$ git clone https://github.com/buildroot/buildroot
$ cd buildroot
$ 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:
$ claude mcp add carron \
-- python -m otcore.mcp_server <graph>