Coder Social home page Coder Social logo

mafredri / asustor-platform-driver Goto Github PK

View Code? Open in Web Editor NEW
49.0 11.0 7.0 85 KB

Linux kernel platform driver for ASUSTOR NAS hardware (leds, buttons)

License: GNU General Public License v3.0

Makefile 1.95% C 98.05%
asustor linux linux-kernel-module linux-kernel-driver led leds button buttons

asustor-platform-driver's Introduction

asustor-platform-driver

Linux kernel platform driver for ASUSTOR NAS hardware (leds, buttons).

On many systems, ASUSTOR uses a mix of IT87 and CPU GPIOs to control leds and buttons. Adding support for more systems should be fairly trivial, but may require some reverse engineering to figure out which GPIOs are responsible for what.

WARNING: Changing GPIO input/outputs (as done by this module) without knowledge of their effects can be dangerous and lead to instability, corrupted data or a broken system. Use at your own risk.

Dependencies

Note: The following dependencies from the mainline linux kernel are required, if they're not included by your distribution you may need to compile them yourself (note that some modules are only required on specific ASUSTOR models):

  • gpio-ich (AS6)
  • hwmon-vid (for the contained asustor-it87 module)

Optional

  • it87 (AS6, AS61, AS62, AS66XX, AS67XX, AS54XX)
    • This project includes a patched version of it87 called asustor-it87 which skips fan pwm sanity checks and supports more variants of IT86XX and the IT87XX chips than the kernels it87 driver. Support for timer-based blinking of up to two LEDs (only works on some models) has also been added.
    • Also includes a patched version of gpio-it87 called asustor-gpio-it87. The only change is supporting the IT8625E chip that is used in several newer ASUSTOR devices.
    • May require adding acpi_enforce_resources=lax to kernel boot arguments for full functionality
    • Temperature monitoring (lm-sensors)
    • Fan speed regulation via pwm1
      • See example/fancontrol for an example /etc/fancontrol config for a AS62 system
      • pwm1 etc should be in /sys/devices/platform/asustor_it87.*/hwmon/hwmon*/
    • Front panel LED brightness adjustment via pwm3

Compatibility

  • AS604T
  • AS6104T (NOT TESTED!)
  • AS6204T
  • AS6602T, AS6604T (NOT TESTED!)
  • AS6702T, AS6704T
  • AS5402T, AS5404T
  • .. possibly more, if they're similar enough. The following DMI system-manufacturer / system-product-name combinations are currently supported (see sudo dmidecode -s system-manufacturer and sudo dmidecode -s system-product-name):
    • "ASUSTOR Inc." / "AS-6xxT"
    • "Insyde" / "AS61xx"
    • "Insyde" / "GeminiLake"
    • "Intel Corporation" / "Jasper Lake Client Platform"

Features

  • LEDs (front panel, disk)
  • Buttons
    • USB Copy Button
    • Power Button (AS6)
  • Power (/sys/class/leds/power:*)
    • LCD
    • Front panel

Installation

git clone https://github.com/mafredri/asustor-platform-driver
cd asustor-platform-driver
make
sudo make install

Tips

Control blinking LEDs with it87

Note: This is probably not supported on all devices, only ones that use the IT8625E or IT8720F chips or similar.

Switch off that annoying blinking of the green status LED:

echo 0 | sudo tee /sys/devices/platform/asustor_it87.*/hwmon/hwmon*/gpled1_blink

You can re-enable it with echo 47 | sudo tee ... because the status led is it87_gp47. You can also make other GPIO LEDs blink by using their GP number instead of 47. Note that this could even be done for two LEDs, as gpled2_blink also exists.

If you want the green status LED to be constantly on (without blinking), the following should work, if gpled1_blink is still 47:

echo 11 | sudo tee /sys/devices/platform/asustor_it87.*/hwmon/hwmon*/gpled1_blink_freq

Or, if you set gpled1_blink to 0 (or to another LED), you can switch on the status LED with:

echo 1 | sudo tee /sys/class/leds/green\:status/brightness

You can also configure the blinking frequency to one of 11 supported modes, for example, set mode 3 with:

echo 3 | sudo tee /sys/devices/platform/asustor_it87.*/hwmon/hwmon*/gpled1_blink_freq

The following blinking frequency modes exist on the IT8625:

  • 0 - 0.125s Off 0.125s On
  • 1 - 0.5s Off 0.5s On
  • 2 - 2s Off 2s On
  • 3 - 0.25s Off 0.25s On
  • 4 - 1s Off 3s On
  • 5 - 3s Off 1s On
  • 6 - 2s Off 6s On
  • 7 - 6s Off 2s On
  • 8 - 0.5s Off 2s On
  • 9 - 1s Off 1s On
  • 10 - 4s Off 4s On
  • 11 - Always On

Other chips also support blinking control, but might support fewer modes. If blink frequency setting is supported at all, mode 11 (always on) should always work, and setting the other modes won't break anything, but might have differing frequencies than described above (and setting modes 8-10 will automatically set mode 0 instead).

Mode 11 for "always on" should always work, at least the bit set there was listed in all datasheets I checked (unfortunately, its function was never described in detail).

Set triggers for LEDs

Linux allows controlling LEDs with "triggers", which means that they will blink on specific events. By default, the trigger is "none" (which means "always on") for most LEDs, but there are others that you may enable (likely in a script that's run after boot), for example:

# make green USB LED blink on USB traffic
echo usb-host > /sys/class/leds/green\:usb/trigger
# make LAN led light up if the first network link is up:
echo r8169-0-200:00:link > /sys/class/leds/blue\:lan

cat /sys/class/leds/green\:usb/trigger will list the available triggers, with the currently used one being marked with square brackes (e.g. [none] kbd-scrolllock kbd-numlock kbd-capslock ...).

it87 and PWM polarity

This project includes a patched version of the it87 module that is part of mainline kernel (asustor-it87). It skips PWM sanity checks for the fan because ASUSTOR firmware correctly initializes fans in active low polarity and can be used straight with fancontrol or similar tools.

Note that it87 conflicts with asustor-it87, you may wish to add it87 to the module blocklist or explicitly load asustor-it87 instead.

You may want to use patches/001-ignore-pwm-polarity-it87.patch for the it87 kernel module if it complains about PWM polarity. In this case, it's possible to use fix_pwm_polarity=1, however, it may reverse the polarity which is unwanted (i.e. high is low, low is high). It works fine when left as configured by the firmware.

Misc

  • blue:power and red:power can be turned on simultaneously for a pink-ish tint
  • green:status and red:status can be turned on simultaneously for a orange-ish tint

Support

If you would like additional hardware to be supported, pull requests are more than welcome. Alternatively, you can install these prerequisites:

sudo apt-get install -y gpiod

And then open an issue and attach outputs from the following commands:

sudo dmesg
sudo dmidecode -s system-manufacturer
sudo dmidecode -s system-product-name
sudo dmidecode -s bios-vendor
sudo dmidecode -s bios-version
sudo dmidecode -s bios-release-date
sudo dmidecode -s bios-revision
sudo gpioinfo

NOTE: If gpioinfo does not return anything, you may need to figure out which (if any) gpio drivers to load. Also keep in mind that your distribution may not ship with all gpio- drivers, so you may need to compile them yourself.

TODO

  • Support variable amount of disk LEDs
  • Create a new led trigger driver so that we can blink disk LEDs individually, the existing disk-activity trigger always blinks all LEDs on activity from any disk

asustor-platform-driver's People

Contributors

danielgibson avatar mafredri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asustor-platform-driver's Issues

Is support AS6302T possible ?

First of all, I wanted to thank you for sharing your work - it is really amazing!
Thanks to your project I was able to get the NAS fan management OOTB working., even the network LEDs and the general notification LED are working without any changes to the code.
I'm missing the disk activity LEDs for full happiness. Disk presence LEDs are on but its activity LEDs are off all the time. Could you direct me how to fix it ?
AS6302T.txt

PWM always inverted as5402t

Hi I have install module asustor_gpio_it87 and asustor_it87 only because my archlinux don't seem to have gpio-inch availlable

sensors are correctly detected

[    0.775619] asustor_gpio_it87: loading out-of-tree module taints kernel.
[    0.775626] asustor_gpio_it87: module verification failed: signature and/or required key missing - tainting kernel
[    0.775910] asustor_gpio_it87: Found Chip IT8625 rev d. 64 GPIO lines starting at 0a00h
[    0.781784] asustor_it87: Found IT8625E chip at 0xa30, revision 13
[    0.781862] asustor_it87: Beeping is supported

but pwm command are always inverted so can't use pwmconfig to configure fan control
does someone have a solution on that?

Asustor AS6604T

Hello,
If you have some time to look for my Asustor AS6604T
But I think we will have the same problem with IT8625E
Ask me if you need more information

# sudo dmidecode -s system-manufacturer
Insyde

# sudo dmidecode -s system-product-name
GeminiLake

# sudo dmidecode -s bios-vendor
INSYDE Corp.

# sudo dmidecode -s bios-version
V1.1C

# sudo dmidecode -s bios-release-date
03/20/2020

# sudo dmidecode -s bios-revision
1.25

gpioinfo.txt
dmesg.txt

GPIO for AS67XXT (Lockerstor 4 Gen 2)

sudo dmidecode -s system-manufacturer
Intel Corporation
sudo dmidecode -s system-product-name
Jasper Lake Client Platform
sudo dmidecode -s bios-vendor
Phoenix Technologies Ltd
sudo dmidecode -s bios-version
V1.14
sudo dmidecode -s bios-release-date
12/02/2021
sudo dmidecode -s bios-revision
0.0

sudo gpinfo returns nothing (cant find any gpio related driver).

dmesg attached
as6704t_dmesg.txt

Support for: Asustor AS5104T. Also requesting usage examples for testing

asustor_as5104t_front
I have Asustor AS5104T. I have already installed Debian bullseye into it.

  • sudo dmesg
  • sudo dmidecode -s system-manufacturer
  • sudo dmidecode -s system-product-name
  • sudo dmidecode -s bios-vendor
  • sudo dmidecode -s bios-version
  • sudo dmidecode -s bios-release-date
  • sudo dmidecode -s bios-revision
  • sudo gpioinfo

as attachment. I also installed asustor platform module

git clone --branch it87 https://github.com/mafredri/asustor-platform-driver.git

Module compiled and loaded without warnings. I am unsure does it work as it should, I don't know how to test it. I would see instructions for, how to:

  • Stop front green led blinking
  • Dim down front led brightness
  • Detect if front buttons are pressed (up, esc, down, enter)
  • Change front panel LCD text "STARTING SYSTEM PLEASE WAIT..." to something else
  • Generate beep sound

asustor-AS5104T.txt

Thank you.

No issue just wanted to say thank you for this driver package it works!. Can confirm pwm and lcd control work as intended on the AS5202T after pwm fix. Unfortunately speed fan inverses the fan control high is low and such meaning I’m stuck using fixed rpm otherwise as the NAS gets hot the fan turns off. You should really try and promote your driver package again now that Asustor customers have been hit with deadbolt on adm one of the big hold backs for people moving to another OS is fan control and led.

Had to create a startup script in /etc/init.d to launch the pwm fix at boot. Didn’t really understand the patch script you had looking at the git.

#!/bin/sh

rmmod it87 && modprobe it87 fix_pwm_polarity=1

And a startup service script under /run/systemd/generator.late/

[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/init.d/pwmfix.sh
Before=multi-user.target
Before=multi-user.target
Before=graphical.target
After=apport.service
After=preload.service
After=hddtemp.service
After=slapd.service
After=nut-client.service
After=lightdm.service

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/etc/init.d/pwmfix.sh start
ExecStop=/etc/init.d/pwmfix.sh stop

also modified the fancontrol.service under /lib/systemd/system/ changed it so my script runs after the lm-sensors.service so it doesn’t conflict with the fancontrol gui by https://github.com/Maldela/fancontrol-gui

[Unit]
Description=fan speed regulator

Run pwmconfig to create this file.

ConditionFileNotEmpty=/etc/fancontrol
After=lm-sensors.service
After=pwmfix.service
Documentation=man:fancontrol(8) man:pwmconfig(8)

[Service]
ExecStartPre=/usr/sbin/fancontrol --check
ExecStart=/usr/sbin/fancontrol
PIDFile=/run/fancontrol.pid

[Install]
WantedBy=multi-user.target

AS5402T memory leak

Hi I use archlinux on my AS5402T and I have a memory leak memory use is always growing but I don't see any application who use it.
somebody have already meet this type of issue on this hardware?

Capture d’écran du 2024-03-31 11-39-49

Asustor AS6706T gen 2 additional leds and lcd

Hi, I have implemented your module and I can now manage my fanspeed: thanks!

For the AS6706T 2 of the 6 sata leds are missing. Trying to figure out how to find out the gpio's for the 5th and 6th bay leds, but it is not clear to me how you do it. Can you explain or maybe if you know them, give them, so I can try to add them to the asusstor.c ?
Also it is not clear to me whether the lcd should function? It is stuck to "system starting please wait..." on my box?

Tia

Support for AS6706T is confirmed

Just letting you know support for the AS6706T platform is confirmed. Your assumptions about the GPIO pins for disks 5 and 6 are also correct. (As suggested in your asustor.c file.)

It works on my old AS3104T, thank you very much

Just installed Void Linux (musl) on AS3104T and found the second top LED (system status) keep blinking. Did some search and it brought me here.

On a fresh Void, install the dev tools (I can't remember what exactly I installed), you will also need these packages:

# headers
sudo xbps-install -S linux-headers
# system.map
sudo xbps-install -S void-repo-debug
sudo xbps-install -S linux6.6-dbg # match your kernel version

And follow the README.md to stop the system LED from blinking:

sudo modprobe asustor_it87
sudo modprobe asustor_gpio_it87
sudo sh -c "echo 0 > /sys/devices/platform/asustor_it87.656/hwmon/hwmon2/gpled1_blink"

I can see the following lines in dmesg when modprobe: (i tried asustor as well)

[ 1215.674589] asustor_it87: loading out-of-tree module taints kernel.
[ 1215.674606] asustor_it87: module verification failed: signature and/or required key missing - tainting kernel
[ 1215.676235] asustor_it87: Found IT8728F chip at 0x290, revision 2
[ 1215.676281] asustor_it87: Beeping is supported
[ 1215.678253] asustor_gpio_it87: Found Chip IT8728 rev 2. 64 GPIO lines starting at 0600h
[ 1215.690004] asustor: No supported ASUSTOR mainboard found

I think the next step for me would be make a package for Void Linux, but I'm completely newbie to Void, so maybe not now :P

Anyway many thanks for this awesome proejct!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.