Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add an installer for LibreELEC #17

Open
Zaroz opened this issue Dec 24, 2020 · 118 comments
Open

Please add an installer for LibreELEC #17

Zaroz opened this issue Dec 24, 2020 · 118 comments

Comments

@Zaroz
Copy link

Zaroz commented Dec 24, 2020

Hello, I would like to request that an installer script for the LibreELEC OS be written, so that people can use the deskpi as a media center case.

@wardnuke
Copy link

My LibreElec MicroSD card runs fine, but since there's no DeskPi scripts for the new SD card reader, SSD, or USB port moves I can't control the desktop. Hopefully they act on this issue cause these things would make great LibreElec Media Centers which is what I bought them for in the first place. I can live with Kodi 18.7 but running the latest Kodi would be awesome.

@jojobrogess
Copy link

I was thinking about this earlier and google searched to see if there was a solution because I will need to do this later myself. Idk if it would work, but you could try ssh'ing into the LibreELEC device and installing the desk pi fan script and turning the IR interface on that way since there isn't a native terminal in libre. As for the usb boot sequencing/quirks idk if that would work with LibreELEC, so you might be limited to SD card only for the time being.

@ghost
Copy link

ghost commented Dec 26, 2020

A litteraly waste 100 buckets for that case.

  • No script for libreelec, only few distros can make use of fans and rear usb, deskpi team can at least make an add-on for libreelec, because there is no possibility to install .sh script on libreelec.

@wardnuke
Copy link

@Bobaxxx

I'd give it some time. I'm not a big fan of "Made in China" stuff, but the unit I have put together seems to work pretty well despite the issue with the SSD speed. As I said in some other posts, they're testing another controller chip and hope to ship replacement PCB's out to past purchasers starting March 2021. They say the new chip they're testing will fix the SSD bottleneck issue. I'm sure some smart cookie will figure out and distribute a script for LibreElec to run along with the DeskPi units. It's in their best interests as that's pretty much what these boxes are designed for and like you, those of us purchased it for. In the meantime, I've run some stress tests on my overclocked Pi4 8GB and I have to say the results are VERY promising. The Ice Tower cooling is awesome. My CPU didn't make it past 57.9 deg C after 10 minutes and the fan never broke 50%. I'm very impressed and the prospects are nice. I'll stick with them for a bit and see how they do. I only paid about $110 for two boxes (I have my own Pi4's) and they only released this "model" with the updated GPIO ports and SSD M.2 support in November. I think if we, the comsumer, bears with them for a little, these boxes will turn out nice.

@yoyojacky
Copy link
Contributor

@Bobaxxx

I'd give it some time. I'm not a big fan of "Made in China" stuff, but the unit I have put together seems to work pretty well despite the issue with the SSD speed. As I said in some other posts, they're testing another controller chip and hope to ship replacement PCB's out to past purchasers starting March 2021. They say the new chip they're testing will fix the SSD bottleneck issue. I'm sure some smart cookie will figure out and distribute a script for LibreElec to run along with the DeskPi units. It's in their best interests as that's pretty much what these boxes are designed for and like you, those of us purchased it for. In the meantime, I've run some stress tests on my overclocked Pi4 8GB and I have to say the results are VERY promising. The Ice Tower cooling is awesome. My CPU didn't make it past 57.9 deg C after 10 minutes and the fan never broke 50%. I'm very impressed and the prospects are nice. I'll stick with them for a bit and see how they do. I only paid about $110 for two boxes (I have my own Pi4's) and they only released this "model" with the updated GPIO ports and SSD M.2 support in November. I think if we, the comsumer, bears with them for a little, these boxes will turn out nice.

Thank you very much for your affirmation of our products, we will continue to work hard.

@yoyojacky
Copy link
Contributor

A litteraly waste 100 buckets for that case.

  • No script for libreelec, only few distros can make use of fans and rear usb, deskpi team can at least make an add-on for libreelec, because there is no possibility to install .sh script on libreelec.

We are preparing to contact libreELEC official, hope they can provide dtoverlay like Raspberry Pi official to support front USB interface, fan driver is provided through C or Python, we are still working hard to test, please be patient, we are Try to support more distributions.

@yoyojacky
Copy link
Contributor

My LibreElec MicroSD card runs fine, but since there's no DeskPi scripts for the new SD card reader, SSD, or USB port moves I can't control the desktop. Hopefully they act on this issue cause these things would make great LibreElec Media Centers which is what I bought them for in the first place. I can live with Kodi 18.7 but running the latest Kodi would be awesome.

Yes, it works on kodi.

@yoyojacky
Copy link
Contributor

Hello, I would like to request that an installer script for the LibreELEC OS be written, so that people can use the deskpi as a media center case.

https://forum.libreelec.tv/thread/23217-i-want-to-try-to-make-libreelec-support-deskpi-what-should-i-do/
I was posted a post here, and try to figure out how to add the funciton to enable dwc2 on libreELEC.

@yoyojacky
Copy link
Contributor

Hello, I would like to request that an installer script for the LibreELEC OS be written, so that people can use the deskpi as a media center case.

My LibreElec MicroSD card runs fine, but since there's no DeskPi scripts for the new SD card reader, SSD, or USB port moves I can't control the desktop. Hopefully they act on this issue cause these things would make great LibreElec Media Centers which is what I bought them for in the first place. I can live with Kodi 18.7 but running the latest Kodi would be awesome.

The dwc2 driver isn't included in LibreELEC, but with LibreELEC 10 you'll be able to use otg_mode=1 - this is already working in development builds, see here [BUG] Missing configuration parameter for DWC2 at RPI4 · Issue #4722 · LibreELEC/LibreELEC.tv · GitHub

@Zaroz
Copy link
Author

Zaroz commented Dec 31, 2020

I was thinking about this earlier and google searched to see if there was a solution because I will need to do this later myself. Idk if it would work, but you could try ssh'ing into the LibreELEC device and installing the desk pi fan script and turning the IR interface on that way since there isn't a native terminal in libre. As for the usb boot sequencing/quirks idk if that would work with LibreELEC, so you might be limited to SD card only for the time being.

I tried ssh'ing into it and installing there, but it said that the installer script required apt, which libreELEC does not have.

A literaly waste 100 buckets for that case.

  • No script for libreelec, only few distros can make use of fans and rear usb, deskpi team can at least make an add-on for libreelec, because there is no possibility to install .sh script on libreelec.
    That's not entirely true, the Argon One uses .sh script and, while not exactly the same as the raspbian version, it does work on LibreELEC.

@ghost
Copy link

ghost commented Dec 31, 2020

Somebody is comparing the argon 1, i got 2 argon1 cases, 20 bucks each :

  • Works flawlessly without some "quirks" command, or anything else
  • argon1 script fan control is intended at start to works on Libreelec (launch as a service at start), and it works (install, working and uninstall script)

How do you explain argon1 script is functioning and then deskpi-team script doesn't function ?

@wardnuke
Copy link

wardnuke commented Jan 2, 2021

@Bobaxxx

I think the "script" they're referring to "not work" for the DeskPi is the one that loads and activates the various drivers and such that make the extension board work. I think there are controllers and such that must be activated and set up so that the board they use to move the HDMI / USB and such along with the IR controller and power button have to be loaded and this is the issue. Like I've said in previous posts, this is the initial launch and I'm sure they'll get things right. I think the biggest issue they have working against them is they're based overseas and getting stuff to the US market takes a bit. My two DeskPi Pro boxes took almost a month to get to me. Hopefully they'll get the bugs worked out and the supply chain flowing so that they can deliver a better product in a more timely manner. Otherwise some enterprising person is going to set up something here in the US and dominate the business. If there is any sort of trade war between the US and China it'll impact their supply flow. Someone here in the US that makes a similar product, using the lessons learned from this box, would make a killing as the UK would probalby follow with the US in any dispute with China. Since Raspberry Pi's are very popular in the UK, that would be real bad for the DeskPi folks if they were cut out of the US market along with the UK market because of flaws and supply issues. They'd better get this fixed or someone will swoop in and take their business.

@yoyojacky
Copy link
Contributor

我想请求编写LibreELEC OS的安装程序脚本,以便人们可以将deskpi用作媒体中心盒

Thanks very much.... and what can i do for you?

@yoyojacky
Copy link
Contributor

The working methods of the two products are different, and the same scripts cannot be used to achieve functions.

@Zaroz
Copy link
Author

Zaroz commented Feb 6, 2021

我想请求编写LibreELEC OS的安装程序脚本,以便人们可以将deskpi用作媒体中心盒

Thanks very much.... and what can i do for you?

The working methods of the two products are different, and the same scripts cannot be used to achieve functions.

We are asking for you to write an install script that will work on LibreELEC OS, so the device is able to work.

@yoyojacky
Copy link
Contributor

我想请求编写LibreELEC OS的安装程序脚本,以便人们可以将deskpi用作媒体中心盒

Thanks very much.... and what can i do for you?

The working methods of the two products are different, and the same scripts cannot be used to achieve functions.

We are asking for you to write an install script that will work on LibreELEC OS, so the device is able to work.

oh, sorry for my misunderstanding, we are working on it, it is a little bit hard for me due to the LibreELEC OS is not a normal linux distribution...

@yoyojacky
Copy link
Contributor

I was thinking about this earlier and google searched to see if there was a solution because I will need to do this later myself. Idk if it would work, but you could try ssh'ing into the LibreELEC device and installing the desk pi fan script and turning the IR interface on that way since there isn't a native terminal in libre. As for the usb boot sequencing/quirks idk if that would work with LibreELEC, so you might be limited to SD card only for the time being.

I tried ssh'ing into it and installing there, but it said that the installer script required apt, which libreELEC does not have.

A literaly waste 100 buckets for that case.

  • No script for libreelec, only few distros can make use of fans and rear usb, deskpi team can at least make an add-on for libreelec, because there is no possibility to install .sh script on libreelec.
    That's not entirely true, the Argon One uses .sh script and, while not exactly the same as the raspbian version, it does work on LibreELEC.

I have tried several times but no luck too. it requires some packages as well.

@jojobrogess
Copy link

@yoyojacky what drivers are you referring to?

I'm going to attempt at making an installer. Idk how to code, and I barely understand Kodi addon/plugins. Or how they operate but it shouldn't be too difficult considering the Argon One m.2 does the same thing and there is an installer script for it.

So I'm basically going to attempt at pirating that script and then hacking it for the deskpi pro case.

I already found the argon one libreelec installer script and ported over a few terms to deskpi already.

https://github.com/jojobrogess/deskpi/blob/Libreelecinstaller/libreelec.sh

Later on tonight I will follow this guide:

https://www.argon40.com/learn/index.php/2020/03/10/argon-one-installation-guide-for-libreelec/

Hopefully I won't have to customize too much.

It honestly doesn't look too complicated.

The Argon one m.2 adapter board seems to work from what people are posting online.

And libreelec 10 beta has already been released so the script can be built using a dev build.

I'm also in the process of trying to understand how Kodi addons work. If I can get this installed and working correctly. I will try to create an addon(and repo), so you can easily change the temp values within Kodi.

And hopefully, just design it as an addon rather than an installer script that has to be SSH'd or CLI'd in. Because that would be lame to have to SSH into your device just to change the fan speed or temp ranges.

Wish me luck!

@jojobrogess
Copy link

yeah so i really do not know how to code. lol
but from the research I keep getting, I honestly think it's possible. just a little more complicated than the other installer scripts since there it isn't a normal OS at all. It's literally a ported over xbmc(kodi), with just enough OS to run everything on hardware.

but i honestly think it's possible, it just has to be done by someone smart than I

To get the Python GPIO library, all you have to do is to install the "Raspberry Pi Tools" add-on. Start your Python script with this lines to import that add-on lib:

#!/usr/bin/python

import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
import RPi.GPIO as GPIO

serial_port='/dev/ttyUSB0'
This is the serial port that connects to the deskPi mainboard and it will
communicate with Raspberry Pi and get the signal for fan speed adjusting.

@yoyojacky
Copy link
Contributor

yeah so i really do not know how to code. lol
but from the research I keep getting, I honestly think it's possible. just a little more complicated than the other installer scripts since there it isn't a normal OS at all. It's literally a ported over xbmc(kodi), with just enough OS to run everything on hardware.

but i honestly think it's possible, it just has to be done by someone smart than I

To get the Python GPIO library, all you have to do is to install the "Raspberry Pi Tools" add-on. Start your Python script with this lines to import that add-on lib:

#!/usr/bin/python
import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
import RPi.GPIO as GPIO

serial_port='/dev/ttyUSB0'
This is the serial port that connects to the deskPi mainboard and it will
communicate with Raspberry Pi and get the signal for fan speed adjusting.
In fact, I tried many methods, but none of them worked, because the user needs to configure two parts of deskpi: on the one hand, the dwc2 function needs to be enabled, so that the /dev/ttyUSB0 device can be created in the Linux system, and This device is the key to the communication between the Raspberry Pi and the MCU of the daughter board. It needs to send the fan speed information and the information of cutting off the power after shutdown to the MCU. I like libelect very much, but there are not enough interfaces for me to perform these operations, maybe I don't understand how it works. There is no detailed introduction in the official documents, so it is more difficult.

@jojobrogess
Copy link

In fact, I tried many methods, but none of them worked, because the user needs to configure two parts of deskpi: on the one hand, the dwc2 function needs to be enabled, so that the /dev/ttyUSB0 device can be created in the Linux system, and This device is the key to the communication between the Raspberry Pi and the MCU of the daughter board. It needs to send the fan speed information and the information of cutting off the power after shutdown to the MCU. I like libelect very much, but there are not enough interfaces for me to perform these operations, maybe I don't understand how it works. There is no detailed introduction in the official documents, so it is more difficult.

Originally posted by @HiassofT in LibreELEC/LibreELEC.tv#4722 (comment)

Just add a line with otg_mode=1 to the end of /flash/config.txt, just like you'd add the dtoverlay line.

This option will enable the builtin XHCI controller on the USB-C port instead of the DWC2 controller.

Yeah this will have to wait until Libreelec v10 is fully released. But as of right now, I am on LibreELEC (official): 9.95.4 (RPi4.arm) and after enabling otg_mode=1 this is what what is returned when I use lsusb -t -v

2021-06-30 02_34_29-Greenshot

and it looks like this located at:

2021-06-30 02_40_42-Greenshot

Might need to mount -o remount,rw /dev before you can use it.

This might help:
2021-06-30 02_49_34-Greenshot

2021-06-30 03_10_07-Greenshot

BTW usb boot on LibreELEC (official): 9.95.4 (RPi4.arm) works fine, I'm just not running it that way atm.

I wish I knew more to help, I'll keep searching and trying. hopefully eventually I get it.

@jojobrogess
Copy link

jojobrogess commented Jun 30, 2021

After a bunch of tinkering I was able to get the install script to install the files correctly in the correct locations, but I'm having problems with installing the drivers.

I'm not sure if I should use c or python, I would assume python but what do I know lol.

With the C driver: idk if the make command works within libreelec. So I'll either have to build one outside of libreelec and include it in the installer or figure out how everything works so I can break it and do it by hand.

With the python driver: it might have to be changed around slightly or include it within an addon for pyserial to work correctly
Like it's suggested here:

https://forum.libreelec.tv/thread/22849-pip-install-not-found/

When that doesn't work, I'll have to install the drivers by hand and then modify the install code to match that "working" process.

I would also care to assume that both pwmFanControl and the shutdown script need to be heavily modified to work within the libreelec file system.

I've already had to remove all "sudo" calls, and find workarounds for the "read-only" file system.

Hopefully later on tonight I'll get a little closer to getting the fan to turn on

If anyone has any type of information they can share to help me out, or point me in the right direction I would greatly appreciate it! I honestly don't know what I'm doing lol

@jojobrogess
Copy link

@yoyojacky do you have any information on the GPIO configuation?

because I found this:

https://forum.libreelec.tv/thread/9472-cooling-fan-control-raspberry-pi-libreelec/

and it seems promising..

@jojobrogess
Copy link

I was able to find a pyserial that was made for libreelec matrix

https://mirrors.kodi.tv/addons/matrix/script.module.pyserial/

@jojobrogess
Copy link

Yeah I think I got it working. let me figure out how to clean everything up and I'll post a follow up instruction manual with files.

@jojobrogess
Copy link

jojobrogess commented Jul 4, 2021


https://github.com/jojobrogess/deskpi/tree/Libreelecinstaller

If you want to help out, or take for yourself

Just make sure you're on the Libreelecinstaller branch and not master


!!!PREFACE!!!:

I have absolutely NO idea what I'm doing.
Use all of this at your own risk!
I also for some reason can't seem to be able to uninstall it fully.
I do NOT know if the power button works, my device has the pins set to always on. The blue light is on though.

I added in a lsb library from my own personal RPI 4 (found in: /lib/lsb/).
The Pyserial module and url was found by GOOGLE SEARCHING so idk if it's safe, but its hosted on a kodi mirror site soooo...

I do NOT (currently) use the Deskpi Pro case for Libreelec.
I just got bored and was curious as to why this would be complicated in the first place.
(Simple answer there just isn't that much info on the OS)
BUT if I get bored again, I might update, clean, and fix the installer.
As well as create an addon so you don't have to ssh into your device everytime if you want to change the temp ranges.
I already have some code sketched out, I just need to learn a little more about how to create an addon and then how to get that addon to operate less like an addon and more like simple bash/python. Oh yeah plus everything else in-between.
But I digress...


How to install DeskPi Pro script for Power Button and Fan Control:


REQUIREMENTS:

You MUST be on at least LibreELEC-RPi4.arm-9.95.4
extra computer or at least ssh terminal
extra usb

You will need to download a matrix ready version of pyserial on a USB and install it as an addon.
https://mirrors.kodi.tv/addons/matrix/script.module.pyserial/
MAKE SURE you choose the latest(as of right now it's):
Script.module.pyserial-3.4.0+matrix.2.zip | 100.0 KiB | 2020-May-01 14:30

IF you're ADVANCED GO TO BOTTOM


After you do that, then follow these instructions:


Connect LibreElec to the internet.
This can be done with either ethernet or WiFi
To check if the Ethernet or WiFi adapters are enabled, go to Settings>LibreElec>Network

Enable SSH. You need another computer to access the terminal of LibreElec
This can be done upon installation during wiki. Default Username= root Password=libreelec
To check if SSH is enabled, go to
Settings>LibreElec> Services

You might also want to make sure to allow addons/updates from any source.
Settings> System> Addons

Install Raspberry Pi Tools and System Tools
These can be installed by going to Addons>Install from Repository>LibreElec Addons>Program Addons

Plug the USB device you loaded with pyserial into your device.
Install Pyserial from usb
Go to Addons>Install from a zip file>Navigate to usb drive>pyserial.zip (should install like an addon) but it's just a library.(AFAIK)

Connect via SSH. The default username for LibreElec is root while the default password is libreelec
For Windows users, the best way to use SSH is through Putty using the IP address of the Pi and port 22.
Linux users ssh root@[ip address of device].
If connecting to the device for the first time, you will be asked if you're sure you want to connect to the device.
Confirm by typing yes FULLY, typing y will NOT suffice.


After you've installed the required libraries, Connect into Libreelec through SSH:


ssh root@IP.TO.YOUR.LIBREELEC

Type this:
wget https://github.com/jojobrogess/deskpi/archive/refs/heads/Libreelecinstaller.zip
unzip Libreelecinstaller.zip
chmod +x deskpi-Libreelecinstaller/lib/lsb/init-functions && chmod +x deskpi-Libreelecinstaller/install-libreelec.sh
./deskpi-Libreelecinstaller/install-libreelec.sh

Skip the next section "For Advanced Users"

Go to "After the device reboot" section


For Advanced Users:


  1. Download https://mirrors.kodi.tv/addons/matrix/script.module.pyserial/ put on USB.
  2. Install .zip through addons page.
  3. Install Raspberry Pi Tools and System Tools from Kodi repo>Programs.
  4. ssh into device
  5. wget https://github.com/jojobrogess/deskpi/archive/refs/heads/Libreelecinstaller.zip
  6. unzip Libreelecinstaller.zip
  7. chmod +x deskpi-Libreelecinstaller/lib/lsb/init-functions && chmod +x deskpi-Libreelecinstaller/install-libreelec.sh
  8. ./deskpi-Libreelecinstaller/install-libreelec.sh
  9. Wait for reboot. Reconnect ssh.
  10. ./Libreelecinstaller/Deskpi-config
  11. Adjust speed and temps.

After the device reboots:


Reconnect through SSH and run this:
./Libreelecinstaller/Deskpi-config

Use the config menu normally.
At this moment, idk what happens if you try to set custom values or if the options would even be persistent after reboot.

Note (as of right now): I have not been able to make an addon to be able to adjust the deskpi-config files so you can change the temperature ranges without having to SSH into your libreelec every time. If I can build one, I will either post in this thread or make a new one.

@jojobrogess
Copy link

IF THIS WORKS FOR YOU, pleeeaaase let me know.
this is my first ever published script.
@Bobaxxx @wardnuke @Bobaxxx and anyone else

@haan2787
Copy link

i have used pinn with libreelec but usb works only deskpi-config not no temp control
but thanks for the great work

@jojobrogess
Copy link

i have used pinn with libreelec but usb works only deskpi-config not no temp control

but thanks for the great work

I really wish I could understand what you wrote, maybe I could help out.
I've never heard of Pinn before, but with a simple google search it looks to be like NOOBS, in that it's a boot loader for rpi's to multi boot.

As long as you are running at least libreelec 9.95.4, everything should work.

Usb boot options(/update eeprom) are in the librelec icon in settings tab of Kodi.

@haan2787
Copy link

thanks for youre help pinn is like noobs
front usb is working
only deskpi-config in putty is not working
so i can not control the temp
i will try again maybe i do something wrong
gr haan2787

@jojobrogess
Copy link

jojobrogess commented Mar 28, 2022

ooooofff, I'm getting closer..


I think I figured out how to fix the deskpi-config user input BUG I reported:

2022-03-27 22_10_10-Greenshot


oh yeah!
And now my makeshift hysteresis fan code somewhat works:

2022-03-27 22_46_39-Greenshot


I just have to figure out if my testing temps/speeds are causing it to vary so much, or if it's going to dynamically run like that always. If it does, then I'll have to change it to be a little more static.

It looks like the code that's setup to check whether the current temp is different from the previous read temp, and to skip changing the fan speed values if differences are between a certain threshold, isn't working correctly.

@jojobrogess
Copy link

UPDATE:

Looks like having temp values separated by at least 5 degrees allows the code to "smooth out".
But it still varies more than the original code.

If the temp speed ranges are less than 5 degrees, you need to lower the hysteresis value lower than 1.


I also have decided not to switch out the current default/custom fan speed script with this new one.
I'll just add it as an additional configuration option.
Just in case you want more "refined" control rather than "dynamic".

To do this, I need to figure out how to add custom inputs to this new code, and then how to save them, and then how to "call" them instead of the default values.


After that, the Libreelec Deskpi Installer will be "fully" finished.
-Without input bugs and added hysteresis fan control option.

Which will make the Libreelec Deskpi Installer Complete
(And working AFAIK, no one has reported otherwise yet)


Then full blown addon work.

Pretty much the only thing I need to learn to complete this, is how to call a script(bash, shell, or python) from INSIDE the addon and be able to get to /storage/.
Once I figure that part out, then it'll be relatively simple'ish.

I'll just need to learn how to send arguments into deskpi-config OR to create code snippets of actions for default/custom value inputs.


THEN, this whole nightmare will be over...

At least kinda, I promised an addon for argon one users after one of my rants #17 (comment) lol

BUT after I just learned how to do all of this, plus having an already made addon blueprint (AND AN ALREADY WORKING(ish) INSTALLER) it shouldn't take me too long to complete it.
Although I do not own the m.2 argon, I have the original.
But AFAIK the only difference is the usb3 jumper(kinda like deskpi) for the m.2 bay.
The fan is the same, installed the same.(I'll double check prior)

I'll do that AFTER this one, of course.
And not post about it here anymore.
I'm just mentioning it now/during the process, in case anyone switched over during all of this since Deskpi didn't(doesn't) have a Libreelec installer.

@jojobrogess
Copy link

Okay so hysteresis fan control works, but modifying it is proving to be difficult.

At the moment I can only open, read, find a key and it's value/OR/write(WHILE TRUNCATING EVERYTHING ELSE) the json config file.
Which is a problem.
I also can't figure out why python user input() code is being sent with quotations around it.
And removing it before it gets written isn't working.

So building a configuration tool for easily adjusting the hysteresis values is out of my reach.
You will have to use the default setup, and then go in yourself to change it.

As well, I need to figure out the systemctl start stop process with adding an additional service.
Have them work correctly with each other(only run one if the other is stopped, or neither when constant values are selected) because as of right now, they don't.

BTW this is all on a DIFFERENT branch, which is in full test and won't work correctly.

The main one, is on the main branch. And still works AFAIK( no one has reported otherwise)
This will be added in once finished, to fix deskpi's fan control code.
And add additional control beyond the basic if over tempvalue then this speedvalue..


As for the addon:

Still can't get it to execute code.
Which means I can't get it to install pyserial, or the installer I made.
OR even change the fan speed. Idk why I could before but can't now..
I probably messed something up somewhere.

It's REALLY DIFFICULT coding, the way I do brute force style with no knowledge, inside a libreelec kodi addon.
The logs are a pain to go through and read.
I posted a support question on the Libreelec Forums, hopefully someone can help out.


I WILL post an update when I get past the next hurdle, which I expect won't be for a while..

!Working! ssh Installer here

@jojobrogess
Copy link

jojobrogess commented Mar 31, 2022

Uh oh, tests are working..

2022-03-30 20_42_57-Greenshot

I can now send predetermined code to the serial port THROUGH ADDON(again), and it works.
I as well can reach /storage/.

But I can't seem to figure out how to turn on/off services, might have to hop skip and jump(use/build file to get it run the code) instead of using CLI commands as the actions themselves.

IDK at this point, I'm 5 min into this thing working.
I just wanted to post an update to let everyone know that the ADDON WORK has fully begun and will hopefully end soon.


ATM I don't think the configuration tool for the default fan control will work as it's currently built.
Honestly I don't think that's going to work at all that way, but I am pretty sure as long as there are 4 different values set(val1,then,val2...) in the deskpi.conf file, the .service will use those values RATHER than the default ones.

So "echoing" user input values into a file doesn't seem too complicated.

After I can control the fan, then I'll move onto trying to get pyserial installed and then the Deskpi Installer.


If the addon CANNOT CONTROL THE FAN, there is NO POINT in getting it to install the installer/dependents.
That's why I'm going this route first, if I can AT LEAST CONTROL IT through the addon BUT CAN'T install the installer/dependents, it'll suck but this wont be a COMPLETE loss, imo.

Users would still be able to install through SSH, but control via addon.
I don't want it that way, I want it PURE ADDON install and control.
with an ssh installer as a "dev" option for those who like to control things that way.

@jojobrogess
Copy link

So I still can't mess with systemctl for some reason, but I can make code and execute it.
But it's super broken atm AND has ZERO NOTIFICATION.

So basically I click the button, look at whatever for change, if nothing repeat.

Which is funky for an install process..
I need to figure out a way to use notifications(or whatever they are called) to show the progress of the execution.
Or at least something because "Click button, wait 10 seconds. If it doesn't reboot, repeat." is a terrible instruction line...


I'll post when I make progress.

@jojobrogess
Copy link

So it looks like my idea of having a SUPER SIMPLE half addon, that ONLY has a settings page to do the initial setup and then to set/control the fan speed won't really work the way I/we need it to.

I mean it WILL WORK, but there will be ZERO indication as to if it worked or not, other than a reboot after a couple seconds. Can't have that.

I have to actually create some python to do the "extra" tasks of showing a dialog window inside kodi.
Which is going to be fun, at least I know all of the components work.
And I have a makeshift addon already made that can open a window and display content.
I just have to get it to display these new values instead.

After that I'll just need to learn how to create a dialog window to show that the command was executed.
Then the addon will be able to install dependencies, install deskpi service, turn fan on and off, and set fan speed to predetermined speeds.

Then I'll need to learn how to send arbitrary(user input) code into the deskpi.conf.
So that the user can configure temps and fan speeds.

Then the addon should be complete.


And then it'll just be waiting on me to figure out how to user input configure the hysteresis fan mode.
But that'll be in addition to the original deskpi installer as it is with the current ssh install method.

@jojobrogess
Copy link

Got notifications working as well as systemctl calls and other basic system calls.
So now when buttons are clicked, you know something happened. Dope.
As well, I can have a button that can serve as instructions if needed. Also dope.
All thanks to people at libreelec forum.


I've built a SOMEWHAT working addon, that half does what we need it to.

ATM: it can install the dependencies, install the deskpi service, and set fan to constant speeds(NOT USER SPECIFIED) or run default temp range fan service.
BUT it can't set any user specified code.

So ZERO customization.

But I am actively working on trying to figure out how to make a real addon.
I just can't seem to understand the addon python functions and they all work.
Once I can figure out how to make functions that work and can get called correctly, it'll be all down hill from there.

I'll just need to figure out how to open a file(the .conf file), parse lines, replace lines, and save.

Then clean up some settings code, remove my test functions, and test from a fresh install.

Then release.

Then I'll restart my work on getting the hysteresis function working with the install/default service.
Then I'll add that functionality into the addon.
Then I'll be done, because it'll be done.
(until a bug/more functionality is requested)


Sorry for the lag btw, if anyone is still following this lol.

I don't really know what I'm doing for any of this, so it's a constant battle of trail and error, man pages, google searching, forums, soul searching, and crying until I can understand it.
Almost there though...

@jojobrogess
Copy link

jojobrogess commented Apr 11, 2022

I can now set custom code inside the addon settings page and have it save into a file, to specific lines.

But I just BARELY understand why, and ALL of the code needs to be rewritten because I'm doing things in a step by step SUPER BROKEN manner(so I can understand what everything is doing while I'm trying to learn how to build this).

So right now you change code in settings page, then run the addon, then the change in the file happens.

To have the addon work as intended, it needs to do things without needing to be ran.
Like every part of this whole thing, idk how to do that lol

Plus atm I can only set 1 value, so I'll need to start writing a crap ton of if then elif statements to have it work dynamically.
Or at least I assume it's better than having all the values literally written out with all actions/ functions.


More than likely, this next little bit will take me more time than the last part.

Since I pretty much have to rewrite things in a different order all at once without being able to test before I know it works.


OHH and btw @inspector71

Pycharm is amazing for testing out python code(its an editor).
You can set up a virtual python environments(install kodistubs) and have it test the code as if it was inside kodi.

Makes coding 1000x times easier, since I don't have to check kodi logs until I know it works in the python environment.
Then if anything bad from there happens, it's simple fixes.
Rather than huge swaths of code being debugged through kodi.logs

I've pretty much fully switched away from ST3, although I'm pretty sure ST3 might still be better for kodi skin development since toolbox script works with it.(unless pycharm works with it too, idk)

@jojobrogess
Copy link

I Can Now:

Install all dependencies,
Install Deskpi Services,
Set constant Fan speeds(&turnon/off),
Configure the Fan Service(set temp/speed values to .conf).
And troubleshoot(turn on/off service)

which is everything it "needs" to do.


I just cleaned up all of the code and got it down to 2 functions under 1 class.
I didn't write if-then statements, I just wrote things out completely.
As well as just finished writing the strings............

I also keep thinking about if it would be efficient to run this as a service, my initial thought was that's how this needs to be ran. But it might be smarter to require the addon to be ran for settings to be saved, so that it's not constantly running. All the user would need is for the values to be changed, not constantly check if an outside entity changed the .conf file(since that probably wouldn't happen/could be solved by setting page to defaults)

I could stick the whole inside a guiwindow, settings page options would still be there and function.
So when using Run, it does something other than a notification that the user settings have have saved.


Other than all that. everything looks like it works correctly.
I just have to double check everything works correctly from a fresh install, 100% from libreelec(not my windows kodi) and it should be ready for initial release after that.

Then like I said, I'll start working on hysteresis for ssh.
Then once that works, add it to the addon.

More than likely by that time I'll know more about what I'm going to do about "needing" to run the addon for the settings to be saved.

@jojobrogess
Copy link

I just turned settings page that had predefined constant fan speed buttons, into a bool condition with user input value.
This will only get more complicated when I add in the hysteresis fan control.
At least now fully custom constant fan speeds can be set.
Rather than predefined buttons.


But now I can't test on my windows kodi anymore or pycharm, since I'm checking if a service is running and it's not on this machine. so the code error's out. but everything is fully complete now.

It just need final checks. which is a tomorrow problem.

@jojobrogess
Copy link

Fresh install is going slow, lots of little fixes but everything appears to be working.

I am having difficulty with installing the pyserial installer I made.
Which is the crux of this whole thing working(without serial the fan can't communicate with the OS)
I keep getting a Using data format AE_FMT_S24NE3 error

Which makes no sense. As well a couple other weird bugs.

Taking a dinner break, then going back at it all night.

@jojobrogess
Copy link

jojobrogess commented Apr 13, 2022

Alright I fixed the pyserial installer, so now the fan service works from being installed solely from the addon.

BUT I messed something up somewhere.

The default fan service/constant values/custom fan service are supposed to be shut off/switched when selected.
Atm, it looks like they are all on... So I think I have to add in the logic from the deskpi-config into the addon python file so when selecting inside the addon settings page, the services are shut off/switched accordingly.

Almost there ..
(this will be the last post until release)

comment 100 btw lol

@inspector71
Copy link
Contributor

inspector71 commented Apr 13, 2022 via email

@jojobrogess
Copy link

@inspector71 at this point all the work I did on this was for the customers, like me, who purchased this with the intention of using it as a media center with Libreelec.

Not for deskpi to use my work as a selling point to market this to new customers.

(since they vehemently opposed spending the time on this)

And I'm not really into monetary compensation for stuff like this.


WITH that being said, if they (@yoyojacky or @deskpi ) did want to send me their new Deskpi Lite (or even the nano version, although they would have to send me the nano device as well since I don't own one) WITH THE INTENTION OF ME RETURNING THE UNIT to create a libreelec installer FOR their device/Company, I totally would!
(the deskpi pro addon version, would still be mine and not be able to be used for marketing though...)

So I'd make them a Deskpi Lite(gpio fan) and a Jetson Nano Libreelec Installer/Controller Addon for free.
WITHOUT MY NAME ON IT, in the way they'd want(if I could code like that) if they sent me a unit for me to test it on.

EVEN THEN I would definitely NEED to know the return address PRIOR, since shipping is a pain atm I don't want to spend too much money returning a device I received for free just to be able to code on it lol


I think it would be fun.
But that scenario is very doubtful. Companies don't send units to people so they can code on them and return.

More than likely since I already own an Argon One(NON-m.2) and I already agreed to build them a working installer/addon. I'll do that first, and that'll teach me how to code for the gpio fans. Which will in-tern help with a Deskpi Lite addon, if there is any need for it(as in if people ask for one).


Honestly, the ONLY THING I need from this is for 1 person that NEVER POSTED IN HERE to post in my addon page telling me it worked.

Because then I'll know I helped at least 1 person out there in the world.

@jojobrogess
Copy link

Happy Easter Everyone!

Today Feels Like A Great Day To Release Something

So here's the culmination of countless hours of work:

https://github.com/jojobrogess/script.deskpifanservice

PLEASE REBOOT AFTER INSTALLING DESKPI SERVICE.
To 'save' settings Run Addon.


THERE STILL MIGHT BE BUGS, I kinda rushed getting this altogether to release it today.
And I WILL BE releasing a REPO so that it's easier to get updates.
Because I still have to add the hysteresis functionality I'm working on.
So If you install VIA .zip then make sure you check up on it because I'll probably have that finished and released soon.

screenshot-01
screenshot-02

screenshot-03

screenshot-04


LET ME KNOW IF THIS WORKS FOR YOU
Thank you and HAVE A GREAT DAY EVERYONE!

@yoyojacky
Copy link
Contributor

Long press on power button, shuts off libreelec.

I AM FULLY UNAWARE IF THIS IS A SAFE SHUT DOWN OR NOT. (will change code names to reflect pure power off command) the serial command being sent is power_off.

First of all, thank you for doing so much work to make it run on libreelect. Regarding the operation of power_off, in fact, what it does is: when you press the button 2 times in a row, the MCU will send a serial port to the The Raspberry Pi sends the string "power_off", what you need is to read this string through the serial port on the Raspberry Pi side and initialize the shutdown sequence to achieve a safe shutdown

@yoyojacky
Copy link
Contributor

I read all your comments today, I am very moved, I can't imagine what you have experienced during this time, I am really grateful to have users like you who insist on their own ideas and realize their own ideas, it is really amazing, During this period of time, due to the epidemic, I have been unable to visit here normally, and there is no corresponding equipment at home for testing. Although my colleagues and I have discussed and discussed many times, there are many obstacles. I am very glad to see your efforts. Thank you very much for your help to purchase deskpi pro and as a media center user, I will give feedback to the leader after unblocking.
Thanks again!

@inspector71
Copy link
Contributor

Great work @jojobrogess !!!

Looks like such a sensational effort. Would be great to give it a go if/when I upgrade, eventually.

Really fantastic work.

Sorry it took me so long to reply! Ever since I filtered github emails ... I forget they are there!

@inspector71
Copy link
Contributor

inspector71 commented Sep 26, 2022

@inspector71 at this point all the work I did on this was for the customers, like me, who purchased this with the intention of using it as a media center with Libreelec.

Not for deskpi to use my work as a selling point to market this to new customers.

(since they vehemently opposed spending the time on this)

And I'm not really into monetary compensation for stuff like this.

Completely understand. Your motivations are your own and that's fair enough, up to you.

WITH that being said, if they (@yoyojacky or @deskpi ) did want to send me their new Deskpi Lite (or even the nano version, although they would have to send me the nano device as well since I don't own one) WITH THE INTENTION OF ME RETURNING THE UNIT to create a libreelec installer FOR their device/Company, I totally would! (the deskpi pro addon version, would still be mine and not be able to be used for marketing though...)

So I'd make them a Deskpi Lite(gpio fan) and a Jetson Nano Libreelec Installer/Controller Addon for free. WITHOUT MY NAME ON IT, in the way they'd want(if I could code like that) if they sent me a unit for me to test it on.

EVEN THEN I would definitely NEED to know the return address PRIOR, since shipping is a pain atm I don't want to spend too much money returning a device I received for free just to be able to code on it lol

I think it would be fun. But that scenario is very doubtful. Companies don't send units to people so they can code on them and return.

I do not understand why not. In this scenario, it makes absolutely perfect sense. As previously suggested, whoever is behind the DeskPi* really needs to get their act together with testing and development of software support. If they cannot outsource this work to get it happening in reasonable time, perhaps because of an unwillingness to spend the money, the very least they can do is loan you the hardware - which of course will only cost them less than retail - to do exactly what a paid developer would do. Quite simply, they are getting your efforts for free. Efforts that are worth much more than the cost of a small hardware device. if they cannot see the business sense in that, they're really not very smart.

More than likely since I already own an Argon One(NON-m.2) and I already agreed to build them a working installer/addon. I'll do that first, and that'll teach me how to code for the gpio fans. Which will in-tern help with a Deskpi Lite addon, if there is any need for it(as in if people ask for one).

Honestly, the ONLY THING I need from this is for 1 person that NEVER POSTED IN HERE to post in my addon page telling me it worked.

Because then I'll know I helped at least 1 person out there in the world.

I absolutely understand how you feel. You've invested all your energy and all you need in return is a little recognition.

I'm sorry I am at present not being more helpful to at least test your efforts. Fortunately my deskpi has been running reasonably well. The odd spontaneous crash but I would imagine that is as much down to Kodi as anything. That is not to say I do not want to still get the product I paid for which is of course a product that works as sold with what I assume is one of the top 5 or so operating systems.

@yoyojacky if you have not yet offered to lend hardware to @jojobrogess, so that he can develop the software functionality he's now proven he can create, that's just not acceptable, as well as being illogical from a business viewpoint, surely?

@sonnysavage
Copy link

@jojobrogess - I plan to try this out in the next couple of days

@yoyojacky
Copy link
Contributor

@jojobrogess Could you please contact our salesmen to get some new product as gift ? sorry for my slow response, I have seen all your incredible effort, that's so cool and amazing. hope we can add it to our installation scripts but I have to submit a request to our team and fully test it and adding to official scripts. thanks for your effort again. please send email to : sales@52pi.com , we are going to shipping some new product to you freely as gift.

@inspector71
Copy link
Contributor

@jojobrogess Could you please contact our salesmen to get some new product as gift ? sorry for my slow response, I have seen all your incredible effort, that's so cool and amazing. hope we can add it to our installation scripts but I have to submit a request to our team and fully test it and adding to official scripts. thanks for your effort again. please send email to : sales@52pi.com , we are going to shipping some new product to you freely as gift.

Well done @yoyojacky

Thank you for doing the decent, fair choice.

@yoyojacky
Copy link
Contributor

@jojobrogess Could you please contact our salesmen to get some new product as gift ? sorry for my slow response, I have seen all your incredible effort, that's so cool and amazing. hope we can add it to our installation scripts but I have to submit a request to our team and fully test it and adding to official scripts. thanks for your effort again. please send email to : sales@52pi.com , we are going to shipping some new product to you freely as gift.

Well done @yoyojacky

Thank you for doing the decent, fair choice.

you are welcome bro, thanks for your good effort on this project ! that is very kind of you...

@jojobrogess
Copy link

UPDATE COMING SOON

@jojobrogess
Copy link

APOLOGIES, There will be a slight lag in the release.
I am going to try adding OSMC support..

@inspector71
Copy link
Contributor

__

APOLOGIES, There will be a slight lag in the release. I am going to try adding OSMC support..

Zero apologies necessary. Love your work ethic on this!

@yoyojacky
Copy link
Contributor

@jojobrogess , our team want to thank you for your effort, could you please send e-mail to jacky.li@52pi.com and contact with me with the gift shipping information confirmation?

@jojobrogess
Copy link

jojobrogess commented Jul 11, 2024

GOOD NEWS EVERYONE!

Version 3 has been released WITH OSMC SUPPORT!

https://github.com/jojobrogess/script.deskpifanservice

Hopefully this time I did it right.
(THERE HASN'T BEEN A LOT OF TESTING, so let me know)
HUGE shoutout to @inspector71 for the encouragement!



IMPORTANT NOTES:
- I am unaware if the newer Deskpi V3 version, with the barrel jack power port, works with this.
- Installation process MODIFIES the /flash/config.txt file to add the flags:
otg_mode=1, dtoverlay=dwc2, dr_mode=host, dtoverlay=gpio-ir, gpio_pin=17
- Minimum (known) working version is LibreELEC-RPi4.arm-9.95.4 and OSMC December 10 2023
- Tested versions: LibreELEC-RPi4.arm-10.0.4, LibreELEC-RPi4.arm-11.0.3, OSMC December 10 2023
- HARDCODED TTY/USB0 SERIAL DEVICE. (If you have issues, please contact me. I was lazy and ignored doing this right. sry)


To install go to Addon Settings > Installation > Install.
To uninstall go to Addon Settings > Installation > Uninstall.

screenshot-01
screenshot-02
screenshot-03
screenshot-04

To troubleshoot the installation or services go to Addon Settings > Troubleshoot > ..
screenshot-05


Mode Description:

Constant Mode:
Description: This mode keeps the fan running at a constant speed.
Operation: This value doesn't change; hence the name, the fan maintains a constant speed, regardless of the CPU temperature.
Implementation: The code fetches the constant value from the XML configuration file and sends it to the fan controller.

Variable Mode:
Description: This mode adjusts the fan speed based on CPU temperature and predefined temperature-speed pairs.
Operation: Users can define multiple temperature-speed pairs. When the CPU temperature crosses these thresholds, the fan adjusts its speed according to the corresponding predefined speed. A minimum of 2 speed pairs are required, unused pairs need to be set to 0(for both values).
- Option: If Always On is turned on and the CPU temperature falls bellow the predefined temperature-speed pairs, the fan will maintain lowest speed value. If Always On is turned off and the CPU temperature falls bellow the predefined temperature-speed pairs, the fan will shut off.
Implementation: The code checks the CPU temperature against the predefined pairs in the XML file. If the CPU temperature matches a predefined temperature, the corresponding fan speed is set.

Over-Under Mode:
Description: This mode operates similarly to Variable Mode but considers a range around the current CPU temperature for fan speed adjustments.
Operation: Users specify a fan speed value in the settings, defining a range around the CPU temperature. The fan speed adjusts within this range, avoiding frequent fan speed changes.
Implementation: The code calculates upper and lower temperature thresholds based on the CPU temperature.



@yoyojacky if you're still offering, (and I know it is excessive), but the DeskpiLite case would be a great gift.
That way I can add in logic to control that case fan as well, offering support for 2 different cases in 1 addon for 2 OS's.
I also would assume there is a Deskpi Pro RPI5 case in the works, I don't own a RPI5 yet but I am planning on getting one eventually. If you are developing one and the addon doesn't work and needs different logic, let me know.

You can add in support for: Libreelec 9.95.4 - 12.0.0 and OSMC (December-10-2023) to https://wiki.deskpi.com/deskpipro/
And Finally Close This Issue.
If I were you I would link to my github page rather than providing it locally, just in case it needs to be fixed or updated.

I can also remove my icon from within the addon if management gets upset lol



@jojobrogess
Copy link

Just created a repo so that you don't have to install it via usb with every release/fix, it'll get updated automatically.
(@yoyojacky if you are going to update the wiki, I would use these instructions)


Just add this to Kodi File Manager Source: https://jojobrogess.github.io/repository.deskpi/



How to install repo and addon:

Go to: Settings >> File manager >> select Add source >> select <None>
Enter the path: https://jojobrogess.github.io/repository.deskpi/
Name: repository.deskpi

Press OK
Back out of File manager to Settings

Go to: Add-ons >> Install from zip file >> repository.deskpi >> select repository.deskpi-0.0.1.zip
Wait for install
Then go to: Install from repository >> Repository Deskpi >> Program add-ons >> select Deskpi Fan Service
ADD-ON should now be installed into Kodi.


To install the add-on services:

Select the add-on Configure >> Installation tab > select Install
Wait for Confirmation Dialogue Window
Then go to the Fan Settings tab and set your desired settings, press OK
Then Reboot(.services will NOT start without reboot)

Deskpi Fan Service add-on and it's services should be fully installed.

@yoyojacky
Copy link
Contributor

Just created a repo so that you don't have to install it via usb with every release/fix, it'll get updated automatically. (@yoyojacky if you are going to update the wiki, I would use these instructions)

Just add this to Kodi File Manager Source: https://jojobrogess.github.io/repository.deskpi/

How to install repo and addon:

Go to: Settings >> File manager >> select Add source >> select <None> Enter the path: https://jojobrogess.github.io/repository.deskpi/ Name: repository.deskpi

Press OK Back out of File manager to Settings

Go to: Add-ons >> Install from zip file >> repository.deskpi >> select repository.deskpi-0.0.1.zip Wait for install Then go to: Install from repository >> Repository Deskpi >> Program add-ons >> select Deskpi Fan Service ADD-ON should now be installed into Kodi.

To install the add-on services:

Select the add-on Configure >> Installation tab > select Install Wait for Confirmation Dialogue Window Then go to the Fan Settings tab and set your desired settings, press OK Then Reboot(.services will NOT start without reboot)

Deskpi Fan Service add-on and it's services should be fully installed.

nice job bro! I will arrange our engineer to check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants