mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 13:16:41 +00:00
Merge pull request #4146 from vpeter4/imx6_p1
project imx6: two system packages (soc fan and status led)
This commit is contained in:
commit
c3a98c3f74
67
packages/sysutils/imx6-soc-fan/bin/imx6-soc-fan-control
Executable file
67
packages/sysutils/imx6-soc-fan/bin/imx6-soc-fan-control
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# This file is part of OpenELEC - http://www.openelec.tv
|
||||||
|
# Copyright (C) 2009-2015 Stephan Raue (stephan@openelec.tv)
|
||||||
|
#
|
||||||
|
# OpenELEC is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# OpenELEC is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
. /etc/profile
|
||||||
|
|
||||||
|
if [ "$SYSTEM_TYPE" != "matrix" ]; then
|
||||||
|
echo "Only for TBS Matrix system."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
fan_on() {
|
||||||
|
echo 1 > /sys/class/leds/fan/brightness
|
||||||
|
}
|
||||||
|
|
||||||
|
fan_off() {
|
||||||
|
echo 0 > /sys/class/leds/fan/brightness
|
||||||
|
}
|
||||||
|
|
||||||
|
soc_temp() {
|
||||||
|
local temp=$(cat /sys/devices/virtual/thermal/thermal_zone0/temp)
|
||||||
|
temp="$(( $temp / 1000 ))"
|
||||||
|
echo "$temp"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "SoC temp: $(soc_temp) C"
|
||||||
|
|
||||||
|
ACTION=$1
|
||||||
|
INTERVAL=$2
|
||||||
|
|
||||||
|
if [ -n "$ACTION" -a "$ACTION" = "on" ]; then
|
||||||
|
echo "Turning fan on."
|
||||||
|
fan_on
|
||||||
|
elif [ -n "$ACTION" -a "$ACTION" = "off" ]; then
|
||||||
|
echo "Turning fan off."
|
||||||
|
fan_off
|
||||||
|
elif [ -n "$ACTION" -a "$ACTION" = "log" ]; then
|
||||||
|
if [ -n "$INTERVAL" ]; then
|
||||||
|
interval=$INTERVAL
|
||||||
|
else
|
||||||
|
interval=60
|
||||||
|
fi
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
echo "SoC temp: $(soc_temp) C"
|
||||||
|
|
||||||
|
sleep $interval
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "Unknown argument - must be on, off or log [interval]."
|
||||||
|
fi
|
83
packages/sysutils/imx6-soc-fan/bin/imx6-soc-fan-monitor
Executable file
83
packages/sysutils/imx6-soc-fan/bin/imx6-soc-fan-monitor
Executable file
@ -0,0 +1,83 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# This file is part of OpenELEC - http://www.openelec.tv
|
||||||
|
# Copyright (C) 2009-2015 Stephan Raue (stephan@openelec.tv)
|
||||||
|
#
|
||||||
|
# OpenELEC is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# OpenELEC is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
. /etc/profile
|
||||||
|
|
||||||
|
if [ "$SYSTEM_TYPE" != "matrix" ]; then
|
||||||
|
echo "Only for TBS Matrix system."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
debug_echo() {
|
||||||
|
if [ -n "$debug" -a "$debug" == "yes" ]; then
|
||||||
|
echo $*
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
fan_on() {
|
||||||
|
echo 1 > /sys/class/leds/fan/brightness
|
||||||
|
}
|
||||||
|
|
||||||
|
fan_off() {
|
||||||
|
echo 0 > /sys/class/leds/fan/brightness
|
||||||
|
}
|
||||||
|
|
||||||
|
soc_temp() {
|
||||||
|
local temp=$(cat /sys/devices/virtual/thermal/thermal_zone0/temp)
|
||||||
|
temp="$(( $temp / 1000 ))"
|
||||||
|
echo "$temp"
|
||||||
|
}
|
||||||
|
|
||||||
|
# default limits
|
||||||
|
high=75
|
||||||
|
low=60
|
||||||
|
interval=30
|
||||||
|
debug=no
|
||||||
|
|
||||||
|
userconfig=/storage/.config/imx6-soc-fan-monitor.conf
|
||||||
|
if [ -e $userconfig ]; then
|
||||||
|
. $userconfig
|
||||||
|
echo "Values from config: low=$low high=$high interval=$interval debug=$debug"
|
||||||
|
else
|
||||||
|
echo "Default values: low=$low high=$high interval=$interval debug=$debug"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#(
|
||||||
|
# # turn fan on for a moment
|
||||||
|
# fan_on
|
||||||
|
# sleep 2
|
||||||
|
# fan_off
|
||||||
|
#)&
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
temp=$(soc_temp)
|
||||||
|
debug_echo "SoC temp: $temp [low: $low, high: $high]"
|
||||||
|
if [ $temp -gt $high ]; then
|
||||||
|
debug_echo "SoC temp exceeds $high celsius, fan on"
|
||||||
|
fan_on
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $temp -lt $low ]; then
|
||||||
|
debug_echo "SoC temp below $low celsius, fan off"
|
||||||
|
fan_off
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep $interval
|
||||||
|
done
|
@ -0,0 +1,37 @@
|
|||||||
|
################################################################################
|
||||||
|
# This file is part of OpenELEC - http://www.openelec.tv
|
||||||
|
# Copyright (C) 2009-2015 Stephan Raue (stephan@openelec.tv)
|
||||||
|
#
|
||||||
|
# OpenELEC is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# OpenELEC is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
#
|
||||||
|
# imx6-soc-fan-monitor.conf.sample - i.MX6 SoC fan monitor config file
|
||||||
|
# used only for TBS Matrix system
|
||||||
|
#
|
||||||
|
|
||||||
|
# default limits without config file
|
||||||
|
# when fan is turned on
|
||||||
|
# high=70
|
||||||
|
# when fan is turned off
|
||||||
|
# low=60
|
||||||
|
# temperature checking interval
|
||||||
|
# interval=30
|
||||||
|
# periodically show temperature
|
||||||
|
# debug=no
|
||||||
|
|
||||||
|
high=70
|
||||||
|
low=55
|
||||||
|
interval=30
|
||||||
|
debug=no
|
47
packages/sysutils/imx6-soc-fan/package.mk
Normal file
47
packages/sysutils/imx6-soc-fan/package.mk
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
################################################################################
|
||||||
|
# This file is part of OpenELEC - http://www.openelec.tv
|
||||||
|
# Copyright (C) 2009-2015 Stephan Raue (stephan@openelec.tv)
|
||||||
|
#
|
||||||
|
# OpenELEC is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# OpenELEC is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
PKG_NAME="imx6-soc-fan"
|
||||||
|
PKG_VERSION="1.0"
|
||||||
|
PKG_REV="1"
|
||||||
|
PKG_ARCH="arm"
|
||||||
|
PKG_LICENSE="GPL"
|
||||||
|
PKG_SITE="http://www.openelec.tv/"
|
||||||
|
PKG_URL=""
|
||||||
|
PKG_DEPENDS_TARGET=""
|
||||||
|
PKG_PRIORITY="optional"
|
||||||
|
PKG_SECTION="system"
|
||||||
|
PKG_SHORTDESC="i.MX6 SoC fan monitor"
|
||||||
|
PKG_LONGDESC="i.MX6 SoC fan monitor for TBS Matrix system"
|
||||||
|
PKG_IS_ADDON="no"
|
||||||
|
PKG_AUTORECONF="no"
|
||||||
|
|
||||||
|
make_target() {
|
||||||
|
: # nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
makeinstall_target() {
|
||||||
|
mkdir -p $INSTALL/usr/config
|
||||||
|
cp -PR $PKG_DIR/config/* $INSTALL/usr/config
|
||||||
|
mkdir -p $INSTALL/usr/bin
|
||||||
|
cp -PR $PKG_DIR/bin/* $INSTALL/usr/bin
|
||||||
|
}
|
||||||
|
|
||||||
|
post_install() {
|
||||||
|
enable_service imx6-soc-fan-monitor.service
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=i.MX6 SoC fan monitor service
|
||||||
|
ConditionPathExists=/var/run/system_type_matrix
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/imx6-soc-fan-monitor
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
49
packages/sysutils/imx6-status-led/bin/imx6-status-led
Executable file
49
packages/sysutils/imx6-status-led/bin/imx6-status-led
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# This file is part of OpenELEC - http://www.openelec.tv
|
||||||
|
# Copyright (C) 2009-2015 Stephan Raue (stephan@openelec.tv)
|
||||||
|
#
|
||||||
|
# OpenELEC is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# OpenELEC is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
. /etc/profile
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"on")
|
||||||
|
TRIGGER=default-on
|
||||||
|
;;
|
||||||
|
"heartbeat")
|
||||||
|
TRIGGER=heartbeat
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
TRIGGER=""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$SYSTEM_TYPE" in
|
||||||
|
"matrix")
|
||||||
|
LED=/sys/class/leds/red/trigger
|
||||||
|
;;
|
||||||
|
"cuboxi")
|
||||||
|
LED=/sys/class/leds/imx6\:red\:front/trigger
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
LED=""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -n "$TRIGGER" -a -n "$LED" ]; then
|
||||||
|
echo $TRIGGER > $LED
|
||||||
|
fi
|
45
packages/sysutils/imx6-status-led/package.mk
Normal file
45
packages/sysutils/imx6-status-led/package.mk
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
################################################################################
|
||||||
|
# This file is part of OpenELEC - http://www.openelec.tv
|
||||||
|
# Copyright (C) 2009-2015 Stephan Raue (stephan@openelec.tv)
|
||||||
|
#
|
||||||
|
# OpenELEC is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# OpenELEC is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
PKG_NAME="imx6-status-led"
|
||||||
|
PKG_VERSION="1.0"
|
||||||
|
PKG_REV="1"
|
||||||
|
PKG_ARCH="arm"
|
||||||
|
PKG_LICENSE="GPL"
|
||||||
|
PKG_SITE="http://www.openelec.tv/"
|
||||||
|
PKG_URL=""
|
||||||
|
PKG_DEPENDS_TARGET=""
|
||||||
|
PKG_PRIORITY="optional"
|
||||||
|
PKG_SECTION="system"
|
||||||
|
PKG_SHORTDESC="i.MX6 status LED control"
|
||||||
|
PKG_LONGDESC="Front status LED control for i.MX6 systems"
|
||||||
|
PKG_IS_ADDON="no"
|
||||||
|
PKG_AUTORECONF="no"
|
||||||
|
|
||||||
|
make_target() {
|
||||||
|
: # nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
makeinstall_target() {
|
||||||
|
mkdir -p $INSTALL/usr/bin
|
||||||
|
cp -PR $PKG_DIR/bin/* $INSTALL/usr/bin
|
||||||
|
}
|
||||||
|
|
||||||
|
post_install() {
|
||||||
|
enable_service imx6-status-led.service
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
################################################################################
|
||||||
|
# This file is part of OpenELEC - http://www.openelec.tv
|
||||||
|
# Copyright (C) 2009-2015 Stephan Raue (stephan@openelec.tv)
|
||||||
|
#
|
||||||
|
# OpenELEC is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# OpenELEC is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# $ cat /sys/devices/soc0/machine
|
||||||
|
# Freescale i.MX6 Quad SABRE Smart Device Board
|
||||||
|
# $ cat /sys/devices/soc0/machine
|
||||||
|
# TBS Matrix
|
||||||
|
# $ cat /sys/devices/soc0/family
|
||||||
|
# Freescale i.MX
|
||||||
|
# $ cat /sys/devices/soc0/soc_id
|
||||||
|
# i.MX6Q
|
||||||
|
# $ cat /sys/devices/soc0/revision
|
||||||
|
# 1.2
|
||||||
|
|
||||||
|
SYSTEM_TYPE=$(cat /sys/bus/soc/devices/soc0/machine)
|
||||||
|
case "$SYSTEM_TYPE" in
|
||||||
|
"TBS Matrix")
|
||||||
|
export SYSTEM_TYPE="matrix"
|
||||||
|
;;
|
||||||
|
"SolidRun Cubox-i Dual/Quad")
|
||||||
|
export SYSTEM_TYPE="cuboxi"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
export SYSTEM_TYPE="undef"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# don't make from initramfs (no touch there)
|
||||||
|
if [ -e /bin/touch ]; then
|
||||||
|
mkdir -p /var/run
|
||||||
|
touch /var/run/system_type_$SYSTEM_TYPE
|
||||||
|
fi
|
@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=i.MX6 status LED service
|
||||||
|
After=kodi.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=-/bin/sh -c "/usr/bin/imx6-status-led on"
|
||||||
|
ExecStop=-/bin/sh -c "/usr/bin/imx6-status-led heartbeat"
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=kodi.target
|
Loading…
x
Reference in New Issue
Block a user