Basic TrueNAS support for the display and status LED on the Asustor Lockerstor Gen2
I recently bought a Asustor Lockerstor 4 Gen2 NAS to run TrueNAS on. Asustor has endorsed installing third-party operating systems, and I had no problems disabling the stock operating system and running TrueNAS instead.
However, the one downside of running TrueNAS instead of the stock OS is that the status LED and built-in LCD display are no longer useful. It’s somewhat annoying to see the green status LED keep blinking away and the display showing “STARTING SYSTEM” even long after TrueNAS has finished booting.
In my case, I wasn’t after anything particularly sophisticated. I’d be happy to just have some indication that TrueNAS has started booting, some indication that TrueNAS has finished booting, and some indication that TrueNAS is shutting down.
The good news here is that it seems that the GPIO controller for the status LED is well documented, and the serial protocol for talking to the display has been reverse-engineered. This should make it possible to extend TrueNAS to make use of those devices.
Open source software to control the LCD display and give it functionality equivalent to what you could get on the stock operating system does exist. However, I did not feel comfortable running 3rd party code (particularly as root) directly on my NAS, nor did I want rely on any unsupported mechanisms for modifying TrueNAS (lest it becomes broken by an update).
In my case, I decided to make use of Init and Shutdown scripts to run scripts that controls the status LED and display. TrueNAS comes with tools like isaset
in the default installation, which is immensely useful, since it allows us to directly interact with the hardware entirely within a shell script, without installing any other programs.
Here are the scripts that I developed:
Pre-Init script
#!/bin/bash
stty -F /dev/ttyS1 115200 raw
echo -ne '\xf0\x12\x27\x00\x00 Welcome to \xb8' > /dev/ttyS1
echo -ne '\xf0\x12\x27\x01\x00 TrueNAS \xcc' > /dev/ttyS1
This script commands the LCD display to show Welcome to TrueNAS
.
Post-Init script
#!/bin/bash
# Unlock the configuration registers for the IT8625E Super I/O chip.
isaset -f -y 0x2e 0x87
isaset -f -y 0x2e 0x01
isaset -f -y 0x2e 0x55
isaset -f -y 0x2e 0x55
# Switch to the GPIO register bank
isaset -y 0x2e 0x2f 0x07 0x07
# Blinking Status LED => Solid Status LED
isaset -y 0x2e 0x2f 0xf9 0x01
This script configures the GPIO controller to stop blinking the status LED.
Shutdown script
#!/bin/bash
# Unlock the configuration registers for the IT8625E Super I/O chip.
# Technically not needed if post-init.sh has already run, but there's no harm.
isaset -f -y 0x2e 0x87
isaset -f -y 0x2e 0x01
isaset -f -y 0x2e 0x55
isaset -f -y 0x2e 0x55
# Switch to the GPIO register bank
isaset -y 0x2e 0x2f 0x07 0x07
# Solid Status LED => Blinking Status LED
isaset -y 0x2e 0x2f 0xf9 0x02
# Power off the display
isaset -f -y 0xa07 0x00 0x08
This script configures the GPIO controller to begin blinking the status LED.
Note that it’s important to power off the display, to ensure it gets power-cycled on a reboot. The firmware will power the display back on, and the display will begin showing “STARTING SYSTEM” again, indicating that the firmware is booting. If the display is not powered off beforehand, a power-cycle will not occur, and it will continue to display “Welcome to TrueNAS”.
Closing thoughts
Ideally, the gpio-it87
kernel driver would support the GPIO controller found on this NAS, so we wouldn’t need to rely on directly modifying the contents of the hardware registers. Alas it currently does not. Upstreaming support for it may be a logical follow-up project.