====== Building FreeBSD-MIPS ======
===== General build instructions =====
You will need the proper MACHINE_ARCH that encodes ABI and endian information. Please see the following table for which to select. For 32-bit MIPS platforms (or to run a 32-bit kernel on a 64-bit CPU) use mipsel or mips, while 64-bit MIPS platforms will use mips64el or mips64. The 'el' variety is used for machines with little endian byte order, while big endian byte order is implicit otherwise.
| Byte | ABI |||
| Order | o32 | n32 | n64 |
| Little | mipsel | mipsn32el | mips64el |
| Big | mips | mipsn32 | mips64 |
You will set TARGET to 'mips' below and TARGET_ARCH to the entry from the table above.
Here are a few examples of TARGET_ARCH:
| System | TARGET_ARCH | System endianness and ABI |
| MALTA (gxemul) | mipsel | o32 little endian |
| rt305x | mipsel | o32 little endian |
| AR71xx/AR93xx | mips | o32 big endian |
| Octeon/ERL | mips64 | n64 big endian |
Choose the kernel you want to build and then use something like this script (the omissions are for size or speed of build reasons only):
#!/bin/csh
setenv SRCROOT /home/gonzo/FreeBSD/svn/mips
setenv TARGET mips
setenv TARGET_ARCH mipsel
# not used:
# setenv TARGET_CPUTYPE mips32
setenv KERNCONF MALTA
setenv MAKEOBJDIRPREFIX /home/gonzo/FreeBSD/obj/mips
set NFSROOT=/home/gonzo/FreeBSD/nfsroot
set TFTPBOOT=/tftpboot
# Select some subset: the following used to be good, but now isn't
# set MAKEFLAGS=(-DWITHOUT_CDDL \
# -DWITHOUT_GAMES \
# -DWITHOUT_DOCS \
# -DWITHOUT_ACPI \
# -DWITHOUT_KERBEROS \
# -DWITHOUT_RESCUE \
# -DWITHOUT_MAN \
# -DWITHOUT_PROFILE \
# -DWITHOUT_BSNMP \
# -DWITHOUT_NIS \
# -DWITHOUT_IPX \
# -DWITHOUT_ATM)
cd ${SRCROOT}
make ${MAKEFLAGS} kernel-toolchain
make ${MAKEFLAGS} buildkernel
make ${MAKEFLAGS} DESTDIR=${TFTPBOOT} installkernel
make ${MAKEFLAGS} buildworld
sudo -E make DESTDIR=${NFSROOT} ${MAKEFLAGS} installworld
sudo -E make DESTDIR=${NFSROOT} ${MAKEFLAGS} distribution
===== Boot =====
There is no ready-for-use firmware yet so you'll need either netboot your board and mount root over NFS. Or build disk image for emulator (like gxemul).
==== Netboot ====
* Setup isc-dhcpd and add entry for board (config courtesy of Andrew Thompson)
subnet 192.168.10.0 netmask 255.255.255.0 {
deny unknown-clients;
option routers 192.168.10.1;
option root-path "192.168.10.196:/src/nfsroot";
# tftp server address and kernel path
next-server 192.168.10.196;
filename "kernel";
}
host mips {
hardware ethernet 00:15:6d:c1:28:2e; # the mac address of the board
fixed-address 192.168.10.x; # pick an unused address
}
* Enable tftpd in inetd.conf, modify -s parameter to point to directory with MIPS kernels and restart inetd
tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /src/FreeBSD/tftpboot
* Add $DESTDIR entry to /etc/exports
$DESTDIR -maproot=root -network 192.168.10/24
* Add root fs to $DESTDIR/etc/fstab
192.168.10.196:/src/nfsroot / nfs rw 0 0
* Enable mountd/nfsd (and optionally rpc.statd/rpc.lockd) in /etc/rc.conf and start them
rpcbind_enable="YES"
rpc_statd_enable="YES"
rpc_lockd_enable="YES"
nfs_server_enable="YES"
mountd_enable="YES"
==== GXEmul ====
* Add line for root fs to $DESTDIR/etc/fstab
* Build proper image using makefs tool (sysutils/makefs):
makefs mips.img $DESTDIR
* Boot gxemul (with GXEMUL kernel configuration):
gxemul -E oldtestmips -d i:/path/to/mips.img /path/to/kernel
* Boot gxemul (with Malta kernel configuration):
gxemul -e malta -d i:/path/to/mips.img -C 4Kc /path/to/kernel