FreeBSD/aarch64 in Gem5 simulator

The gem5 simulator is a modular platform for computer system architecture research, encompassing system-level architecture as well as processor microarchitecture.

Build instructions

0. Preparation

$ export WORKDIR=~/gem5-test
$ mkdir $WORKDIR
$ git clone
$ git clone
$ svnlite co

1. Build Gem5 Simulator System

$ cd $WORKDIR/gem5
$ export SWIG=/usr/local/bin/swig2.0
$ export CXX=c++
# use -j <n> as appropriate for your machine
$ scons -j 16 build/ARM/gem5.opt
$ gmake -C util/term

2. Build FreeBSD

$ cd $WORKDIR/head
$ cat $WORKDIR/aarch64-tools/gem5/freebsd_gem5.patch | patch -p0
$ sh $WORKDIR/aarch64-tools/ $WORKDIR/head

$ mkdir $WORKDIR/gem5/binaries $WORKDIR/gem5/disks
$ ln -s $WORKDIR/aarch64-tools/gem5/aarch64_gem5.dtb $WORKDIR/gem5/binaries/
$ ln -s $WORKDIR/aarch64-tools/gem5/boot_emm.arm64 $WORKDIR/gem5/binaries/
$ ln -s ~/arm64-workspace/obj/arm64.aarch64/usr/home/$USER/gem5-test/head/sys/GENERIC/kernel $WORKDIR/gem5/binaries/
$ ln -s ~/arm64-workspace/rootfs/disk.img $WORKDIR/gem5/disks/

Running in Full System mode

$ cd $WORKDIR/gem5
$ export M5_PATH=$WORKDIR/gem5
$ ./build/ARM/gem5.opt --debug-flags=-Exec configs/example/ --kernel=kernel --machine-type=VExpress_EMM64 --dtb-file=aarch64_gem5.dtb --disk-image=disk.img --mem-size=256MB
$ (from another console) ./util/term/m5term 3456

Running in Syscall Emulation mode

$ cd $WORKDIR/gem5
$ export M5_PATH=$WORKDIR/gem5
$ ./build/ARM/gem5.opt --debug-flags=-Loader,-Exec,-Faults,-SyscallVerbose,-TLBVerbose configs/example/ -c your_app

Known problems

  1. Simulation speed is slow. It takes ~1 hour to boot freebsd in FS mode
  2. UART driver needs to be fixed


gem5 (last edited 2022-02-10T03:12:06+0000 by KubilayKocak)