Welcome! Log In Create A New Profile

Advanced

Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)

Posted by 1000001101000 
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 19, 2019 05:06PM
# cat /proc/device-tree/model
Buffalo Linkstation LS421D
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 19, 2019 05:19PM
That looks right. Do you get any dmesg output if you plug something into it?
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 19, 2019 05:30PM
-



Edited 1 time(s). Last edit at 03/19/2019 05:32PM by oxygen8.
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 19, 2019 05:31PM
thank you, i will try this tomorrow



Edited 1 time(s). Last edit at 03/19/2019 05:33PM by oxygen8.
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 19, 2019 05:37PM
When I get home i’ll look at mine and see what else you can check.
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 21, 2019 07:10PM
here is what my dmesg output looks like
[66517.863078] usb 1-2: new high-speed USB device number 2 using xhci_hcd
[66518.013465] usb 1-2: New USB device found, idVendor=0930, idProduct=6544
[66518.020242] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[66518.027447] usb 1-2: Product: USB Flash Memory
[66518.031931] usb 1-2: Manufacturer:         
[66518.036151] usb 1-2: SerialNumber: 001D92DC4AE6C910F3C50294
[66518.074210] usb-storage 1-2:1.0: USB Mass Storage device detected
[66518.085982] scsi host2: usb-storage 1-2:1.0
[66518.095316] usbcore: registered new interface driver usb-storage
[66518.108440] usbcore: registered new interface driver uas
[66519.124589] scsi 2:0:0:0: Direct-Access              USB Flash Memory 1.00 PQ: 0 ANSI: 2
[66519.138704] sd 2:0:0:0: Attached scsi generic sg1 type 0
[66519.145636] sd 2:0:0:0: [sdb] 7823296 512-byte logical blocks: (4.01 GB/3.73 GiB)
[66519.164334] sd 2:0:0:0: [sdb] Write Protect is off
[66519.169229] sd 2:0:0:0: [sdb] Mode Sense: 65 44 09 30

you can also see it shows up as attached via pcie:
root@ls421de-stretch:/dev# find /dev/disk/by-path/
/dev/disk/by-path/
/dev/disk/by-path/platform-soc:pcie-controller-pci-0000:01:00.0-usb-0:2:1.0-scsi-0:0:0:0-part1
/dev/disk/by-path/platform-soc:pcie-controller-pci-0000:01:00.0-usb-0:2:1.0-scsi-0:0:0:0

root@ls421de-stretch:~# ls -l /sys/class/block/sdb
lrwxrwxrwx 1 root root 0 Mar 21 19:09 /sys/class/block/sdb -> ../../devices/platform/soc/soc:pcie-controller/pci0000:00/0000:00:01.0/0000:01:00.0/usb1/1-2/1-2:1.0/host2/target2:0:0/2:0:0:0/block/sdb
root@ls421de-stretch:~# 
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 24, 2019 02:02PM
thank you again
USB3 is running



Edited 1 time(s). Last edit at 03/24/2019 02:05PM by oxygen8.
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 24, 2019 03:11PM
I’ve tested all the hardware I can think of on all the devices. The only thing not working out of the box with the vanilla debian kernel is the rtc, though that’s just because the driver isn’t included by default. I’ve included info on how to enable it if needed.

For the ts1400 and the ts3000 models the lcd/fans/etc are controlled via the built-in microcontroller which requires a seperate script to control (hmm Instill need to ipdate the docs about that).

Let me know if you run into anything else that doesn’t seem to work.
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 25, 2019 10:18AM
It would be nice to reaktivate the rear switsch to stop and start the nas.

at the moment i am searching to resolve a problem with the apcupsd.
the daemon uses /sbin/shutdown
the nas restarts directly after the shutdown an will be killes from the ups
this has demaged my filesystem
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 25, 2019 10:56AM
For these devices Buffalo uses the unused 3rd LED output from the ethernet controller to signal to the boot loader whether it should shutdown or reboot when the system shuts down. I defaulted that line to signal restart by default in the DTB (it's the opposite for the ls441 because that line is also tied to the power button gpio).

I included a script to set this value right before reboot but I don't install it by default. When I originally put this together I was trying to avoid automatically installing anything that would run after the installer was done though adding support for the TS3000 series has required me to change that policy a bit. I'd be willing to add it by default going forward if we can confirm it works as expected.

The script and a systemd service to run it at shutdown/restart can be found in the repo under:
Tools/ls400-restart.sh
Tools/ls400-restart.service

I think the logic for determining whether it's being called for a shutdown vs. restart vs halt might not be working. I've been meaning to come back to this for a while.
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 25, 2019 12:02PM
i will try that
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 26, 2019 05:09PM
i am not able to shutdown the device
(with halt it is able to shutdown, but i can not give the command halt to apcupsd. It uses shutdown)

i have tried the following

1) i have created the file /usr/local/bin/ls400-restart.sh
( after the first unworking test i have tried with the add
 || [ "$1" == "shutdown" ]


#!/bin/bash

which phytool > /dev/null
if [ $? -ne 0 ]; then
   exit
fi

if [ "$1" == "halt" ] || [ "$1" == "poweroff" ] || [ "$1" == "shutdown" ]; then
    led2=8
else
    led2=9
fi

current_reg="$(phytool write eth0/0/22 3 && phytool read eth0/0/16)"
phytool write eth0/0/22 0

if [ ${#current_reg} -ne 6 ]; then
   exit
fi

new_reg=${current_reg:0:3}$led2${current_reg:4:2}

phytool write eth0/0/22 3 && phytool write eth0/0/16 $new_reg
phytool write eth0/0/22 0

2)
chmod 755 /usr/local/bin/ls400-restart.sh

3) i have created the service /lib/systemd/system/ls400-restart.service
[Unit]
Description = Set PHY LED2 pin to signal restart rather than poweroff

[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=/usr/local/bin/ls400-restart.sh

[Install]
WantedBy = multi-user.target

i have not changed the permissions
$ ls -lha  /lib/systemd/system/ls*
-rw-r--r-- 1 root root 205 Mär 26 22:47 /lib/systemd/system/ls400-restart.service


4) i have started the service
systemctl enable ls400-restart.service ; systemctl start ls400-restart.service


the result:
shutdown reboots the nas
halt shuts down the nas correctly
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 26, 2019 05:25PM
i have now a solution for apcupsd

1) create the file /usr/local/bin/halt_test

#!/bin/bash
/sbin/halt

exit 99

2)
chmod +x  /usr/local/bin/halt_test


3)
ln -s /usr/local/bin/halt_test /etc/apcupsd/doshutdown
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 26, 2019 05:39PM
the issue is with the service rather than the commands, I probably misread the documentation when I created it.


if you run the following the device will shutdown (I just did it with mine):
phytool write eth0/0/22 3 && phytool write eth0/0/16 0x0881; phytool write eth0/0/22 0
shutdown now
**note you need all 3 phytool commands on one line when running interactively. This is because the network is disconnected when you run the first command and reconnects after the last one which is not normally a problem when running at shutdown but can cause problems over ssh if you're not careful.

We basically just need to adjust the service so that it sets the appropriate value (0x08XX vs 0x09XX) based on whether shutdown or restart is called.
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 26, 2019 06:10PM
1000001101000 Wrote:
-------------------------------------------------------
> For these devices Buffalo uses the unused 3rd LED
> output from the ethernet controller to signal to
> the boot loader whether it should shutdown or
> reboot when the system shuts down. I defaulted
> that line to signal restart by default in the DTB
> (it's the opposite for the ls441 because that line
> is also tied to the power button gpio).

So these boxes don't have Poweroff GPIO like other Armada NAS?

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 26, 2019 06:25PM
Nope. Depending on the model they either use a built in microcontroller for power management which they send commands to over a serial connection or use this clever ethernet controller hack.

Actually, on the ls200 series they shutdown and restart normally without any of the above.

None of them use the poweroff gpio as far as I can tell.
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 27, 2019 11:25AM
Quote

phytool write eth0/0/22 3 && phytool write eth0/0/16 0x0881; phytool write eth0/0/22 0
shutdown now

this makes a reboot on LS421D
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 27, 2019 11:36AM
I ran it before posting and got a successful shutdown on my ls421de

can you run the following and post the output?

phytool write eth0/0/22 3 && phytool read eth0/0/16; phytool write eth0/0/22 0
phytool write eth0/0/22 3 && phytool write eth0/0/16 0x0881; phytool write eth0/0/22 0 
phytool write eth0/0/22 3 && phytool read eth0/0/16; phytool write eth0/0/22 0
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 27, 2019 11:47AM
oh, I may know what the problem was. If you set up my old script + systemd service it probably changed the value back to "restart" when you issued the shutdown command.

if you remove the ls400_reboot script and then issue those commands the device will shutdown rather than restart.

I'm working on a new version of the shutdown/restart script that sets these values appropriately and adds the logic necessary to handle the ts1400/ts3000 version as well.
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 27, 2019 02:07PM
systemctl stop ls400-restart.service  ; systemctl disable ls400-restart.service

now it is able to shutdown with

phytool write eth0/0/22 3 && phytool write eth0/0/16 0x0881; phytool write eth0/0/22 0
shutdown now


thank you
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 27, 2019 02:19PM
Now i am testing triggerhappy
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 28, 2019 02:14PM
i have tested a simple trigger

root@debian:~# cat /etc/triggerhappy/triggers.d/1.conf
KEY_OPTION 1    /bin/echo 1 >>/sys/devices/platform/gpio-leds/leds/led\:function\:red/brightness
KEY_OPTION 0    /bin/echo 0 >>/sys/devices/platform/gpio-leds/leds/led\:function\:red/brightness


i am not able to start or stop thd with

root@debian:~# systemctl enable triggerhappy.service
; systemctl start triggerhappy.service
root@debian:~# systemctl stop triggerhappy.service


the manual way is working

thd --daemon --triggers /etc/triggerhappy/triggers.d/ /dev/input/event*

and killall thd

please help me
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 28, 2019 02:30PM
I don't know much about triggerhappy but the following seems to work:

root@ls421de-stretch:~# /etc/init.d/triggerhappy stop
[ ok ] Stopping triggerhappy (via systemctl): triggerhappy.service.
root@ls421de-stretch:~# /etc/init.d/triggerhappy start
[ ok ] Starting triggerhappy (via systemctl): triggerhappy.service.
root@ls421de-stretch:~# /etc/init.d/triggerhappy restart
[ ok ] Restarting triggerhappy (via systemctl): triggerhappy.service.
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 28, 2019 03:46PM
it seams to work bit it does not work
i am testing with the fuction button an the red function led
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 28, 2019 03:55PM
are you saying that starting/stopping triggerhappy isn't working or that your triggers aren't working?
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 28, 2019 04:04PM
thank you very much again
now i can use my on/off switch to control the nas


echo 'KEY_ESC 0 /usr/local/bin/phytool write eth0/0/22 3 && /usr/local/bin/phytool write eth0/0/16 0x0881; /usr/local/bin/phytool write eth0/0/22 0;/sbin/shutdown now' >/etc/triggerhappy/triggers.d/1.conf
echo 'KEY_OPTION 0 /bin/echo 0 >>/sys/devices/platform/gpio-leds/leds/led\:function\:red/brightness' >>/etc/triggerhappy/triggers.d/1.conf;
echo 'KEY_OPTION 1 /bin/echo 1 >>/sys/devices/platform/gpio-leds/leds/led\:function\:red/brightness' >>/etc/triggerhappy/triggers.d/1.conf;

echo '#! /bin/sh' >/etc/init.d/thd.sh;echo 'PATH=/sbin:/usr/sbin:/bin:/usr/bin' >>/etc/init.d/thd.sh;
echo '/usr/sbin/thd --daemon --triggers /etc/triggerhappy/triggers.d/ /dev/input/event*' >>/etc/init.d/thd.sh;
cd /etc/init.d/;chmod 755 /etc/init.d/thd.sh;ln -s ../init.d/thd.sh /etc/rc5.d/S01thd;
killall thd ;/etc/init.d/thd.sh
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 28, 2019 04:35PM
nice.

I've finally got the restart script adjusted so that it properly handles shutdowns and restarts for the ls400 models (note it no longer uses a systemd service). I'll be posting it to github but if you want to try it out here it is:

#!/bin/bash

# place in /lib/systemd/system-shutdown/ for debian based systems
# other systems it's /usr/lib/systemd/system-shutdown/

phytool="/usr/local/bin/phytool"
ifup eth0
sleep 5

if [ "$1" == "halt" ] || [ "$1" == "poweroff" ]; then
    led2=8
else
    led2=9
fi

current_reg="$($phytool write eth0/0/22 3 && $phytool read eth0/0/16)"
$phytool write eth0/0/22 0

##don't try to make the change if the lookup failed
if [ ${#current_reg} -eq 6 ]; then
    new_reg=${current_reg:0:3}$led2${current_reg:4:2}

    $phytool write eth0/0/22 3 && $phytool write eth0/0/16 $new_reg
    $phytool write eth0/0/22 0
fi

ifdown eth0
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 30, 2019 03:50AM
With APC UPS i have this shutdownscript:

root@debian:~# cat /lib/systemd/system-shutdown/apcupsd_shutdown
#!/bin/sh
# apcupsd: kill power via UPS (if powerfail situation)
# (Originally from Fedora.)

# See if this is a powerfail situation.
if [ -f /etc/apcupsd/powerfail ]; then
echo
echo "APCUPSD will now power off the UPS"
echo
/etc/apcupsd/apccontrol killpower
fi


Where should i use your script?
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 30, 2019 04:25AM
My try on a LS420
The LS421 is running very good and now in use

On this mashine i have not installed your service
i have created a executeable script shutdown with your content

root@debian:~# ls -l /lib/systemd/system-shutdown/
total 8
-rwxr-xr-x 1 root root 270 Jul 16 2016 apcupsd_shutdown
-rwxr-xr-x 1 root root 628 Mar 30 09:52 shutdown


root@debian:~# shutdown
Shutdown scheduled for Sat 2019-03-30 09:54:16 CET, use 'shutdown -c' to cancel.

this makes a reboot and uses a new IP from DHCP
These are 2 problems


The shutdown takes a long time (60s), the grenn network led is flashing fast.
Now it is not able to shutdown with the ON/OFF switch.
It is rebooting.



Edited 1 time(s). Last edit at 03/30/2019 05:38AM by oxygen8.
Re: Debian Stretch on Armada-370 Buffalo Devices (LS2XX, LS4XX, TS1XXX)
March 30, 2019 02:55PM
I think most of the delay is from how shutdown works by default. "shutdown now" instructs the system to immediately begin the shutdown.

putting that script in place on my ls421de allowed "shutdown" and "reboot" to have the expected effects. I still have a fair amount of testing/tweaking before I add it to the repository.

I figured if it worked for you it might be simpler than the other approaches. It seems to not work with your setup for some reason.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: