Other Projects

[HowTo-V4.5] DIY Arcade Kiosk - RetroArch (0.37b5 iMAME4all, SNES) on ArchLinux

91 54544
Edited by xefil at Thu Feb 19, 2015 13:54

Post Last Edited by xefil at 2015-02-19 16:33 (GMT+2) adding Version4.5 (ArchLinux updated, new kernel, emulationstation in framebuffer)
Post Edited by xefil at 2015-01-02 09:48 (GMT+2) adding Version4.1 (added steps to include emulationstation as frontend)
Post Edited by xefil at 2014-11-20 17:07 (GMT+2) adding Version4 (ISO available)
Post Edited by xefil at 2014-10-21 10:07 (GMT+2) adding Version3 (Hardware and Video)
Post Edited by xefil at 2014-10-2 05:53 adding Version2 (framebuffer support and minor fixes)


I've updated this thread with Version 4.5
I still maintain X desktop because, as you can see from the last video, I'm using the kiosk not only to play games, but to play music and use the browser as well. It has a touchscreen monitor.

What's new:
  • updated Arch Linux to last release
  • updated kernel to 3.4.103
  • framebuffer fixes under X11:
  • --- now the emulator, if in framebuffer, will executed automatically on tty2, not more in X11. This helps to prevent flickers issues
  • --- now exiting the emulator, if in framebuffer, the program goes back to X desktop refreshing the view NOTE: the refresh is done via ths script /home/bananapi/screen_reset.sh. Edit the script to fit your screen resolution!!!
  • added emulationstation in framebuffer mode (edit/add themes or manual scraper in /root/.emulationstation)
  • added skin for emulationstation
  • fixed execution of Retroarch in framebuffer and X11
  • removed old instructions from this thread due outdated
  • removed it-keyboard, qjoypad and florence keyboard autostart

    Actually I've only imame4all and pocketnes. Feel free to add new cores and games

    At the end of this post (not thread) I present you my Arcade Kiosk. Let's start with the software part, restricted only on the emulator, that is remained the same.


    I would like to share with you a big improovment in RetroArch. I was able to let it work with framebuffer instead with X11. The difference is Retroarch doesn't start anymore in Windowed X11, but in fullscreen. It's NOT needed to start framebuffer from terminal without X11 (what I was erroneous thinking that at the beginning) so it's possible to start framebuffer version from a Desktop. It has a little bug that doesn't refresh the screen on exit, that I've resolved with a startup script.
    I'll highlight the differences during this setup between X11 and framebuffer.

    Suggested setup: FRAMEBUFFER

    OS choosen: Arch Linux (latest ISO available on the forum)

    A big thanks to ryad which helped me with the setup. On his blog here (http://ryadeldajani.blogspot.de/) there are many interesting informations for X11 compilation.

    First of all, after setting up the OS and some dependencies, we enable hardware acceleration.
    This is required to have a fluid emulation.
    1. yaourt -S xorg-server-devel xorg-server mesa-libgl make gcc git automake autoconf pkg-config libtool dh-autoreconf
    Copy the Code
    We start with libdri2:

    1. cd $HOME
    2. git clone https://github.com/robclark/libdri2.git
    3. cd libdri2
    4. ./autogen.sh --prefix=/usr
    5. sudo make install
    Copy the Code
    Then, libump:

    1. cd $HOME
    2. git clone https://github.com/linux-sunxi/libump.git
    3. cd libump
    4. autoreconf -vi
    5. ./configure --prefix=/usr
    6. make
    7. sudo make install
    Copy the Code
    Choose X11 for windowed mode or framebuffer for fullscreen mode.
    sunxi-mali X11:

    1. cd $HOME
    2. git clone https://github.com/linux-sunxi/sunxi-mali.git
    3. cd sunxi-mali
    4. git submodule init
    5. git submodule update
    6. make config ABI=armhf VERSION=r3p0
    7. sudo make install
    Copy the Code
    sunxi-mali framebuffer:

    1. cd $HOME
    2. git clone https://github.com/linux-sunxi/sunxi-mali.git
    3. cd sunxi-mali
    4. git submodule init
    5. git submodule update
    6. make config ABI=armhf VERSION=r3p0 EGL_TYPE=framebuffer
    7. sudo make install
    Copy the Code
    And at least fbturbo for X11:

    1. cd $HOME
    2. git clone https://github.com/ssvb/xf86-video-fbturbo.git
    3. cd xf86-video-fbturbo
    4. autoreconf -vi
    5. ./configure --prefix=/usr
    6. make
    7. sudo make install
    Copy the Code
    Now, create a file '/etc/X11/xorg.conf.d/99-fbturbo.conf' with this content:

    1. Section "Device"
    2.         Identifier      "Allwinner A10/A13 FBDEV"
    3.         Driver          "fbturbo"
    4.         Option          "fbdev" "/dev/fb0"
    5.         Option          "SwapbuffersWait" "true"
    6.         Option          "AccelMethod" "G2D"
    7.                 EndSection
    Copy the Code
    After reboot, fbturbo drivers should be loaded:

    1. [bananapi@lemaker ~]$ grep -i fbturbo /var/log/Xorg.0.log
    2. [    11.667] (II) LoadModule: "fbturbo"
    3. [    11.668] (II) Loading /usr/lib/xorg/modules/drivers/fbturbo_drv.so
    4. [    11.691] (II) Module fbturbo: vendor="X.Org Foundation"
    5. [    11.691] (II) FBTURBO: driver for framebuffer: fbturbo
    6. [    11.692] (WW) Falling back to old probe method for fbturbo
    7. [    11.699] (II) FBTURBO(0): using /dev/fb0
    8. [    11.700] (II) FBTURBO(0): Creating default Display subsection in Screen section
    9. [    11.700] (==) FBTURBO(0): Depth 24, (==) framebuffer bpp 32
    10. [    11.700] (==) FBTURBO(0): RGB weight 888
    11. [    11.700] (==) FBTURBO(0): Default visual is TrueColor
    12. [    11.700] (==) FBTURBO(0): Using gamma correction (1.0, 1.0, 1.0)
    13. [    11.700] (II) FBTURBO(0): hardware:  (video memory: 10240kB)
    14. [    11.700] (**) FBTURBO(0): Option "fbdev" "/dev/fb0"
    15. [    11.700] (**) FBTURBO(0): Option "SwapbuffersWait" "true"
    16. [    11.701] (II) FBTURBO(0): processor: ARM Cortex-A7
    17. [    11.701] (II) FBTURBO(0): checking modes against framebuffer device...
    18. [    11.701] (II) FBTURBO(0): checking modes against monitor...
    19. [    11.702] (--) FBTURBO(0): Virtual size is 1280x1024 (pitch 1280)
    20. [    11.702] (**) FBTURBO(0):  Built-in mode "current": 108.0 MHz, 64.0 kHz, 60.0 Hz
    21. [    11.702] (II) FBTURBO(0): Modeline "current"x0.0  108.00  1280 1328 1440 1688  1024 1025 1028 1066 +hsync +vsync -csync (64.0 kHz b)
    22. [    11.702] (==) FBTURBO(0): DPI set to (96, 96)
    23. [    11.737] (II) FBTURBO(0): using backing store heuristics
    24. [    11.799] (II) FBTURBO(0): enabled G2D acceleration
    25. [    11.799] (==) FBTURBO(0): Backing store enabled
    26. [    11.809] (==) FBTURBO(0): DPMS enabled
    27. [    11.809] (II) FBTURBO(0): using sunxi disp layers for X video extension
    28. [    11.812] (II) FBTURBO(0): using hardware cursor
    29. [    11.847] (II) FBTURBO(0): tear-free zero-copy double buffering needs more video memory
    30. [    11.847] (II) FBTURBO(0): please set fb0_framebuffer_num >= 3 in the fex file
    31. [    11.847] (II) FBTURBO(0): and sunxi_fb_mem_reserve >= 15 in the kernel cmdline
    32. [    11.848] (II) FBTURBO(0): enabled display controller hardware overlays for DRI2
    33. [    11.848] (II) FBTURBO(0): Wait on SwapBuffers? enabled
    34. [    11.848] (II) FBTURBO(0): [DRI2] Setup complete
    35. [    11.848] (II) FBTURBO(0): [DRI2]   DRI driver: lima
    36. [    11.848] (II) FBTURBO(0): [DRI2]   VDPAU driver: sunxi
    37. [    11.848] (II) FBTURBO(0): using DRI2 integration for Mali GPU (UMP buffers)
    38. [    11.848] (II) FBTURBO(0): Mali binary drivers can only accelerate EGL/GLES
    39. [    11.848] (II) FBTURBO(0): so AIGLX/GLX is expected to fail or fallback to software
    Copy the Code
    We can test the sunxi driver acceleration within X11 (or framebuffer) as follow:

    Choose X11 for windowed mode or framebuffer for fullscreen mode.
    TEST X11:

    1. cd $HOME\sunxi-mali\test
    2. cc -Wall -o test test.c -lEGL -lGLESv2 -lX11
    3. ./test
    Copy the Code
    TEST framebuffer:

    1. cd $HOME\sunxi-mali
    2. make test
    3. ./test/test
    Copy the Code
    You should see triangle and some informations about EGL and GL on console (in X11) or a triangle with black background in framebuffer.
    The command 'es2gears_x11' (package mesa-demos), in addiction, shows an average of FPS on the displayed animated image.

    It is very important that you can reach the average of 150FPS on this test. Every time you install a new package with pacman, at the end of the installation process you get:

    1. ...
    2. ldconfig: libraries libGLESv1_CM.so.1 and libGLESv1_CM.so.1.1.0 in directory /usr/lib have same soname but different type.
    3. ldconfig: libraries libGLESv2.so.2 and libGLESv2.so.2.0.0 in directory /usr/lib have same soname but different type.
    Copy the Code
    This means that those libraries are overwritten. If you try again the test, you get an average FPS of 60!!! The './test' command from sunxi-mali doesn't work at all.
    So you need to reinstall sunxi-mali drivers. The 'sudo make install' from '$HOME/sunxi-mali' folder is enough and all comes back again!

    Look at the Ryad post later down (http://forum.lemaker.org/forum.p ... 72&fromuid=1212) for solution.

    Lest's go on with RetroArch. We need the frontend (retroarch) and the core.


    1. cd $HOME
    2. git clone https://github.com/libretro/RetroArch.git
    3. cd $HOME/RetroArch
    4. mkdir -p /opt/retroarch
    Copy the Code
    Choose X11 for windowed mode or framebuffer for fullscreen mode.

    1. ./configure --enable-gles --disable-oss --disable-sdl --disable-netplay --prefix=/opt/retroarch
    Copy the Code
    Here, we need to checkout a particular version (#9e132a0) of RetroArch to apply a patch from Lakka for mali framebuffer. Then we apply it.

    1. git checkout 9e132a0 -- '*'
    2. cd gfx/context/
    3. wget https://raw.githubusercontent.com/lakkatv/Lakka/lakka/packages/lakka/RetroArch/patches/RetroArch-02-fix-mali-fbdev.patch
    4. cp -a mali_fbdev_ctx.c mali_fbdev_ctx.c_backup
    5. patch mali_fbdev_ctx.c < RetroArch-02-fix-mali-fbdev.patch
    Copy the Code
    Back to main directory for compile it in framebuffer:

    1. cd $HOME/RetroArch
    2. ./configure --disable-vg --disable-ffmpeg --disable-sdl --disable-x11 --disable-xvideo --enable-gles --disable-kms --enable-neon --enable-fbo --enable-mali_fbdev --enable-lakka --enable-freetype --enable-glui
    Copy the Code
    From here again, same steps for X11 or framebuffer.

    Before we start to build it, we need to recover gl2.h and gl2ext.h header files; those taken from sunxi-mali are outdated.
    ryad has posted them on pastebin:

    Just backup the existing files and copy the new ones to /usr/include/GLES2.

    Then proceed with the build:

    1. make
    2. sudo make install
    Copy the Code
    We need then a libretro core, we can install it with yaourt:

    1. yaourt -S libretro-imame4all-git
    Copy the Code
    It installs it automatically on: /usr/lib/libretro/

    In the same way you can install SNES emulator like ryad has descrived on his blog (link at the beginning).
    I've tested for now only imame4all, which works with ROMs version 0.37b5!
    Other mame cores I've tested are:
    libretro-mame [coredumped, maybe too big, tested only mslug3]
    libretro-mame078, not working.

    Much depends on the ROM verisons and the BIOS files, which needs to be correct!

    be sure to set this into retroarch.cfg:

    1. video_driver = "gl"
    Copy the Code
    The follow is to set only for framebuffer

    1. video_gl_context = "mali-fbdev"
    Copy the Code
    This tells video_driver which OpenGL context implementation to use. For framebuffer we use "mali-fbdev". In X11 you don't need to specify it.
    Then, again, start over with common steps for both versions.

    You can then execute the following command to play your rom:

    1. /opt/retroarch/bin/retroarch -c /etc/retroarch.cfg -L /usr/lib/libretro/libretro-imame4all.so [PATH_TO_YOUR_ROM]
    Copy the Code
    The game will appear windowed (X11 version) or fullscreen (framebuffer).
    I've tested a DIY joystick with no problems. You can setup it with retroarch-joyconfig or from --menu option.
    More on retroarch.cfg could be set to improove some settings.

    For now, I've set:

    1. libretro_path = "/usr/lib/libretro"
    2. rgui_browser_directory = "PATH_TO_YOUR_ROMS"
    Copy the Code
    And I'm starting retroarch using the link on the desktop alone or via emulationstation.

    Here the games I was able to play:

    - Wonder Boy
    - Metal Slug
    - Metal Slug 2
    - 1942
    - 1943
    - Bubble Bobble
    - Golden Axe
    - Bomberman
    - The New Zeland Story

    Audio works well!

    Here some pictures:




    So, more is possible to set-up to improove the system, but meanwhile we can play a little bit MAME games ;-)


    Here I present you my project, an old Kiosk transformed into an Arcade Cabinet with some extra capabilities.
    Hardware used:

    - BananaPi board
    - 2x DIY Joystick KITs
    - 1x Touchscreen Glass applied over existing monitog
    - 1x Relay board
    - 1x Bose Docking Station Series 1

    The main propose of the project was to obtain an Arcade Station to play games.
    In addiction I would like to add some Kiosk capabilities like Browser and able to play music.

    The emulation softare installation is descrived at the beginning, so I would not repeat all again.
    About the hardware, I think there is no better way to show it with pictures!

    Original Kiosk! Yess, it's a nice Kiosk that was abandoned somewhere in our office so I've taken it to prepare my new Arcade Station

    Original Kiosk

    Original Kiosk

    Original Keyboard, before the modding.

    Original Keyboard

    Original Keyboard

    Here the layout I've used to make the holes. It's a smaller version of the Sega Layout. You can find a lot of versions here:

    Keys Layout

    Keys Layout

    So this is the result of the three layers I've used. Two are thick and need to create holes and thickness to fit buttons and joystick. The last Layer is thin and ned to cover all.



    Here some tests to insert the joystick...

    Some Tests

    Some Tests

    ...and then all together to some other checks

    Other Tests

    Other Tests

    This is the last layer...

    Final Level

    Final Level

    ...then the layer with a vinyl sticker. The same you can use to attach on cars. Before attaching it I've painted the wood with a transparent color.

    Vinyl attached

    Vinyl attached

    It's time to put all together. First two layers and the joysticks.



    Last layer



    Last but not least the buttons! Nice uh?

    Joysticks Ready

    Joysticks Ready

    Bottom view

    Bottom View

    Bottom View

    Some software tests. Under check joysticks and the touchscreen!

    Preparing all together

    Preparing all together

    Internal view of the Kiosk.

    Kiosk inside

    Kiosk inside

    FINAL VIEW of the totem. Here you cannot see the BOSE docking station on the top of the KIOSK. The internal audio is poor so I've modified an old BOSE Docking Station to work with an AUX input.
    The AUX input is not present so you need to make some modifications. More here: www.youtube.com/watch?v=Mkr5D3pW5Dg
    It sounds GREAT!

    Final View

    Final View

    Extra modification. Here you can see a relay board attached to the GPIO ports.
    Why this? Well... I was thinking the Kiosk should turned on all the time. The power consumptions is between 2-5WATT (0.5 - 0.9A) for the BananaPi.
    So what about the monitor and the Docking Station? I've installed a relay board that can be triggered using a combination of joystick buttons (via Qjoypad and xbindkeys).
    Pressing them I can turn on and off the monitor and/or the Docking Station. The monitor power button is inside the KIOSK so, when it's closed I cannot reach it. For the BOSE there is no power button.
    The relay board starts on boot with Monitor "normally closed" (also turned ON) and the BOSE System "normally opened" (also turned OFF). This because I need to see when it does boot but would like to avoid the NOISE comes from the BOSE until the sistem is not started up.
    On the video you can see it on test!

    BananaPi and Relay Board - 2

    BananaPi and Relay Board - 2

    Another pucture of the internal case. All is ready!

    BananaPi and Relay Board

    BananaPi and Relay Board

    Here the video, all in action (old video):

    Sorry for the poor quality and light.


    Last but not least here you can download the ISO.
    It fits on a 8GB SD card, based on a BananaPi board.
    Use your preferred software to burn it on a SD.

    Arcade Kiosk

    What's in:
    • default pwd: bananapi
    • autologin with bananapi user
    • auto startup of following apps from '/etc/xdg/lxsession/LXDE/autostart' (or ~/.config/lxsession/LXDE/autostart):
      • florence virtual keyboard for touchscreen (I use a touchscreen 15" with this kiosk) -- REMOVED
      • xset scripts to disable black screen timeout
      • setxkbmap it (for italian keyboard) -- REMOVED
      • qjoypad + keybindings to map joystick buttons to relay actions (for turn on off monitor and sound docking station)  -- REMOVED
      • some gpio settings
    • RetroArch (of course!) + imame4all and pocketsnes
    • EmulationStation
    • some tested games (add more on /opt/retroarch/roms)
    • desktop shortcuts to execute: RetroArch in framebuffer (recommended) or in X11 and EmulationStation
    • Chromium

    Feel free to edit it and let me know for further help, if needed

    Let me know your opinion! :-)


  • Great job!

    Wow, nice tutorial! And thanks for the credits

    Wow, nice tutorial! And thanks for the credits
    ryad Posted at 2014-10-3 01:49

    Thanks to you for the help as well... again ;-)

    Post Last Edited by KyRol at 2014-10-3 09:26

    Reply 4# xefil

    Job done really good! Could you record and publish video here with Metal Slug in action? Please show on frame rate. Which emulator is used to play Metal Slug - Mame or RetroArch?

    Edited by tony_zhang at Mon Apr 13, 2015 01:31

    Post Last Edited by ryad at 2014-10-3 14:19

    Small addition: Today I researched the ldconfig issue and could solve it! I posted the complete text on my blog. The short version: You install the sunxi-mali libraries into /usr/lib/mali (which you create before) and make them accessible via an entry in /etc/ld.so.conf.d/. This way you won't get conflicts with mesa-libgl anymore.
    1. cd $HOME
    2. git clone https://github.com/linux-sunxi/sunxi-mali.git
    3. cd $HOME/sunxi-mali
    4. git submodule init
    5. git submodule update
    6. sudo mkdir /usr/lib/mali
    7. make config ABI=armhf VERSION=r3p0
    8. sudo make -C include install
    9. sudo make -C lib/mali prefix=/usr/ lib dir='$(prefix)/lib/mali/' install
    10. sudo sh -c 'echo "/usr/lib/mali" > /etc/ld.so.conf.d/mali.conf'
    Copy the Code
    Edit: I removed the wget for gl2.h and gl2ext.h in the previous code because of issues with the forum software.


    TY ryad, great!
    I'll correct it :-)


    Great job! Thanks for sharing!!!

    Edited by xefil at 2014-10-15 02:09

    Hello guys!
    I share you a big improovment using FRAMEBUFFER instead of X11. This let you play the games in fullscreen without loosing in performances.



    @KyRol Reply

    Sorry, I've not seen your question before. I'm ready to share a video and a step-by-step for the creation of my Arcade Case. I'll then show picures of the setup and a video on Metal Slug ingame. With framebuffer it's smooth!

    Very nice improvement! Maybe you could share an image of your solution for http://forum.lemaker.org/forum.php?mod=viewthread&tid=1871 ?


    You have to log in before you can reply Login | Sign Up

    Points Rules