need help for extending libreElec

  • Hi,

    I'm planning to migrate the fan-driver of pentasata package. It is a driver available for debian systems which consist of several python scripts.

    ... but most of the required python modules are not available in libreElec.

    Therefore my plan looks like a huge challenge, which I can't solve on my own.

    Searching the forum I thought, I would find some advice on adding packages, but it looks as if that wiki section has been removed.

    Now I'm unsure, whether the right way would be, create several packages or create an addon.

    I tried to create a package by creating a directory below packages/tools called pigpio. There I created a package.mk by using a clone from another package and modified the variables. I removed all functions from package.mk

    Executing scripts/download works so far and creates the files in sources tree.

    On executing make image the only thing that happens is, that pigpio appears in .cache_package_global but no logfile that shows anything about a failed build process.

    I tried to understand the build system, but it is really complex and I don't know, how to build a single package within the toolchain.

    Is there any docs I can learn how to create a package for libreElec?

    Or anything to read and try to understand the build process?

    How should/could I proceed?

  • I'm planning to migrate the fan-driver of pentasata package

    libgpiod might be a idea too, its universal and works at RPi , Allwinner and whatnot

    if you try to build a single package

    PROJECT=RPi ARCH=arm DEVICE=RPi4 scripts/build package_name


    if you share your changes it is likely easier to help :)

    a addon sounds reasonable, also don't require manual steps

  • libgpiod might be a idea too, its universal ...


    Hm, if I got it right, pigpio is not used for its gpio functionality but for providing access to hardware pwm.

    rpi.gpio is already included in libreElec, so that may be the preferred migration path.

    gpio requirements of the driver are pretty simple. Just one button ...

    Fan speed control uses hardware pwm.

    ... and multiprocessing is used for main control. Don't know, whether "multiprocessing" is a standard module already provided by libreElec.

  • if you try to build a single package

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


    Thank you for that hint!

    What am I missing?

    When I issue a PROJECT=Rockchip ARCH=arm DEVICE=RK3399 scripts/build tools/pigpio the package builds fine without any modification, but when I issue a PROJECT=Rockchip ARCH=arm DEVICE=RK3399 make image the package will not be build.

    What I did is create a directory packages/tools/pigpio and add a package.mk to that directory containing this:

  • You just need to use

    PROJECT=Rockchip ARCH=arm DEVICE=RK3399 scripts/build pigpio (you don't need the package folder)

    And to get it in your image you need to make sure it's actually referenced somewhere

    you can either hard code it somewhere like LibreELEC.tv/package.mk at master · LibreELEC/LibreELEC.tv · GitHub

    or you can use the custom options file at ~/.libreelec/options and add ADDITIONAL_PACKAGES+="pigpio"

  • And to get it in your image you need to make sure it's actually referenced somewhere


    you can either hard code it somewhere like http://LibreELEC.tv/package.mk at master · LibreELEC/LibreELEC.tv · GitHub

    Thanks a lot for that hint. Very helpful!

    Good to know the background for package usage in image creation!

    Actually pigpio was just the first package to add. Others will follow.

    How do I create a package, that consists of just a few files, that need to be copied unchanged to given location?

    Is the root-filesystem assembled at runtime (and so I have to copy the files to different filesystems at build time), or can I specify whatever path I want as copy destination?

  • Thanks a lot for that hint. Very helpful!

    Good to know the background for package usage in image creation!

    Actually pigpio was just the first package to add. Others will follow.

    How do I create a package, that consists of just a few files, that need to be copied unchanged to given location?

    Is the root-filesystem assembled at runtime (and so I have to copy the files to different filesystems at build time), or can I specify whatever path I want as copy destination?

    see here for some hints: LibreELEC.tv/package.mk at master · LibreELEC/LibreELEC.tv · GitHub

  • That's an excellent blueprint - Thank you!

    So I could overwrite (?) bash functions in package.mk where I can use common linux commands.

    ... but how are the files from system.d directory installed? Is there an implicit copy action or is it related to file usage at post_install() ?

    Another question to pigpio - that package already contains the python api together with a setup.py file. How do I install the python part of that package?

    May be its already handled by the build system - don't know.

    On debian systems binary and python api are separate packages - how should it be at libreElec?

  • some folders are installed automatically if present as part of the normal build, "system.d" is one of them, see LibreELEC.tv/install at master · LibreELEC/LibreELEC.tv · GitHub

    As for your other question I'm not really sure what you are asking. Python packages typically require manual setup to use. Please see this package as a reference. LibreELEC.tv/package.mk at master · LibreELEC/LibreELEC.tv · GitHub

    Note that Pillow requires compiling some c modules and that's why it has a separate build step.

  • Python packages typically require manual setup to use.

    I added a makeinstall_target() which calls python with setup.py ...

    ... but now only the python files make it into the image.

    make install is ommitted and all the binary targets stay forgotten in build tree.

    I tried PKG_TOOLCHAIN as cmake and without this setting (default). No difference.

  • Thank you very much for your support!

    well, you can just call make install in makeinstall_target() if that's what you need

    Well, I already assumed that. The point is, make install is not what I need.

    (Makefile is provided by package creator. Build system uses other files, which I don't understand yet).

    I found out, that I made a mistake at function naming. So I changed the name into pre_makeinstall_target. Now the installation is called, but none of the files make it into image tree.

    So there's stil a big gap in understanding.

    This is the build log:

    What I don't understand:

    - installation of project is executed twice?

    - in both cases runtime path of pigpiod is cleared

    - none of the files make it into the image tree (which I suppose is the base for generated image).

    - who is responsible for copying of files from install_pkg to image?

    Edited once, last by tony013 (April 25, 2021 at 5:53 AM).

  • Hi,

    I don't know why or how - I removed the build tree and run a complete make image and now everything seems to be in place. Looks as if I'm done.

    To proove, that it works, I have to wait for a new pi - I killed mine with that lot of testing.

  • Hi,

    I have new problems. I built an image with my changes but pigpio denies to work, as rockpi is not a "real" pi.

    So I restarted with a debian installation where everything works and it looks as if they don't use pigpio but mraa.

    I build a package.mk for the radxa flavor of mraa but build output fails and looks pretty strange. I downloaded and used version 2.1 but during build, buildsystem switches to git master, which has a different version and fails on build.

    I don't know enuf of the build system to disable that git handling.

    I attach the logfiles (as they are too long for inlining):

    LE-build.log is built with LE build system and it fails,

    local-build.log is built with manual download and manual build outside of LE.

  • could you share the needed changes (github?) ?

    I finally worked out fan-control for LE. No additional packages needed. Just some plain text files.

    You find it at Github.

    Please pay attention to the READ.ME file.

    I don't know how to patch the kernel to get desired result, so I wrote a recipe how any nodeveloper could activate and use fan-control.

    It works until next update.

    Then you have to follow the READ.ME again.

    I have it active on my rockpi-tower running LE nightly and I'm very happy with it.