Skip to content

Raspberry Pi

Georg Zotti edited this page Aug 1, 2022 · 35 revisions

Stellarium on Raspberry Pi

The Raspberry Pi is a very popular family of single-board computers for many kinds of programming experiments and hardware tinkering projects. A new open-source graphics driver has been created by Eric Anholt, which enables you to run Stellarium with hardware acceleration on the multi-core models 2 and 3. Don't expect a super computer, but you should get typically over 10 frames per seconds, which should be enough for many applications where you don't want to waste too much energy. (E.g. solar/battery powered observatory.) I get 18fps on a 1400x1050 screen with Satellites not shown.

For Raspberry OS ("bullseye", 2021), you must

  • activate the "OpenGL Driver" in raspi-config, Advanced options, Full KMS.
  • activate "Glamor" in raspi-config, Advanced options.
  • follow the building instructions for Linux. You will not have QtWebEngineView, but the rest should work.

For the previous Raspbian ("Buster", 2019), just

  • activate the "OpenGL Driver" in raspi-config, Advanced options, Full KMS.
  • Add drm headers: sudo apt install libdrm-dev
  • follow the building instructions for Linux.

For previous Raspbian ("Stretch" as of early 2018), you must

  • activate the "Experimental OpenGL Driver" in raspi-config
  • build libdrm and Mesa 17 from sources (see below)
  • follow the building instructions for Linux.

Alternatively, you can run Ubuntu Mate. On version 16.04.3 which has Mesa 17.0.7, I followed https://ubuntu-mate.community/t/tutorial-activate-opengl-driver-for-ubuntu-mate-16-04/7094 to activate VC4, and tried Stellarium 0.16.1 from our ppa. You don't have to compile anything yourself!

The following seemed to work on Pi3B+ model (2019) http://www.raspberryconnect.com/gamessoftware/item/314-trying_out_opengl_on_raspberry_pi_3

2019-08: Ubuntu Mate 18.04.2 LTS also works. However, the arm64 version seems not yet polished. Stellarium shows nice 8-14fps in 1680x1050 but frequently crashes.

2021-11: Ubuntu Mate 20.04 LTS on RPi3B+ installed, but never really made it to the desktop.

2022-07: Ubuntu Mate 22.04 LTS on RPi4 (4GB) installed. Compiles with Qt6 and runs. (Follow Linux instructions.)

First Impressions, Limitations

The new driver seems to work pretty well in many cases, but some hardware limitations persist (observed in ~2018)

  • You cannot show your own landscapes or 3D sceneries with any textures larger than 2048x2048 pixels. Also the built-in "Sterngarten" scenery will not work.
  • The Scenery3D plugin should be used with Perspective Projection only. All other projections require too much texture memory.
  • It seems that some bug prevents OBJ planets from being rendered. Keep this option disabled!
  • If you want higher framerate, consider disabling the Satellites plugin, or at least think about reducing number of satellites to the ones you are critically interested in. Also, don't load too many minor bodies.
  • The DSS layer seems to work for short periods, then the X server fails. It may have to do with limitations of texture memory. You can try to press Ctrl-Alt-Backspace to restart it, but sometimes you will have to reboot if the graphics failed.

Notes for building Stellarium

You may want to install a swap file or enlarge an existing, otherwise you may run out of virtual memory when compiling. For Raspberry OS, just edit /etc/dphys-swapfile and increase the swapfile size to e.g. CONF_SWAPSIZE=512, then reboot. For other distributions, follow e.g.
https://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/

If you are doing the compile on your Pi, follow the Linux instructions but use the command

nice make -j4

Otherwise, you may lose control of the pi with all cores busy. Or run with

make -j3

to keep one core free for other tasks.

Raspberry Pi Model 4B

2019-10-10: Stellarium works great out of the box. Install Raspbian, clone the GIT repo, install Linux build dependencies, and

mkdir build; cd build
cmake -DCMAKE_BUILD_TYPE="Release" ../stellarium
nice make -j4 

On a model with 4GB you don't need a larger swap file. Within 16 minutes, Stellarium was built, with about 17fps at FullHD resolution. Without satellites, 22fps.

2020-01-29: On an aarch64 build, we found (#940) you need to convince MESA to run without issues:

MESA_GL_VERSION_OVERRIDE=3.0 MESA_GLSL_VERSION_OVERRIDE=130 stellarium

Building the external libraries (for the obsolete Raspbian "Stretch" only!)

The following instructions which are required for Raspbian "Stretch" have been taken from Eric Anholt's site (https://github.com/anholt/mesa/wiki/VC4-complete-Raspbian-upgrade) on February 24, 2018. Fortunately we don't need to build a new kernel!

libdrm

Until Raspbian gets its libdrm updated, we need to build it ourselves.

sudo apt-get install \
    xutils-dev libpthread-stubs0-dev \
    automake autoconf libtool git
git clone git://anongit.freedesktop.org/mesa/drm
cd drm
./autogen.sh \
    --prefix=/usr \
    --libdir=/usr/lib/arm-linux-gnueabihf
make
sudo make install

Mesa

sudo apt-get install \
    flex bison python-mako \
    libxcb-dri3-dev libxcb-dri2-0-dev \
    libxcb-glx0-dev libx11-xcb-dev \
    libxcb-present-dev libxcb-sync-dev \
    libxshmfence-dev \
    libxdamage-dev libxext-dev libxfixes-dev \
    x11proto-dri2-dev x11proto-dri3-dev \
    x11proto-present-dev x11proto-gl-dev \
    libexpat1-dev libudev-dev gettext \
    libxrandr-dev

git clone git://anongit.freedesktop.org/mesa/mesa
cd mesa
./autogen.sh \
    --prefix=/usr \
    --libdir=/usr/lib/arm-linux-gnueabihf \
    --with-gallium-drivers=vc4 \
    --with-dri-drivers= \
    --with-egl-platforms=x11,drm
make
sudo make install
Clone this wiki locally