Diff for /wikisrc/ports/evbarm/qemu_arm.mdwn between versions 1.6 and 1.7

version 1.6, 2017/07/01 07:24:09 version 1.7, 2019/12/02 22:55:55
Line 4  This page attempts to document running N Line 4  This page attempts to document running N
 [QEMU](http://www.qemu.org/) open source processor emulator.  [QEMU](http://www.qemu.org/) open source processor emulator.
 This can be extremely useful for development and testing.  This can be extremely useful for development and testing.
   
 # Introduction  
 QEMU emulates ARM's Integrator/CP board. You can run NetBSD under it.  
 Older NetBSD had the problem to run under QEMU's emulated Integrator/CP  
 board.  
 Sergio López had created the patch for NetBSD current and had posted  
 to port-arm mailing list in [6 Febrary, 2013](http://mail-index.NetBSD.org/port-arm/2013/02/06/msg001739.html).  
   
 # Requirements  # Requirements
 * pkgsrc/emulators/qemu 1.6.2 and 1.7.0  * qemu 4.1.0 or higher
 * INTEGRATOR_CP kernel of NetBSD/evbearm 6.99.28 or later  * disk image
 (some provious versions should work, but not tested)    * [NetBSD 9.x armv7](http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-9/latest/evbarm-earmv7hf/binary/gzimg/armv7.img.gz)
     * [NetBSD 9.x arm64](http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-9/latest/evbarm-aarch64/binary/gzimg/arm64.img.gz)
   * Tianocore EDK2 firmware
     * [QEMU_EFI.fd for armv7](http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-ARM/RELEASE_GCC5/QEMU_EFI.fd)
     * [QEMU_EFI.fd for arm64](http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd)
   
 ## Preparing QEMU  # Installing QEMU on NetBSD
 You can install latest qemu with the following commands.  You can install latest qemu with the following commands.
 It is assumed that your pkgsrc tree is in /usr/pkgsrc directory.  It is assumed that your pkgsrc tree is in /usr/pkgsrc directory.
   
     # cd /usr/pkgsrc/emulators/qemu      # cd /usr/pkgsrc/emulators/qemu
     # make install      # make install
   
 ## Preparing NetBSD userland and kernel  # Preparing the disk image
 You can create INTEGRATOR_CP kernel, and kernel/userland tarball with  
 the following commands.  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.
 It is assumed that your NetBSD src tree is in /usr/src directory.  
       $ gunzip arm64.img.gz
     $ cd /usr/src      $ qemu-image resize arm64.img 20g
     $ ./build.sh -U -T /usr/tools/evbearm-el -O /usr/obj/evbearm-el \  
       -D /usr/NewWorld/evbearm-el -R /usr/release/evbearm-el \  # Booting the system (arm64)
       -m evbearm release  
     $ ./build.sh -U -T /usr/tools/evbearm-el -O /usr/obj/evbearm-el \      $ qemu-system-aarch64 -M virt -cpu cortex-a53 -smp 4 -m 4g \
       -D /usr/NewWorld/evbearm-el -R /usr/release/evbearm-el \            -drive if=none,file=arm64.img,id=hd0 -device virtio-blk-device,drive=hd0 \
       -m evbearm kernel=INTEGRATOR_CP            -netdev type=user,id=net0 -device virtio-net-device,netdev=net0,mac=00:11:22:33:44:55 \
             -bios QEMU_EFI.fd -nographic
 # Booting  
 INTEGRATOR_CP kernel has no disk drive support.  # Booting the system (armv7)
 You should setup netboot environment.  
       $ qemu-system-arm -M virt -cpu cortex-a15 -smp 4 -m 2g \
 ## Setting up netboot environment            -drive if=none,file=armv7.img,id=hd0 -device virtio-blk-device,drive=hd0 \
 You can use existing NetBSD or other Unix like operating system environment            -netdev type=user,id=net0 -device virtio-net-device,netdev=net0,mac=00:11:22:33:44:55 \
 for host netboot.            -bios QEMU_EFI.fd -nographic
 You can also utilize qemu-system-amd64 or qemu-system-i386 to host  
 netboot.  # Bridged networking
   
 tftp is not needed, kernel is specified in commandline of qemu-system-arm.  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.
 Only NFS root is needed.  
 In detail see [Diskless NetBSD howto's Setting up the NFS server section](http://www.netbsd.org/docs/network/netboot/nfs.html).  The following example assumes NetBSD as a host OS, and a physical interface named *bge0*.
   
   
 # Booting INTEGRATOR_CP kernel  
 You can boot INTEGRATOR_CP kernel with the following commandline.  
 It is assumed that the host machine uses bge0 to connect to your network.  
   
     # ifconfig bridge0 create  
     # brconfig bridge0 add bge0  
     # ifconfig bridge0 up  
     # ifconfig tap0 create  
     # ifconfig tap0 0.0.0.0 up  
     # brconfig bridge0 add tap0  
     $ cp /usr/obj/evbearm-el/sys/arch/evbarm/compile/INTEGRATOR_CP/netbsd.gz.ub .  
     $ qemu-system-arm -M integratorcp -cpu arm1136 -m 512m -kernel netbsd.gz.ub -serial stdio -net nic -net tap,fd=3 3<>/dev/tap0  
   
 # After booted  
 You will get the following boot messages.  
   
     Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,  
         2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014  
         The NetBSD Foundation, Inc.  All rights reserved.  
     Copyright (c) 1982, 1986, 1989, 1991, 1993  
         The Regents of the University of California.  All rights reserved.  
       
     NetBSD 6.99.28 (INTEGRATOR_CP) #0: Sat Jan 11 23:47:15 UTC 2014  
         ryo_on@bismuth.elements.tetera.org:/usr/obj/evbearm-el/sys/arch/evbarm/compile/INTEGRATOR_CP  
     total memory = 255 MB  
     avail memory = 246 MB  
     sysctl_createv: sysctl_create(machine_arch) returned 17  
     timecounter: Timecounters tick every 10.000 msec  
     mainbus0 (root)  
     cpu0 at mainbus0 core 0: ARM1136J-S r1p3 (ARM11J V6J core)  
     cpu0: DC enabled IC enabled WB disabled EABT  
     cpu0: isar: [0]=0x140011 [1]=0x12002111 [2]=0x11231111 [3]=0x1102131, [4]=0x141, [5]=0  
     cpu0: mmfr: [0]=0x1130003 [1]=0x10030302 [2]=0x1222110 [3]=0  
     cpu0: pfr: [0]=0x111 [1]=0x1  
     cpu0: 4KB/32B 4-way L1 Instruction cache  
     cpu0: 64KB/32B 4-way write-through L1 Data cache  
     vfp0 at cpu0: VFP11  
     vfp0: mvfr: [0]=0x11111111 [1]=0  
     ifpga0 at mainbus0: Build 0, Rev A, Manufacturer Unknown, ASB, Little-endian,  
     ifpga0: FPGA unknown, SYSCLK 2.00MHz  
     ifpga0: vendor 0x0000 product 0x0000 (miscellaneous prehistoric)  
     pci_configure_bus done  
     sm0 at ifpga0 addr 0xb8000000 irq 27  
     sm0: SMC91C111, revision 1, buffer size: 8192  
     sm0: MAC address 52:54:00:12:34:56, default media MII (internal PHY)  
     plcom0 at ifpga0 addr 0x6000000 irq 1  
     plcom0: console  
     plcom1 at ifpga0 addr 0x7000000 irq 2  
     plrtc0 at ifpga0 addr 0x5000000  
     pci0 at ifpga0 bus 0  
     pci0: i/o space, memory space enabled  
     timecounter: Timecounter "clockinterrupt" frequency 100 Hz quality 0  
     clock: hz=100 stathz = 100 profhz = 500  
     timecounter: Timecounter "ifpga" frequency 62500 Hz quality 100  
     boot device: <unknown>  
     root device: sm0  
     dump device:   
     file system (default generic):   
     root on sm0  
     nfs_boot: trying DHCP/BOOTP  
     nfs_boot: DHCP next-server: 192.168.81.249  
     nfs_boot: my_domain=elements.tetera.org  
     nfs_boot: my_addr=192.168.81.167  
     nfs_boot: my_mask=255.255.255.0  
     nfs_boot: gateway=192.168.81.1  
     root on 192.168.81.249:/exports/integratorcp  
     root file system type: nfs  
     init path (default /sbin/init):   
     init: trying /sbin/init  
   
   
 You will see many error messages from src/sys/arch/evbarm/ifpga/ifpga_clock.c.  
   
     statclockhandler: Statclock overrun  
   
 After NetBSD is booted, you can setup sm0 network interface with dhcpcd command.  
   
     # dhcpcd sm0  
   
 # Using QEMU to debug the kernel  
  - there is info elsewhere on the wiki about this; maybe adapt to ARM  
    and link?  
   
 # Additional links  [[!template  id=filecontent name="/etc/ifconfig.bridge0" text="""
   descr "LAN VM bridge" up
   !brconfig bridge0 add bge0
   """]]
   
 # What works  [[!template  id=filecontent name="/etc/ifconfig.tap0" text="""
   link f2:0b:a4:d1:f2:69 descr "NetBSD Arm64 VM" up
   !brconfig bridge0 add tap0
   """]]
   
 # What needs work  Then replace the *-netdev* part of the qemu command with:
   
 # more info      -net nic -net tap,ifname=tap0,script=no

Removed from v.1.6  
changed lines
  Added in v.1.7


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