Welcome! Log In Create A New Profile

Advanced

Debian on Synology RS816 (Armada 385)

Posted by zifxify 
Re: Debian on Synology RS816 (Armada 385)
May 11, 2019 07:58AM
Richard,

That's a wrong assigment

reg_sata1: pwr-sata1 {
		compatible = "regulator-fixed";
		regulator-name = "pwr_en_sata1";
		regulator-min-microvolt = <12000000>;
		regulator-max-microvolt = <12000000>;
		enable-active-high;
		regulator-boot-on;
		gpio = <&gpio1 5 GPIO_ACTIVE_HIGH>;
	};

In bank 1, you need to subtract 32. So it should be 5.

Also 5V regulator should be included in the DTS, too, like the example in sata0.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 05/11/2019 08:00AM by bodhi.
Re: Debian on Synology RS816 (Armada 385)
May 11, 2019 04:53PM
@bodhi
Doh!! That worked!
Thanks for the pointer I might have missed that for quite some time :) and the 5V section was just a complete oversight on my part. I actually added a 12V section as well just because it had one for sata0. I removed my alias addition and we are now on version 7 which I attach here.


@1000001101000
Yes, that's what I had done and discovered pin 37 was the one we were looking for but there are two gpio blocks on the box and what I hadn't realized until @bodhi pointed me in the right direction is that when addressing them in the dts you start numbering block 2 from the end of block 1 and hence pin 37 becomes block 2 pin 5.
Thanks for posting as all help very gratefully received and I had found your previous posts very helpful in getting this far.
Attachments:
open | download - armada-385-synology-rs816-v7.dts (6.6 KB)
open | download - armada-385-synology-rs816-v7.dtb (17.4 KB)
Re: Debian on Synology RS816 (Armada 385)
May 11, 2019 05:03PM
Richard,

> Doh!! That worked!

Awesome!

> Thanks for the pointer I might have missed that
> for quite some time :) and the 5V section was just
> a complete oversight on my part. I actually added
> a 12V section as well just because it had one for
> sata0. I removed my alias addition and we are now
> on version 7 which I attach here.

Cool! So we've done with 4 SATA for the DTS.

Some of the rest of the GPIOs are LEDs.

The fan might or might not be GPIO, though (I hope it is). Usually running stock OS will tell you if there is a fan control script or daemon. And perhaps it is somewhere in the RS815 GPL source if it is hardcoded.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Synology RS816 (Armada 385)
May 11, 2019 05:08PM
@bodhi
The fans were previously listed in the DTS which I removed to avoid gpio conflicts with no apparent change in the fans behavior. I will have a hunt around on my other rs816 which is still stock and see if I can fathom what it is doing. Stock includes software control to run three profiles quiet, cool and max (or something like that)

I will make a start and report back.
Re: Debian on Synology RS816 (Armada 385)
May 11, 2019 06:02PM
@bodhi
I installed lm-sensors and did a sensors-detect and got zero sensors detected.
A quick look on my stock RS816 looks like the fans are controlled via a script which uses the HDD temps to control the fans speed. There is an xml config file at /usr/syno/etc/scemd.xml broken down by hardware versions example below

<scemd>
    <fan_config hibernation_speed="UNKNOWN" type="DUAL_MODE_HIGH" threshold="6" period="20">
        <disk_temperature fan_speed="001" action="NONE">0</disk_temperature>
        <disk_temperature fan_speed="011" action="NONE">43</disk_temperature>
        <disk_temperature fan_speed="111" action="NONE">53</disk_temperature>
        <disk_temperature fan_speed="111" action="SHUTDOWN">61</disk_temperature>

        <cpu_temperature fan_speed="001" action="NONE">0</cpu_temperature>
        <cpu_temperature fan_speed="011" action="NONE">47</cpu_temperature>
        <cpu_temperature fan_speed="111" action="NONE">70</cpu_temperature>
        <cpu_temperature fan_speed="111" action="SHUTDOWN">90</cpu_temperature>
    </fan_config>
    <fan_config hibernation_speed="UNKNOWN" type="DUAL_MODE_LOW" threshold="6" period="20">

The scemd.xml is referenced by an upstart daemon named scmed, I will need to get into the source code of that to see whats going on.
Re: Debian on Synology RS816 (Armada 385)
May 11, 2019 06:47PM
Richard,


> A quick look on my stock RS816 looks like the fans
> are controlled via a script which uses the HDD
> temps to control the fans speed.

> The scemd.xml is referenced by an upstart daemon
> named scmed, I will need to get into the source
> code of that to see whats going on.

Perhaps it is i2c like the Zyxel boxes.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Synology RS816 (Armada 385)
May 11, 2019 07:04PM
@bodhi
lm-sensors should detect i2c but of course it may not be a recognized chip or it may need to be powered up first ?

Is it worth me cycling the gpio pins again and checking for new sensors at each iteration ?



Edited 1 time(s). Last edit at 05/11/2019 07:10PM by richjn.
Re: Debian on Synology RS816 (Armada 385)
May 11, 2019 07:24PM
@bodhi
I'm probably using the tools incorrectly but for what its worth.

root@debian:~# i2cdetect -l
i2c-0   i2c             mv64xxx_i2c adapter                     I2C adapter
root@debian:~# i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- 64 -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@debian:~# i2cdump 0 0x64
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0, address 0x64, mode byte
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
20: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
30: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
40: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
f0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
root@debian:~#



Edited 1 time(s). Last edit at 05/11/2019 07:29PM by richjn.
Re: Debian on Synology RS816 (Armada 385)
May 11, 2019 07:45PM
Hi Richard,

I meant if it is like the Zyxel NSA325, then it is not under GPIO control. And that box use i2cget like this to read the temperature and fan speed

Excerpt from my login ~/.profile
MACHINE=`dmesg | grep -i machine | cut -c40-120`

if [ "$MACHINE" == "ZyXEL NSA325" ]; then
	echo "CPU Temperature" $(($(/usr/sbin/i2cget -y 0x0 0x0a 0x07))) "C"
	echo "Fanspeed" $[60000/$(($(/usr/sbin/i2cget -y 0x0 0x0a 0x08)))] "RPM"
fi
if [ "$MACHINE" == "Zyxel NSA310S" ]; then
        echo "CPU Temperature" $(($(/usr/sbin/i2cget -y 0x0 0x0a 0x07))) "C"
	if [ $(($(/usr/sbin/i2cget -y 0x0 0x0a 0x08))) == 0 ]; then
		echo "Fanspeed 0 RPM";
	else
		echo "Fanspeed" $[60000/$(($(/usr/sbin/i2cget -y 0x0 0x0a 0x08)))] "RPM"
	fi
fi

And we can't use lm-sensors for this either.

But it is only my speculation. I think you need to look at scmed to see what stock OS does.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Synology RS816 (Armada 385)
May 11, 2019 07:58PM
@bodhi
Understood,

Sometimes my brain is ahead of what I actually type! or maybe the other way round :)

From my i2cdump posted above I can't see any value that I can read or write to but I'm very conscious that my knowledge is severely lacking here. Is there something I'm missing in probing the i2c ?

As far as the gpio pins are concerned I was just wondering if you thought there was mileage in cycling the pins and looking for new sensors appearing ?

I will make a start on looking at the source for scmed.
Re: Debian on Synology RS816 (Armada 385)
May 11, 2019 08:11PM
Richard,


> As far as the gpio pins are concerned I was just
> wondering if you thought there was mileage in
> cycling the pins and looking for new sensors
> appearing ?
>

Yes, definitely would be good to do.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Synology RS816 (Armada 385)
May 11, 2019 08:24PM
@bodhi
I will get on with that and whilst I'm cycling the pins I will keep an eye on the led's as well.

It's Mothers day here in Australia and I have family arriving soon so will have to leave this till tomorrow.
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 04:54PM
@bodhi
My main target today is the fans but whilst cycling the gpio I hit upon leds first at pin 6.
Pre setting this pin we have a single falshing green power light at Debian login after setting the pin active we get;

1) Green ethernet light on the correct nic and disconnecting / reconnecting works as does nic 2

2) Green HDD light on drive 1 removing and reinserting the disk works.

3) Amber HDD light on drive 2, 3, 4 removing and reinserting the disk does not work.

I have tried to enable this pin in the DTS but it does not work, maybe I have made a mistake ?
gpio-leds {
			compatible = "gpio-leds";
			label = "rs816:leds";
			default-state = "on";
			enable-active-high;
			gpio = <&gpio0 6 GPIO_ACTIVE_HIGH>;
	};

I have also tried with default-state and label omitted.

The control of leds in stock is via scemd which in turn utilizes synobios which I have not looked at yet but I presume is a kernel module. Both of these are closed source but I have seen at least synobios in their GPL so maybe we can glean some info there.

Back to cycling the gpio pins for me, I will look at scemd & synobios afterwards but if you do spot something with the leds let me know.
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 05:24PM
Richard,

Quote

Pre setting this pin we have a single falshing green power light at Debian login after setting the pin active we get;

So 6 is the System LED.

Usually each LED is assigned a GPIO. They don't mix, unless the manufacturer intended to wire them together. So 4 HDD ports likely to have 4 different GPIOs, does this box have individual LED for each HDD slot?

In this kernel, currently we can only control 2 HDD LEDs individually (that's something I can add to the patch for the next kernel version). In mainline kernel, the HDD has one trigger for all HDDs activity.

Ethernet LEDs are not GPIO driven. They turn on amber or green when the ethernet PHY is active and working.

Let me modify our latest version 7 and make version 8 of the DTS, adding Sys LED as an example.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 05:38PM
@bodhi
Yes, each HDD has its own led. I am still cycling through gpio pins so may hit more later (currently at 32)

Quote

Ethernet LEDs are not GPIO driven. They turn on amber or green when the ethernet PHY is active and working.
OK but just for clarity the led's I'm referring to are on the front of the NAS there are no led's on the nic's themselves.
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 05:51PM
Richard,

> OK but just for clarity the led's I'm referring to
> are on the front of the NAS there are no led's on
> the nic's themselves.

I see. So this box has network activity LED in front. And that should take 1 GPIO.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 06:05PM
@bodhi
Yes, they are unlit until pin 6 is active after which they appear to function as expected.
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 06:14PM
Richard,

Let me clarify this.

Quote

Pre setting this pin we have a single falshing green power light at Debian login after setting the pin active we get;

Does that mean the "Power LED" or "System LED" flashing green?

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 06:19PM
@bodhi
Yes, the power led flashes green even before setting pin 6 and no change after setting pin 6 active.

Whilst posting latest result from cycling the gpio is pin 48 sets the fans to high
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 06:26PM
Richard,

Then GPIO 6 is not the System LED.

So when you clear/set GPIO 6, which LED change to off/on?

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 06:39PM
@bodhi
Setting pin 6 active / inactive turns all of the following on / off

1) Both nic's but no led until an ethernet cable is plugged in
2) Drive 1 led green (recognized as /dev/sdb) but only if a drive is plugged in.
3) Drive 2, 3 4 led amber regardless of whether a drive is plugged in or not

I have completed the gpio cycling manually one pin at a time and carfuly checking for changes. Apart from pin 6 above the only other pin that appears to do something is pin 48 where active sets the fans to high speed.
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 08:10PM
@bodhi
Just re-ran pin 6 toggle active / inactive to check results and slightly different to as I reported above.

Quote

2) Drive 1 led green (recognized as /dev/sdb) but only if a drive is plugged in.

The observed action is Drive 1 led green regardless of if a HDD is plugged in or not. Everything else as stated, however, I'm 100% sure the light went out when I pulled the drive last time I tested which I didn't do until I had got to about pin 20 in my tests.

When testing I'm echoing "1" into the gpio value but I don't echo "0" before unexporting a gpio, so the led's were left on as I tested subsequent pins. I will go back and re-test to see if a pin between 7 - 20 various the action of the led's.
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 08:36PM
Richard,

Usually the LED is on/off when we control it directly.

While the HDD is inserted, it will cause a different trigger that detects the HDD access (blinking). You will see clearly what I meant in the v8 DTS.

Ok so most likely 6 is HDD 1 LED, or all HDDs.

Fan behaves like that with 48 means this is GPIO fan control. That can be defined in DTS.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 08:43PM
@bodhi
You haven't posted V8 yet
Re: Debian on Synology RS816 (Armada 385)
May 12, 2019 10:08PM
@bodhi
I have added fan control based on armada-385-synology-rs816-v1.dts but with just 1 pin (48) this is now active at boot but I'm not sure how to get the box hot enough to test because even whilst recompiling the kernel the rootfs HDD remains ~28C according to hddtemp whilst idle is ~26C

gpio-fan {
			compatible = "gpio-fan";
			gpios = <&gpio1 16 GPIO_ACTIVE_HIGH>;
			gpio-fan,speed-map = <   0 0
					      1500 1
					      2500 2
					      3000 3
					      3400 4
					      3700 5
					      3900 6
					      4000 7>;
			#cooling-cells = <2>;
		};


I attach my v8 DTS here but we can just drop this one if you would prefer me to.
Attachments:
open | download - armada-385-synology-rs816-v8.dts (7 KB)
Re: Debian on Synology RS816 (Armada 385)
May 13, 2019 12:33AM
OK so it will be version 9!

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Debian on Synology RS816 (Armada 385)
May 13, 2019 01:26AM
Here is version 9.

1. Assuming the GPIO 6 is for HDD 1 LED.

The trigger here is ide-disk1. Whenever the disk is accessed (Read/Write), the LED should flash. This is the default mode for HDD1 LED after the kernel has booted.

======

To control this HDD LED trigger, use the sys class LEDS trigger.

To turn off the trigger completely:
echo none > /sys/class/leds/rs816:green:sata1/trigger

To turn on the trigger. This will trigger the LED to flash when there is disk access:
echo ide-disk1 > /sys/class/leds/rs816:green:sata1/trigger


2. The GPIO fan seems to have too many speeds, but it is OK. As we go and test it, it should be obvious which speed is valid.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Attachments:
open | download - armada-385-synology-rs816-v9.dtb (17.8 KB)
open | download - armada-385-synology-rs816-v9.dts (7.2 KB)
Re: Debian on Synology RS816 (Armada 385)
May 13, 2019 01:39AM
@bodhi
Thanks for v9 and some test commands to try I will get to this shortly.

As we are getting quite close on this one I am preparing things for real world use. I'm setting rootfs up on a 10GB 4 disk raid1 (meta 0.9) swap on a 2GB 4 disk raid1 and the remainder as a 4 disk raid 5.

Once we have the DTS as we want it I could do with some help embedding this into the mtdblock which will be another first for me.

Its all been very informative and interesting stuff and I would like to thank you for your time and patience.
Re: Debian on Synology RS816 (Armada 385)
May 13, 2019 02:07AM
Richard,

> As we are getting quite close on this one I am
> preparing things for real world use. I'm setting
> rootfs up on a 10GB 4 disk raid1 (meta 0.9) swap
> on a 2GB 4 disk raid1 and the remainder as a 4
> disk raid 5.
>

10TB and 2TB, you meant?

> Once we have the DTS as we want it I could do with
> some help embedding this into the mtdblock which
> will be another first for me.

We don't want to store the rootfs in flash (too large), only the kernel files. That should be easy. However, we might want to patch stock u-boot and rebuild it to enable booting with USB or HDD directly.

> Its all been very informative and interesting
> stuff and I would like to thank you for your time
> and patience.

You are welcome! zifxify and you are really good contributors in making this box run with modern kernel.

If I ever get to building the new 2019 u-boot for the Mirabox, what follow should be this box or the Thecus N2350. I've been procastinating about u-boot, because most of the Armada boxes have a decent u-boot version that can boot the box well enough. No great motivation like with the Kirkwood SoCs boxes.

WIth that said, IMO this stock u-boot is the worst among the Armada boxes :)

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 2 time(s). Last edit at 05/13/2019 03:43AM by bodhi.
Re: Debian on Synology RS816 (Armada 385)
May 13, 2019 04:29AM
@bodhi
Not a typo;
rootfs is on 10GB raid 1
swap 2GB raid 1
files 5.4TB raid 5

Your rootfs stripped down a bit but including dev tools takes up 875M so circa 10%. This box won't have much in the way of software installed so 10GB should be fine. All data will go on the raid 5 mount.

Disk sync is getting there slowly
cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
md1 : active (auto-read-only) raid1 sdd2[3] sdc2[2] sda2[0] sdb2[1]
      1951744 blocks super 1.2 [4/4] [UUUU]
      
md2 : active raid5 sdd3[4] sdc3[2] sda3[0] sdb3[1]
      5824994304 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [UUU_]
      [=========>...........]  recovery = 48.0% (933090604/1941664768) finish=200.1min speed=83976K/sec
      bitmap: 2/15 pages [8KB], 65536KB chunk

md0 : active raid1 sdd1[3] sdc1[2] sda1[0] sdb1[1]
      9764800 blocks [4/4] [UUUU]
      
unused devices: <none>

Now the install is complete I am just preparing my build environment including building linux-5.1.1 then I will be ready to test v9 DTS.

I may have a new challenge for you, I hooked up my Synology 5 bay nas via serial and was surprised to see it used grub as a boot loader, I didn't spend anytime with it but I bet grub has been stripped of most of its modules. One for the future perhaps :)
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: