Skip to content
David Gilhooley edited this page Mar 8, 2017 · 14 revisions

What do I have to do?

The first thing to do is install Vagrant, which is a lightweight wrapper around virtual box. We have set up a Vagrant file to automatically install the packages that you will need in a lightweight environment.

To run the OS on a Raspberry Pi, you need to:

To run on the QEMU emulator, you need to:


## Pi Hardware Setup

Before you begin, you will need the following hardware components:

The Raspberry Pi should be powered from an outlet, as your computer may not output enough voltage for it to function properly. If this is the case, you should see either a Rainbow square, or a lightning bolt icon appear in the top right corner of your monitor when you start the Raspberry Pi.


## Pi SD Card Setup

The OS will be loaded and run from the SD Card. To setup the SD Card, you need to:

kernel_old=1
disable_commandline_tags=1
disable_overscan=1
framebuffer_swap=0
disable_l2cache=0
  • After you build the OS, copy over the kernel7.img file to update it

## Vagrant

Download the Vagrant from here and follow the instructions to install it on your machine. Next follow the instructions in Getting Started.

Getting Started

To get started download the repository to your choice. You will need to install Vagrant which is a lightweight wrapper for virtual box. Once vagrant is installed, migrate to the directory where you have downloaded the code. Run the following command to create an Ubuntu image with the compiling toolchain built in:

vagrant up

Once the command finishes you can run vagrant ssh to connect to the Ubuntu image. Your code is stored at /vagrant/ and it is a copy of the code on your local machine. Edit the code on your local machine with your favorite text editor and it will be updated automatically!

When you are done working on the project, remember to run vagrant halt in the code directory to close your vagrant image. Otherwise the Ubuntu image will constantly be running on the background of your computer.


# Compiling and Running the OS

Compiling:

  • Verify that you have performed all steps for your target in the 'What do I have to do' section above
  • cd into the root directory for the project (Makefile should be in the current directory)
  • Run make
  • Verify that kernel7.img and kernel.elf have been built

Other Makefile Options:

The Makefile supports the following commands:

  • make all: Same as make, builds pi, qemu targets
  • make pi: Builds for Raspberry Pi 2 target. Generates kernel7.img
  • make qemu: Builds for QEMU Emulator target. Generates kernel.elf
  • make depend: Builds dependency files
  • make clean: Removes all build files

Running on a Pi:

Insert the SD Card into your SD Card Adapter, then insert the Adapter into your computer.

Replace the kernel7.img on the SD Card with your newly built kernel7.img

Eject the SD Card Adapter, then insert the SD Card into the Raspberry Pi

Connect the Pi to the monitor with the HDMI cable, and plug in the micro-USB charger. The Pi should turn on (a green LED should flash), and the monitor should display the Raspberry Pi logo, followed by a rainbow screen, followed by the output of your kernel image.

After you've made a change to the kernel, unplug the power cable, eject the SD Card and copy over the new kernel7.img. You can then re-insert the SD card into the Pi, and plug in the power cable to see your new changes.

Running with QEMU:

First, start up your virtual image with vagrant up, then log into it with vagrant ssh.

The command make qemu will generate the QEMU kernel image. The command run-qemu kernel.elf will run the kernel image and display output.

Press Control-A, X to exit QEMU.

Running with QEMU GDB

The command run-qemu-gdb will start the kernel image with a GDB server. To connect to this server, open another terminal window, and vagrant ssh into the virtual image, then run the following commands:

gdb
file /vagrant/kernel.elf
target remote localhost:1234

breakpoint c_entry
continue