Building linux kernel for gem5 FS mode

So, this tutorial assumes that we are building the linux kernel 3.x for ARM architecture (aarch64)

Dependencies and Source files

Kernel source

1. Kernel source: 
    `git clone https://gem5.googlesource.com/arm/linux-arm64-legacy`
2. Version tags:
    ```shell
    (cd linux-arm64-legacy && f=`git rev-parse --git-dir`/hooks/commit-msg ; curl -Lo $f https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; chmod +x $f)
    ```
3. What I did:
    `git checkout -b hegi`

Tools to build kernel

I presume you have qemu installed with aarch64-static. 1. gcc-4.8: this version of kernel is old so it needs old gcc which is silly, but that’s the only way I got it to work. No idea to what date this package would be supported: sudo apt-get install gcc-4.8-aarch64-linux-gnu 2. Switch to aarch64-gnu-gcc-4.8 by modifying the soft link. Samething applies for cpp and nm-gcc (we have a shell script that does this)

Building the kernel

This step is pretty easy if all configurations are well made.

Make Config

From within the kernel directory run:

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- gem5_defconfig

Build thy kernel

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j 4

location of this readme: /mnt/ftpw/ftpw/docker/ufs/home/shashank/project/ARM_LINUX/kernel_sandbox