Annotation of wikisrc/ports/evbarm/qemu_arm.mdwn, revision 1.9

1.1       riz         1: [[!meta title="NetBSD/evbarm under QEMU"]]
                      2: 
1.3       ryoon       3: This page attempts to document running NetBSD/evbarm under the
1.6       ryoon       4: [QEMU](http://www.qemu.org/) open source processor emulator.
1.3       ryoon       5: This can be extremely useful for development and testing.
1.1       riz         6: 
                      7: # Requirements
1.7       wiki        8: * qemu 4.1.0 or higher
                      9: * disk image
                     10:   * [NetBSD 9.x armv7](http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-9/latest/evbarm-earmv7hf/binary/gzimg/armv7.img.gz)
                     11:   * [NetBSD 9.x arm64](http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-9/latest/evbarm-aarch64/binary/gzimg/arm64.img.gz)
                     12: * Tianocore EDK2 firmware
                     13:   * [QEMU_EFI.fd for armv7](http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-ARM/RELEASE_GCC5/QEMU_EFI.fd)
                     14:   * [QEMU_EFI.fd for arm64](http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd)
1.4       ryoon      15: 
1.7       wiki       16: # Installing QEMU on NetBSD
1.4       ryoon      17: You can install latest qemu with the following commands.
                     18: It is assumed that your pkgsrc tree is in /usr/pkgsrc directory.
                     19: 
                     20:     # cd /usr/pkgsrc/emulators/qemu
                     21:     # make install
                     22: 
1.7       wiki       23: # Preparing the disk image
                     24: 
                     25: The disk image (armv7.img.gz or arm64.img.gz) must first be uncompressed. The *qemu-img* tool can then resize the image to the desired size. On first boot, NetBSD will grow the root file-system to match the size of the disk.
                     26: 
                     27:     $ gunzip arm64.img.gz
1.8       wiki       28:     $ qemu-img resize arm64.img 20g
1.7       wiki       29: 
                     30: # Booting the system (arm64)
                     31: 
                     32:     $ qemu-system-aarch64 -M virt -cpu cortex-a53 -smp 4 -m 4g \
                     33:           -drive if=none,file=arm64.img,id=hd0 -device virtio-blk-device,drive=hd0 \
                     34:           -netdev type=user,id=net0 -device virtio-net-device,netdev=net0,mac=00:11:22:33:44:55 \
                     35:           -bios QEMU_EFI.fd -nographic
                     36: 
                     37: # Booting the system (armv7)
                     38: 
                     39:     $ qemu-system-arm -M virt -cpu cortex-a15 -smp 4 -m 2g \
                     40:           -drive if=none,file=armv7.img,id=hd0 -device virtio-blk-device,drive=hd0 \
                     41:           -netdev type=user,id=net0 -device virtio-net-device,netdev=net0,mac=00:11:22:33:44:55 \
                     42:           -bios QEMU_EFI.fd -nographic
                     43: 
1.9     ! wiki       44: # Enabling graphics support
        !            45: To enable graphics support, remove the following command-line argument:
        !            46: 
        !            47:     -nographic
        !            48: 
        !            49: and replace it with:
        !            50: 
        !            51:     -device ramfb -device nec-usb-xhci,id=xhci -device usb-mouse,bus=xhci.0 -device usb-kbd,bus=xhci.0
        !            52: 
1.7       wiki       53: # Bridged networking
                     54: 
                     55: To bridge a QEMU guest to your network, you need to create a tap(4) interface for your VM, then connect it to a physical interface with a bridge(4) interface.
                     56: 
                     57: The following example assumes NetBSD as a host OS, and a physical interface named *bge0*.
1.1       riz        58: 
1.7       wiki       59: [[!template  id=filecontent name="/etc/ifconfig.bridge0" text="""
                     60: descr "LAN VM bridge" up
                     61: !brconfig bridge0 add bge0
                     62: """]]
1.1       riz        63: 
1.7       wiki       64: [[!template  id=filecontent name="/etc/ifconfig.tap0" text="""
                     65: link f2:0b:a4:d1:f2:69 descr "NetBSD Arm64 VM" up
                     66: !brconfig bridge0 add tap0
                     67: """]]
1.1       riz        68: 
1.7       wiki       69: Then replace the *-netdev* part of the qemu command with:
1.2       wiki       70: 
1.7       wiki       71:     -net nic -net tap,ifname=tap0,script=no

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb