layout: doc title: “Set up your environment - Raspberry Pi”

These instructions explain how to set up Cobalt for your workstation and your Raspberry Pi device.

Set up your device

Configure the Raspberry Pi memory split.

  1. sudo raspi-config
  2. Go to Advanced
  3. Memory Split: 256 for RasPi-0, 512 for all others.

Cobalt assumes the Raspberry Pi is configured to use non-default thread schedulers and priorities. Ensure that /etc/security/limits.conf sets rtprio and nice limits for the user. For example, if the user is pi, then limits.conf should have the following lines:

@pi hard rtprio 99
@pi soft rtprio 99
@pi hard nice -20
@pi soft nice -20

The following commands update the package configuration on your Raspberry Pi so that Cobalt can run properly:

$ apt-get remove -y --purge --auto-remove libgl1-mesa-dev \
          libegl1-mesa-dev libgles2-mesa libgles2-mesa-dev
$ apt-get install -y libpulse-dev libasound2-dev libavformat-dev \
          libavresample-dev rsync

Set up your workstation

The following steps install the cross-compiling toolchain on your workstation. The toolchain runs on an x86 workstation and compiles binaries for your ARM Raspberry Pi.

  1. Run the following command to install packages needed to build and run Cobalt for Raspberry Pi:

    $ sudo apt install -qqy --no-install-recommends g++-multilib \
          python-requests wget xz-utils
    
  2. Choose a location for the installed toolchain – e.g. raspi-tools – and set $RASPI_HOME to that location.

  3. Add $RASPI_HOME to your .bashrc (or equivalent).

  4. Create the directory for the installed toolchain and go to it:

    mkdir -p $RASPI_HOME
    cd $RASPI_HOME
    
  5. Clone the GitHub repository for Raspberry Pi tools:

    git clone git://github.com/raspberrypi/tools.git
    
  6. Sync your sysroot by completing the following steps:

    1. Boot up your RasPi, and set $RASPI_ADDR to the device's IP address.

    2. Run mkdir -p $RASPI_HOME/sysroot

    3. Run:

      rsync -avzh --safe-links \
            --delete-after pi@$RASPI_ADDR:/{opt,lib,usr} \
            --exclude="lib/firmware" --exclude="lib/modules" \
            --include="usr/lib" --include="usr/include" \
            --include="usr/local/include" --include="usr/local/lib" \
            --exclude="usr/*" --include="opt/vc" --exclude="opt/*" \
            $RASPI_HOME/sysroot
      password: raspberry
      

Build, install, and run Cobalt for Raspberry Pi

  1. Build the code by navigating to the src directory in your cobalt directory and run the following command :

    $ cobalt/build/gyp_cobalt raspi-2
    
  2. Compile the code from the src/ directory:

    $ ninja -C out/raspi-2_debug cobalt
    
  3. Run the following command to install your Cobalt binary (and content) on the device:

    rsync -avzLPh --exclude="obj*" --exclude="gen/" \
          $COBALT_SRC/out/raspi-2_debug pi@$RASPI_ADDR:~/
    

    The rsyncs get somewhat faster after the first time, as rsync is good at doing the minimum necessary effort.

  4. Even if you have a keyboard hooked up to the RasPi, you should SSH into the device to run Cobalt. Using SSH will make it easy for you to quit or restart Cobalt.

    ssh pi@$RASPI_ADDR
    cd raspi-2_debug
    ./cobalt
    

    With this approach, you can just hit [CTRL-C] to close Cobalt. If you were to run it from the console, you would have no way to quit without SSHing into the device and killing the Cobalt process by its PID.

    Note that you can also exit YouTube on Cobalt by hitting the [Esc] key enough times to bring up the “Do you want to quit YouTube?” dialog and selecting “yes”.

Improving Cobalt performance on Raspberry Pi

  1. You will find that there are some processes installed by default that run on the Raspberry Pi and can take away CPU time from Cobalt. You may wish to consider disabling these processes for maximum (and more consistent) performance, as they have been found to occasionally take >10% of the CPU according to top. You can do this by typing:

    apt-get remove -y --auto-remove [PACKAGE_NAME, ...]
    

    For example:

    apt-get remove -y --auto-remove avahi-daemon