Subject: How to crosscompile and run NetBSD-current on your Dreamcast
To: None <port-dreamcast@netbsd.org>
From: Harold Gutch <logix@foobar.franken.de>
List: port-dreamcast
Date: 08/28/2002 01:41:48
Hi,
since I haven't really seen any step-by-step documentation on how
to build NetBSD for the Dreamcast (and run it), I thought, I'd
write down the steps that I took. Not all of it may apply to
you, but I hope that at least some people will find at least
parts of this helpful.
To Marcus (or anybody else with the appropriate rights):
I could bring the following into a readable HTML-form (but
frankly, if somebody else is willing to do so, I'll let him do
that :) ) if you want to add it to the main Dreamcast-port
webpage.
Requirements:
A) for the build:
NetBSD-current sourcetree
B) a Dreamcast and an ethernet-card for the Dreamcast (I used a
LAN-adapter, but a BBA should work fine as well).
A cd-burner and (at least) one blank :).
C) a machine running nfsd.
First I started by creating a "boot-cd", a CD that basically only
contained the "dcload" tool. I already created this CD half a
year ago, and I don't remember all steps I took, but basically
you get dcload-ip (with the LAN-adapter patch, if you have a
LAN-adapter) from
http://adk.napalm-x.com/dc/dcload-ip/ ,
compile that, and burn the way Marcus describes on
http://mc.pp.se/dc/cdr.html .
These steps should work more or less straight-forward. You can
test the CD by booting from it. The screen should turn black and
you should get some counters in the upper left corner of your TV
with your ethernet card's MAC-address and two counters (both at 0
right now).
Now to the NetBSD-part. If you want to use a LAN-adapter, get
Christian Roesslers patches (see PR port-dreamcast/17493). You
will also need the patches from PR kern/17193. Then do the
following:
1) edit /usr/src/libexec/ftpd/Makefile and remove "logtmp.c" and
"logutmp.c" from the line starting with "SRCS=".
2) edit /usr/src/distrib/sets/lists/base/mi and remove the two
lines starting with "./rescue/fdisk" and "./rescue/ldconfig".
3) cd /usr/src
4) ./build.sh -m dreamcast -t
This will build the toolchain required to compile NetBSD
(compilers and binutils).
5) ./build.sh -m dreamcast -d -D /usr/dreamcast
This will build a full NetBSD-distribution to /usr/dreamcast -
replace this path with whatever you think is appropriate.
6) Prepend the directory your toolchain-binaries reside in to
your $PATH environment variable. This would look something
like the following:
setenv PATH /usr/src/tools/obj.dreamcast/tools.NetBSD-1.6F-i386/bin:$PATH
(if you use a csh-alike shell, like csh or tcsh) - or:
export PATH=/usr/src/tools/obj.dreamcast/tools.NetBSD-1.6F-i386/bin:$PATH
(if you use a bourne shell alike shell, like bash).
7) cd /sys/arch/dreamcast/conf
8) nbconfig DREAMS.LANA if you have a LAN-adapter
nbconfig GENERIC if you have a BBA
9) cd ../compile/DREAMS.LANA if you have a LAN-adapter
cd ../compile/GENERIC if you have a BBA
10) nbmake-dreamcast depend && nbmake-dreamcast
11) shle--netbsdelf-objcopy -O binary netbsd netbsd-binary
You now have a complete NetBSD userland for the dreamcast, an ELF
kernel, and a kernel in binary format (which the dreamcast can
run).
Now for the setup on your NFS-server. For security reasons I
recommend hosting the Dreamcast userland in a dedicated
filesystem. I accomplished this without adding a new disk to the
NFS-server by using NetBSD's vnode-devices. If you want to do
the same, you will need a line saying
pseudo-device vnd 1
in your kernel (and recompile and install it). The GENERIC
kernel already supports this. First of all, we will create a
dummy-file. The Dreamcast-userland needs a little less than
300MB space, so a 350MB filesystem will give us a little room to
play around with:
# dd if=/dev/zero of=/usr/dreamcast-filesystem bs=1k count=350k
# vnconfig /dev/vnd0 /usr/dreamcast-filesystem
# disklabel -e -I /dev/vnd0
My partitiontable looks like this:
c: 716800 0 4.2BSD 1024 8192 44 # (Cyl. 0 - 349)
d: 716800 0 4.2BSD 0 0 0 # (Cyl. 0 - 349)
# mount /dev/vnd0d /mnt
From now on I assume that the NFS-server has the IP-address
192.168.1.1 and the Dreamcast will get the IP-address
192.168.1.2. Change those to whatever addresses you want to use.
Now copy your complete distribution you created before to /mnt
and add the following line to /etc/exports:
/mnt/vnode -maproot=root:wheel 192.168.1.2
Create the file /etc/dhcpd.conf with the following content:
ddns-update-style none;
subnet 192.168.1.0 netmask 255.255.255.0 {
}
host dreamcast {
hardware ethernet 00:11:22:33:44:55;
fixed-address 192.168.1.2;
option root-path "/mnt/vnode";
}
replacing the MAC-address above with yours.
Create the file /mnt/vnode/etc/ifconfig.lana0 (or ifconfig.rtk0
if you are using a BBA) with the following line:
inet 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255
Create the file /mnt/vnode/etc/fstab with the following line:
192.168.1.1:/mnt/vnode / nfs rw 0 0
Add the following to /mnt/vnode/etc/rc.conf:
nfs_client=YES
auto_ifconfig=NO
rc_configured=YES
sshd=YES
Now allow yourself to login as root by copying your SSH public
key to /mnt/vnode/root/.ssh/authorized_keys and setting
PermitRootLogin yes
in /mnt/vnode/etc/ssh/sshd_config .
Finally use dc-tool from the dcload-package to send your binary
kernel to the dreamcast:
1) arp -s 192.168.1.2 11:22:33:44:55
(replacing the ethernet-address again with the MAC-address of
your LAN-adapter or BBA).
2) cd /sys/arch/dreamcast/compile/DREAMS.LANA if you have a LAN-adapter
cd /sys/arch/dreamcast/compile/GENERIC if you have a BBA
3) dc-tool -x netbsd-binary -t 192.168.1.2
You Dreamcast should now boot the kernel, request an IP-address
via DHCP, and boot. You can then login via SSH with your
RSA-key, add a normal user, add him to group wheel, and set a
root-password (and then set "PermitRootLogin" back to "no" in
/etc/ssh/sshd_config.
bye,
Harold