[HowTo] Emulating Debian Stretch arm64 on a x86_64 Linux host

Hi @all,

here’s how to emulate a Cortex-A53 cpu for building Leia outside the Vero, mine was built on Linux Mint 18.3

Starting with creating a folder in the home directory

    mkdir Debian_arm64
    cd Debian_arm64

Then getting the netboot-kernel, two parts

wget -O installer-linux http://http.us.debian.org/debian/dists/stretch/main/installer-arm64/current/images/netboot/debian-installer/arm64/linux

wget -O installer-initrd.gz http://http.us.debian.org/debian/dists/stretch/main/installer-arm64/current/images/netboot/debian-installer/arm64/initrd.gz

Installing needed packages

sudo apt install build-essential git qemu-utils g++ zlib1g-dev libglib2.0-dev libpixman-1-dev

We create the qemu repo

cd ..
git clone https://github.com/qemu/qemu.git
cd qemu.git

./configure --prefix=/usr/local --target-list=aarch64-softmmu,aarch64-linux-user 
make
sudo make install

Need to create a disk-image with qcow2, which takes the space just as needed, in my case i’ve choosed 25 GB, but depends on u.

qemu-img create -f qcow2 hda.qcow2 25G

Now we can lauch the installer-kernel:

/home/osmc/qemu.git/aarch64-softmmu/qemu-system-aarch64 -M virt -m 2048 -cpu cortex-a53 -smp 4 \
 -kernel installer-linux \
 -initrd installer-initrd.gz \
 -drive if=none,file=hda.qcow2,format=qcow2,id=hd \
 -device virtio-blk-pci,drive=hd \
 -netdev user,id=mynet \
 -device virtio-net-pci,netdev=mynet \
 -nographic -no-reboot -append "console=ttyAMA0"

Just install as usual, u will come to a point, where it is said that grub couldn’t be installed, just ignore it ;), there is no reboot because we didn’t permit it.

We need the installed kernel and initrd, for this we just mount the image:

modprobe nbd max_part=16
sudo qemu-nbd --connect=/dev/nbd0 hda.qcow2
# mount first partition
sudo mount /dev/nbd0p1 /mnt/hda1

release it:

sudo umount /mnt/hda1
sudo qemu-nbd --disconnect /dev/nbd0

Copying the installed kernel to our folder

sudo cp -f /mnt/hda1/vmlinuz-4.9.0-4-arm64 .
sudo cp -f /mnt/hda1/initrd.img-4.9.0-4-arm64 .
sudo chown osmc:osmc *

We can now run the installed system

/home/osmc/qemu.git/aarch64-softmmu/qemu-system-aarch64 -M virt -smp 4 -m 2048 -cpu cortex-a53 \
  -kernel vmlinuz-4.9.0-4-arm64 \
  -initrd initrd.img-4.9.0-4-arm64 \
  -append 'root=/dev/vda2' \
  -drive if=none,file=hda.qcow2,format=qcow2,id=hd \
  -device virtio-blk-pci,drive=hd \
  -netdev user,id=mynet,hostfwd=tcp::5555-:22 \
  -device virtio-net-pci,netdev=mynet \
  -nographic

SSH-Server is available IP.of.your.host:5555

ssh -p 5555 <whatever>, change port to ur needs

Now u’re ready to compile a nightly for the vero 4k!

Have fun! I did! :wink:

You can install the OSMC repo to sources and install the toolchains this way, eliminating the need for any tar packaging

Hi Sam, thx for the info :wink: , was just a bit confused, the sources are installed already, but that’s not a part of this HowTo! :slight_smile:

cu