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.

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:

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):

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

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
}

tftp    dgram   udp     wait    root    /usr/libexec/tftpd      tftpd -l -s /src/FreeBSD/tftpboot

$DESTDIR -maproot=root -network 192.168.10/24

192.168.10.196:/src/nfsroot     /       nfs     rw      0       0

rpcbind_enable="YES"
rpc_statd_enable="YES"
rpc_lockd_enable="YES"
nfs_server_enable="YES"
mountd_enable="YES"

GXEmul

makefs mips.img $DESTDIR

gxemul -E oldtestmips -d i:/path/to/mips.img /path/to/kernel

gxemul -e malta -d i:/path/to/mips.img -C 4Kc /path/to/kernel

BuildingMIPS (last edited 2019-09-07T07:48:41+0000 by LorenzoSalvadore)