I have been a fan of both distros, LibreElec and Lakka, it's time to have the best of both worlds in one place, I want to have my cake and eat it too.
Teorically, this should work for all architectures, I focused on my rpi4 aarch64.
It totally can be an addon with a helper, I spent a whole day making it work this way described below, right now, I just want to enjoy it. =D
UPDATE: I realized that all tools needed were present ar LibreElec image so I wrote the script below to get it working easily.
NOTE: Keep a keyboard at hand to configure joystick first time you run it.
NOTE: Share a download directory with zachmorrris IAGL addon to get games.
Option 1: Automagic Script for a Running LibreElec
NOTE: Published at: https://github.com/basilean/retroarch_install
One line install:
wget -q -O - https://raw.githubusercontent.com/basilean/retroarch_install/refs/heads/main/retroarch_install.sh | bash
Option 2: Manual Procedure Using a GNU/Linux PC
DISCLAIMER: Take a time to read and understand each step, most of the commands used needs to run as root, that means you can criple your PC if done wrong.
1. Download LibreElec image and install it on an SD as usual.
NOTE: Change the image version to your like.
wget https://releases.libreelec.tv/LibreELEC-RPi4.aarch64-12.0.2.img.gz
gunzip LibreELEC-RPi4.aarch64-12.0.2.img.gz
WARNING: Make sure "/dev/mmcblk0" is the SD target. Change it yo suit you.
dd if=LibreELEC-RPi4.aarch64-12.0.2.img of=/dev/mmcblk0 bs=4M
WARNING: Be sure IO transfer is done, await for "sync" command to return.
sync
2. Boot new sd card in the target device. Once Kodi is up, just power it off, remove the card and insert it back in the PC.
NOTE: This is needed to get "storage" resized in the first boot.
3. Download Lakka image and mount it
NOTE: Change the image version to your like, just match architecture with LibeElec and try to be close on release dates.
https://nightly.builds.lakka.tv/6.x/2025-02-07/RPi4.aarch64/Lakka-RPi4.aarch64-6.x-20250207-0af7dae.img.gz
gunzip Lakka-RPi4.aarch64-6.x-20250207-0af7dae.img.gz
Create mount points.
mkdir /media/flash
mkdir /media/root
WARNING: Make sure /dev/loop0 and /dev/loop1 are the targets or change them. Command "losetup" will return assigned loop for each file.
Mount "Lakka" source (flash),
losetup --show -P -f Lakka-RPi4.aarch64-6.x-20250207-0af7dae.img
mount /dev/loop0p1 /media/flash
From there, mount "SYSTEM" source (rootfs)
losetup --show -f /media/flash/SYSTEM
mount /dev/loop1 /media/root
4. Copy retroarch Lakka components into kodi LibreElec "/storage" filesystem.
Create a mount point.
mkdir /media/storage
WARNING: Make sure "/dev/mmcblk0p2" is the SD target partition. Change it to suit you.
Mount SD card "storage" partition target.
mount /dev/mmcblk0p2 /media/storage
Copy binary (72M).
cp -a /media/root/usr/bin/retroarch /media/storage/retroarch
Copy assets (806M).
cp -a /media/root/usr/share/retroarch /media/storage/.config/retroarch
Copy cores (4.9G).
cp -a /media/root/usr/lib/libretro /media/storage/.config/retroarch/cores
LibRetro Database (684M).
cp -a /media/root/usr/share/libretro-database /media/storage/.config/retroarch/database
Filters (3M)
mkdir /media/storage/.config/retroarch/filters
cp -a /media/root/usr/share/video_filters /media/storage/.config/retroarch/filters/video
cp -a /media/root/usr/share/audio_filters /media/storage/.config/retroarch/filters/audio
WARNING: Be sure IO transfer is done, await for "sync" command to return.
sync
5. Create a retroarch systemd unit.
NOTE: kodi.conf has HOME definition used by retroarch.
vi /media/storage/.config/system.d/retroarch.service
[Unit]
Description=Retroarch
After=network-online.target graphical.target
Requires=graphical.target
Wants=network-online.target
[Service]
EnvironmentFile=/usr/lib/kodi/kodi.conf
ExecStartPre=systemctl stop kodi
ExecStart=/storage/retroarch/retroarch
ExecStopPost=systemctl start kodi
TimeoutStopSec=10
Restart=no
StartLimitInterval=0
LimitNOFILE=16384
[Install]
WantedBy=kodi.target
Display More
Reload systemd and disable retroarch service. It only is going to run when swaps with kodi.
systemctl daemon-reload
systemctl disable retroarch
6. Create a wrapper script.
vi /media/storage/retroarch.py
from xbmc import executebuiltin
from subprocess import run
executebuiltin('Notification(Retroarch, Loading..., 5000, /storage/.config/retroarch/assets/xmb/monochrome/png/retroarch.png)')
run(["/usr/bin/systemctl", "start", "retroarch"])
7. Create a shortcut in favourites
vi /media/storage/.kodi/userdata/favourites.xml
<favourites>
<favourite name="RetroArch" thumb="/storage/.config/retroarch/assets/xmb/monochrome/png/retroarch.png">RunScript(/storage/retroarch.py)</favourite>
</favourites>
8. Clear all mounted filesystems and used devices.
umount /media/storage
umount /media/root/
losetup -d /dev/loop1
umount /media/flash/
losetup -d /dev/loop0