back to the upper level

NetBSD installation into QEMU SPARC

Today, I need a big-endian UNIX computer to test my C code portability. Because I have only an Intel PC in my office, I will use an emulator to create a virtual machine.
Note: indeed, few weeks later, I have found preconfigured Debian 7.0 images for QEMU MIPS and POWERPC. It is easier and quicker.

Configuration

Install qemu

# apt-get install qemu

Download NetBSD files

$ mkdir ~/netbsd-sparc
$ cd ~/netbsd-sparc
$ wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/iso/NetBSD-7.0-sparc.iso

Virtual machine creation

Create a virtual machine and install NetBSD into.
$ cd ~/netbsd-sparc
$ qemu-img create -f raw ./netbsd7_sparc_hda.img 8G
$ qemu-system-sparc -nographic -m 256 -hda ./netbsd7_sparc_hda.img -net nic -net user -cdrom ./NetBSD-7.0-sparc.iso -boot d
Note: At the end of the installation, shutdown the virtual machine and restart it with the following command:
$ qemu-system-sparc -nographic -m 256 -hda ./netbsd7_sparc_hda.img -net nic -net user
Note: Full boot log:
Configuration device id QEMU version 1 machine id 32
Probing SBus slot 0 offset 0
Probing SBus slot 1 offset 0
Probing SBus slot 2 offset 0
Probing SBus slot 3 offset 0
Invalid FCode start byte
No display device located during SBus probe - falling back to internal TCX driver
Probing SBus slot 4 offset 0
Probing SBus slot 5 offset 0
Invalid FCode start byte
CPUs: 1 x FMI,MB86904
UUID: 00000000-0000-0000-0000-000000000000
Welcome to OpenBIOS v1.1 built on Aug 16 2014 09:09
  Type 'help' for detailed information
Trying disk...
Not a bootable ELF image
Loading a.out image...
Loaded 65536 bytes
entry point is 0x4000
bootpath: /iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@0,0
start_adr: 0
num_bytes: 10000000

Jumping to entry point 00004000 for type 00000005...
switching to new context:
>> NetBSD/sparc Secondary Boot, Revision 1.15
Booting netbsd
4500096+147192 [272448+263376]=0x4f1c5c
OBP version 3, revision 2.25 (plugin rev 2)
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
    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 7.0 (GENERIC.201509250726Z)
total memory = 239 MB
avail memory = 230 MB
kern.module.path=/stand/sparc/7.0/modules
bootpath: /iommu@0,10000000/sbus@0,10001000/espdma@5,8400000/esp@5,8800000/sd@0,0
mainbus0 (root): SUNW,SPARCstation-5: hostid 80123456
cpu0 at mainbus0: MB86904 @ 170 MHz, MB86910 or WTL1164/5 FPU
cpu0: 16K instruction (32 b/l), 8K data (16 b/l), 512K external (32 b/l): cache enabled
obio0 at mainbus0
clock0 at obio0 slot 0 offset 0x200000: mk48t08
timer0 at obio0 slot 0 offset 0xd00000: delay constant 230, frequency = 2000000 Hz
timer: limit 0 shift 9 mask 3fffff
zs0 at obio0 slot 0 offset 0x100000 level 12 softpri 6
zstty0 at zs0 channel 0 (console i/o)
zstty1 at zs0 channel 1
zs1 at obio0 slot 0 offset 0x0 level 12 softpri 6
zstty4 at zs1 channel 0
kbd0 at zstty4
zstty5 at zs1 channel 1
ms0 at zstty5
wsmouse0 at ms0 mux 0
fdc0 at obio0 slot 0 offset 0x400000 level 11: no drives attached
auxreg0 at obio0 slot 0 offset 0x900000
power0 at obio0 slot 0 offset 0x910000 level 2
slavioconfig at obio0 slot 0 offset 0x800000 not configured
iommu0 at mainbus0 addr 0x10000000: version 0x5/0x0, page-size 4096, range 64MB
sbus0 at iommu0: clock = 21.250 MHz
dma0 at sbus0 slot 5 offset 0x8400000: DMA rev 2
esp0 at dma0 slot 5 offset 0x8800000 level 4: ESP200, 40MHz, SCSI ID 7
scsibus0 at esp0: 8 targets, 8 luns per target
ledma0 at sbus0 slot 5 offset 0x8400010: DMA rev 2
le0 at ledma0 slot 5 offset 0x8c00000 level 6: address 52:54:00:12:34:56
le0: 8 receive buffers, 2 transmit buffers
tcx0 at sbus0 slot 3 offset 0x800000 level 5 (ipl 9) (8-bit only TCX)
tcx0: SUNW,tcx, 1024 x 768

tcx0: STIP register too small (0x1)
audiocs0 at sbus0 slot 4 offset 0xc000000 level 5 (ipl 9): CS4231A
audio0 at audiocs0: full duplex, playback, capture
power-management at sbus0 slot 4 offset 0xa000000 not configured
scsibus0: waiting 2 seconds for devices to settle...
wskbd0 at kbd0 mux 1
sd0 at scsibus0 target 0 lun 0:  disk fixed
sd0: 8192 MB, 16383 cyl, 16 head, 64 sec, 512 bytes/sect x 16777216 sectors
cd0 at scsibus0 target 2 lun 0:  cdrom removable
kbd0: reset failed
root on sd0a dumps on sd0b
root file system type: ffs
Mon Oct 12 11:17:49 UTC 2015
Starting root file system check:
/dev/rsd0a: file system is clean; not checking
swapctl: setting dump device to /dev/sd0b
swapctl: adding /dev/sd0b as swap device at priority 0
Starting file system checks:
esp0: !TC on DATA XFER [intr 18, stat 82, step 4] prevphase 2, resid 0
Loaded entropy from /var/db/entropy-file.
Setting tty flags.
Setting sysctl variables:
ddb.onpanic: 1 -> 0
Starting network.
/etc/rc: WARNING: $hostname not set.
IPv6 mode: host
Configuring network interfaces:.
Adding interface aliases:.
Waiting for DAD completion for statically configured addresses...
Building databases: dev, utmp, utmpx, services.
Starting syslogd.
Mounting all file systems...
Clearing temporary files.
Creating a.out runtime link editor directory cache.
Checking quotas: done.
Setting securelevel: kern.securelevel: 0 -> 1
swapctl: setting dump device to /dev/sd0b
Starting virecover.
Checking for core dump...
savecore: no core dump
Starting local daemons:.
Updating motd.
/usr/sbin/postconf: warning: valid_hostname: empty hostname
/usr/sbin/postconf: fatal: unable to use my own hostname
Oct 12 11:18:13  postfix[1425]: fatal: unable to use my own hostname
/etc/rc.d/postfix exited with code 1
Starting inetd.
Starting cron.
The following components reported failures:
    /etc/rc.d/postfix
See /var/run/rc.log for more information.
Mon Oct 12 11:18:16 UTC 2015

NetBSD/sparc (Amnesiac) (console)

login:

First login

Now you can login as root.
login: root
Oct 12 11:19:04  login: ROOT LOGIN (root) on tty console
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
    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 7.0 (GENERIC.201509250726Z)

Welcome to NetBSD!

Terminal type is wsvt25.
We recommend that you create a non-root account and use su(1) for root access.
# echo dhclient=YES >> /etc/rc.local
# echo sshd=YES >> /etc/rc.local
# echo hostname=netbsd-sparc >> /etc/rc.local
# reboot

Bridge network

Now we will configure a bridge network to allow SSH login from the computer host.
Install and configure bridge-utils on the Linux host
# apt-get install bridge-utils
# /usr/sbin/brctl addbr br0
# /sbin/ifconfig eth0 0.0.0.0 promisc up
# /usr/sbin/brctl addif br0 eth0
# /sbin/dhclient br0
# /sbin/iptables -F FORWARD
Create a qemu-ifup file
# cat ./qemu-ifup
#!/bin/sh
/sbin/ifconfig $1 0.0.0.0 promisc up
/usr/sbin/brctl addif br0 $1
Give execution privilege
# chmod +x ./qemu-ifup
Start qemu as root
# qemu-system-sparc -hda ./netbsd7_sparc_hda.img -m 256 -nographic -net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=./qemu-ifup
Now enjoy your SPARC computer running NetBSD 7.0 !
Updated on Oct 12th, 2015 by Sebastien BLANCHET