Skip to content

VC4 complete Raspbian upgrade

Eric Anholt edited this page Mar 1, 2019 · 26 revisions

These are instructions for a complete replacement of the system's kernel, Mesa, and X Server on Raspbian Jessie (2016-05-27 desktop image) with upstream, for testing the current driver stack.

You do not need these instructions just to use the driver. Raspbian ships with the driver and it can be enabled with raspi-config. And if you want to just update the kernel, or Mesa, or the X Server, any of those should be individually installable without complete replacement.

First boot

Set your hostname and resize your partition, then:

sudo apt-get update
sudo apt-get dist-upgrade

sudo apt-get install ccache
export PATH=/usr/lib/ccache:$PATH

Building the kernel

git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux

This will get you git master, which what is trending toward being the next released kernel. You may also want to test:

git remote add anholt [email protected]:anholt/linux.git
git fetch anholt
git checkout -b drm-vc4-fixes anholt/drm-vc4-fixes # The current set of VC4 fixes to be merged to the next kernel release
git checkout -b drm-vc4-next anholt/drm-vc4-next # The current set of VC4 changed to be merged to the kernel after the next release.

or

git remote add next git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch next
git checkout -b next next/master # All changes to be merged to the kernel after the next relese.

Next, do the build. Pick one of:

make bcm2835_defconfig # Raspberry Pi 0/1
make multi_v7_defconfig # Raspberry Pi 2

# kernel build deps
sudo apt-get install bc libncurses5-dev

# We need to enable "General setup" -> "Namespaces support" for systemd-hostnamed
make menuconfig

then:

make
sudo make zinstall modules_install dtbs_install
echo KERNELVERSION is `make kernelrelease 2> /dev/null`

Edit /boot/config.txt to add:

kernel=vmlinuz-KERNELVERSION
device_tree=dtbs/KERNELVERSION/bcm2836-rpi-2-b.dtb # replace with the appropriate dtb for your board
avoid_warnings=2

Edit /boot/cmdline.txt to add:

cma=256M@512M 

Now you should be able to reboot to the new kernel. If there is any trouble, you will need a serial console for debug.

libdrm

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

sudo apt-get install \
    xutils-dev libpthread-stubs0-dev ninja-build
pip3 install meson
git clone git://anongit.freedesktop.org/mesa/drm
cd drm
meson build \
    --prefix=/usr \
    --libdir=/usr/lib/arm-linux-gnueabihf
ninja -C build
sudo -E ninja -C build install

Mesa

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

git clone git://anongit.freedesktop.org/mesa/mesa
cd mesa
meson build \
    --prefix=/usr \
    --libdir=/usr/lib/arm-linux-gnueabihf \
    -Dbuildtype=release \
    -Dplatforms=x11,drm,surfaceless \
    -Ddri-drivers= \
    -Dgallium-drivers=vc4,v3d
ninja -C build \
sudo -E ninja -C build install

X Server

# We're going to be using modesetting, so remove the fbturbo override.
sudo rm /usr/share/X11/xorg.conf.d/99-fbturbo.conf

sudo apt-get install \
    libepoxy-dev libpixman-1-dev \
    libevdev-dev libmtdev-dev \
    libfontenc-dev libxkbfile-dev \
    libpciaccess-dev libssl-dev \
    x11proto-bigreqs-dev x11proto-composite-dev \
    x11proto-dri2-dev x11proto-dri3-dev \
    x11proto-damage-dev x11proto-fixes-dev x11proto-fonts-dev \
    x11proto-input-dev x11proto-kb-dev \
    x11proto-randr-dev x11proto-render-dev \
    x11proto-record-dev x11proto-resource-dev \
    x11proto-scrnsaver-dev x11proto-video-dev \
    x11proto-xinerama-dev \
    x11proto-xcmisc-dev x11proto-xf86dri-dev \
    x11proto-xf86vidmode-dev 

# Raspbian needs its protos updated
git clone git://git.freedesktop.org/git/xorg/proto/xproto
(cd xproto && ./autogen.sh --prefix=/usr && make && sudo make install)

git clone git://git.freedesktop.org/git/xorg/proto/randrproto
(cd randrproto && ./autogen.sh --prefix=/usr && make && sudo make install)

# Raspbian is missing libxfont2.
git clone git://git.freedesktop.org/git/xorg/lib/libXfont
(cd libXfont && ./autogen.sh --prefix=/usr --libdir=/usr/lib/arm-linux-gnueabihf && make && sudo make install)

git clone git://git.freedesktop.org/git/xorg/xserver
cd xserver
./autogen.sh \
    --prefix=/usr \
    --libdir=/usr/lib/arm-linux-gnueabihf \
    --with-log-dir=/var/log \
    --enable-install-setuid
make
sudo make install

# Build the evdev driver, since it's not included in the server.
git clone git://git.freedesktop.org/git/xorg/driver/xf86-input-evdev
(cd xf86-input-evdev/ && ./autogen.sh --prefix=/usr --libdir=/usr/lib/arm-linux-gnueabihf && make && sudo make install)

First tests

sudo reboot # Switch to new kernel and X Server.

sudo apt-get install mesa-utils
LIBGL_DEBUG=verbose glxinfo # Should report vc4 gallium renderer
glxgears # Should run at 60fps.