One of the biggest projects that I am working on for the ODROID community is the ODROID GameStation Turbo image, which works as a frontend for both games and media playback. It's intended as an entertainment system that allows you to control your ODROID just by using a game controller in your hand without ever having to touch the keyboard in order to watch movies, listen to music, or play your favorite games. For a better understanding of the usefulness of the image, I want to give you an inside view on how the image was created, what motivation I had, and how you can adapt it to meet your own needs.
The first ARM based devices I considered was actually the Open Pandora, but by the time I was ready to to buy one, it was not available. However, even when it came available again, it was so expensive that I couldn't afford it. Finally, when I had enough money, I was already skeptical and was looking into other options. The Pandora board is an ARM-based single core device with just 1GHz and only 512MB RAM for $700, so was it really worth it? Well, although the community was and continues to be awesome, and it's a fully portable device (like a Nintendo DS), it was way too expensive, in my opinion, for what it could do. By that time there were better devices available, including the ODROID. After seeing the ODROID-X2 in an article on a German IT News page, I got really hooked up to it. By the time Ubuntu was announced for the ODROID, I bought myself an X2. However, what I wanted the Pandora for was to play games, and the ODROID didn't have too many games at that time (2012). As my nephews got older, I figured that I could make something really nice for them that would grow with them as they grew. First, the ODROID could be a console for playing games, and later, it would function as a PC in order to do homework and learn Linux. That was my goal and motivation for creating the image.
Steps to success
The first step towards achieving that goal was to generate content, so lots of games and emulators had to be ported to the ODROID. If you read the ODROID Forum’s Ubuntu (All Linuxes) section, you will find many games and programs there that I ported myself. It was hard work, since I went from knowing basically nothing about porting games or compiling software on Linux to what I know now. ODROID was a great help in learning new skills and getting better at knowing that kind of Linux stuff. Now, I know how to optimize certain programs, how to set different optimization flags, and when those flags are needed. I learned more about how ARM CPUs work and, especially the hardware differences between the Hardkernel boards. My first project was then to port lots of games, and compile some emulators as well. If you’ve read my columns from the previous issues of ODROID Magazine, you will find lots of informations on what games are actually running on the ODROID, and it keeps getting bigger. The next big step was to make it easy, even for children, to use and work with Linux and play games. I started building Gamestation Turbo from the Linaro Ubuntu 12.04 Image. I preferred that over all other operating systems because of its Unity Desktop. Unity is easy to use and understand even for people that never used Linux before. It might not be the best desktop environment for all applications, but it's colorful, and easy to handle. For someone who has never used Linux before, it's a very nice way to get started with it. My first approach was to get the programs easy enough to run on all system. I gave all applications and games that I created a .desktop icon file, so you can find it in Unity or just place a shortcut on the desktop. This worked fine for games, but not for emulators, since emulators normally use their own file browser interface to load the ROMs. Although adults might be able to handle starting all of the games manually, kids will have no clue what certain words mean, and it's hard to see which games are available, or what to search for on Unity. It was immediately clear that I needed some kind of front end in which to start the games. I had already used XBMC on an old PC that functioned as a Home Theater PC (HTPC), and subsequently discovered a nice XBMC addon called Rom Collection Browser (RCB). RCB allows you to organize the emulator ROMs in the same way that you can organize your video collection. It’s even able to download preview images and covers and gave a short description to the games, just like video services do for movies.
Knowing this, the idea came up to use XBMC as a frontend and set it up in a way for children to play and have fun with, or better to say to set it up in a way that even a child could play with it. During that time, hardware accelerated XBMC and video playback was out of question since it development hadn’t yet been completed. The XBMC version that came with Ubuntu 12.04 was XBMC 11 (Eden), which was working, but not very fast due to software decoding. Although the Menu was working smoothly, video playback was not smooth. Still, it was working well enough that I could test out the Rom Collection Browser, and experimented with how to set everything up. When the first image of XBMC 12 (Frodo) for ODROID came out, it still did not support hardware-accelerated movie playback, but did come with OpenGL ES 2 support. Things got a little difficult to manage around that time, since compiling Hardkernel’s XBMC source code didn't work for me, and the version provided has no joystick support, which I considered very crucial to my plans I decided that, since it was planned as a gaming platform, video playback was not the most important feature, and you still could play everything that was not HD smoothly as long as it was 720p or lower. For children, it generally doesn’t matter if their favorite anime or cartoon is in HD or just SD. Well, it was about that time that a working hardware accelerated XBMC image was released, and I was able to rebuild the image with the necessary joystick support. Shortly before I released the first version of GameStation Turbo, I moved over to a fully working XBMC version.
Parts that were included
After i decided how the image should work, it was important to put all the tiny pieces together into a nicely packaged image, and for this, some work and different kinds of programs were necessary to achieve what I wanted to have. The first priority was the Operating System, which had to be very stable, easy to maintain, and with an interface that many people are already familiar with. The only choice here was between Ubuntu 12.04 and Debian Wheezy. Every other image was either unstable (Debian Jessie/Sid) or wouldn't be supported for very long (Ubuntu 13.04 or newly released 13.10). Ubuntu 12.04 is an LTS version that is supported until 2017, which is always good, however, Debian Wheezy outperformed Ubuntu 12.04. I also found that while developing for Debian Wheezy, the programs were most likely to run on Ubuntu 12.04 and higher without any issue, but not the other way around. So, I decided to use Debian Wheezy and LXDE, which uses less than 150 MB RAM even with XBMC and a couple of other programs running. After that, it was a question of putting together the right kind of software to turn the ODROID into a gaming machine.
Rom Collection Browser
I used Rom Collection Browser as a base to install different kind of emulators such as Retoarch, Mednafen, PPSSPP and ScummVM. Once the basic setup was done, it turned out that not everything was working with a gamepad out of the box, so I added antimicro which is able to map certain keys to a joystick button to fill the gaps where the joystick drivers did not work. I also maintain my own kernel builds and include the header files as well, since some parts of the kernel provided by Hardkernel did not meet my needs, and header files were not included. Besides that, there was a huge space difference between hardkernel’s kernel modules and the one that I produced. The size was Hardkernel’s build was over 300MB, but mine was only 16MB of my own build, which was achieve just by stripping the modules. My scripts also allows users to install or uninstall kernel packages, instead of just copying the kernel directly over the existing files.
The biggest problem for me was how to get all the parts to work with each other, and make it easy for people to use the image, even if they do not have knowledge on how to set it all up. The Rom Collection Browser was somewhat difficult to use for a beginner, since you had to choose the emulator, starting parameters and give the ROM files standard extension to set it up and get it to run. So I had to come up with a system that made it rather easy for a user to deal with that. There was another issue. I wanted to have full Joystick (GamePad) control, but some emulators required keys as well, such as Retroarch and Mednafen which required the ESC-key to end the current game and go back to XBMC, and also MAME games which required to enter an “OK” to continue.
One problem with preconfiguring the Rom Collection Browser was that it requires the full path of where the emulator and ROMs are located, and what file extension is used to search for ROMs. This can be rather confusing for someone that has never worked with the Rom Collection Browser. That's why I pre-selected the emulator and games, and created a folder structure where the ROMs should be placed, in order for the Rom Collection Browser to find the games. Additional emulators can be added by pressing the C key in the Rom Collection Browser and selecting “Add a new ROM collection”. There you have to give the path to the emulator, the path to the ROMs, the path where it should store information and pictures and the extension of the ROMs it should look for. The configuration file for ROM Collection Browser is stored in
/home/odroid/.xbmc/userdata/addon_data/script.game.rom.collection.browser/config.xmlBy editing this file, you can alter other options as well, such as if a .zip file should be extracted into a temporary folder, and whether to look for a ROM inside of a .zip file (which, for example, has to be deactivated for MAME games). If you're experienced enough, you can even add new collections directly in this file.
Starting an emulator
Although starting a ROM directly through the emulator will definitely work, it has a couple of disadvantages. First of all, XBMC will still be running in the background and will use some of the resources needed for a better gaming experience. Second, as mentioned before, some emulators need extra keys that are not mapped to a button. If using a joystick that is not supported, you need need antimicro to map the buttons for you. If so, you need to make sure that antimicro is started when you need it, which might not always be the case. Directly starting antimicro along with the emulator didn’t work either. To solve these and other issues, I let XBMC run a small scriptiInstead of directly starting the emulator. In that script, the emulator is started, which then runs the ROM file which is given to the script as a command-line parameter from XBMC. That way, I can define different steps to make sure the emulator works the best.
Example: running an SNES game with Retroarch: #!/bin/sh /usr/bin/killall -STOP xbmc.bin if [ `ps aux | grep antimicro | grep -v grep | wc -l` -lt 1 ]; then antimicro --tray --profile /home/odroid/joydev.xml & else /usr/bin/killall -CONT antimicro fi /usr/local/bin/retroarch -L /usr/local/share/retroarch/cores/working/snes9x_next_libretro.so "$1" /usr/bin/killall -CONT xbmc.bin /usr/bin/killall -STOP antimicroReading through the above code, you can see that XBMC is set to suspend mode, which means it won't use any processing power while we run our emulator. After that, I make a check to see whether antimicro is running, and either load it with the required profile file, or resume it in case it's still running. Then, I call the actual emulator. Here I can pass command parameters which allows me to configure the emulator. After the emulator is terminated by exiting the emulator, XBMC is resumed and antimicro is suspended. Just after the script is completely done, it switches control back to XBMC. This allows for some cleanup work that may be necessary. I wrote quite some scripts to adapt to different circumstances. For example, the ScummVM and Amiga script is a little bit more complicated; but all in all it's pretty much always the same.
- Suspend the processes you don't need (for example XBMC)
- Setup your environment by preparing the system with the stuff you need (for example, loading antimicro with the right profile)
- Call the emulator and give it the parameters that you think you'll need. The “$1” represents the ROM file that is getting passed by XBMC as a parameter.
- Do some clean up work and resume the processes that you suspended earlier
All the scripts that I used for launching emulators are located in /usr/local/bin/, where you can review, improve or add your own scripts.
Every now and then, I receive some questions about my image which I would like to address here as a FAQ.
Where do I have to put the ROM files for my games? Navigate to /home/odroid/ROMS, where you will find a structure of folders already created for each type of ROM you want to play, such as GBA and SNES. Please check the forum post at http://bit.ly/1nVvQqz for details on which file extensions are supported.
Is there a way to load ROMs from an external storage? Copy the contents of /home/odroid/ROMS to your external storage device and then auto-mount the external device to /home/odroid/ROMS by adding it to /etc/fstab, or using /etc/rc.local to make it permanent.
What joystick/gamepad are supported? I built the image for use with an Xbox 360 wireless controller and Xbox 360 wireless USB receiver. So if you have that hardware, the image should work out of the box with no modification necessary, unless I forgot something again. Besides that, every joystick/gamepad that is supported by Linux should work as well, but you will have to adapt settings for your device. Therefore you have to change the joystick settings on the individual emulators. Running Mednafen, you can simply press ALT+SHIFT+1 to setup controlls for your device. The setup program is easy to understand. The second player, if supported by emulator can be setup with ALT+SHIFT+2, and so on. For Retroarch, it's a bit more complicated. Quit XBMC, open a terminal, and type retroarch-joyconfig, then follow the instructions on the screen. At the end, you will get a long list of configuration parameters in the Terminal window. Copy this list, then open the file /home/odroid/.config/retroarch/retroarch.cfg, where you will find the same parameters listed. Replace the already existing parameters with the ones you got from retroach-joyconfig, and your device should work in retroarch.
XBMC unfortunately does not support a lot of devices for joystick support. Although Xbox 360 controllers are working fine, others do nothing at all. With PPSSPP, you can change the controller configuration within the emulator by just going into the menu. However, on PPSSPP, the way controllers are implemented is rather sluggish so only a few really work well. In worst case, you can't even use the keyboard anymore. since the controller settings won't allow you to hit certain direction keys. If that happens, delete the file /home/odroid/.config/ppsspp/PSP/SYSTEM/controls.ini and start over. If all else fails, remove any mappings for the controller and keep the settings for Keyboard only, which should always work. Then, use your best buddy, antimicro! If you use a different joystick device and really have trouble getting PPSSPP or XBMC to work with it, antimicro will work. Using antimicro, you can map keyboard commands to a button on your gamepad/joystick in the same way that you could simply map the keyboard arrow keys to your gamepads.
Does the image support CEC? Not initially. The image has libcec installed which is working on HDMI 1, but I removed CEC from the XBMC image since it was causing issues. However, you can install XBMC with CEC support if you want from my repository at http://oph.mdrjr.net/meveric/.
When I exit an emulator, the XBMC window is really small, how can I fix that? If you exit XBMC and restart it again, it will go back to fullscreen. I would advise you to “maximize” the XBMC window anyway to make it easier for you to select options.
Is there an environment besides XBMC on the image? Yes, running behind XBMC is a full fledged Debian distribution with LXDE. This means that you can install everything you want on the image that is available from he Debian repository, and more. You can do everything that you can do on the Ubuntu images as well, such as web browsing, document editing, and graphics design.
How's the XBMC and 3D performance? ODROID GameStation Turbo uses the latest Mali drivers (r4p0) that are provided by Hardkernel, together with the new armsoc framebuffer drivers and Xorg patches which give very good performance. The benchmark program es2gears runs with over 250fps, and glmark2-es2 runs with over 90fps. XBMC runs full speed with 60fps and supports 1080p playback of h.264 movies. It even allows vsync on movie playback and will change the frequency of your TV to match the movies frame rate. While doing so it uses very little CPU and RAM and outperforms the original Lubuntu 13.10 image that I previously published.