Minimal Build

  • Hi,

    As I understand, Lakka is built on Libreelec. That made me interested in seeing if I could make my own build. I'm trying to build a minimal OS with accelerated video/audio on a single-board computer like a Raspberry Pi. I assume that means GLES v2 and maybe OpenAL. The goal is to boot fast into my own program.

    I'm just getting started. Do I need Ubuntu desktop or can I build from a server edition?

  • I'm just getting started. Do I need Ubuntu desktop or can I build from a server edition?

    There's no need for a Desktop version although it's often easier to work with(in) if the VM is on a laptop. If the build VM is on a remote device, minimal server images are fine and have lower overheads.

  • Thanks. I'm going through that but I ran into a problem, pretty quickly.

    Using Ubuntu server 20.04.3 LTS:

    I've updated and upgraded everything. I try to install the packages as indicated but I get an error:

    Quote

    E: Unable to locate package makeinfo

    E: Unable to locate package mkfontscale

    E: Unable to locate package mkfontdir

    E: Unable to locate package bdftopcf

    E: Unable to locate package java

  • I guess I can ignore those. The build seems to have worked without them.

    If they really don't matter, it would make sense to remove them from the docs. I wasn't able to add them to a fresh Ubuntu LTS server install. I don't think they were in the docker build, either.

  • htop already exists in the build-system, so you can either install the system-tools add-on package via the Kodi GUI (which contains htop) or you can add "htop" to extra packages in one of distribution/project/device 'options' files and it should be added to the default image.

  • htop already exists in the build-system, so you can either install the system-tools add-on package via the Kodi GUI (which contains htop) or you can add "htop" to extra packages in one of distribution/project/device 'options' files and it should be added to the default image.

    Oh, okay. Thanks :)

    How would I compile my own hello.c, so that it links to the correct libraries and will run on my device? Does it need to go into the image or can I copy it over to the existing LibreElec (running via SD card on my device)?

    If there's a way to add gcc / build tools, that's fine, too. Then I can compile on the device.

  • LE is based on a cross-compile workflow where the buildsystem will download package sources, cache them, unpack them, apply local patches to the sources, and then build them. The package is then included into an image or update tar file by adding the package to the distro/project/device options config. It's possible to use local sources in the package folder but that's a bad habit, and some binaries you might be able to copy accross as-is from another distro, but it depends on how they were compiled (static or dynamic) and it's never guaranteed to work. There is intentionally no package install system in LE (other than the tools add-ons in the Kodi GUI) so to build on-device you'll have to delve into the world of Docker to have a build environment. As a rule its a lot easier to work in a VM on a desktop/laptop which has more grunt.

    See documentation in https://github.com/LibreELEC/Libr…master/packages and go read the wiki sections on self-building..

  • Right. I'm not really interested in taking binaries from other packages. I'm just trying to figure out how to compile something in the build system, so that I can get it on my device and try it. I'd prefer not to need to build images, write that to SD, etc. for every change.

  • Okay, I used the toolchain in the build system. It was easy to get a simple "hello world" working.

    Is there a way to dig up the command line used to compile Kodi? I want to include all the headers and libs for audio, input and EGL (GLES2).

    Edited once, last by flystar (December 29, 2021 at 7:26 AM).

  • https://wiki.libreelec.tv/development-1/build-basics

    https://wiki.libreelec.tv/development-1/…d-commands-le10

    So for RPi4

    Code
    PROJECT=RPi ARCH=arm DEVICE=RPi4 make image

    To make a package

    Code
    PROJECT=RPi ARCH=arm DEVICE=RPi4 scripts/build htop

    Thanks! That is good to know how to build a package.

    Right now, I'm trying to figure out how to get a minimal EGL test working. I'm calling things in this order:

    eglGetDisplay

    eglInitialize

    eglBindAPI

    eglChooseConfig

    eglCreateContext

    eglCreateWindowSurface

    Everything works until I get to eglCreateWindowSurface.

    Somehow, I need to create a "native window". Otherwise, I don't have a valid handle to give eglCreateWindowSurface.

    The info log from Kodi shows:

    EGL_VERSION = 1.4

    EGL_VENDOR = Mesa Project

    GL_VENDOR = lima

    GL_RENDERER = Mali400

    It's not using X. I think it's DRM. How can I create a window?

  • Can I ask, what exactly are you going to try and build?

    I had fun with an old Odroid SBC that I hacked together with a modified SDL. My image has an accelerated framebuffer, audio, input - enough to put together an app or game. It worked well for some small projects. I like being able to boot an SBC into a minimal environment and run, essentially, one program. I tried pushing the GPU to see how it performed.

    I've always wanted that on a Pine A64+ but never succeeded. The Odroid image was a pain to put together. I couldn't get it ported to the A64+, GPU efficiency seemed sub-par and booting was a bit slow. The modified SDL needs maintenance, too.

    LibreElec seems perfect for what I want, which is a minimal OS and hardware acceleration. It works on lots of hardware (including the A64+), which is great.

    Does that help explain? :)

  • It helps. You'll find that our documentation on the build-system is rather light, which is a little deliberate. Our observation over the years is that the people who succeed at custom images and things built on our codebase generally look at the huge pile of prior-art the build-system represents and just get on with it. You'll find "git grep" is helpful for tracing variables and packages.

    An older example of minimal config https://github.com/chewitt/LibreE…93ae1a9d2ff85e8

    NB: Current record for a minimal image is 35MB for a functional Kodi + TVHeadend + screensaver image for WeTek Play 2 (also S905 like C2) but that required junking the entirety of systemd for a more minimal LinuxFromScratch and init based approach.