Blog by Max Ammann

Installing ROS on virtual Raspberry PI Zero

**This post represents a slow way to compile ROS. In a new post I show how to crosscompile ROS.”

This post should guide you through the process of compiling ROS on a virtualized Raspberry PI Zero.

Setup virtual Raspberry PI Zero with QEMU

Start by checking out the repo of a custom kernel for qemu:

1
git clone https://github.com/dhruvvyas90/qemu-rpi-kernel

Next download the latest Raspbian Image. It is advised to create a qemu image of the extracted image:

1
qemu-img convert -f raw -O qcow2 2018-11-13-raspbian-stretch-lite.img raspbian-stretch-lite.qcow

You can resize the image by running qemu-img convert -f raw -O qcow2 2018-11-13-raspbian-stretch-lite.img raspbian-stretch-lite.qcow. This will not resize the root partition! You’ll have to do this later by using raspi-config or doing it manually.

That’s all! Now you can start the virtual PI by running:

1
2
3
4
5
6
7
8
9
qemu-system-arm \ 
  -M versatilepb \ 
  -cpu arm1176 -smp 1 \ 
  -m 256 -net nic -net user \ 
  -hda raspbian-stretch-lite.qcow \ 
  -dtb qemu-rpi-kernel/versatile-pb.dtb  \ 
  -kernel qemu-rpi-kernel/kernel-qemu-4.14.79-stretch \ 
  -append 'root=/dev/sda2 panic=1' \ 
  -no-reboot

Please note that you can not use more than 256MB of RAM and only one core.

Login with pi:raspberry and you should have a working PI with access to the internet like the host.

To install ROS you basically have to follow this guide. A TLDR version is the following:

You can try to compile with -j2 (More does not make sense), but you maybe will get an out of memory error because the PI has only 256MB of RAM. Here is an example of the memory consumption ;)

1
2
3
4
pi@raspberrypi:~$ free -h
              total        used        free      shared  buff/cache   available
Mem:           247M        218M         21M          0B        7.7M        1.3M
Swap:           99M         99M          0B

You can active the ROS environment with source ~/ros_catkin_ws/install_isolated/setup.bash. You can also add this to your .bashrc if you like.

The next task for me is to get the data from the qemu image to copy it to the real hardware.

See this post for how to mount qcow2 images.

Do you have Questions? Send an E-Mail to max@maxammann.org