[MOD] LibreELEC for S905 with 32 bit libs to run regular arm binaries

  • For those who may be interested in running regular 32 bit arm binaries on your S905 64 bit arm (AARCH64 architecture), you will be happy to hear the linux kernel compiled by LibreELEC Odroid C2 as well as kszaq's builds already has all kernel config parameters to allow for that. The only thing missing were the actual 32 bit libraries so I created this simple modification to add those to your LibreELEC setup.


    F.A.Q.

    [Q] why would I want to run 32 bit binaries on my awesome 64 bit arm device?
    [A]
    Unfortunately not all source packages out there have already been ported to AARCH64. And from the packages not available yet, you will find many gaming related ones which make use of some assembly coding for faster responses (I believe those will take a little longer to be ported). One example is RetroArch, which although I have been able to compile it for S905 AARCH64, it does not make use of assembly code and therefore is quite slow on some cores. But if you use the RetroArch compiled for S805 devices for instance, which is an armhf 32bit binary, you can enjoy faster emulation.

    [Q] what is the trade-off of running both 64 and 32 bit programs on my box.
    [A]
    Slight RAM usage increase. When you start a 32bit program it will need to load the required libraries (ld-linux-armhf at a very minimum plus others it needs) into memory for the first time. So by running 64 bits and 32 bits applications in parallel you will use a bit of more memory. However, in most situations this side effect will not be noticeable and not affect your box's performance. Also by just having the 32 bits libraries there you are not using more RAM, just when you start launching 32 bit apps.

    [Q] for which boxes does this MOD work?
    [A]
    All S905 boxes for which kszaq's LibreELEC package work as well as the Odroid C2 based on official LE 7.9 Alpha build. It is basically the same as these original builds with the additional 32 bit libraries.

    [Q] how was this modification implemented
    [A]
    It is a very simple mod. I unpacked LibreELEC-S905.aarch64-7.0.2.008-fix.zip, extracted the SYSTEM squashfs image file and mounted it so I could access the files. I then did the same for the S805 LibreELEC image from kszaq and then copied the 32 libraries from S805 version into equivalent /lib32 and /usr/lib32 new folders I created on the S905 SYSTEM partition file. Next I created a symbolic link of /lib/ld-linux-armhf.so.3 pointing to /lib32/ld-linux-armhf.so.3 and added a startup script into /etc/profile.d to add these two new library folders into LD_LIBRARY_PATH. In the end, I just repackaged the updated SYSTEM into a tar file for easy update on LibreELEC.
    If you want to make this modification on your own, feel free to do so and leverage the source code for the script I made available here.


    INSTALLATION

    1) Recommended method (this is the only method that works for LE installed to NAND)
    This installation is done as an update to a working LibreELEC installation. Steps to follow:

    • If not done yet, you should first install the latest original build from either LE (for OdroidC2) or kszaq (for generic S905 and S905X devices) as per instructions provided by them
    • download the tar file from the link provided below and copy it into the /storage/.update folder of your box. You can do this via SSH or samba mapping as per official LibreELEC upgrade instructions from here. For generic S905(X) devices using kszaq's builds you should also download the appropriate device tree for your device (as per update instructions from kszaq`s thread), rename it to dtb.img and put it into .update folder as well. The link for the appropriate device trees is also provided in the download section below. Then just reboot the box and it will start installing the mod.

    2) Dirty & Risky method (not recommended; can be used for LE installed to SD or USB only)
    On this installation method you just replace the SYSTEM file (which is the actual system filesystem for LibreELEC compressed into one squashfs image file) directly in your removable media (SD card or USB storage). Steps to follow:

    • Turn off your device and remove the USB key or SD card.
    • Plug your USB or SD card into your windows computer. It may take a little but at some point you will see the first 500MB partition mounted. That is the FAT32 partition where the KERNEL and SYSTEM files are.
    • Replace the SYSTEM and SYSTEM.md5 files on the USB device or SD card with the modified ones you can download from the link below (rename them to SYSTEM and SYSTEM.md5 respectively). You may want to backup the existing ones from USB/SD prior to overwriting them so you have a a way to revert back in case things stop working. Also please make sure you do not modify any other file other than SYSTEM and SYSTEM.md5.
    • That's it. Just plug the USB or SD back into your device and it "should" work

    THANKS
    Credits to LE team for the offical builds
    Credits for the S905 unofficial version of LibreELEC go to its maintainer: kszaq.

    DOWNLOAD
    I have repackaged a few of the latest available builds based on LE 7.0 as well the preview of LE 8.0 (which is for now called 7.9-Alpha). Please chose the version you want from the list below (and remember to always install the MOD for the same version of the original build you have installed). Also if you are already using a version I created prior to Nov 21, 2016, you may want to update it once again as I made a minor improvement that might help to run binaries created for generic ARM devices.

    LibreELEC 7.0 Stable versions
    [hr]
    Build Name: 7.0.2.008
    Type: Released
    Device: s905
    Original installation: LibreELEC-S905.aarch64-7.0.2.008-fix.img.gz
    Device trees to use:  device_trees
    MOD update (tar): LibreELEC-S905.aarch64-7.0.2.008-fix_lib32Added.tar
    Just SYSTEM file: SYSTEM_S905-7.0.2.008_lib32Added
    Just SYSTEM.md5 file: SYSTEM_S905-7.0.2.008_lib32Added.md5
    [hr]
    Build Name: 7.0.2.009
    Type: Released
    Device: s905
    Original installation: LibreELEC-S905.aarch64-7.0.2.009.img.gz
    Device trees to use: device_trees
    MOD update (tar): LibreELEC-S905.aarch64-7.0.2.009_lib32Added.tar
    Just SYSTEM file: SYSTEM_S905-7.0.2.009_lib32Added
    Just SYSTEM.md5 file: SYSTEM_S905-7.0.2.009_lib32Added.md5


    LibreELEC 7.0 Development versions
    [hr]
    Build Name: 7.0 Development 2016-11-19
    Type: Development
    Device: s905
    Original installation: LibreELEC-S905.aarch64-7.0-devel-20161119092613-r23439-gc23e2fb.img.gz
    Device trees to use: device_trees
    MOD update (tar): LibreELEC-S905.aarch64-7.0-devel-20161119092613-r23439-gc23e2fb_lib32Added.tar
    Just SYSTEM file: SYSTEM_S905-7.0-devel-20161119092613-r23439-gc23e2fb_lib32Added
    Just SYSTEM.md5 file: SYSTEM_S905-7.0-devel-20161119092613-r23439-gc23e2fb_lib32Added.md5


    LibreELEC 7.9-Alpha Development versions
    [hr]
    Build Name: 7.90 Alpha [Krypton 8.0 preview] Development 2016-11-22 PR10887
    Type: Development
    Device: s905
    Original installation: LibreELEC-S905.aarch64-8.0-devel-20161122210840-r24442-g1aa8951.img.gz
    Device trees to use: device_trees
    MOD update (tar): LibreELEC-S905.aarch64-8.0-devel-20161122210840-r24442-g1aa8951_lib32Added.tar
    Just SYSTEM file: SYSTEM_S905-8.0-devel-20161122210840-r24442-g1aa8951_lib32Added
    Just SYSTEM.md5 file: SYSTEM_S905-8.0-devel-20161122210840-r24442-g1aa8951_lib32Added.md5
    [hr]
    Build Name: 7.90 Alpha [Krypton 8.0 preview] Development 2016-11-09
    Type: Development
    Device: s905
    Original installation: LibreELEC-S905.aarch64-8.0-devel-20161109230131-r24433-g7e8b96d.img.gz
    Device trees to use: device_trees
    MOD update (tar): LibreELEC-S905.aarch64-8.0-devel-20161109230131-r24433-g7e8b96d_lib32Added.tar
    Just SYSTEM file: SYSTEM_S905-8.0-devel-20161109230131-r24433-g7e8b96d_lib32Added
    Just SYSTEM.md5 file: SYSTEM_S905-8.0-devel-20161109230131-r24433-g7e8b96d_lib32Added.md5
    [hr]
    Build Name: 7.90.008 Alpha [Krypton 8.0 preview]
    Type: Development
    Device: Odroid C2
    Original installation: LibreELEC-Odroid_C2.aarch64-7.90.008.img.gz
    MOD update (tar): LibreELEC-Odroid_C2.aarch64-7.90.008_lib32Added.tar
    Just SYSTEM file: SYSTEM_OdroidC2-7.90.008_lib32Added
    Just SYSTEM.md5 file: SYSTEM_OdroidC2-7.90.008_lib32Added.md5

    As new versions are released I will create correspondent packages with 32 bit libraries.

    SOURCE
    If you want to implement the mod on your own, please use the suggested source code from here (instructions provided in the readme file):
    GitHub - JoKeRzBoX/MOD_add_32bit_libraries_to_LibreELEC_AARCH64: Simple instructions and additional files to combine 32 bit ARM libraries to a 64 bit AARCH64 LibreELEC Build.


    That's it. I hope you enjoy it and feel free to ask questions on this thread and I will try to answer as time permits.

    Cheers!

    Edited once, last by JoKeRzBoX (November 24, 2016 at 10:51 AM).


  • Thank you very much!
    Can it be used on Odroid C2(LibreELEC (Krypton) v7.90.008 ALPHA)? if no, would you please make one for me? :)

    No, this version will not work for you.
    However, if the current kernel compiled for the C2 has the required config options for running 32-bit libraries, a custom version can be made for your case.

    Give me a couple of days to check on that and I'll get back to you.

  • No, this version will not work for you.
    However, if the current kernel compiled for the C2 has the required config options for running 32-bit libraries, a custom version can be made for your case.

    Give me a couple of days to check on that and I'll get back to you.

    Thx a lot, I am right here waiting! :D

    Edited once, last by wxyhxh (November 5, 2016 at 4:20 PM).

  • Thx a lot, I am right here waiting! :D

    Good news! Kernel for Odroid C2 has the parameters for Kernel support for 32-bit EL0.

    I will create a version of my mod for odroid c2 for you to test later this weekend. It will be not previously tested since I do not have a C2 board, but it will be an update to LibreELEC- hence pretty safe for you to try.

  • Good news! Kernel for Odroid C2 has the parameters for Kernel support for 32-bit EL0.

    I will create a version of my mod for odroid c2 for you to test later this weekend. It will be not previously tested since I do not have a C2 board, but it will be an update to LibreELEC- hence pretty safe for you to try.


    It is wonderful! I'm sorry to take up your time, thanks again!

  • Any chance you could do the same for kzaq's WIP LibreELEC 7.9.0 Alpha build located here

    I'm finding this build better than the 7.0 build for a number of reasons (mainly playback improvements and improved Bluetooth stability) and would love to get RetroArch working on it. I'm fine with injecting the files into the filesystem myself but I'm a bit unsure about how to implement the other changes you've made myself.


  • Any chance you could do the same for kzaq's WIP LibreELEC 7.9.0 Alpha build located here

    I'm finding this build better than the 7.0 build for a number of reasons (mainly playback improvements and improved Bluetooth stability) and would love to get RetroArch working on it. I'm fine with injecting the files into the filesystem myself but I'm a bit unsure about how to implement the other changes you've made myself.

    i agree, krypton is the only version that support PS3 Bluetooth controller, no point to run game without controller :)

  • Each time someone comes up with an unpack/hack/repack/share modification the staff sigh deeply and another unicorn dies. Doing it for you own consumption if fine, but if you want to publicly share things you should be making an effort to learn the build-system and compile things properly from sources. This would also ensure you can easily publish your work on GitHub so that others can collaborate on the effort or benefit from it, with the added bonus of honouring your GPLv2 license obligations.


  • Thx for sharing tested retroarch and works fine. :)

    LeapOfFaith

    I installed the latest available Retroarch package released for the MK808B+ and MXQ.
    Unfortunately i got the error message in Putty that the retroarch executable was not found
    but i also was able to start it manually as a service. The retroarch menu also wont show up.

    My Box is a K1 DVB plus with the latest Image from afl1 with all the latest kszaq's patches (7.0.2.008)
    The binary installation was running without any problems.

    What was my mistake?
    Any help would be very appreciated....

    Edited once, last by Samui67 (November 6, 2016 at 1:36 PM).


  • Each time someone comes up with an unpack/hack/repack/share modification the staff sigh deeply and another unicorn dies. Doing it for you own consumption if fine, but if you want to publicly share things you should be making an effort to learn the build-system and compile things properly from sources. This would also ensure you can easily publish your work on GitHub so that others can collaborate on the effort or benefit from it, with the added bonus of honouring your GPLv2 license obligations.

    I totally understand your point, chewitt. Thanks for bringing up compliance with the GNU license. Since my change is just a straight combination of 2 publicly available builds (the AARCH64 build plus linux libraries from the ARCH build) and a couple of scrips I created, I published the steps and custom scripts to Github so it should now be GPLv2 compliant. The MOD's associated source code is available here (GitHub - JoKeRzBoX/MOD_add_32bit_libraries_to_LibreELEC_AARCH64: Simple instructions and additional files to combine 32 bit ARM libraries to a 64 bit AARCH64 LibreELEC Build.) with instructions so hopefully anyone can make their own instance of the mod.

    Regarding your suggestion to make this solution built from source, I don't mind looking into that (probably already have enough knowledge of the libreELEC build process to do so) but would such change (i.e. include 32 bit library into 64 bit builds, which includes compiling two toolchains, etc.) be something that could make into the official main stream at some point? Because if not, I am not really sure if it is worth the effort to keep an independent fork of the Librelec source just for that. But I am all ears here, and willing to help the community the proper way. I am thankful for what LibreELEC has become and want to collaborate where I can.
    [hr]


    [hr]

    I am glad it worked for you! I was not aware of the Gamestarter addon and will take a look at it.

    If you want to just have retroarch, this thread here gives a lot of tips on how to do that. In there I also published a modified version of the pure retroarch addon which does the chmod +x via kodi addon settings (details here).
    (I hope I am not breaking any rules by posting links to other forums here)
    [hr]


    It is wonderful! I'm sorry to take up your time, thanks again!

    Please test this version for OdroidC2 and report.
    [hr]


    Any chance you could do the same for kzaq's WIP LibreELEC 7.9.0 Alpha build located here

    I'm finding this build better than the 7.0 build for a number of reasons (mainly playback improvements and improved Bluetooth stability) and would love to get RetroArch working on it. I'm fine with injecting the files into the filesystem myself but I'm a bit unsure about how to implement the other changes you've made myself.

    Please test this version here and report back it it works.

    Edited once, last by JoKeRzBoX (November 6, 2016 at 9:11 PM).

  • Hi I did test on latest LibreELEC 7.9.0 but get errors during install :(

    Can you be more specific? Was it an error expanding the tar, verifying checksum for KERNEL or SYSTEM, etc... What did it show on the TV screen? I am not able to test this version although I used the same steps so more details on the error will be helpful to troubleshoot.