Till KTH:s startsida Till KTH:s startsida

Before you start

These are the tools that you will need to complete the project.

A Linux environment

If you already run a Linux distribution you'll probably be fine. If not you might have some trouble installing some of the tools that we need or have to find similar tool. The alternative is of course to run a Linux operating system in a virtual environment.

For visualization you ca either choose VMWare or VirtualBox, the functionality is for our purposes the same. You will also need a Linux operating system and why not choose Ubuntu to make things easy.

Important - when you install a virtual system you need more space than the default 8 GiB of disk space. Choose 20GiB or more so that you have enough room to install Rust.

The following tools assume that you have a Linux environment up and running, either as the host operating system or as a virtual system.

The nasm assembler

We will not do very much in assembler bu the first steps will of course have to be in assembler since we do not have any support from an existing operating system. We us the Netwide Assembler (nasm) which is  a portable x86 assembler. Don't worry if you have not done very much assembly programming before, it will work out just fine.

> sudo apt-get install nasm

The xorriso iso tool

We will bundle our kernel in a .iso file i.e. what you would normally find on an installation CD. The .iso image will be used by our emulator to start the operating system but you might equally well patch your own boot-loader or create a  bootable USB-stck and boot your own machine with your own operating system.

> sudo apt-get install xorriso

The curl tool to download stuff

Curl is a tool similar to wget i.e. it will download stuff using http etc. It's more convenient to use since it will pipe the down loaded stuff to standard output.

> sudo apt-get install curl

The QEMU emulator

It is very cool to actually boot your own machine with your own operating system but when your developing the system it will take too long to test it. We will therefore use a emulator that will run the operating system. The great thing with an emulator such as QEMU is that you can configure it to behave like another processor i.e. ARM, MIP, SPARC etc We will target the x86 architecture and I assume that you're already running on a x86 machine so we will not use this feature but it is good to know.

>sudo apt-get install qemu

Installing Rust

We will use the Rust tool chain to compile for different architectures so we're installing a bit more than we would actually need. You will not have to learn all features of this process since everything will be hidden in make scripts. The first thing that we will install is rustup, choose the default installation when prompted and then add the environment as suggested.

>  curl https://sh.rustup.rs -sSf | sh
:
To configure your current shell run source $HOME/.cargo/env
> source ~/.cargo/env

Rustup is a toolchain manager and will allow us to keep our rust environment updated. We use rustup to install the nightly version of the rust compiler since the tutorials might use things that are not in the stable branch.

> rustup default nightly

We now have most of teh tools that we need, among other things the rust compiler, rustc, and the rust package manager, cargo. Cargo is the tool with which we create new projects and make sure that we have the right packages available. Since the project is ready to do cross-compilation to other platforms we will however use a version call xargo, not a problem install it using cargo.

>cargo install xargo

We also need some src library files so we install them using rustup.

>rustup component add rust-src

That should be it, you're ready to roll.