At the time of this writing, there’s no binary package ready to install on the Raspberry Pi 4 ‘Buster’ release. Also, I need to make sure I can run the VICE emulator on the console and not in X-Windows for my diorama project. That install isn’t difficult but isn’t a single line or two either, so we’ll start from scratch on a fresh Raspbian lite install. This article assumes some familiarity with how VICE works. Let’s install VICE on a Raspberry Pi 4!
Here’s the video that accompanies the article:
Step 0 – Hardware before the Software
This part is pretty simple – you’ll need:
- Raspberry Pi 4 Model B
- Micro SD Card (we’re generally at the days of 16GB or higher)
- Micro HDMI cable (or full HDMI if you’re using a Raspberry Pi 3B+)
- Keyboard / Mouse for initial setup, Wifi connectivity for later SSH connectivity.
Step 1 – Write The Raspberry Pi 4Image
Step 2 – Boot the Raspberry Pi and get connected.
We know our default password is raspberry and our default user name is pi. You should change these if you’re going to keep this install around. Regardless, we need to set just a couple of things before we start with VICE – such as my desire for SSH access so I could copy/paste commands more easily. Here are those steps after you give yourself a good old fashioned
- Set hostname to vice-pi-install (This makes it unique and through bonjour lets me access it from my Windows PC as vice-pi-install.local.)
- Set WIFI up to my access point (Country Code and SSID)
- Allow SPI interface access (my diorama is going to be controlling an LCD through SPI)
- Allow SSH interface access (so we can copy/paste from a Windows SSH client)
- Verify Internet Connectivity (ping google.com)
- Perform your normal
apt update / apt upgradecommands to update your system.
sudo apt update sudo apt upgrade
Step 3 – Compiling SDL2 for console usage with the kmsdrm video driver
I’m not in a window environment, so we need to enable the kmsdrm video driver in SDL 2 for our VICE compile. Unfortunately, the SDL2 libraries from package repositories don’t have that enabled, so we’ll make our own. I’ll use a separate directory called sdl-work in my home directory.
We’ll install required dependencies and download the sourced code for the three primary SDL libraries we’re compiling.
sudo apt install libfreetype6-dev libgl1-mesa-dev libgles2-mesa-dev libgbm-dev libudev-dev \ libasound2-dev liblzma-dev git build-essential mkdir ~/sdl-work cd ~/sdl-work #Download all three SDL library sources - core, image, and ttf wget https://libsdl.org/release/SDL2-2.0.10.tar.gz && tar zxvf SDL2-2.0.10.tar.gz && wget https://libsdl.org/projects/SDL_image/release/SDL2_image-2.0.4.tar.gz && tar zxvf SDL2_image-2.0.4.tar.gz && wget https://libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.tar.gz && tar zxvf SDL2_ttf-2.0.14.tar.gz
Then we’ll compile the first two:
cd SDL2-2.0.10 ./configure --enable-video-kmsdrm --disable-video-opengl --disable-video-x11 --disable-video-rpi && make -j $(nproc) && sudo make install && cd .. cd SDL2_image-2.0.4 ./configure && make -j $(nproc) && sudo make install && cd ..
Step 3B – Fixing SDL-TTF build failures
Building SDL-TTF will most likely fail for you with this error during the configure stage:
cd SDL2_ttf-2.0.14 ./configure && make -j $(nproc) Unable to find FreeType2 library (http://www.freetype.org/)
We essentially have some old code here looking for
freetype-config which has been replaced with
pkg-config. We can stub out this file quickly by performing the following actions:
sudo vi /bin/freetype-config
Then paste these contents in, essentially mapping the input to pkg-config:
#!/bin/sh /usr/bin/pkg-config "$@" freetype2
Then set the executable flag and rebuild:
sudo chmod +x /bin/freetype-config cd SDL2_ttf-2.0.14 ./configure && make -j $(nproc) && sudo make install && cd ..
Step 4 – VICE Prerequisite Libraries and Build
We won’t be installing libsdl2-dev, as we just made our own of this, so the VICE libraries are everything normally required except libsdl2:
sudo apt install libmpg123-dev libpng-dev zlib1g-dev libasound2-dev libvorbis-dev libflac-dev \ libpcap-dev automake bison flex subversion libjpeg-dev portaudio19-dev texinfo xa65
We’re going to take the latest trunk of the VICE source code (3.4 as the time of this writing, so we’ll make a vice-src directory just to keep things separated. After we download the source (this is pure VICE, not my dioramma patching, that comes later) we’ll run the required build commands.
mkdir ~/vice-src cd ~/vice-src svn checkout svn://svn.code.sf.net/p/vice-emu/code/trunk/vice/ cd ./vice ./autogen.sh ./configure --prefix=/home/pi/viceinstall --enable-sdlui2 --without-oss --enable-ethernet \ --disable-catweasel --without-pulse make -j $(nproc) make install
Note the ‘prefix’ setting above – that’s where the make install command will put the binaries.
Step 5 – Setting the Video Driver in Raspi-Config
If you were to run the emulator right now by going into your install directory, you’d see the following:
pi@vice-pi-install:~/viceinstall/bin $ ./x64sc The path /dev/dri/ cannot be opened or is not available The path /dev/dri/ cannot be opened or is not available SDL error: No available video device archdep_init failed.
You need to set the video driver to support the kmsdrm driver we compiled support into SDL2 in Step 3. Perform a
sudo raspi-config and select
- Advanced Options
- GL Driver
- GL (Fake KMS) OpenGL desktop driver with fake KMS
Reboot your Raspberry Pi as prompted when you exit raspi-config
Step 6 – Download a demo and test
I downloaded a simple demo from csdb.dk by Booze Design known as ‘The Elder Scrollers‘. Downloaded the .D64 file and uploaded that to the VICE Pi. Moving into the /home/pi/viceinstall/bin directory, I typed ./x64sc and was greeted with an old blue friend:
After autostarting the image and the loading our demo, I enjoy that classic SID sound and Elder Scrollers demo:
With that, we finish the install of VICE on a Raspberry Pi 4 in console mode as the foundation of my Diorama 64 project. Any thoughts or concerns, things that didn’t work well for you with your install? Leave a comment down below or join the discord at https://discord.gg/wbngTy8 and we can chat. Next up: the Raspberry Pi 4 and the LCD display turned monitor.
Raspberry Pi 3B+ Instructions
Generally, the build is very similar. I’m going to skip all the discussion points and run down what I think seems to work on a Raspberry Pi 3B. The key differences are how we build SDL. I didn’t seem to need to change any graphic related driver setting to get this to work.
sudo apt update sudo apt upgrade #SDL for Raspi-3B dependencies sudo apt-get install libfontconfig-dev qt5-default automake mercurial \ libtool libfreeimage-dev libopenal-dev libpango1.0-dev libsndfile-dev \ libudev-dev libtiff5-dev libwebp-dev libasound2-dev libaudio-dev \ libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxss-dev \ libesd0-dev freeglut3-dev libmodplug-dev libsmpeg-dev libjpeg-dev mkdir ~/sdlwork cd ~/sdlwork hg clone http://hg.libsdl.org/SDL cd SDL ./autogen.sh ./configure --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland \ --disable-video-opengl --host=arm-raspberry-linux-gnueabihf make sudo make install cd ~/sdlwork wget http://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.5.tar.gz wget http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.4.tar.gz wget http://www.libsdl.org/projects/SDL_net/release/SDL2_net-2.0.1.tar.gz wget http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.15.tar.gz tar zxvf SDL2_image-2.0.5.tar.gz tar zxvf SDL2_mixer-2.0.4.tar.gz tar zxvf SDL2_net-2.0.1.tar.gz tar zxvf SDL2_ttf-2.0.15.tar.gz cd SDL2_image-2.0.5 ./autogen.sh ./configure make sudo make install cd .. cd SDL2_mixer-2.0.4 ./autogen.sh ./configure make sudo make install cd .. cd SDL2_net-2.0.1 ./autogen.sh ./configure make sudo make install cd .. #Interestingly enough TTF builds just fine on the 3B. cd SDL2_ttf-2.0.15 ./autogen.sh ./configure make sudo make install cd .. #Now, on to VICE for the Raspi 3B sudo apt install libmpg123-dev libpng-dev zlib1g-dev libasound2-dev libvorbis-dev libflac-dev \ libpcap-dev automake bison flex subversion libjpeg-dev portaudio19-dev texinfo xa65 svn checkout svn://svn.code.sf.net/p/vice-emu/code/trunk/vice/ cd ./vice ./autogen.sh ./configure --prefix=/home/pi/viceinstall --enable-sdlui2 --without-oss --enable-ethernet \ --disable-catweasel --without-pulse make -j $(nproc) # I got an error here for the running of make install - you may or may not need to do the sudo. sudo make install #after this point, I went directly to the vice install directory and ran it cd ~/viceinstall/bin ./x64sc