2020年7月11日星期六

Setup Qemu aarch64 emulation board

This is a note to drop down those steps involving to setup Qemu environment for Aarch64 emulation. We are performing the tasks on Ubuntu 18.04.1:

(base) user@user-RF511-RF411-RF711:~$ uname -a
Linux user-RF511-RF411-RF711 5.3.0-61-generic #55~18.04.1-Ubuntu SMP Mon Jun 22 16:40:20 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

1.) install Qemu
a.) apt-get install qemu
- find out the command location 
b.)  which qemu-system-aarch64
/usr/local/bin/qemu-system-aarch64

2.) download linux kernel source & decompress (from:https://www.kernel.org/)
a.) wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.7.8.tar.xz
b.) tar -xz linux-5.7.8.tar.xz

3.) install aarch64-linux-gnu-gcc
a.) sudo apt-get install gcc-aarch64-linux-gnu

4.) compile kernel as arm64 aarch64
a.) make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
b.) make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image -j8
the image is located @ "./arch/arm64/boot/Image"

5.) download BusyBox : for making a minimal bundle of basic linux applications (i.e. applets) in a single binary. (https://busybox.net/downloads/BusyBox.html)
a.) wget https://busybox.net/downloads/busybox-1.32.0.tar.bz2
b.) tar -jxvf busybox-1.32.0.tar.bz2

6.) configure/install cross compiler toolchain & build statis busybox binary
a.) cd busybox-1.32.0
b.) make menuconfig
---- change the followings in "Settings" ----
- - Settings
[*] Build static binary (no shared libs)
(aarch64-linux-gnu-) Cross compiler prefix
c.) make
d.) make install

7.) use file system to create console
cd _install
mkdir dev
cd dev
sudo mknod console c 5 1
sudo mknod null c 1 3 

8.) compress and patch a filesystem file
find . | cpio -o -H newc |gzip > ../rootfs.cpio.gz



9.) create qemu.sh bash script for env. startup
$ cat qemu.sh
qemu-system-aarch64 \
        -machine virt,virtualization=true,gic-version=3 \
        -nographic \
        -m size=1024M \
        -cpu cortex-a57 \
        -smp 2 \
        -kernel Image \
        -initrd rootfs.cpio.gz \
        --append "console=ttyAMA0 rdinit=/linuxrc"
10.) put Image, rootfs.cpio.gz, qemu.sh in the same folder
11.) RUN QEMU
sh qemu.sh

DADA!!! FINISH!!



沒有留言: