diff --git a/packages/sysutils/imx6-soc-fan/bin/imx6-soc-fan-control b/packages/sysutils/imx6-soc-fan/bin/imx6-soc-fan-control new file mode 100755 index 0000000000..88d051794d --- /dev/null +++ b/packages/sysutils/imx6-soc-fan/bin/imx6-soc-fan-control @@ -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 . +################################################################################ + +. /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 diff --git a/packages/sysutils/imx6-soc-fan/bin/imx6-soc-fan-monitor b/packages/sysutils/imx6-soc-fan/bin/imx6-soc-fan-monitor new file mode 100755 index 0000000000..ee7e7e8088 --- /dev/null +++ b/packages/sysutils/imx6-soc-fan/bin/imx6-soc-fan-monitor @@ -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 . +################################################################################ + +. /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 diff --git a/packages/sysutils/imx6-soc-fan/config/imx6-soc-fan-monitor.conf.sample b/packages/sysutils/imx6-soc-fan/config/imx6-soc-fan-monitor.conf.sample new file mode 100644 index 0000000000..a8da70d4d0 --- /dev/null +++ b/packages/sysutils/imx6-soc-fan/config/imx6-soc-fan-monitor.conf.sample @@ -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 . +################################################################################ + +# +# 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 diff --git a/packages/sysutils/imx6-soc-fan/package.mk b/packages/sysutils/imx6-soc-fan/package.mk new file mode 100644 index 0000000000..f7a2797720 --- /dev/null +++ b/packages/sysutils/imx6-soc-fan/package.mk @@ -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 . +################################################################################ + +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 +} diff --git a/packages/sysutils/imx6-soc-fan/system.d/imx6-soc-fan-monitor.service b/packages/sysutils/imx6-soc-fan/system.d/imx6-soc-fan-monitor.service new file mode 100644 index 0000000000..b21e53c947 --- /dev/null +++ b/packages/sysutils/imx6-soc-fan/system.d/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 diff --git a/packages/sysutils/imx6-status-led/bin/imx6-status-led b/packages/sysutils/imx6-status-led/bin/imx6-status-led new file mode 100755 index 0000000000..fb1af9f557 --- /dev/null +++ b/packages/sysutils/imx6-status-led/bin/imx6-status-led @@ -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 . +################################################################################ + +. /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 diff --git a/packages/sysutils/imx6-status-led/package.mk b/packages/sysutils/imx6-status-led/package.mk new file mode 100644 index 0000000000..1eb9424486 --- /dev/null +++ b/packages/sysutils/imx6-status-led/package.mk @@ -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 . +################################################################################ + +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 +} diff --git a/packages/sysutils/imx6-status-led/profile.d/01-system_type.conf b/packages/sysutils/imx6-status-led/profile.d/01-system_type.conf new file mode 100644 index 0000000000..d7260629da --- /dev/null +++ b/packages/sysutils/imx6-status-led/profile.d/01-system_type.conf @@ -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 . +################################################################################ + +# $ 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 diff --git a/packages/sysutils/imx6-status-led/system.d/imx6-status-led.service b/packages/sysutils/imx6-status-led/system.d/imx6-status-led.service new file mode 100644 index 0000000000..ab51a5e49c --- /dev/null +++ b/packages/sysutils/imx6-status-led/system.d/imx6-status-led.service @@ -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