Welcome! Log In Create A New Profile

Advanced

Debian on Zyxel NAS326

Posted by Kirsch 
Re: Zyxel NAS326 - Debian / Boot from USB?
September 28, 2019 05:51PM
ahorner,


> The main issue I encountered was that things
> stored on the flash filesystem would get erased
> each boot, so I couldn't really install anything
> easily,

See the installation instruction here:

https://forum.doozan.com/read.php?2,88619

The flash reset problem was overcome by setting some u-boot envs like I described in the instruction.

Post more questions if you don't understand some of the info there.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Zyxel NAS326
October 06, 2019 04:51AM
Hi Bohdi,
first of all - thank you very much for your great work!
I think I found a solution for the WOL Problem.
I searched in the orignal rcS2 in /etc on the original RootFS and found this:

###### setup WOL ######
if [ -e ${CONF_PATH}/wol.status ]; then
	/sbin/i2cset -y 0x0 0xa 0xa 0x0006 w
else
	/sbin/i2cset -y 0x0 0xa 0xa 0x0306 w
fi

If I put:

/usr/sbin/i2cset -y 0x0 0xa 0xa 0x0006 w


in my /etc/rc.local WOL works for me.

Tested with 5.1.7-mvebu-tld-1.

In the same rcS2 I found:

###### set auto power-on ######
if [ -e ${CONF_PATH}/storage/pwron.status ]; then
	pwrmode=`${CAT} ${CONF_PATH}/storage/pwron.status`
	#zyshclient -p 150 -e "pwron ${pwrmode}"
	if [ $pwrmode = 'always' ]; then
		/sbin/i2cset -y 0x0 0x0a 0x0a 0x0107 w
	else
		/sbin/i2cset -y 0x0 0x0a 0x0a 0x0007 w
	fi
else
	#zyshclient -p 150 -e "pwron former"
	/sbin/i2cset -y 0x0 0x0a 0x0a 0x0107 w
fi


Maybe someone needs this too, like me.
Hope I could help!

====
bodhi edit: added code tags to highlight scripts/logs.



Edited 1 time(s). Last edit at 10/07/2019 03:16AM by bodhi.
Re: Debian on Zyxel NAS326
October 06, 2019 05:26AM
030theo,

Quote

> I think I found a solution for the WOL Problem.
> I searched in the orignal rcS2 in /etc on the
> original RootFS and found this:
>
> ###### setup WOL ######
> if [ -e ${CONF_PATH}/wol.status ]; then
> /sbin/i2cset -y 0x0 0xa 0xa 0x0006 w
> else
> /sbin/i2cset -y 0x0 0xa 0xa 0x0306 w
> fi

Ah, that was pretty good detective works :)

Zyxel seems to like to do everything through i2c. The fan speed and CPU temperature readout is also through i2cget!


Quote

> If I put:
>
> /usr/sbin/i2cset -y 0x0 0xa 0xa 0x0006 w
>
> in my /etc/rc.local WOL works for me.
>
> Tested with 5.1.7-mvebu-tld-1.

Cool!

I will try this WOL and post back later.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Zyxel NAS326
October 07, 2019 12:30AM
030theo,

/usr/sbin/i2cset -y 0x0 0xa 0xa 0x0006 w

It works great on my box!

So the efftect of that i2cset command is also that the WOL status is turned on in the network chip. Before running this i2cset command, the status was "Wake-on: d".


When you look at the eth0 status using ethtool (after running the i2csetc command):

root@Nas326:~# ethtool eth0

Settings for eth0:
	Supported ports: [ TP MII FIBRE ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Supported pause frame use: Symmetric
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Advertised pause frame use: Symmetric
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Link partner advertised link modes:  10baseT/Half 10baseT/Full 
	                                     100baseT/Half 100baseT/Full 
	                                     1000baseT/Full 
	Link partner advertised pause frame use: Symmetric
	Link partner advertised auto-negotiation: Yes
	Link partner advertised FEC modes: Not reported
	Speed: 1000Mb/s
	Duplex: Full
	Port: MII
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: on
	Supports Wake-on: g
	Wake-on: g
	Link detected: yes

And it is sticky. Meaning the i2c bus is hooked up so some status register that turns this on permanently. You don't have to add that to /etc/rc.local. It will survive shutdown and reboot.

============

This has caused me to think that perhaps the boot source could be force set the same way when we want to test UART booting (the Sample on Reset register is static).

From your finding, we know that these are for WOL and PowerOff

/sbin/i2cset -y 0x0 0xa 0xa 0x0006 w 
/sbin/i2cset -y 0x0 0xa 0xa 0x0306 w 
/sbin/i2cset -y 0x0 0xa 0xa 0x0107 w 
/sbin/i2cset -y 0x0 0xa 0xa 0x0007 w


The hard part is figuring out what are possible values that can be written to the memory at that 32-bit mask!

/sbin/i2cset -y 0x0 0xa 0xa <some 32 bit mask> w

Perhaps more searching in stock OS would turn up some more clues :) Have you looked at other init scripts that run during halt ?

Thanks!

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 1 time(s). Last edit at 10/07/2019 12:49AM by bodhi.
Re: Debian on Zyxel NAS326
October 07, 2019 12:01PM
Hi Bohdi,
I searched, but except of the known fanspeed and cpu-temp readings, there were no other occurences of ic2read or ic2write in the RootFS.
Re: Debian on Zyxel NAS326
October 07, 2019 06:19PM
030theo,

> I searched, but except of the known fanspeed and
> cpu-temp readings, there were no other occurences
> of ic2read or ic2write in the RootFS.

Thanks for doing the research!

I've modified the Installation instruction to point to your post for WOL.

Quote

A3. Normal Operation

The USB rootfs should be plugged in permanently, and the serial console module should be removed.

1. Whenever the NAS326 is rebooted or cold started, to boot without manual intervention, the serial console module must be unplugged from the NAS326. If the serial console module is plugged in, then step 1 in the installation instruction A2 must be executed (so that the NAS326 will continue booting when it detected the serial console present). Note that reboot in some instance will work with serial console plugged in.

2. If you want to boot back to stock OS in NAND, just shutdown the box, unplug the USB and power up the box. It will boot the kernel 1 in NAND and then if not successful, it will try kernel 2.

This also serves as a rescue system. Whenever the rootfs on USB has problem and cannot boot (the effect is just like the USB drive is not plugged in), the NAS326 will fall back to booting the kernel 1 or 2 in NAND. When this occurs, the u-boot envs in step 4 must be reentered at serial console again to allow booting back to USB rootfs.

3. Setup WOL. Please see this post for how to activate WOL:

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Zyxel NAS326
October 09, 2019 04:24AM
030theo,

It was not sticky as I thought it was!

There is some instance where I shutdown the box and could not wake it up (I only ran i2cset once, and after that it survived many reboots and shutdowns).

So, that i2cset command is really needed to be added to /etc/rc.local to ensure it can be woken up always.
/usr/sbin/i2cset -y 0x0 0xa 0xa 0x0006 w

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 2 time(s). Last edit at 10/09/2019 05:13AM by bodhi.
Re: Debian on Zyxel NAS326
October 12, 2019 09:06AM
Hey bodhi,

I have only just got the change to mess with this now, and I have reached B2. Installation in the guide, however the command fw_printenv just returns command not found. Any ideas whats done wrong?

Thanks,

AHorner
Re: Debian on Zyxel NAS326
October 12, 2019 05:39PM
AHorner,

Are you inside stock OS?

Please post the log of what you did so far (don't describe it, just copy/paste whatever on the terminal).

-bodhi
===========================
Forum Wiki
bodhi's corner
Author:

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: