Welcome! Log In Create A New Profile

Advanced

Debian on Zyxel NAS326

Posted by Kirsch 
Debian on Zyxel NAS326
March 28, 2016 08:21AM
I have a NSA325v2 and boot a Linux from a Flashdrive.
I created my own Debian RootFS and use bodhi's Kirkwood-Kernel (from this forum) for a bootable Linux.

Now, i plan to buy a NAS326.

My question:
Can a boot from Flashdrive too?

On NSA325 i must configure U-Boot, so that it boot from USB.
The NAS326 is very new, no one has been tried before.


------
moderator edit: modified thread title to make it easier to find



Edited 3 time(s). Last edit at 09/15/2017 01:01AM by bodhi.
Re: Zyxel NAS326 - Debian / Boot from USB?
March 28, 2016 02:07PM
Kirsch,

Post the specs if you have it. Ususally the Zyxel NAS can be booted from USB with just some adjustment in u-boot envs. To know if possible to boot kirkwood rootfs, we need at least the specs (e.g which SoC).

To know if possible to have new u-boot, I have to see the boot log. So either you have bought it, or someone did and posted their serial bootlog.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
March 28, 2016 02:23PM
I don't buy it yet

No Kirkwood, its now "Marvell Armada 380 1.3 GHz" SoC
I have no more infomation

https://www.zyxel.com/ProductTab.shtml?pid=20150327120001&idx=2&c=gb&l=en
Re: Zyxel NAS326 - Debian / Boot from USB?
March 28, 2016 02:28PM
Kirsch Wrote:
-------------------------------------------------------
> I don't buy it yet
>
> No Kirkwood, its now "Marvell Armada 380 1.3 GHz"
> SoC
> I have no more infomation
>
> https://www.zyxel.com/ProductTab.shtml?pid=2015032
> 7120001&idx=2&c=gb&l=en

You could use the same rootfs, but with a new kernel in it. This is highly possible, but I can't promise it without seeing the bootlog! you should find the bootlog somewhere.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
octomike
Re: Zyxel NAS326 - Debian / Boot from USB?
April 03, 2016 01:53PM
I have been trying to do just that for the last couple of days. Here is the beginning of the bootlog, let me know if you need to see more: https://paste.debian.net/423594/

While the u-boot has usb support compiled in it does not find any devices. Scsi/sata support on the other hand is working. I can select, list and jump to zImage/uImages on a hard disk but after that I am stuck at:

Starting kernel ...


I compiled the Archlinuxarm Kernel package linux-armv7.
Re: Zyxel NAS326 - Debian / Boot from USB?
April 03, 2016 03:40PM
octomike,

> I compiled the Archlinuxarm Kernel package
> linux-armv7.

Are you trying to run Arch rootfs on USB?

If you'd want me to help taking a look at why it is not booting with USB, interrupt serial console, and get the listing of

printenv
help
usb start
usb part

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
octomike
Re: Zyxel NAS326 - Debian / Boot from USB?
April 03, 2016 05:23PM
I'd be glad to run a fresh kernel either with the usb or scsi part of u-boot.

Here is printenv output: http://paste.debian.net/423651/

Currently I suspect that Zyxel modified u-boot to validate against a checksum (either zld_checksum or core_checksum ).
Re: Zyxel NAS326 - Debian / Boot from USB?
April 03, 2016 06:46PM
Looks like you only need to adjust envs to boot SATA (you already have SATA working). But let see if USB can start, too.

help
usb start
usb part
ide reset
ide part

And list files in rootfs (assuming it is mounted as /media/sda1):

ls -lart /media/sda1/boot
find /media/sda1/ -name '*.dtb'

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



Edited 3 time(s). Last edit at 04/03/2016 07:17PM by bodhi.
octomike
Re: Zyxel NAS326 - Debian / Boot from USB?
April 06, 2016 03:54AM
Here you go: http://paste.debian.net/424820/

I tried plugging a USB thumb drive in all of the 3 ports and it could not find any devices. So I assume booting off of USB is not working with the stock U-Boot. SCSI on the other hand is working. It's just ignoring my kernel images.

The stock rootfs is in nand and there is no dtb file around:

/ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
ubi4:ubi_rootfs1         90256     45544     44712  50% /firmware/mnt/nand
/dev/loop0              140805    122802     18003  87% /ram_bin
/dev/loop0              140805    122802     18003  87% /usr
/dev/loop0              140805    122802     18003  87% /lib/security
/dev/loop0              140805    122802     18003  87% /lib/modules
/dev/loop0              140805    122802     18003  87% /lib/locale
/dev/ram0                 5120         4      5116   0% /tmp/tmpfs
/dev/ram0                 5120         4      5116   0% /usr/local/etc
ubi2:ubi_config           2292        56      2084   3% /etc/zyxel
/dev/sdb1             15420336     47912  14589116   0% /e-data/5113cf2fd4501f7934d2f0d4dbef27b8
/ # find / -name '*dtb'
/ #
Re: Zyxel NAS326 - Debian / Boot from USB?
April 06, 2016 04:16AM
octomike,

>
> I tried plugging a USB thumb drive in all of the 3
> ports and it could not find any devices. So I
> assume booting off of USB is not working with the
> stock U-Boot.

True. Stock uboot does have USB support (shown in "help") and
Marvell>> usb sart   tart
(Re)start USB...
USB0:   Port (usbActive) : 0	Interface (usbType = 2) : USB EHCI 1.00
scanning bus 0 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found

But it is typical of Zyxel NAS to not enable it (similar situation as other Zyxel NAS). What we did was do a memory write (aka poke) to turn on USB power. Let's see if I can find that in the forum. I always failed to record this in the log, it must be a subconcious thing that shows an extreme dislike for this :))

... OK found this poke for the NSA325. So try this in serial console:
mw.l f1010100 0020c000
usb start

> SCSI on the other hand is working.
> It's just ignoring my kernel images.

This is usually just a lack of correct env to boot it.

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



Edited 1 time(s). Last edit at 04/06/2016 04:17AM by bodhi.
octomike
Re: Zyxel NAS326 - Debian / Boot from USB?
April 06, 2016 08:05AM
> ... OK found this poke for the NSA325. So try this
> in serial console:
>
> mw.l f1010100 0020c000
> usb start
>

Sorry I won't do that, I do not want to brick my device just yet :)

This is a completely different soc (Armada 380) so it's unlikely the addresses match, right ?

Also I just want to boot from hard disk on my device.
Re: Zyxel NAS326 - Debian / Boot from USB?
April 06, 2016 02:27PM
octomike Wrote:
-------------------------------------------------------
> > ... OK found this poke for the NSA325. So try
> this
> > in serial console:
> >
> > mw.l f1010100 0020c000
> > usb start
> >
>
> Sorry I won't do that, I do not want to brick my
> device just yet :)
>

Very wise :)

> This is a completely different soc (Armada 380) so
> it's unlikely the addresses match, right ?
>

It could.


> Also I just want to boot from hard disk on my
> device.

Then you only need to modify the u-boot envs to boot it. In serial ocnsole, get the listing of
printenv

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
rr4m
Re: Zyxel NAS326 - Debian / Boot from USB?
April 25, 2016 05:01PM
Got my NAS326 yesterday, managed to connect via usb-serial - and, yep, usb power is disabled in uboot.
After experimenting a bit, I've found a way to enable it. Yep, another "magic number" to apply (NAS326 is based on Armada 380, it has different GPIO addresses from Kirkwood chips).

Before we start, let's remember the default memory value:
Marvell>> md.l f1018140 1
f1018140: 003c8000

And here you are - enable usb power from uboot on NAS326 (front usb socket only - usb2.0):

Marvell>> mw.l f1018140 003c8800
Marvell>> usb reset
(Re)start USB...
USB0:   Port (usbActive) : 0    Interface (usbType = 2) : USB EHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found
Marvell>> ext2ls usb 0:1
<DIR>       4096 .
<DIR>       4096 ..
<DIR>      16384 lost+found
              13 1.txt


If one wants more details - read ARMADA370-FunctionalSpec-datasheet, page 1067 (I know, our box is build on Armada380, but it's data sheet isn't publicly available). Simply - f1018100 is address of GPIO0, f1018140 - address of GPIO1. USB power control sits on GPIO1 bit 11 (as far as I can count, it's MPP42 ?).

Kirkwood chip had GPIO0 was at f1010100, GPIO1 - f1010140, and usb power was attached to a different pin.

Also, blinking led on NAS326:

mw.l f1018148 00100000

So, we need a kernel + initrd for debian/ubuntu to boot now. Personally, I'm looking at ubuntu 16.04 for armhf netboot initrd - may be it'll run there.

Cheers! Hope this post was useful.
octomike
Re: Zyxel NAS326 - Debian / Boot from USB?
May 05, 2016 05:01AM
rr4m Wrote:
-------------------------------------------------------
> Got my NAS326 yesterday, managed to connect via
> usb-serial - and, yep, usb power is disabled in
> uboot.

Yai, a fellow struggler! :)

>
> Marvell>> mw.l f1018140 003c8800
> Marvell>> usb reset
> (Re)start USB...
> USB0:   Port (usbActive) : 0    Interface (usbType
> = 2) : USB EHCI 1.00
> scanning bus 0 for devices... 2 USB Device(s)
> found
>        scanning usb for storage devices... 1
> Storage Device(s) found
>        scanning usb for ethernet devices... 0
> Ethernet Device(s) found
> Marvell>> ext2ls usb 0:1
> <DIR>       4096 .
> <DIR>       4096 ..
> <DIR>      16384 lost+found
>               13 1.txt
>

Very nice.

Meanwhile I got the source from Zyxel and managed to build a 4.5 kernel based on the (very basic) Archlinuxarm PKGBUILD for armv7 with a modified dts based on Zyxel's dts attached to the zImage.

Everything seems to work fine (sata, usb, crypto) but I cannot get any packets through to the ethernet device (mvneta) and I have no idea how to debug this further. :(

The GPIO pokes you found, that I thought were part of u-boot, actually resided in arch/arm/boot/compressed/misc.c in decompress_kernel()
Re: Zyxel NAS326 - Debian / Boot from USB?
May 05, 2016 02:34PM
rr4m,

Thanks for the info. Do you have a serial boot log? can you post it here?

BTW, GPIO1 11 is 43 :)

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



Edited 1 time(s). Last edit at 05/05/2016 02:36PM by bodhi.
musv
Re: Zyxel NAS326 - Debian / Boot from USB?
May 12, 2016 12:51PM
Bodhi:
In the Arch Thread I posted the serial logs with the original Zyxel firmware:

Boot process

Shutdown process

Uboot environment variables

Hope, it helps somehow.
Re: Zyxel NAS326 - Debian / Boot from USB?
May 12, 2016 03:02PM
musv,

Thanks musv! interesting info. Do you have serial console connected?

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
rr4m
Re: Zyxel NAS326 - Debian / Boot from USB?
May 13, 2016 06:49AM
Bodhi,

Haven't been here for a while, sorry. nas326_bootlog.txt as I see it (no HDDs installed, ethernet cable disconnected).

BTW, I've managed to install Ubuntu 16.04 to usb flash drive, using nas326 stock kernel + uInitrd from here. 16.04 Netboot launches and installs everything (except grub) - takes pretty long time (slow usb drive).

But, after installation, stock kernel is not enough to boot ubuntu (wants autofs, ...) - need one more step here - kernel rebuild with ubuntu kernel config.

If anyone wants to repeat - here you are the steps how to run ubuntu xenial xerus installation process on nas326:

1. Take a clean USB flash drive, format it as ext2 (or ext4) partition
2. Create 'boot' folder, put Xenial Xerus for arm netboot uInitrd there. (/boot/uInitrd)
3. Put flash drive to Nas326 front usb socket
4. Connect ethernet cable (netboot will get ip address via dhcp and will be downloading ubuntu packages)
5. Boot into u-boot console (I hope you already attached usb-serial console to your nas326 box)
6. Launch the following commands:

setenv bootargs "console=ttyS0,115200"
nand read 0x1000000 0x00E00000 0xF00000
mw.l f1018140 003c8800
usb reset
ext2load usb 0:1 0x2000000 /boot/uInitrd
bootz 0x1000000 0x2000000

What it does - it loads stock kernel from nas326 flash rom (to 0x1000000) + enables usb power + loads uInitrd from USB flash drive (/boot/uInitrd to 0x2000000) and lauches all together.

As I said, it's enough to install the system. But not yet enough to run it after installation - need to recompile a kernel and add missing modules.
Re: Zyxel NAS326 - Debian / Boot from USB?
May 13, 2016 02:37PM
rr4m,

Thanks for the info!

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
musv
Re: Zyxel NAS326 - Debian / Boot from USB?
May 16, 2016 11:08AM
> Thanks musv! interesting info. Do you have serial
> console connected?

Yes, I have. It's this thing.

Works quite well with one restriction:
The Uboot-Loader seems to be configured to try booting first from Serial. Hence, if the tiny-breakout is connected, the Zyxel doesn't start.

So I can't access the Uboot-Console directly. But I can change the environment variables via fw_setenv.
Re: Zyxel NAS326 - Debian / Boot from USB?
May 16, 2016 12:09PM
musv,

> Works quite well with one restriction:
> The Uboot-Loader seems to be configured to try
> booting first from Serial. Hence, if the
> tiny-breakout is connected, the Zyxel doesn't
> start.
>

Have you tried other serial converter such as CP2xx or PL3xx ?

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
musv
Re: Zyxel NAS326 - Debian / Boot from USB?
May 16, 2016 02:08PM
No, don't have any other serial converter.

I bought this thing to rewrite the boot order of my previous NSA325 some years ago.

The behaviour is more exactly:
The LEDs don't start blinking, if the tinybreakout is connected. When I unplug the serial converter it begins to boot. Then I can re-plug it and get the output. So I assume, "something" inside the NSA326 checks, if the certain pins are connected and refuses to boot or tries to boot via serial console.
Re: Zyxel NAS326 - Debian / Boot from USB?
May 17, 2016 12:04AM
musv,

> The behaviour is more exactly:
> The LEDs don't start blinking, if the tinybreakout
> is connected. When I unplug the serial converter
> it begins to boot. Then I can re-plug it and get
> the output. So I assume, "something" inside the
> NSA326 checks, if the certain pins are connected
> and refuses to boot or tries to boot via serial
> console.

That's abnormal. The bootROM should not behave that way. It seems u-boot did not even come in to play.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
rr4m
Re: Zyxel NAS326 - Debian / Boot from USB?
May 21, 2016 02:03PM
Ubuntu 16.04 on Nas326 project update - all boots and runs now.

In previous post I wrote how to install 16.04 armhf to usb stick, but NAS326 stock kernel was lacking some features to boot Ubuntu. Here you are 2 missing pieces - recompile the kernel with "File systems -> Kernel automounter version 4 support" and "General setup -> Control Group support" - and everything just boots and works (IMO will also boot with Debian Initrd from Bodhi).

Exact kernel config options to append:

CONFIG_CGROUPS=y
CONFIG_CGROUP_DEBUG=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CPUSETS=y
CONFIG_PROC_PID_CPUSET=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_RESOURCE_COUNTERS=y
# CONFIG_MEMCG is not set
# CONFIG_CGROUP_SCHED is not set
CONFIG_BLK_CGROUP=y
# CONFIG_DEBUG_BLK_CGROUP is not set
# CONFIG_BLK_DEV_THROTTLING is not set
# CONFIG_CFQ_GROUP_IOSCHED is not set
# CONFIG_NETPRIO_CGROUP is not set
CONFIG_AUTOFS4_FS=m

After kernel recompile, put it to usb stick (/boot/zImage_dbt_custom) + copy modules to /lib/modules/3.10.39, and we're ready to boot into Ubuntu:

setenv bootargs "console=ttyS0,115200 root=/dev/sda1"
mw.l f1018140 003c8800
usb reset
ext2load usb 0:1 0x2000000 /boot/uInitrd
ext2load usb 0:1 0x1000000 /boot/zImage_dbt_custom
bootz 0x1000000 0x2000000

I'm using "root=/dev/sda1", because my usb stick detects as sda1 (with no HDDs inserted). But if you install 1/2 HDD drives, it can be sdb1 or sdc1.

Another thing to mention - fan speed. As you probably know, NSA320/NSA325/NSA325v2 had no software fan speed control. And NAS326 is no exception here. It has no fan speed controller, and fan itself is 3-pin 12V fan (Ground, +VCC, Sensor) - it has no PWM line, so we can only read fan RPM but cannot set it. What a shame, ZyXEL!!!

# echo "Fanspeed" $[60000/$(($(i2cget -y 0x0 0x0a 0x08)))] "RPM"
# Fanspeed 1818 RPM
# echo "CPU Temperature" $(($(i2cget -y 0x0 0x0a 0x07))) "C"
# CPU Temperature 31 C

The good thing about it - at least we don't need to recompile/tweak the software here :) You could do that on NSA310 and on NAS540. But in our case, it's not software-solvable. So, to make my NAS326 a little less noisy, I lowered fan voltage from 12V to 6.5-7V. Now it runs at 680 RPM and is almost quiet. Pure hardware solution.

Yet another thing to mention - NAS326 power consumption. Empty box eats 5W. With 1 HDD installed (7200RPM Hitachi 1TB) - 10W. With 2 HDDs installed (7200RPM hitachi 1TB + 5400RPM toshiba 3TB - both spinning) - 14.5W. Probably will eat another 5-7W under some useful load. Overall - IMO that's great.

What's left to be absolutely happy - a bit of sysctl tweaking, samba, nfs - and all done. Oh, and I don't like my old usb stick performance. May be it makes sense to move the system to a faster usb 3.0 drive or class10 sd card...
Re: Zyxel NAS326 - Debian / Boot from USB?
May 21, 2016 11:32PM
rr4m Wrote:
-------------------------------------------------------
> I'm using "root=/dev/sda1", because my usb
> stick detects as sda1 (with no HDDs inserted). But
> if you install 1/2 HDD drives, it can be
> sdb1 or sdc1.

Give the partition on the USB flash drive a unique name (e.g. rootfs) and try this:
root=LABEL=rootfs
rr4m
Re: Zyxel NAS326 - Debian / Boot from USB?
May 22, 2016 12:26PM
Kirsch,

Thanks for the tip - it worked great! Just created a label ('sudo e2label /dev/disk2s1 rootfs') - and it works.

BTW, I've recompiled NAS326 kernel to append ubuntu 16.04 initramfs - so it's now a single file. The booting process looks like:

setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs"
mw.l f1018140 003c8800
usb reset
ext2load usb 0:1 0x2000000 /boot/zImage_3.10.39_nas326_ubuntu1604_initramfs
bootz 0x2000000

And, to make it even nicer, I flashed that new kernel+initramfs into NAND (rewrote kernel2 15MB partition - 0x08700000):

mw.l f1018140 003c8800
usb reset
ext2load usb 0:1 0x2000000 /boot/zImage_3.10.39_nas326_ubuntu1604_initramfs
nand erase 0x08700000 0x00F00000
nand write 0x2000000 0x08700000 0x00F00000

As a result - we don't need to access USB drive from U-Boot anymore - so it can be inserted into rear USB 3.0 socket. Yep, U-Boot only can work with front USB 2.0 socket. But after the kernel is booted, usb drive with rootfs can be attached anywhere - including rear usb 3.0.

Finally - command to boot custom kernel + ubuntu initrams from NAND:

setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs"
nand read 0x2000000 0x08700000 0xF00000
bootz 0x2000000

Ah, bootargs can be saved permanently, too:

setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs"
saveenv

How the bootlog looks - nas326_ubuntu1604_bootlog.txt

---

I'm sharing the custom kernel + config + modules for installing/booting Debian/Ubuntu on NAS326. See README.txt - it includes all these steps.
You can take a Xenial Xerus armhf netinstall uInitrd (like I did), or some Debian armhf netinstall image (from Bodhi) - hope custom kernel will work there too.

nas326_custom_kernel_for_ubuntu_20160522.tar.gz (MD5 - 2c8c13198995ea788b676806220a665e)
Re: Zyxel NAS326 - Debian / Boot from USB?
May 24, 2016 01:08AM
FYI,

In a few weeks, when I got the hardware, I will start testing this kernel.

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



Edited 1 time(s). Last edit at 05/25/2016 03:12AM by bodhi.
Re: Zyxel NAS326 - Debian / Boot from USB?
May 25, 2016 03:15AM
The differences in kernel configuration from the Kirkwood to Armada is not a whole lot. So I've built the custom 4.6 kernel for this. It might work.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
musv
Re: Zyxel NAS326 - Debian / Boot from USB?
June 21, 2016 08:58AM
Hi there,

long time has passed since the last messages. What's the state of this project?

Did you get it completely running? How about the dts file?
Re: Zyxel NAS326 - Debian / Boot from USB?
June 21, 2016 04:10PM
The Armada kernel was built easily, without any trouble. But I have been quite busy so have not got back to this. And I don't have the hardware yet, either :).

-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: