Welcome! Log In Create A New Profile

Advanced

NAS326 does not boot reliably

Posted by michael_kaeppler 
NAS326 does not boot reliably
July 18, 2019 07:14AM
Hi all,
I'm running Debian 9.9 with kernel 4.19.1-mvebu-tld-1 on my NAS326 box and I am very happy with it,
excluding one problem: The box does not boot reliably. Every second (or third, I was not able to figure it out clearly) time I shutdown the box with
shutdown -h now
and try to boot the box again, the box remains in a state where it is not reachable through samba/ssh/etc.
While in this state, all three front leds are shining continuosly.
When I "switch off" the box by removing the power plug and booting up again, it works.
Attached are my u-boot envs. Unfortunately I do not have a serial interface available.
Anybody out there experiencing a similar problem?

Michael
Attachments:
open | download - envs_18_7_2019 (4.8 KB)
Re: NAS326 does not boot reliably
July 18, 2019 01:22PM
Michael,

It is best that you have serial console to fix this problem.

Warning: If what I suggest below does not work, and the box reboot to stock, you might need serial console to troubleshoot. So do not attempt if you don't have serial console or don't plan to connect one.

Login into Debian.

Make sure to doublecheck the following envs are set like:

curr_bootfrom=1
next_bootfrom=1
kernel_addr_1=0x00000000; run bootcmd_custom;


And set this env

fw_setenv change_boot_part 0

And reboot.

shutdown -r now


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


And if the box happens to boot into stock consistently afterward, reset envs like in the installation instruction step 4

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

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: NAS326 does not boot reliably
July 21, 2019 03:53PM
bodhi,
thanks for your advice.
I decided to give it a try hooking up my USB-TTL-interface to the serial port of my NAS326 box.
Don't know the chip but from the driver I assume it is a FT232.
If I hook it up and try to boot the NAS remains in a state with all leds shining continously which is,
if I understand the descriptions in the forum here, normal (waiting for commands on serial console).
That shows that it somehow detects that the interface is attached. If I remove the cable the box does boot.
However, I do not get any output coming from the serial port.
The pinout I used is the one you posted in an thread some years ago:
Zyxel NAS326 Serial Pinouts (same as NSA325 and NSA310S/320S)

GND  
RX 
TX 

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

I am not sure with TX/RX. Does "TX" mean here, TX from NAS326? In that case I would have to connect it with my FT232's RX and the other way around, right?
Is baud rate critical? I set it to 112500, 8N1.
Maybe my interface does only allow 5V operation? I also ordered a ch340g interface https://www.ebay.de/itm/252713824136 for testing.

All the best,
Michael
Re: NAS326 does not boot reliably
July 21, 2019 11:26PM
Michael,

Quote

> USB-TTL-interface to the serial port of my NAS326
> box.
> Don't know the chip but from the driver I assume
> it is a FT232.
> If I hook it up and try to boot the NAS remains in
> a state with all leds shining continously which
> is,
> if I understand the descriptions in the forum
> here, normal (waiting for commands on serial
> console).
> That shows that it somehow detects that the
> interface is attached. If I remove the cable the
> box does boot.

That is the behavior we expect from this box. When serial console connected, sometime it got stuck in the BootROM phase.

To "nudge" it to get pass this phase, on the box that you have serial console module connected. If it is a Linux box, then things are quite easy. Instead of running picocom/minicom/screen to be the serial console server, you would run kwboot in debug mode (I mentioned this in the installation instruction):

kwboot -t -B 115200 /dev/ttyUSB0 -d

After a few seconds, it will continue booting.

Quote

> Zyxel NAS326 Serial Pinouts (same as NSA325 and
> NSA310S/320S)
>
> GND
> RX
> TX
>
> +----+----+
> | | |
> +----+----+----+----+----+
> |3.3V| TX | RX | | GND|
> +----+----+----+ +----+
> [/code]
>
> I am not sure with TX/RX. Does "TX" mean here, TX
> from NAS326? In that case I would have to connect
> it with my FT232's RX and the other way around,
> right?
> Is baud rate critical? I set it to 112500, 8N1.

Yes. baud rate and other setting are very important. 112500, 8N1 is correct.

> Maybe my interface does only allow 5V operation?

The power pin 3.3V must not be connected. It will fry your serial console port. The only pins we use are: TX (transmit), RX (receive), and GND (ground).

Depending on the serial module chip, you might need to reverse the TX/RX connection, or might not. The old CP2xxx chip serial module already reversed, meaning TX should be connected to TX, RX to RX. The PLxxxx chip module is always reversed, meaning RX should be connected to TX, TX to RX.

=====

Note: you don't have a Linux box to run serial console module then, you can also trick the box this way: disconnect the serial console module USB conector, and as soon as the box power up and start booting, plug it in, and run screen (Mac OS) or putty (Windows) to start serial console server. You will lose some log at the beginning, but serial console will work.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: NAS326 does not boot reliably
July 22, 2019 02:14AM
bodhi,
many thanks for your advice! Great that you spend time to help others.
I actually had to reverse TX/RX pins and now serial console works like a charm.
I set change_boot_part to 0, rebooted several times and up to now it works. (consistently boots into custom kernel)
What I would really like to understand is what change_boot_part does.
In your installation instructions change_boot_part is set to 1 and it seems to work for most people.
I thought it is part of the mechanism
Quote

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.
So setting change_boot_part to 0 switches this mechanism off, right?
Re: NAS326 does not boot reliably
July 23, 2019 10:01AM
Michael,

No, the change_boot_part does not switch that off. Basically, that env was set to switch NAND kernel 1 to 2, and vice versa. When we set this to 0, we tell stock uboot to boot the current kernel which is curr_bootfrom=1.

Stock FW use this to upgrade kernel.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
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: