Raspberry Pi 4 - Lakka Emulation Guide

Guide

I put together this guide on how to setup a Raspberry Pi 4 (Model B) running Lakka.

No Game ROMs or BIOS files are linked.


Contents

  • Overview
  • Raspberry Pi
  • Lakka
    • Software
    • Setup
    • Access
    • File Paths
    • Overclocking
    • Configuration
  • Emulators
    • Consoles
    • Configuration
  • Games
    • Adding Games
    • Configuration
  • Overrides
    • Configurations
    • Core Options
  • Controllers
    • Remaps
  • Backup
  • Notes
  • Resources

Overview

  1. Build Raspberry Pi
  2. Download Lakka
  3. Install Lakka to SD Card or USB Flash Drive
  4. Overclocking
  5. Configure Lakka
  6. Add games
  7. Configure Emulators, Games, and Controllers
  8. Backup SD Card

Raspberry Pi

Raspberry Pi

Raspberry Pi 4 (Model B) 4GB or 8GB

Recommendations

Pi 4 Kits:

  • CanaKit Starter Kit
  • CanaKit EXTREME Kit (Aluminum Fanless Heatsink Case)
  • Vilros Basic Starter Kit
  • Raspberry Pi 4 Official Full Kit

These have the proper power supply, power switch, and quality SD Card.
Or build your own custom setup with heatsink and cooling fan.

Cases:

  • Retroflag NESPi 4
  • anidees Aluminum
  • anidees Aluminum Extra High
  • anidees Aluminum Heat Sink Fanless Extra High
  • GeeekPi Armor Case with Fan

Heatsinks:

  • GeeekPi Aluminum with Fan
  • GeeekPi Low-Profile Cooler with RGB Cooling Fan
  • Noctua NF-A4x10 5V 40x10mm Fan

Drives:

  • Samsung EVO microSDXC Card
  • Samsung FIT Plus USB 3.1 Flash Drive

Lakka

Lakka

https://www.lakka.tv

Software

Operating System
Download Lakka for Raspberry Pi 4 (aarch64) (64-bit)

(Don’t use development images, it caused many problems.)

Raspberry Pi Imager
https://www.raspberrypi.org/software
Install Lakka to the SD Card or USB Flash Drive.

FileZilla SFTP
FileZilla (Windows)
For transferring files over the network if needed.

Setup

  1. Use Raspberry Pi Imager to install Lakka to the SD Card or USB Flash Drive.
  2. After installation, eject the drive and insert into the Pi.
  3. Power on the Pi and allow Lakka to boot and finish setup.
  4. Set up your Lakka Main Configuration and Directories Paths.

Access

https://www.lakka.tv/doc/Accessing-Lakka-filesystem

Credentials

User: root
Password: root

Network

Once connected to the network, find your Raspberry Pi’s IPv4 Address from your router’s device list.
Or from the Pi’s terminal type ifconfig -a.

Wi-Fi
If you are not using Ethernet, enable Wireless network connection.

Settings β†’ Wi-Fi


SSH
Use this for accessing the Pi’s terminal from Windows.

Enable the OpenSSH Server in Windows 10

or Download PuTTY

In Windows Command Prompt:

ssh [email protected]  

If something gets messed up, you can open C:\Users\[Username]\.ssh\known_hosts with a text editor and erase it.


SAMBA
Use this for transferring files from Windows to the Pi.

Settings β†’ Services β†’ SAMBA: On

Windows, OS X, and most Linux distributions should be able to navigate directly to Lakka’s Samba share by entering \\lakka\ into their file browser.


SFTP
Use this for transferring files from Windows to the Pi.

Host: 192.168.1.xxx


File Paths

Lakka
/tmp/assets/ Assets, Menu Themes, Sounds, etc.
/tmp/cores/ Emulator Cores & Info
/tmp/databases/ Databases
/tmp/joypads/ Controller Autoconfig
/tmp/overlays/ Overlays
/tmp/shaders/ Shaders
/tmp/system/ BIOS
/storage/.update/ Update
User
/storage/database/cht/ Cheats
/storage/cores/ Custom Emulator Cores & Info
/storage/logfiles/ Logs
/storage/remappings/ Controller Remaps .rmp
/storage/savefiles/ Memory Card Save Files .mcd, .mcr, .srm, .rtc, etc.
/storage/savestates/ Save States
/storage/screenshots/ Screenshots
/storage/thumbnails/ Game Cover Art
Config
boot partition Overclock, GPU Memory, and Overscan set in config.txt
/storage/.config/retroarch/retroarch.cfg Main Lakka Configuration
/storage/.config/retroarch/config/ Emulator Configurations .cfg and Core Options .opt
Games
/storage/roms/ Games (Interal SD / USB)
/storage/roms/media/ Games (External USB)

Directory Structure

There seems to be 4 duplicates sets of the same folders in:

/storage/
/storage/.config/retroarch/
/tmp/
/usr/share/

Everything in /tmp/ is a link to /usr/share/ and /usr/lib/.

  • /usr/lib/libretro - cores and info files
  • /usr/share/libretro-database - database, cursor, cheats
  • /usr/share/retroarch-assets - assets
  • /usr/share/retroarch-overlays - overlays
  • /usr/share/retroarch-system - bios

Everything in /storage/.config/retroarch/ are the configuration files.

The folders in /storage/ are for user provided content, such as roms, custom assets, saves, thumbnails.

Source

root
└─ storage
β”‚   └─ .config
β”‚   β”‚   └─ retroarch
β”‚   β”‚      └─ autoconfig
β”‚   β”‚      └─ config
β”‚   β”‚      β”‚   └─ Flycast
β”‚   β”‚      β”‚   └─ Mesen
β”‚   β”‚      β”‚   └─ mGBA
β”‚   β”‚      β”‚   └─ remaps
β”‚   β”‚      └─ content_favorites.lpl
β”‚   β”‚      └─ retroarch.cfg
β”‚   β”‚
β”‚   └─ playlists
β”‚   └─ remappings
β”‚   └─ roms
β”‚   β”‚   └─ Nintendo - Game Boy
β”‚   β”‚   └─ Sega - Dreamcast
β”‚   β”‚   └─ Sony - PlayStation
β”‚   β”‚   └─ External USB Drive
β”‚   β”‚       └─ More Games
β”‚   β”‚
β”‚   └─ savestates
β”‚   └─ savefiles
β”‚   └─ system
β”‚   └─ thumbnails
β”‚
└─ tmp
β”‚   └─ assets
β”‚   └─ cores
β”‚   └─ database
β”‚   └─ joypads
β”‚   └─ overlays
β”‚   └─ shaders
β”‚   └─ system
β”‚
└─ usr
    └─ share
        └─ retroarch-assets
        └─ retroarch-overlays
        └─ retroarch-system

Overclocking

(Optional)

Config
config.txt Documentation
Overclocking Documenation

Using Windows PC
Insert SD Card and open config.txt with Notepad.

Settings
Guides
How to overclock Raspberry Pi 4
How to Safely Overclock your Raspberry Pi 4 to 2.147GHz

Warning:

Setting over_voltage higher than 6 or using force_turbo=1 will void the Raspberry Pi’s warranty and could cause damage.

Overclocking requires heatsink cooling. If the Pi overheats passed 85Β°c it will throttle the CPU, defeating the purpose of the overclock.

Add one of these:

Mid

over_voltage=2
arm_freq=1750

High

over_voltage=6
arm_freq=2048
gpu_freq=600

Extreme

over_voltage=6
arm_freq=2147
gpu_freq=750

Recover From a Bad Overclock

From Windows PC

  1. Power off the Pi
  2. Remove SD card
  3. Insert SD card into PC
  4. Open the config.txt with Notepad
  5. Change, comment out #, or remove the overclock settings

Configuration

Settings

Drivers
Video: Vulkan
Audio: alsathread
Input: udev
Menu: ozone

Menu Controls

  • Settings β†’ Input β†’ Menu Controls β†’
    • Unified Menu Controls: On
    • Menu Swap OK and Cancel Buttons: On

Quick Menu Hotkeys

  • Settings β†’ Input β†’ Hotkeys β†’
    • Menu Toggle Controller Combo: Start + Select

Directory Paths

  • Settings β†’ Directory
    • Make sure all of your paths are set where you want them.

Main Config Resolution

  • Settings β†’ Video β†’ Fullscreen Mode
    • Fullscreen Width: 1280
    • Fullscreen Height: 720

Saving Sorting

  • Settings β†’ Saving β†’
    • Sort Saves into Folders by Core Name: On
    • Sort Save States into Folders by Core Name: On

Hidden Files & Unknown Extensions

  • Settings β†’ File Browser β†’
    • Show Hidden Files and Directories: On
    • Filter Unknown Extensions: Off

Emulators

Emulators

Console Core
Arcade MAME 2003-Plus, MAME 2010, FinalBurn Neo
Atari 8-bit Atari800
Atari 2600 Stella
Atari 5200 Atari800
Atari 7800 ProSystem
Atari Jaguar Virtual Jaguar
Atari - Lynx Mednafen Lynx
Commodore - 64 VICE
Commodore - Amiga FS-UAE
DOS DOSBox, DOSBox Pure
Magnavox - Odyssey2 MAME
Mattel - Intellivision jzIntv
Microsoft - MSX blueMSX
Microsoft - MSX2 blueMSX
NEC - PC Engine - TurboGrafx 16 Mednafen PCE-Fast
NEC - PC Engine SuperGrafx Mednafen PCE-Fast
NEC - PC Engine CD - TurboGrafx-CD Mednafen PCE-Fast
NEC - PC-98 Neko Project II Kai
NEC - PC-FX Mednafen PC-FX
SNK - Neo Geo FinalBurn Neo
SNK - Neo Geo CD FinalBurn Neo
SNK - Neo Geo Pocket Mednafen NGP
SNK - Neo Geo Pocket Color Mednafen NGP
Nintendo - Game Boy Same Boy
Nintendo - Game Boy Color Same Boy
Nintendo - Game Boy Advance mGBA
Nintendo - Nintendo Entertainment System Mesen
Nintendo - Super Nintendo Entertainment System Snes9x-Current
Nintendo - Nintendo 64 Mupen64Plus-Next
Nintendo - Wii Dolphin
Sega - Master System - Mark III Genesis Plus GX
Sega - Mega Drive - Genesis Genesis Plus GX
Sega - 32X Genesis Plus GX
Sega - CD Genesis Plus GX
Sega - Saturn Yabause
Sega - Dreamcast Flycast
Sega - Naomi Flycast
Sony - PlayStation PCSX-ReARMed
Sony - PlayStation Portable PPSSPP
The 3DO Company - 3DO Opera

Emulator Notes

Arcade
MAME

Lakka Core MAME Version
MAME 2000 0.037b5
MAME 2003 0.078
MAME 2003-Plus 0.078
MAME 2009 0.135u4
MAME 2010 0.139
MAME 2014 0.152
MAME 2015 0.157
MAME 2016 0.174

Your roms need to be compatible with the MAME Core version you are using.
Most roms work on 2003-Plus or 2010. If it doesn’t, try the FinalBurn Neo Core.

Some games, such as Donkey Kong, will need the missing audio samples zip files placed in:

/storage/system/mame2003-plus/samples/

Check here for samples https://samples.mameworld.info


Nintendo - NES / SNES,
Sega - Master System / Genesis,
Mesen
Genesis Plus GX

If you experience input lag, try disabling Threaded Video with a Configuration Override.


Nintendo - Nintendo 64
Mupen64Plus-Next

Could not achieve full speed with most games, Video/Audio slowdown and stuttering.


Sega - Saturn
Yabause

Could not achieve full speed with most 3D games, Video/Audio slowdown and stuttering.
2D games are playable. Enable frameskip to reduce any Audio stuttering.


Sega - Dreamcast
Flycast

In the system BIOS folder, create a new folder named dc. Inside put the Dreamcast BIOS bin files.

dc_boot.bin
dc_flash.bin

Fixing Graphical Texture glitches, such as in Street Fighter III: 3rd Strike

  • In-Game β†’ Quick Menu (Start + Select) β†’ Options β†’
    • Anisotropic Filtering: Off
    • Threaded Rendering: Off
  • Manage Core Options β†’ Save Game Options

It will create Game Options file /storage/.config/retroarch/config/Flycast/Street Fighter III: 3rd Strike.opt


Sega - Naomi
Flycast

In the system BIOS folder, create a new folder named dc. Inside put the Naomi BIOS zip files.

awbios.zip
hikaru.zip
mie.zip
naomi.zip
naomi2.zip
naomigd.zip

ROM Directory Structure Example (zip & chd):

Guilty Gear XX Accent Core

storage
└─ roms
    └─ Sega - Naomi (folder)
        └─ ggxxac.zip (keep zipped)
        β”‚    └─ 203_203.bin
        β”‚    └─ epr-21576e.ic27
        β”‚    └─ sp5002-a.bin
        β”‚    └─ ...
        └─ ggxxac (folder)
             └─gdl-0041.chd

Sony - PlayStation
PCSX-ReARMed

Try the psxonpsp660.bin BIOS.
Set path in the /tmp/cores/pcsx_rearmed_libretro.info file.

firmware1_desc = "psxonpsp660.bin (PS1 US BIOS)"
firmware1_path = "psxonpsp660.bin"

MSX 1 & 2
blueMSX
Requires Database and Machines folders and files in BIOS /storage/system/.


Games

Games

Adding Games

Add game rom files to the SD Card/USB Flash Drive over the network.
Or copy them from your computer to the SD card or external USB Flash Drive.

Naming your rom folders by these Libretro schemes will make them easier to navigate.

Game File Compression

Use CHDMAN to convert .bin/.cue files into .chd. Works with PlayStation 1 and Saturn.

  1. Place chdman.exe and CUE or GDI to CHD.bat in your ROMs folder.
  2. Run the CUE or GDI to CHD.bat file.
  3. It will convert all games in the current folder and sub-folders.

Create Console Playlists
Import Content β†’ Manual Scan

You can set the Default Core better with Manual Scan than with Scan Directory.


Overrides

Overrides

Configuration Per-Core or Per-Game

These Configuration files .cfg will be loaded and override settings in the Main Configuration file.

Mesen Core (Nintendo - NES) Example:

  1. Quick Menu β†’ Back out to Main Menu β†’ Settings

  2. Make your changes to Drivers, Video, Audio, Input, Latency, etc.

  3. Main Menu β†’ Quick Menu β†’ Overrides

    • Per-Emulator
      • Save Core Overrides
    • Per-Console
      • Save Content Directory Overrides
    • Per-Game
      • Save Game Overrides
  4. It will create Config Override file /storage/.config/retroarch/config/Mesen/Mesen.cfg

  5. The Override will now be loaded the next time you launch the emulator or game.


To improve performance in certain emulator cores, you can set the resolution lower (480p) than the Main Config (720p).

Note: Some TV’s lowest resolution is 480p and can’t display 240p.

Settings β†’ Video β†’ Fullscreen Mode
Fullscreen Width: 640
Fullscreen Height: 480

Nintendo 64 Mupen64Plus-Next.cfg
GameCube / Wii Dolphin.cfg
Saturn Yabause.cfg
Dreamcast Flycast.cfg
Naomi Flycast.cfg
video_fullscreen_x = "640"
video_fullscreen_y = "480"

Some Cores may not function without the proper Video Driver.

Settings β†’ Drivers β†’ Video β†’ glcore

Saturn Yabause.cfg
video_driver = "glcore"

Disable Threaded Video for less input lag in some Cores.

Settings β†’ Video β†’ Threaded Video: Off

Nintendo Mesen.cfg
Super Nintendo Snes9x-Current.cfg
Master System Genesis Plus GX.cfg
Genesis Genesis Plus GX.cfg
video_threaded = "false"

Core Options Per-Game

These Option .opt files will be loaded and override settings in the default Core Options file.

Super Mario Bros. 3 (Mesen Core) Example:

In-Game β†’ Quick Menu (Start + Select) β†’ Options β†’ Manage Core Options β†’ Save Game Options

It will create Game Options file /storage/.config/retroarch/config/Mesen/Super Mario Bros 3.opt


Controllers

Controllers

Remaps

  • In-Game β†’ Quick Menu (Start + Select) β†’ Controls β†’ Set Port 1 Controls β†’
    • Per-Emulator
      • Save Core Remap File
    • Per-Console
      • Save Content Directory Remap File
    • Per-Game
      • Save Game Remap File

Saved to /storage/remappings/.


Backup

Win32DiskImager

Create a backup image of your SD card with Win32 Disk Imager.

  1. Select your Device drive letter.
  2. Select Image File save location (make sure it has .img file extension).
  3. Click the Read button.

If the SD ever corrupts, you can restore the backup image with the Write button.


Notes

Notes

My Setup

  • Windows 10
  • Raspberry Pi 4 8GB
  • Lakka (aarch64 64-bit)
  • GPU Memory: 256
  • Overclock: High
  • Resolution: 1280x720, 640x480

Frame Rate FPS

  • If you have a 4K TV, make sure to set the Lakka Main Config to a lower resolution, such as 1080p/720p, or you will get menu lag, low game FPS, and some Emulator Cores will crash.
  • Leaving the Fullscreen Resolution configuration set at 0 will use the native resolution of the TV.
  • Set each Emulator Core to its own desired resolution, to ensure the Main Config does not override the resolution when using a 4K TV. (Optional)

Safe Shutdown

  • Always shut off the Raspberry Pi through the Lakka Menu.
  • After the green light has stopped blinking, then it is safe to press the power switch.
  • Improper shutdown could corrupt the SD card.

Resources

Notes

6 Likes

That’s fantastic! thanks for sharing!

2 Likes

thanks for the advice.