Welcome! Log In Create A New Profile

Advanced

Debian on Zyxel NAS326

Posted by Kirsch 
Re: Zyxel NAS326 - Debian / Boot from USB?
March 15, 2017 03:46AM
Yes it's amber ... (Kernel 4.9, 4.10 and now 4.11 rc2)
Re: Zyxel NAS326 - Debian / Boot from USB?
March 15, 2017 04:25AM
Hey pengu :) thanks for the report.

I'm testing kernel 4.10. I can't seem to find the LED green setting in the GPL source. When ethernet is running Gbits, the green LED should be set. But that's a minor inconvenience for not being able tell by looking at the port.

The reason I'm looking for it is: a lot of time, the interrupt line is on the green LED (crazy I know :).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
March 15, 2017 06:14PM
@pengu,

Is your kernel built using my patch as is? and any change in config files?

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
March 16, 2017 04:58AM
YES it's based on your config as my kirkwood kernel builds were too.

The patch can still be applied without failures
I think its usable but ... see below.

The file attached is diff between your config and the one I'm using now.

[Edit]

lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 9.0 (stretch)
Release:	9.0
Codename:	stretch

[    0.000000] Linux version 4.10.3-rm-1 (root@debiannas326) (gcc version 6.3.0 20170205 (Debian 6.3.0-6) ) #1 SMP Fri Mar 17 19:13:20 CET 2017
[    0.000000] CPU: ARMv7 Processor [414fc091] revision 1 (ARMv7), cr=10c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt:Machine model: Zyxel NAS326

I've got some connection issues with NFS .. perhaps it's gone now ...



Edited 3 time(s). Last edit at 03/17/2017 05:11PM by pengu.
Attachments:
open | download - changes.txt (39.6 KB)
Re: Zyxel NAS326 - Debian / Boot from USB?
March 19, 2017 02:40AM
I've been booting succesfully from USB key attached to front port. Unfortunately I'm not able to boot into stock mode, once pulling out the USB key, NAS326 just keeps continously beeping. I have not connected the serial cable, as I installed with the USB option. Should I do that or is it safe to try something else? I'm a bit scared changing (back) the uboot env's to stock mode. Below my envs for booting and information about mtd's. One is with a bad block.
Quote

curr_bootfrom=1
next_bootfrom=1
load_dtb_addr=0x1000000
load_image_addr=0x02000000
load_initrd_addr=0x2900000
usb_init=mw.l f1018100 20420000; mw.l f1018140 003E8800; sleep 3; usb start
set_bootargs_stock=setenv bootargs "console=ttyS0,115200 ubi.mtd=4,2048 rootfstype=ubifs root=ubi0:rootfs1 rw rootdelay=2"
bootcmd_stock_1=run set_bootargs_stock; echo Booting from NAND kernel 1 ...; nand read 0x2000000 0x00E00000 0xF00000 && bootz 0x2000000
bootcmd_stock_2=run set_bootargs_stock; echo Booting from NAND kernel 2 ...; nand read 0x2000000 0x08700000 0xF00000 && bootz 0x2000000
usb_set_bootargs=setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts earlyprintk=serial init=/bin/systemd"
usb_bootcmd=echo Booting from USB ...; setenv fdt_skip_update yes; run usb_init; ext2load usb 0:1 $load_image_addr /boot/zImage; ext2load usb 0:1 $load_dtb_addr /boot/dts/armada-380-zyxel-nas326.dtb; ext2load usb 0:1 $load_initrd_addr /boot/uInitrd; run usb_set_bootargs; bootz $load_image_addr $load_initrd_addr $load_dtb_addr
bootcmd_custom=if run usb_bootcmd; then; else if run bootcmd_stock_1; then; else run bootcmd_stock_2; reset; fi; fi
kernel_addr_1=0x00000000; run bootcmd_custom;
change_boot_part=1

bootargs=console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 mtdparts=armada-nand:2m(u-boot),2m(env),2m(config),15m(kernel1),110m(rootfs1),15m(kernel2),-(rootfs2) earlyprintk=serial init=/bin/systemd
kernel_addr=${kernel_addr_1}
kernel_addr_2=0x08700000
kernel_addr_r=2080000
kernel_mtd_1=3
kernel_mtd_2=5
mtdparts=mtdparts=armada-nand:2m(u-boot),2m(env),2m(config),15m(kernel1),110m(rootfs1),15m(kernel2),-(rootfs2)

I have a bad block on /dev/mtd4.
Quote

nandtest /dev/mtd4
ECC corrections: 0
ECC failures : 0
Bad blocks : 1
BBT blocks : 0
00740000: reading...
1 bit(s) ECC corrected at 00740000
02900000: reading...
2 bit(s) ECC corrected at 02900000
Bad block at 0x04120000
069e0000: checking...
Finished pass 1 successfully

Should I try to reflash /dev/mtd3-6? There are some instruction to use the "Usb key func.sh" for firmware upgrade, but unfortunately this won't boot either. NAS box keeps beeping, if even the "Usb key func.sh" key has be inserted into front port.
Re: Zyxel NAS326 - Debian / Boot from USB?
March 19, 2017 03:11AM
nielsek,

> Should I do that or is it safe to t
> ry something else? I'm a bit scared changing (bac
> k) the uboot env's to stock mode. Below my envs f
> or booting and information about mtd's. One is wi
> th a bad block.

You are right to be careful. No, it is not safe to change u-boot envs to something else if you don't have serial console, because if it does not work, you will have to wait until you install serial console to recover.

The bad block on mtd4 could be the problem. It is the rootfs for kernel 1, which is the option that I set to boot when the USB is not plugged in.So since you can still boot with USB as in normal operation, I would stay with that for now.

I will try the kernel 2 as the fallback and see if perhaps we can use that. After I've tested it, I will let you know.

All that said, connecting serial console is always a great idea. It gives you a lot of latitude in playing with u-boot envs. The NAS326 is quite easy to connect serial console, the header is factory built. All you'd need is the serial module converter (see here in case you are looking), and some wires long enough to route them out through the hole in the back.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
March 19, 2017 05:19AM
I have used standard pl2303 usb/serial converter with Dockstar and GoFlex. It should work also for NAS326?
Re: Zyxel NAS326 - Debian / Boot from USB?
March 19, 2017 05:54AM
nielsek,

Yes it will work the same way whether it's Dockstar, GoFlex, or Zyxel.

Here is the layout. This header has a unique layout where the missing pin (2nd from right) can be used as the reference point .

Zyxel NAS326 Serial Pinouts (same as NSA325 and NSA310S/320S)

GND  
RX 
TX 

          +----+----+           
          |    |    |
+----+----+----+----+----+
|3.3V| TX | RX |    | GND|
+----+----+----+    +----+

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



Edited 1 time(s). Last edit at 03/19/2017 05:56AM by bodhi.
ZyXEL NAS326 Serial Cable and temp sensor
March 25, 2017 03:43AM
The USB Serial converter ....
I'm using a fiew cp210x based ones .. and I'm seeing the following:

To power up the device, I have to disconnect tx/rx for a while to bring the box up.
The next thing is that ZyXEL OS is starting ... whenever I connect the serial cable to the box ...
To use Debian again, I have to disconnect the serial cable while the system is running ..

I'm getting strange temperature readouts .. can somebody confirm?


pengu@debiannas326:~$ sensors
armada_thermal-virtual-0
Adapter: Virtual device
temp1:        +73.7°C  

pengu@debiannas326:~$


On high loads up to 85 degrees.



Edited 1 time(s). Last edit at 03/25/2017 03:46AM by pengu.
Re: ZyXEL NAS326 Serial Cable and temp sensor
March 25, 2017 04:08AM
pengu,

> armada_thermal-virtual-0
> Adapter: Virtual device
> temp1: +73.7°C
>

That module cannot be used, yet. See the release thread notes:

Quote

Updated 03 Feb 2017:

Kernel linux-4.9.0-mvebu-tld-12 package has been uploaded. This kernel has been fully developed with all the capabilities similar to the Kirkwook kernel.

Notables:

- This kernel is configured as SMP PREEMPT (supports up to 4 cores and run with preemptive scheduler).
- Power Off works fine, but will print out a warning in console (which can be safely ignored).
- For fan speed and CPU temperature reading see this post.
- SPI is temporarily removed until we can find out more info.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: ZyXEL NAS326 Serial Cable and temp sensor
March 25, 2017 04:11AM
> To power up the device, I have to disconnect tx/rx
> for a while to bring the box up.

Also regarding serial console, see the release thread notes:

Quote

B3. Normal Operation

The USB rootfs should be plugged in permanently, and if there is serial console module attached before then it should be removed during booting.

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 Section A2 installation instruction must be executed (so that the NAS326 will continue booting when it detected the serial console present).

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 Debian command line again to allow booting back to USB rootfs.

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



Edited 1 time(s). Last edit at 03/25/2017 04:14AM by bodhi.
Re: ZyXEL NAS326 Serial Cable and temp sensor
March 25, 2017 05:14AM
Thanks bodhi ..
I cannot do this all the time anymore .. so .. didn't noticed ...
Re: Zyxel NAS326 - Debian / Boot from USB?
March 25, 2017 03:17PM
nielsek,

Here is a simple change that will allow booting stock kernel 2 as a fallback.

Assuming you did use section B in the installation thread to install

B2. Installation 

....

4. Enter the following commands (copy/paste each line to the stock OS command line). 

fw_setenv curr_bootfrom 1
fw_setenv next_bootfrom 1
fw_setenv load_dtb_addr 0x1000000
fw_setenv load_initrd_addr 0x2900000
fw_setenv load_image_addr 0x02000000
fw_setenv usb_init 'mw.l f1018100 20420000; mw.l f1018140 003E8800; sleep 3; usb start'
fw_setenv set_bootargs_stock 'setenv bootargs "console=ttyS0,115200 ubi.mtd=4,2048 rootfstype=ubifs root=ubi0:rootfs1 rw rootdelay=2"'
fw_setenv bootcmd_stock_1 'run set_bootargs_stock; echo Booting from NAND kernel 1 ...; nand read 0x2000000 0x00E00000 0xF00000 && bootz 0x2000000'
fw_setenv bootcmd_stock_2 'run set_bootargs_stock; echo Booting from NAND kernel 2 ...; nand read 0x2000000 0x08700000 0xF00000 && bootz 0x2000000'
fw_setenv usb_set_bootargs 'setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=10 $mtdparts earlyprintk=serial"'
fw_setenv usb_bootcmd 'echo Booting from USB ...; setenv fdt_skip_update yes; run usb_init; ext2load usb 0:1 $load_image_addr /boot/zImage; ext2load usb 0:1 $load_dtb_addr /boot/dts/armada-380-zyxel-nas326.dtb; ext2load usb 0:1 $load_initrd_addr /boot/uInitrd; run usb_set_bootargs; bootz $load_image_addr $load_initrd_addr $load_dtb_addr'
fw_setenv bootcmd_custom 'if run usb_bootcmd; then; else if run bootcmd_stock_1; then; else run bootcmd_stock_2; reset; fi; fi'
fw_setenv kernel_addr_1 '0x00000000; run bootcmd_custom; '
fw_setenv change_boot_part 1

Now in Debian, you can change the order of kernel section:

Save current envs as a precaution:
fw_printenv > current_envs.txt

Then change the custom bootmd:
fw_setenv bootcmd_custom 'if run usb_bootcmd; then; else if run bootcmd_stock_2; then; else run bootcmd_stock_1; reset; fi; fi'

The above will allow booting stock kernel 2 first as a fallback.

I've tested this change on my box. But if you are worry about being locked out then connect serial console first before trying this.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
March 26, 2017 04:10AM
Thanks bodhi.

I attached serial and it seems that both NANDs are corrupt. NAND2 doesn't boot at all, NAND1 is trying but can't attach ubi.
It should be possible to write firmware again from debian or u-boot? I'm unable to find instructions though. There is an interesting file http://downloads.zyxel.nas-central.org/Users/Mijzelf/NAS326/ zyxel_support_send_instruction.zip I tried to boot the Usb key func.sh, but it didn't work, kept booting unsuccesfully to stock and failed.
Attachments:
open | download - boot_log.txt (25.5 KB)
Re: Zyxel NAS326 - Debian / Boot from USB?
March 26, 2017 04:37AM
nielsek,

> I attached serial and it seems that both NANDs are
> corrupt. NAND2 doesn't boot at all, NAND1 is tryi
> ng but can't attach ubi.

Yes it does look like both were corrupted.

> It should be possible to write firmware again from
> debian or u-boot? I'm unable to find instructions
> though.

Yes. If you have saved your mtds using nanddump then you could write them back. Did you? If not, somebody needs to upload their mtds for you. I could, but it will take some time (I have a slow upload speed internet).

These are about 240MB:
0x000000e00000-0x000001d00000 : "Kernel-1"
0x000001d00000-0x000008700000 : "RootFS-1"
0x000008700000-0x000009600000 : "Kernel-2"
0x000009600000-0x000010000000 : "RootFS-2"

Let's wait until tomorrow. If there is no one has uploaded them by then. I'll create a tarball and upload it to Dropbox.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
March 26, 2017 05:08AM
Thanks in advance!
Unfortunately I don't have copies of them myself. I did backups of them, but after I ran into problems :-(
Re: Zyxel NAS326 - Debian / Boot from USB?
March 27, 2017 02:02AM
Uploading...

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
March 28, 2017 12:08AM
bodhi Wrote:
-------------------------------------------------------
> Uploading...

Awesome, thanks!
Re: Zyxel NAS326 - Debian / Boot from USB?
March 28, 2017 01:24AM
Dropbox:
NAS326_stock_kernel_rootfs.tar.bz2

md5sum
4b2bfbf9c03eb4ebf8ca0c2e2be4179e
sha256sum
75148905141f1555c5f06ed2f4347ced51cefe4cacd3d909749c6f4050481cc7

The tarball contains
mtd3
mtd4
mtd5
mtd6

which correspond to
mtd3: 00f00000 00020000 "Kernel-1"
mtd4: 06a00000 00020000 "RootFS-1"
mtd5: 00f00000 00020000 "Kernel-2"
mtd6: 06a00000 00020000 "RootFS-2"

The commands to dump these mtds were:
nanddump --noecc --omitoob -f mtd3 /dev/mtd3
nanddump --noecc --omitoob -f mtd4 /dev/mtd4
nanddump --noecc --omitoob -f mtd5 /dev/mtd5
nanddump --noecc --omitoob -f mtd6 /dev/mtd6

So to restore do flash_erase, and then nandwrite for each mtd. See this post for example.

And use admin/1234 for credential to login.

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



Edited 2 time(s). Last edit at 03/29/2017 03:26PM by bodhi.
Re: Zyxel NAS326 - Debian / Boot from USB?
March 28, 2017 03:04AM
Great, will try as soon as get home.

Is nandwrite the correct command for that and are there any specific switches?
Re: Zyxel NAS326 - Debian / Boot from USB?
March 28, 2017 03:30AM
The commands to dump were

root@debian:/boot/nas326_nands# nanddump --noecc --omitoob -f mtd3 /dev/mtd3
Block size 131072, page size 2048, OOB size 64
Dumping data starting at 0x00000000 and ending at 0x00f00000...

root@debian:/boot/nas326_nands# nanddump --noecc --omitoob -f mtd4 /dev/mtd4
Block size 131072, page size 2048, OOB size 64
Dumping data starting at 0x00000000 and ending at 0x06a00000...

root@debian:/boot/nas326_nands# nanddump --noecc --omitoob -f mtd5 /dev/mtd5
Block size 131072, page size 2048, OOB size 64
Dumping data starting at 0x00000000 and ending at 0x00f00000...

root@debian:/boot/nas326_nands# nanddump --noecc --omitoob -f mtd6 /dev/mtd6
Block size 131072, page size 2048, OOB size 64
Dumping data starting at 0x00000000 and ending at 0x06a00000...

So make sure that nandwrite have the same option (noecc, omitoob). And you just nandwrite the entire mtd for mtd5 and mtd6, no need to specify the length. The length is already confirmed by your cat /proc/mtd.

Note that I did not post nandwrite commands, because you need to verify the nandwrite options on your current rootfs (if you are not sure, post the version of nandwrite).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
March 28, 2017 11:35AM
It seems I needed to do flash_erase before nandwrite.
Testing..



Edited 1 time(s). Last edit at 03/28/2017 12:49PM by nielsek.
Re: Zyxel NAS326 - Debian / Boot from USB?
March 28, 2017 11:38AM
Awesome, working. Huge thanks!



Edited 3 time(s). Last edit at 03/28/2017 12:50PM by nielsek.
Re: Zyxel NAS326 - Debian / Boot from USB?
March 28, 2017 02:34PM
Cool!

So kernel 2, rootfs2, and user/pass root/root?

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
March 28, 2017 03:58PM
Hi.

I was able to log in with defaults (admin/1234). I also found out that my mtd2 was problematic:
UBI error: ubi_attach_mtd_dev: failed to attach mtd2, error -22
UBIFS error (pid 1606): ubifs_mount: cannot open "ubi2:ubi_config", error -19
Finally I got both NANDs working, by flashing firmware first from mtd6 and then from mtd4. Then I got rid of mtd2 errors and was able to save configuration. Before that it was default settings every reboot.
Is it possible to corrupt something, if my uboot envs are:
fw_setenv curr_bootfrom 2
fw_setenv next_bootfrom 2
and boot to NAND1?

bootcmd_stock_1
After that I got again the:
Marvell>> run bootcmd_stock_1
Booting from NAND kernel 1 ...

NAND read: device 0 offset 0xe00000, size 0xf00000
 15728640 bytes read: OK
*  kernel: cmdline image address = 0x02000000
Bad Linux ARM zImage magic!
But flashing then from NAND2/mtd6 helped to fix it.

Thanks a lot again!



Edited 1 time(s). Last edit at 03/28/2017 04:03PM by nielsek.
Re: Zyxel NAS326 - Debian / Boot from USB?
March 28, 2017 04:17PM
nielsek,

Thanks about the login credential admin/1234. So I did nandump without changing that.

> Is it possible to corrupt something, if my uboot e
> nvs are:
>
> fw_setenv curr_bootfrom 2
> fw_setenv next_bootfrom 2
>
> and boot to NAND1?

No, I dont think that's the reason. During my testing, if the wrong envs are set, the box will reboot and restore the default envs.

> But flashing then from NAND2/mtd6 helped to fix it

Cool!

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
April 09, 2017 03:53PM
Kernel linux-4.10.9-mvebu-tld-1 package has been uploaded. Please see release thread for download link.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
April 09, 2017 06:12PM
@everybody,

I need someone to test the new kernel WOL patches in 4.10.9-mvebu-tld-1 on your box. Please try:

ethtool -s eth0 wol g
And then verify
ethtool eth0
Expected result
Settings for eth0:
	Supported ports: [ TP MII ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Half 1000baseT/Full 
	Supported pause frame use: No
	Supports auto-negotiation: Yes
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Half 1000baseT/Full 
	Advertised pause frame use: No
	Advertised auto-negotiation: Yes
	Link partner advertised link modes:  10baseT/Half 10baseT/Full 
	                                     100baseT/Half 100baseT/Full 
	                                     1000baseT/Full 
	Link partner advertised pause frame use: No
	Link partner advertised auto-negotiation: No
	Speed: 1000Mb/s
	Duplex: Full
	Port: MII
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: on
	Supports Wake-on: g
	Wake-on: g
	Link detected: yes

Then power down. See if the ethernet NIC still has power and whether you can wake it up with
etherwake <NAS326 mac address>


----------

Note:

If you build your own kernel, either

- applying the whole patch, or
- you can incorporate the code in the *.c files. But you need to use the new DTS.

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



Edited 2 time(s). Last edit at 04/10/2017 01:58PM by bodhi.
Re: Zyxel NAS326 - Debian / Boot from USB?
April 13, 2017 08:47AM
For me it worked!
Re: Zyxel NAS326 - Debian / Boot from USB?
April 13, 2017 03:08PM
nielsek,

> For me it worked!

Cool :)

I need the following information from you. This will help everybody who wanted to activate this feature and could not.

1. Which rootfs are you using? is it Debian-4.9.0-mvebu-tld-12-rootfs-bodhi.tar.bz2 ?
2. Are you running my released kernel linux-4.10.9-mvebu-tld-1? (i.e. you are not using your own build).
3. Which command did you use to power down? "poweroff" or "shutdown -h now" ?

Please also post the output of the following before power down:
dmesg
ethtool eth0
ifconfig -a
cat /etc/init.d/halt
cat /etc/init.d/reboot

- Now power down.

At this point, what is the behavior of the system LED and the ethernet LED? is the ethernet LED still lit amber or green?

From another box in the network issue
etherwake <mac address>


See if the box starting successfully, and after it booted into Debian.

At this point, what is the behavior of the system LED and the ethernet LED? is the ethernet LED lit amber or green?

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



Edited 1 time(s). Last edit at 04/13/2017 03:09PM by bodhi.
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: