Monday 17 October 2016

Add Lakka to your E2B USB drive and play SuperMario (and 100's of other console games)

Lakka is an open source game console emulator. See the YouTube demo here (there are many YouTube videos too, including a Hak5 intro video here!).


You can boot to Lakka from a variety of different computers including a Raspberry Pi. On an x86 PC you can directly boot from a USB drive (or install it onto a dedicated PC, if you have one to spare!).

Lakka does not support\work on a Virtual Machine - you must boot from a REAL SYSTEM!

You also need to connect USB or WiFi controllers to the PC too (recommended because using the PC keyboard is very difficult/impossible when playing games using the PC keyboard!).

I downloaded the Windows 32-bit version for a PC from here and then wrote the .img file (Lakka-Generic.i386-devel-20161002110423-r21593-g03241bf.img) to a spare 8GB USB 3.0 drive using RMPrepUSB (see below for details). For Nintendo 64 games, use Lakka 64-bit.

I then booted from the Lakka USB drive on my IdeaPad 300 (does not work on Virtual Box).



When you first boot, it automatically partitions the USB drive so that the 2nd partition is made as large as possible (max-512MB for 1st partition). For this reason, if you want to eventually add Lakka to your E2B USB drive, I suggest you choose a spare USB drive for Lakka of only 1GB or 2GB max (don't worry if it is slow - we will transfer it to the E2B USB drive later).

I then downloaded a copy of the N64 Super Mario 64 ROM file (Super Mario 64 (USA).zip 6MB) onto my Windows PC and transferred it to the Lakka USB drive that was connected to the IdeaPad 300 via Ethernet. Tip: Google for 'Lakka roms download' to find ROM files.

Tip: Unzip the game first (e.g. to xxxx.n64) - this saves space because if you copy the .zip file, Lakka will unzip it anyway and leave the .zip file there as well.

To learn how to do this in more detail, I suggest you buy Issue 408 of WebUser magazine (this weeks issue) and refer to page 61 and watch the You Tube videos.

Here are the steps I used, in outline, to get Lakka onto my E2B multiboot USB drive.

Note: This blog post is not about how to use Lakka, it is only about how to transfer it onto your E2B USB drive once you have it working. You can then carry your E2B USB drive with you and take it to your friend's house and play any console game on his/her PC.

Revised Instructions for E2B

Here is how to make the two partitions needed, a boot partition and a storage partition...

Use 7Zip to extract the boot files to a new folder.

Use 7Zip to look at the download .img.gz file (may be called system.img or something else)
Extract the files from the larger image to a new folder

Make a .imgPTN file from the folder and also a ext3 'lakka' file using RMPrepUSB...

Copy the new lakka file and lakka.imgptn file to the E2B drive

Use Switch_E2B.exe to switch to the lakka.imgPTN file (you do not need to re-order the files if prompted)

  1. Use 7Zip to extract the contents of the 524MB 0.img file which is inside the Lakka-Generic.i386-devel-20161002110423-r21593-g03241bf.img file to an empty folder (e.g. C:\temp\Lakka0).
    The folder C:\temp\Lakka0 should now contain an 8MB KERNEL file and a 235MB SYSTEM file plus various other files, if you have done this correctly.
    http://www.lakka.tv/get/windows/generic/
  2. Drag-and-Drop the C:\temp\Lakka0 folder onto the MPI_FAT32 Windows Desktop shortcut and make a C:\temp\lakka.imgPTN file. Use the size suggested. You obviously need to have installed the MPI Tool Pack onto your Windows PC first. If asked, choose 5 or 6 for the syslinux version.
  3. Use RMPrepUSB - Create ext2\3\4 File button:
    Filename = lakka
    Volume name = storage    (must be lower case 'storage')
    Size = (whatever you like - e.g. 500)
    FileType = ext3
  4. Copy the lakka.imgPTN and lakka files to your E2B USB drive menu folder (e.g. \_ISO\MAINMENU)
  5. Switch to the new lakka.imgPTN partition by using \_ISO\SWITCH_E2B.exe and double-click on the lakka.imgPTN&lakka file.
  6. You should now see the contents of the first 'Lakka' partition on the E2B USB in Windows Explorer. It should contain the \SYSTEM and \KERNEL files in the root + many others.
    There is no syslinux user menu, but only a prompt to type 'installer' or 'live', so we need to create a menu entry...
  7. Use NotePad to add the following lines to the bottom of the \menu.lst file (the file should be quite long if you have the correct one!):
  8. title LAKKA \n Lakka Game Console
    kernel /KERNEL boot=UUID=%UUID% disk=LABEL=storage quiet ssh vt.global_cursor_default=0 loglevel=2
    boot

    #For later 2017 PC 32-bit version, use this menu - Lakka-Generic.i386-2.0.img.gz
    title LAKKA 2017 \n Lakka Game Console
    kernel /KERNEL boot=UUID=%UUID% disk=LABEL=storage portable quiet vt.global_cursor_default=0 loglevel=2
    boot
See the instructions below for how to copy ROM files, etc.

Tip: If Lakka boots, but you don't see any icons in the menu system (just blue blocks), then you have not made the storage partition lakka file correctly.

Lakka 2 2017 may not boot in a VM such as Virtual Box (just get lakka icon but no 'Desktop'- try booting on a real system).

The CSM menu #1 will only boot to the normal lakka syslinux boot: prompt. You can type live [ENTER] or install [ENTER]. However, only the install option will work. You must use the new Lakka CSM menu entry to boot to Lakka live.

For UEFI-booting, you will need to modify the \EFI\boot\syslinux.cfg file and replace the disk= parameter with disk=LABEL=storage, e .g.

LABEL live

KERNEL /KERNEL
APPEND boot=UUID=F858-50E4 disk=LABEL=storage portable vt.global_cursor_default=0 loglevel=2

You can also modify the \syslinux.cfg file in the same way if you want to boot using syslinux (menu entry #1). This saves having to modify the \menu.lst file.

If you see a 'boot:' prompt when UEFI booting - press TAB to see a choice of either live or installer. Type live and [ENTER] to boot to the live version.

No USB boot option from BIOS

Once you run Lakka, it seems to affect the USB controller on some systems. If you try to reboot from the USB drive again, you may find that your BIOS does not give you the option to pick the USB drive as a boot drive. In this case you must switch off your PC\notebook - wait 15 seconds - then switch it on again. If you are using a notebook and this does not fix the USB boot issue, remove the notebook battery and disconnect the AC adapter after you switch it off, so that all power is removed for 15 seconds.

Instructions to copy existing Lakka USB drive

Step 1 - First prepare a Lakka USB drive

We need to make a bootable Lakka USB Flash drive first and make sure that it works...

1a. Download the Lakka file for a Windows PC (32-bit or 64-bit - I suggest you use the 32-bit version as it will then run on both 32-bit and 64-bit PCs - I used Lakka-Generic.i386-devel-20161002110423-r21593-g03241bf.img.gz

Use 64-bit version if you want to run Nintendo-64 games.

1b. Extract the Lakka-Generic.i386-devel-20161002110423-r21593-g03241bf.img file using 7Zip.

1c. Use RMPrepUSB - File->Drive - (img file) - 0 - 0 - 0  to write the .img file to a spare USB flash drive of size 1GB (WARNING: All contents on the flash drive will be destroyed).

Don't use a too large a USB drive because we will need to image it and then copy the image to the E2B drive. Use a 1 or 2GB drive if you have one, rather than an 8GB or larger drive.

1d. Connect the USB drive to a real PC (it does not work using an emulator like QEMU or Virtual Box!) and choose the 'Run Live' option. Allow it to resize and maximise the 2nd partition when it boots and allow it to get to the Main menu.

1e. Connect an Ethernet cable from the Lakka PC to your router/network.

1f. On your Windows PC, open the 'Network' panel and you should see a 'Lakka'  computer listed. If not, wait a few minutes and refresh the window...



1g. Download any ROMs you want from www.emuparadise.me on your Windows PC and copy them to the 'ROMs' folder under 'LAKKA'. I tried Super Mario 64 (USA).zip (6MB) and a few others. Unzip them first.


1h. Now check it is all working (you will need to read up on how to control the game and how the PC keys are mapped - press the wrong key and it can reset or reboot!). Read the WebUser article to see how to load a game or watch the YTube videos. You will need to connect a game controller (USB or WiFi) to be able to play any game.

Tip: Use the Z key=Back and X key=Select and cursor keys. ESC=abort. Enter may also work.

Inside a game, you will need look up what PC keys to press (it is not obvious!). Beware ESC=back, H=reset, P=Pause, X=go, Enter=Select, +/- keys=volume. See the Input settings for more keys. To turn, etc. you may need a game controller!

See also the FAQ 

Step 2 - Make the image files for E2B

WARNING: You must use a Lakka flash drive that has been successfully booted to the Main Menu at least once, so that the 2nd partition has been expanded. If you use a 'virgin' Lakka USB drive, the first boot may erase your E2B drive!
  1. Use RMPrepUSB - Drive->File - (filename=C:\temp\Lakka) - P2 - P2 - 0  to save partition 2 to a file. Note that the size of the file will be the size of the USB drive, minus 512MB. The file that is made should have no extension.
    Note: modern drives seem to have a GPT partition now. If RMPrepUSB fails then download the FTK Imager v3.2.0 (you will need to supply your email address) and then use FTK Imager - File - Create disk image - Logical drive - (select 2nd ptn letter of usb flash drive - not FAT ptn letter) - Add raw (dd) - Case 'Lakka' - Fragment size 0 - Start.
  2. Use 7Zip to extract the contents of the 524MB 0.img file which is inside the Lakka-Generic.i386-devel-20161002110423-r21593-g03241bf.img file to an empty folder (e.g. C:\temp\Lakka0). The folder C:\temp\Lakka0 should contain an 8MB KERNEL file and a 235MB SYSTEM file plus various other files, if you have done this correctly.
  3. Drag-and-Drop the C:\temp\Lakka0 folder onto the MPI_FAT32 Windows Desktop shortcut and make a C:\temp\Lakka.imgPTN file. Use the size suggested. You obviously need to have installed the MPI Tool Pack onto your Windows PC first.
  4. Now copy both the C:\temp\Lakka.imgPTN and C:\temp\Lakka files to your E2B USB drive (e.g. to the \_ISO\MAINMENU folder). The file names must be identical.
  5. Switch to the new Lakka.imgPTN partition by using \_ISO\SWITCH_E2B.exe and double-click on the Lakka.imgPTN file.
  6. You should now see the contents of the first 'Lakka' partition on the E2B USB in Windows Explorer. It should contain the \SYSTEM and \KERNEL files in the root + many others.
  7. Use NotePad to add the following lines to the bottom of the \menu.lst file (the file should be quite long if you have the correct one!):
title LAKKA \n Lakka Game Console
kernel /KERNEL boot=UUID=%UUID% disk=UUID=80879429-300a-449d-ace4-0ee8ddf684ce quiet ssh vt.global_cursor_default=0 loglevel=2
boot

    title LAKKA INSTALLER \n Install Lakks Game Console
    kernel /KERNEL boot=UUID=%UUID% installer quiet tty vga=ask vt.global_cursor_default=0 loglevel=2
    boot
    If you wish you can delete the 'BOOT from this drive' and the two 'Alternate boot' menu entries from the \menu.lst file because they won't work anyway (items 1, 2 and 3 in the screenshot below).

    Select the LAKKA entry to run it live.



















    If you have display issues when getting to the Main Lakka Menu, add  vga=ask to the cheat codes after the word quiet.

    You can copy more game files to the ROMs folder (if there is room) using Windows Explorer.

    P.S. I did not actually test the Install menu item for obvious reasons. If you are not going to install Lakka to a spare PC, then you can omit that menu entry.

    Have fun and please tick one of the Reactions boxes below if you enjoyed this post...

    7 comments:

    1. Hi, i managed to get a usb with lakka running, but when i reach the part where i have to make an image file of the 2nd usb partition it gives me a "invalid partition table". I'm using a 8gb usb stick, RMPrep V2.1.743. win10 x64

      ReplyDelete
      Replies
      1. There is Revised Instruction, Step 1 and Step 2 in this article.
        Each of the small steps are also numbered under each of these headings.
        If you want help, then kindly specify EXACTLY what step you get the error at and what is giving the 'invalid partition table' error.

        Delete
      2. oh yeah, sorry, forgot to put where exactly was the error. In the copy existing Lakka USB drive, step 2 (Make the image files for E2B), part 1 (Use RMPrepUSB - Drive->File). Worth to mention that i tested the usb in a live machine. i'm using the newest lakka x32 image (Lakka-Generic.i386-2.3.1).

        Delete
      3. Try RMPrepUSB - Drive Info
        Are there partitions?
        What are they
        Any reason why 2nd partition should give an RMPrepUSB error message?

        Delete
      4. https://pastebin.com/P4c1V6rk

        In any case, i will test with another usb stick later.

        Delete
      5. EE is an EFI partition type.
        Is there an option to make a standard MBR drive?

        Delete
      6. You can either use FTK Imager instead of RMPrepUSB to get an image of the 2nd partition - see new instructions (edited).

        Delete