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!

Raspberry Pi 4 Version Log

EVOLVING VERSIONS NOTE:

This initially worked on the 2019-09-26 buster lite install and VICE 3.4. It seems some things have changed lately and I am unable to activate the emulator due to ‘SDL device not found’ errors.



To fix that, I’ve had to rework how SDL is utilized.



The original guide must evolve to support the latest developments from Raspberry Pi, SDL, and VICE as needed.

This guide has been updated to reference the following versions, and was last updated on 5/7/2020.

Raspbian Buster Lite 2020-02-13

SDL 2.0.10 ( sourced from retropie’s github – they’ve made Pi specific modifications)

– they’ve made Pi specific modifications) VICE 3.4 (the latest released version)

To that end, the video below is no longer 100% accurate. It still covers the general setup tasks, but SDL’s compile has changed.

You may wonder why I am doing it this way vs RetroPie, Combian 64, or BMC64… I probably could have, but I knew I’d be in the VICE source code a bit in a later article so I wanted to start with the basics first and make sure I could compile VICE myself. Plus, at this time , the packages referenced above aren’t completely ready for the Raspberry Pi 4.

Step 0 – Hardware before the Software

This part is pretty simple – you’ll need:

Raspberry Pi 4 Model B, or Raspberry Pi 3B+

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.

Got a Raspberry Pi 3B? I’ve added instructions on that at the very end of this document.

Step 1 – Write The Raspberry Pi 4Image

We’ll start with a fresh SD Card and a Raspberry Pi 4. We’re going to burn Buster Lite (I’m not using a window environment) on to the SD Card using Balena Etcher.

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 sudo raspi-config :

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) Setup locale, keyboard, etc. Verify Internet Connectivity (ping google.com) Perform your normal apt update / apt upgrade commands 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. Why? We want to run VICE from the console. Unfortunately, the SDL2 libraries from package repositories don’t have the kmsdrm driver piece enabled, so we’ll make our own. I’ll use a separate directory called sdl-work in my home directory.

In previous versions of this guide, we compiled SDL2, SDL2-image, and SDL2-ttf. We also used SDL directliy from libsdl.org. It seems that some things have changed with later versions of Raspbian possibly firmware – I am no longer able to follow my previous guide and have things work. I attempted numerous settings and rebuilds, and finally accepted a different solution:

We will build SDL2-2.0.10 from RetroPie’s fork that has Raspberry Pi specific modifications. Part of the compilation below is from RetroPie’s SDL 2.0 install script. To learn more about the excellent RetroPie project, head on over to their site here.

NOTE: It is advised to copy/paste this over via SSH sessions into your PI instead of typing it by hand. There’s a lot of stuff going on here and I haven’t converted these updates into a full script yet – I do have a donated script sent to me that I’ll see about updating for the new Raspi 4 build somtime. Until then, use SSH and copy/paste from your browser instead of tring to type any of this stuff in. Just don’t paste it all at once. 🙂



Keep in mind the browser page may hide text that is to the right for really long lines, so copy the next ‘blank’ line as well. You can see if it you drag your mouse over to the right when highlighting lines.

#install dependencies for how we'll compile SDL2 and install the output package sudo apt install lsb-release git dialog wget gcc g++ build-essential unzip xmlstarlet python3-pyudev ca-certificates libasound2-dev libudev-dev libibus-1.0-dev libdbus-1-dev fcitx-libs-dev libsndio-dev libx11-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxkbcommon-dev libxrandr-dev libxss-dev libxt-dev libxv-dev libxxf86vm-dev libgl1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev libgl1-mesa-dev libglu1-mesa-dev libdrm-dev libgbm-dev devscripts debhelper dh-autoreconf libraspberrypi-dev libpulse-dev mkdir ~/sdl-work cd ~/sdl-work #Download SDL from RetroPie's SDL fork git clone --single-branch --branch retropie-2.0.10 https://github.com/RetroPie/SDL-mirror cd SDL-mirror #update debian package rules and control files, which update dependencies specific #to the raspberry pi and enables kmsdrm conf_depends="libasound2-dev, libudev-dev, libibus-1.0-dev, libdbus-1-dev, fcitx-libs-dev, libsndio-dev, libx11-dev, libxcursor-dev, libxext-dev, libxi-dev, libxinerama-dev, libxkbcommon-dev, libxrandr-dev, libxss-dev, libxt-dev, libxv-dev, libxxf86vm-dev, libgl1-mesa-dev, libegl1-mesa-dev, libgles2-mesa-dev, libgl1-mesa-dev, libglu1-mesa-dev, libdrm-dev, libgbm-dev," sed -i 's/libgl1-mesa-dev,/libgl1-mesa-dev, '"${conf_depends[*]}"'/' ./debian/control conf_flags="--disable-video-vulkan --enable-video-rpi --enable-video-kmsdrm" sed -i 's/confflags =/confflags = '"${conf_flags[*]}"' \

/' ./debian/rules # move proprietary videocore headers sed -i -e 's/\"EGL/\"brcmEGL/g' -e 's/\"GLES/\"brcmGLES/g' ./src/video/raspberry/SDL_rpivideo.h sudo mv /opt/vc/include/EGL /opt/vc/include/brcmEGL sudo mv /opt/vc/include/GLES /opt/vc/include/brcmGLES sudo mv /opt/vc/include/GLES2 /opt/vc/include/brcmGLES2 #perform the build via dpkg-buildpackage PKG_CONFIG_PATH= dpkg-buildpackage -b

At this point, you should have the debian packages in the directory above SDL-mirror:

Continuing on, we’ll install the package and clean up.

# restore proprietary headers sudo mv /opt/vc/include/brcmEGL /opt/vc/include/EGL sudo mv /opt/vc/include/brcmGLES /opt/vc/include/GLES sudo mv /opt/vc/include/brcmGLES2 /opt/vc/include/GLES2 #remove any old installed library sudo dpkg --remove libsdl2 libsdl2-dev #Now we sudo login to do some of the install sudo su -l #as sudo in a shell... and move to where those .deb packages are cd /home/pi/sdl-work if ! dpkg -i libsdl2-2.0-0_2.0.10_armhf.deb libsdl2-dev_2.0.10_armhf.deb ; then apt-get -y -f --no-install-recommends install fi echo "libsdl2-dev hold" | dpkg --set-selections #exit sudo shell exit

You should now have your SDL2 custom library installed on your system. The last output of the package installation gave me no errors.

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 #if you want trunk, do this: #svn checkout svn://svn.code.sf.net/p/vice-emu/code/trunk/vice/ #3.4 is the latest VICE release svn checkout svn://svn.code.sf.net/p/vice-emu/code/tags/v3.4/ cd ./v3.4/vice ./autogen.sh ./configure --prefix=/home/pi/viceinstall --enable-sdlui2 --without-oss --enable-ethernet \ --disable-catweasel --without-pulse --enable-x64 make -j $(nproc) make install

Note the ‘prefix’ setting above – that’s where the make install command will put the binaries.

x64sc or x64? The configure line above has ‘–enable-x64’. By default VICE builds create an x64sc binary, but NOT an x64 binary anymore. What’s the difference? Seems the SC binary is the preferred as it focuses on accuracy of emulation over speed. That being said, I find I like to use x64 on the C64 DemoScene that still lives on to this day – otherwise the demoscenes are quite choppy. For normal game play I use x64sc.

Step 5 – Setting the Video Driver in Raspi-Config

This step seems to no longer be necessary. We used to have to go into raspi-config and enable the ‘Fake KMSDRM’ driver, but with the changes in utilizing SDL from RetroPie’s fork, there doesn’t seem to be that need to change the driver configuration anymore.

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:

Hello, Retro my old friend…

Now, depending on how this all comes together, you might have a really tiny C64 screen in the corner of your big monitor. Simply hit F12, scroll down to Video Settings -> Screen Settings -> Fullscreen.

After autostarting the demo image I donwloaded, I was able to sit back and enjoy classic SID sound from the Elder Scrollers demo:

I’ve come to scroll with you again…

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 mkdir ~/vicework cd ~/vicework #3.4 is the latest VICE release svn checkout svn://svn.code.sf.net/p/vice-emu/code/tags/v3.4/ cd ./v3.4/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

References: