Installing OS/161 On Your Own Machine

The following instructions describe how to install OS/161 on machines that are outside of the student.cs computing environment. If you are trying to install OS/161 in the student.cs computing environment, there is another set of instructions for doing so. These instructions assume that the target machine is running Linux.

For marking purposes, your code will be compiled and executed in the CSCF undergraduate (student.cs) environment. You are responsible for ensuring that your code runs there.

Getting OS/161 and related tools running on your Linux machine should not be too difficult. However, this is not a guarantee - there are too many variables beyond our control. Ensuring that OS/161 runs in the student.cs environment is our responsibility. Getting it running on your machine is yours. The course newsgroup may be a good place to turn if you are stuck.

Setting up OS/161 on your own machine is more involved than setting it up in your account in the student.cs environment. In the student.cs enviroment, both the sys/161 simulator (on which OS/161 runs) and the associated toolchain (compiler, debugger, binary utilities) are set up in the CS350 course account and can be used from there. To run OS/161 on your home machine, you will need to download and build your own copies of the simulator and the toolchain before you can work with OS/161.

Step 0: Please be aware of the FAQ

If things go wrong please have a look at the FAQ for answers and solutions. In particular most systems require the installation of additional software and/or libraries. This will vary by Linux distro and/or Mac OS X version and we'll try to collect information in the FAQ.
OS161 and Toolchain FAQ

Step 1: Download

Start by downloading the necessary files, which are described in the following table:
What Download Link Approx. Download Size (MB) Approx. Unpacked Size (MB)
Binutils for MIPS os161-binutils.tar.gz 18 113
GCC MIPS Cross-Compiler os161-gcc.tar.gz 23 95
GDB for Use with OS/161 os161-gdb.tar.gz 20 116
sys/161 sys161.tar.gz 0.1 2
OS/161 os161.tar.gz 0.3 3



Step 2: Build and Install the Binary Utilities (Binutils)

Unpack the binutils archive:
tar -xzf os161-binutils.tar.gz
Move into the newly-created directory:
cd binutils-2.17+os161-2.0.1
Configure binutils
./configure --nfp --disable-werror --target=mips-harvard-os161 --prefix=$HOME/sys161/tools
Make binutils:
make
If the make command fails because of a problem related to makeinfo, try running the following command:
find . -name '*.info' | xargs touch
and then re-run make
Finally, once make has succeeded, install the binutils into their final location:
make install
This will create the directory $HOME/sys161/tools/ and populate it.

Step 3: Adjust Your Shell's Command Path

First, make the directory in which your shell will eventually find the toolchain binaries:
mkdir $HOME/sys161/bin
Next, add two directories ($HOME/sys161/bin and $HOME/sys161/tools/bin) to your shell's search path. Users of bash or sh should do something like this in your .bashrc or .profile file in uour home directory.
NOTE: on Linux it looks like this may need to be .bashrc for bash. For some reason .profile doesn't seem to work for sh so you might need to use bash.

export PATH=$HOME/sys161/bin:$HOME/sys161/tools/bin:$PATH
while users of csh or tcsh would typically use .cshrc (in your home directory)
setenv PATH $HOME/sys161/bin:$HOME/sys161/tools/bin:${PATH}

Note that setting these variables only works in the shell or window you issue the above commands in. You will need to ensure that the proper path is set and used for future logins and for other newly created shells.
A bit more information about setting up your shell.

Note that you may need to log out and log back in again so that this PATH change will take effect. You can check the current setting of the PATH environment variable using the command

printenv PATH

Step 4: Install the GCC MIPS Cross-Compiler

Unpack the gcc archive:
tar -xzf os161-gcc.tar.gz
Move into the newly-created directory:
cd gcc-4.1.2+os161-2.0
Configure gcc
./configure -nfp --disable-shared --disable-threads --disable-libmudflap --disable-libssp --target=mips-harvard-os161 --prefix=$HOME/sys161/tools
Make it and install it:
make
make install

Step 5: Install GDB

Unpack the gdb archive:
tar -xzf os161-gdb.tar.gz
Move into the newly-created directory:
cd gdb-6.6+os161-2.0
Configure gcc
./configure --target=mips-harvard-os161 --prefix=$HOME/sys161/tools
Make it and install it:
make

[NOTE: if the make above fails you could try disabling werror and rebuilding]
make clean
./configure --target=mips-harvard-os161 --prefix=$HOME/sys161/tools --disable-werror
make
make install

Step 6: Build and Install the sys161 Simulator

Unpack the sys161 archive:
tar -xzf sys161.tar.gz
Move into the newly-created directory:
cd sys161-1.99.05
Next, configure sys161:
./configure --prefix=$HOME/sys161 mipseb
Build sys161 and install it:
make
make install

Step 7: Set Up Links for Toolchain Binaries

cd $HOME/sys161/tools/bin
sh -c 'for i in mips-*; do ln -s ../tools/bin/$i ~/sys161/bin/cs350-`echo $i | cut -d- -f4-`; done'
cd $HOME/sys161
ln -s share/examples/sys161/sys161.conf.sample sys161.conf

When you are finished with these steps, a listing of the directory $HOME/sys161/bin should look similar to this:

cs350-addr2line@  cs350-gcc-4.1.2@  cs350-nm@       cs350-size@      stat161-1.99.05*
cs350-ar@         cs350-gccbug@     cs350-objcopy@  cs350-strings@   sys161@
cs350-as@         cs350-gcov@       cs350-objdump@  cs350-strip@     sys161-1.99.05*
cs350-c++filt@    cs350-gdb@        cs350-ranlib@   hub161@          trace161@
cs350-cpp@        cs350-gdbtui@     cs350-readelf@  hub161-1.99.05*  trace161-1.99.05*
cs350-gcc@        cs350-ld@         cs350-run@      stat161@
These are all of the tools you will need to work with sys161.

Step 8: Install OS/161

First, create a directory to hold the OS/161 source code, your compiled OS/161 kernels, and related test programs.
cd $HOME
mkdir cs350-os161

Next, move the OS/161 archive into your new directory and unpack it:
mv os161.tar.gz cs350-os161
cd cs350-os161
tar -xzf os161.tar.gz

This will create a directory called os161-1.11 (under cs350-os161) containing the OS/161 source code. You should now be able build, install, and run an OS/161 kernel and related application and test programs by following steps similar to those used to install OS/161 in the student.cs computing environment, starting with the step "Configure and Build OS/161".

Step 9: Cleanup (optional)

Once you have completed the above steps, your OS/161-related development tools (binutils, gcc, gdb) and the sys/161 simulator will be installed under $HOME/sys161, and OS/161 itself will be installed under $HOME/cs350-os161. The archive files (filenames ending in .tar.gz) that you downloaded in Step 1 are no longer needed, so feel free to remove them if you want to save space or reduce clutter. You can also remove the directories in which you unpacked the archives and built the software: binutils-2.17+os161-2.0.1, gcc-4.1.2+os161-2.0, gdb-6.6+os161-2.0 and sys161-1.99.05. However, do not delete the OS/161 source code (under $HOME/cs350-os161/os161-1.11), since you will be making use of it for your assignments.

Optionally, you may also remove the directory $HOME/sys161/tools/bin from your shell command path, as it is needed only during the process of building the toolchain. However, you be sure to leave $HOME/sys161/bin in your path, as that is the home of the toolchain binaries that you will be using as you work with OS/161.