Welcome! Log In Create A New Profile

Advanced

Debian on Zyxel NAS326

Posted by Kirsch 
Re: Zyxel NAS326 - Debian / Boot from USB?
September 13, 2016 04:23PM
@Bodhi: do you mind sharing the Kernel 4.6 Armada 38x build and configs (maybe patches if needed)

Cheers Carl
Re: Zyxel NAS326 - Debian / Boot from USB?
September 13, 2016 07:06PM
Peacemaker Wrote:
-------------------------------------------------------
> @Bodhi: do you mind sharing the Kernel 4.6 Armada
> 38x build and configs (maybe patches if needed)
>
> Cheers Carl

Sure, let me find it.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Zyxel NAS326 - Debian / Boot from USB?
September 13, 2016 07:18PM
Here is the kernel config file version config-4.6-mvebu-tld-1. You can use my kernel linux-4.6.0-kirkwood-tld-1 patch with it.

Quote

Updated 20 May 2016:

Kernel linux-4.6.0-kirkwood-tld-1 package has been uploaded. The following features were added/updated:

- Supports for Linksys EA4500. Use kirkwood-ea4500.dtb to boot this box. DSA (kirkwood-ea4500-dsa.dtb) is still a work-in-progress.
- HP T5325: Enable internal sound chip.
- Fix network issue with Zyxel NSA320S and NSA310S.
- New file system is enabled in the kernel: OrangeFS.


This is only a preliminary build to see if there is any potential trouble. There are much more to be added to this kernel config. This version might work with some limited funtionality.

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



Edited 1 time(s). Last edit at 09/13/2016 07:23PM by bodhi.
Attachments:
open | download - config-4.6-mvebu-tld-1 (143.1 KB)
Re: Zyxel NAS326 - Debian / Boot from USB?
September 18, 2016 12:43AM
I will have a hands-on look at this Armada 38x box within a couple weeks.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Zyxel NAS326 - Debian / Boot from USB?
September 18, 2016 05:12AM
bodhi Wrote:
-------------------------------------------------------
> I will have a hands-on look at this Armada 38x box
> within a couple weeks.

Nice, but the I changed my mind and bought a cheap WD Ex2 Ultra (Dualcore & 1 gb Ram) as replacement for my old NAS, but I started to regread my decision for the locked U-Boot.

Hope the Kernel's are some how compatible to all 38x, with the right *.dtb.
Re: Zyxel NAS326 - Debian / Boot from USB?
September 23, 2016 10:00AM
It takes some time, but i buy a NAS326 last week and its arrived today.
For a RPi and my old NSA325, i build my own RootFS with debootstrap and used prebuilt linux kernels.

Which steps must i do, to build a kernel for this Armada 380 Box?

Or has somebody a working kernel that i can try?
rr4m
Re: Zyxel NAS326 - Debian / Boot from USB?
October 04, 2016 12:12PM
Kirsch, you can take my kernel for NAS326 (3.10.39, almost same as stock, but with few added options) - see my post above for download link. My nas326 box runs Ubuntu 16.04 for ARM HF with this kernel all summer long - no probs at all.

If you want to rebuild a kernel yourself, you need a firmware source code of course - just request it from here, ZyXEL support will send you a link (includes a 3.10.39 kernel source with config + tools + instructions how to build a world).

In case you want a fresher kernel (4.x), there are some things to do (minimaly - porting nas326 device tree + hardware init from 3.10.39 source - you know, they hardcoded HDD power up inside kernel decompressor routine, yea... )
musv
Re: Zyxel NAS326 - Debian / Boot from USB?
October 07, 2016 02:44PM
Thanks for that information.

I tried to build the system on base of Gentoo. I set up an qemu-user environment. And now I tried to configure the kernel. I've used the kernel config you provided in the link above. But of course it doesn't match exactly the kernel options of kernel 4.7. A lot of things have been changed.

About the hardcoded HDD power up I didn't know.

I thought also in getting the built system including the kernel running inside Qemu. But when I start the virtual machine, I don't get any output. Only the virtual cpu last goes up to 100%. Of course the NSA326 isn't supported by Qemu. So I chose vertex-a9 as a similar CPU model and tried to activate the vertex options in the kernel config.

At least it's good to know about the HDD power up. If I would have been changed the Uboot config, my NSA326 would have been soft-bricked, because I still have to problem to be able to connect the serial convert only, when the kernel has been started booting.

rr4m:
Did you use this Howto? Are there any important things to know for the installation? I have to be careful. After changing the Uboot config, I guess I'll have only one trial.
rr4m
Re: Zyxel NAS326 - Debian / Boot from USB?
October 08, 2016 06:57AM
Hey, musv!

Nope, I didn't use that Howto, just booted into ubuntu installer and followed the installation steps there to install ubuntu system onto usb stick. I noted all my steps - see attached archive here (includes my kernel, modules and README.txt). One more thing - after you install the system, copy /lib/modules to usb stick one more time (as far as I remember, ubuntu installer erases /lib)

Unless you decide to rewrite nas326 NAND ROM you're safe to experiment - just boot your kernel and system from usb stick manually (pass boot commands via serial console - see my README.txt). Stock ZyXel system will stay untouched in NAND. Just don't use 'saveenv' and 'nand erase' commands before you absolutely sure.

Good luck!
hean01
Re: Zyxel NAS326 - Debian / Boot from USB?
October 11, 2016 02:06PM
musv Wrote:
-------------------------------------------------------
>
> 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.

I have the same problem, did you find out why this happend to you ?
hean01
Re: Zyxel NAS326 - Debian / Boot from USB?
October 12, 2016 01:29AM
Hi,

I followed the guide to install ubuntu1604 onto the nas326 device and it works nice (replaced ubuntu 1603 initrd with debian 8 installer). I stored the kernel/initrd into nand and updated bootcmd and botargs to boot directly into ubuntu1604 upon start. However it does not, the device always boots into uboot prompt, my guess it is something about checksum verification that fails ? (cant actually see any text before uboot prompt due to my problem with serial connection as described in previous post).

What would be needed to get nas326 to successfully boot the custom nand kernel/initrd, my setup boots correctly when i enter the uboot command 'boot' which I have read is what should be done after the uboot prompt.

Regards,

Henrik Andersson
rr4m
Re: Zyxel NAS326 - Debian / Boot from USB?
October 14, 2016 07:48AM
hean01, could you post your bootlog + printenv. May be it will give us some clue.
musv
Re: Zyxel NAS326 - Debian / Boot from USB?
October 18, 2016 01:43PM
hean01 Wrote:
-------------------------------------------------------
> musv Wrote:
> --------------------------------------------------
> -----
> >
> > 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.
>
> I have the same problem, did you find out why this
> happend to you ?

Didn't find any solution yet. Ok, let's start from the beginning. Maybe we find our error. First of all the pins on the board:

---------  ------------------- 
| ? | ? |  | ? |TX|RX| - |GND|
---------  -------------------

Then we have 5 named LEDs on the board:
SYS, HDD1, HDD2, USB, COPY

The command to access the serial console is:
screen /dev/ttyUSB0 115200 8N1

1. Plug the serial cable, then switch on the NSA326: SYS and HDD1 are shining red, the others white - nothing happens.
2. Switch on the NSA, then plug the cable immediately: All 5 LEDs are shining, nothing happens.
3. Switch on the NSA, wait until the SYS LED starts blinking, then plug the cable: I see the kernel booting and get access to the serial console.

What am I doing wrong? I'm not able to access the Uboot console. On the NSA325 I got access easily. Do I have to press any buttons at any time?

The risk just to change some Uboot bootargs in order to boot an Ubuntu from HDD seems to high to me. Just a small error would deny any access to the device.
hean01
Re: Zyxel NAS326 - Debian / Boot from USB?
October 22, 2016 07:50AM
I have the exact problem as you, tho I just recently got myself another serial cabel which i haven't yet tested.

> musv Wrote:
> --------------------------------------------------
>
> The risk just to change some Uboot bootargs in order to boot an Ubuntu from HDD seems to high to me. Just a small error would
> deny any access to the device.
>

The boot delay configuration is 3 secounds. I'm able to break the boot process with "minor" effort having allthing hooked up.

  • wait for the red led displayed as you decsriped with serial cabel connected
  • unplug the usb serial cabel and insert it, the nas326 will start boot
  • as fast as possible, run screen or what ever com program and hammer on keyboard to enter uboot consol. If fail, retry until you are fast enough :)

While you are in, increase bootdelay to 10 seconds like:

setenv bootdelay "10"
saveenv

This will make the process easy to get into uboot console.
musv
Re: Zyxel NAS326 - Debian / Boot from USB?
October 23, 2016 01:40PM
Ok, will try this. Thanks for that idea. Additionally to my post I wrote an email to the Zyxel support. Maybe they have another hint for me. But I'm not sure, if they answer anyway. Or if so, if they give me any information about hacking their devices. :)

Btw. the bootdelay parameter you can change from inside the original firmware too with fw_setenv.

Would be annoying, if the problem would be produced by different serial cables.
musv
Re: Zyxel NAS326 - Debian / Boot from USB?
October 24, 2016 08:58AM
hean01 Wrote:
-------------------------------------------------------
>
>
    >
  • wait for the red led displayed as you
    > decsriped with serial cabel connected
    >
  • unplug the usb serial cabel and insert it, the
    > nas326 will start boot
    >
  • as fast as possible, run screen or what ever
    > com program and hammer on keyboard to enter uboot
    > consol. If fail, retry until you are fast enough
    > :)
    >
>

Thank you so much. It worked. :)

Took me 6 months to get to this point.
musv
Re: Zyxel NAS326 - Debian / Boot from USB?
October 24, 2016 03:44PM
Someone wrote above, the kernel needs an additional patch to power on the hard-disks.

Does that mean, it's not possible to boot the system including the kernel from a hard-disk?
hean01
Re: Zyxel NAS326 - Debian / Boot from USB?
October 24, 2016 04:55PM
musv Wrote:
-------------------------------------------------------
> Someone wrote above, the kernel needs an
> additional patch to power on the hard-disks.
>
> Does that mean, it's not possible to boot the
> system including the kernel from a hard-disk?

That was my first thing to try, I even managed to find the correct bits to poke to power up hdd just like usb power earlier mentioned in this thread. However uboot seems not to be able to find any disk, probably and ide / sata issue.. = No boot from kernel on disk as far as I know.

I have a 4.8.2 kernel compiled and working (sata, usb, rtc etc), however I can't get the ethernet device running. I have problems with porting the device tree over to the new kernel which actually includes armada-38x. Anyway, kernel boots fine with rootfs on ext2 specified via bootargs in uboot environment.

Anyone who could take a look at the patch/ethernet problem, patch linked below ?

build like:

make stg328_defconfig
make zImage
make armada-380-zyxel-nas-326.dtb
cat arch/arm/boot/zImage arch/arm/boot/dts/armada-380-zyxel-nas-326.dtb > zImage_dtb


nas326 kernel 4.8.2 patch
hean01
Re: Zyxel NAS326 - Debian / Boot from USB?
October 24, 2016 05:11PM
Here are the pokes for powerup of usb, hdd1 and hdd2.

First the a dump of GPIO0 and GPIO1 on powerup:

Marvell>> md.l f1018100 1
f1018140: 00420000
Marvell>> md.l f1018140 1
f1018140: 003c8000

and to power on usb and hdd, we should set bit 29 (HDD1) and bit 11 (USB) and 13 (HDD2), just like:

Marwell>> mw.l f1018100 20420000
Marwell>> mw.l f1018140 003E8800
musv
Re: Zyxel NAS326 - Debian / Boot from USB?
October 25, 2016 02:01AM
hean01 Wrote:
-------------------------------------------------------
> and to power on usb and hdd, we should set bit 29
> (HDD1) and bit 11 (USB) and 13 (HDD2), just like:
>
>
> Marwell>> mw.l f1018100 20420000
> Marwell>> mw.l f1018140 003E8800
>

Are you sure, if that is correct?
20420000
HDD1               HDD2  USB
  =                   ?  ?
0010 0000 0100 0010 0000 0000 0000 0000

003c8000
HDD1               HDD2  USB
  ?                   ?  ?
0000 0000 0011 1100 1000 0000 0000 0000

I tried to configure the Kernel on Gentoo (4.7). There have been added a lot of Armada-38x/380 stuff. You shouldn't need to add any Armada patches. I would assume, only the NSA326 specific stuff (HDD/USB Power on) should have been added. Don't know if there's something else NSA326 specific on that board.
hean01
Re: Zyxel NAS326 - Debian / Boot from USB?
October 25, 2016 02:39AM
musv Wrote:
>
> Are you sure, if that is correct?
>

This is was I get it to:

GPIO0:

0000 0000 0100 0010 0000 0000 0000 0000
0010 0000 0100 0010 0000 0000 0000 0000
  ^
 HDD1

GPIO1:

0000 0000 0011 1100 1000 0000 0000 0000

0000 0000 0011 1110 1000 1000 0000 0000
                 ^       ^
               HDD2     USB


> I tried to configure the Kernel on Gentoo (4.7).
> There have been added a lot of Armada-38x/380
> stuff. You shouldn't need to add any Armada
> patches. I would assume, only the NSA326 specific
> stuff (HDD/USB Power on) should have been added.
> Don't know if there's something else NSA326
> specific on that board.

I know, that is my problem, we need to create a dts for nas326 board which is included in my patch.
However it is not complete due to my absent knowledge of device trees in general, just took a copy
of armada-380.dts from zyxel source and modified a bit to build correctly. It is using the upstream
aramada-38x dts.

My patch only includes hdd power startup code, config file and a device tree.
musv
Re: Zyxel NAS326 - Debian / Boot from USB?
October 25, 2016 03:33PM
Got the kernel compiled. But for some reason the part with switching on the USB and the HDD doesn't work.

I have applied your patch, compiled merged the zImage with the dtb file.

Marvell>> setenv bootargs "console=ttyS0,115200 root=LABEL=USB_GENTOO"
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>> ext4load usb 0:1 0x02000000 /boot/zImage_dtb
4566967 bytes read in 337 ms (12.9 MiB/s)
Marvell>> bootz 0x02000000
*  kernel: cmdline image address = 0x02000000

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.7.2-gentoo (root@armv7a-hardfloat-linux-gnueabi) (gcc version 5.4.0 (Gentoo 5.4.0 p1.0, pie-0.6.5) ) #2 SMP Tue Oct 25 22:06:55 CEST 2016
[    0.000000] CPU: ARMv7 Processor [414fc091] revision 1 (ARMv7), cr=10c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache

If I look into the patched kernel source:
arch/arm/boot/compressed/misc.c
        unsigned int regvalue = 0;

        // power on HDD1
        putstr("Power on HDD1 ...\n");
        regvalue = MEMIO32_READ(REG_GPIO_DATA_OUT(GPIO_POWER_ON_HDD1)); // get original reg value
        MEMIO32_WRITE(REG_GPIO_DATA_OUT(GPIO_POWER_ON_HDD1), regvalue|VALUE_POWER_ON_HDD1);
        sleep1(6);

        // power on HDD2
        putstr("Power on HDD2 ...\n");
        regvalue = MEMIO32_READ(REG_GPIO_DATA_OUT(GPIO_POWER_ON_HDD2)); // get original reg value
        MEMIO32_WRITE(REG_GPIO_DATA_OUT(GPIO_POWER_ON_HDD2), regvalue|VALUE_POWER_ON_HDD2);
        sleep1(6);

        // power on USB
        putstr("Power on USB ...\n\n");
...

        arch_decomp_setup();

        putstr("Uncompressing Linux...");
Neither I see the "Uncompressing Linux" message nor the "Power on ...". Did I forget to select something in the menuconfig? On my x86 machine I can see "Uncompressing Linux", when I start the computer. Any idea?

About the network:
Not sure, but when I checked the kernel config there are some strange drivers activated, e.g. e1000 and e1000e. Both are Intel network cards and get loaded on that arm box. Can't imagine, those cards are on that board. But I will clean up the Config as soon as I got the system loaded.
hean01
Re: Zyxel NAS326 - Debian / Boot from USB?
October 25, 2016 05:12PM
musv Wrote:
-------------------------------------------------------
>
> Neither I see the "Uncompressing Linux" message
> nor the "Power on ...". Did I forget to select
> something in the menuconfig? On my x86 machine I
> can see "Uncompressing Linux", when I start the
> computer. Any idea?
>

I think that is related to when serial console is initialized in kernel. Maybe a EARLY_PRINTK is needed. Anyway, I haven't looked
it up due to it powers on the hdds..

> Not sure, but when I checked the kernel config
> there are some strange drivers activated, e.g.
> e1000 and e1000e. Both are Intel network cards and
> get loaded on that arm box.

That config is inherited from the kernel config used in orginal firmware, which had e1000 and 1000e compiled in. Didn't dig deeper
into why was the case so I left them there. I also added a few storage stuff to the config such as dm* and md.
hean01
Re: Zyxel NAS326 - Debian / Boot from USB?
October 26, 2016 03:53PM
I finally got some time to get the network going, here is an updated device tree for linux-4.8.2

armada-380-zyxel-nas326.dts
hean01
Re: Zyxel NAS326 - Debian / Boot from USB?
October 27, 2016 08:05AM
Here is another update, patch applies to kernel 4.8.4.

- network and usb is now working as expected
- E1000 drivers are removed from config

http://pastebin.com/2bT5FzjR]nas326_kernel_4.8.4.patch[/url]
hean01
Re: Zyxel NAS326 - Debian / Boot from USB?
October 27, 2016 08:09AM
hean01 Wrote:
-------------------------------------------------------
> Here is another update, patch applies to kernel
> 4.8.4.
>
> - network and usb is now working as expected
> - E1000 drivers are removed from config
>
> http://pastebin.com/2bT5FzjR]nas326_ke
> rnel_4.8.4.patch[/url]

nas326_kernel_4.8.4.patch
Re: Zyxel NAS326 - Debian / Boot from USB?
October 27, 2016 03:47PM
Good progress guys :)

I've got the hardware but have not have time to start looking into this u-boot.

-bodhi
===========================
Forum Wiki
bodhi's corner
hean01
Re: Zyxel NAS326 - Debian / Boot from USB?
October 28, 2016 01:25AM
musv Wrote:
-------------------------------------------------------
>
> Would be annoying, if the problem would be
> produced by different serial cables.
>

Another cable (PL2303) solved the problem, I can now boot the device without the hang.
musv
Re: Zyxel NAS326 - Debian / Boot from USB?
October 31, 2016 02:01PM
hean01:
Thank you very much. Got it running!

2 small things:
In the boot process I get the error message:
Okt 30 23:45:27 nas kernel: m25p80 spi0.0: unrecognized JEDEC id bytes: ff, ff, ff
Maybe there's still something missing in the dts file.

And the 2nd thing:
If you run systemd, you'll most probably need:
CONFIG_SECCOMP=y
Otherwise journald fails to start.

No there's one thing left for me:
Tasks:  57 total,   2 running,  55 sleeping,   0 stopped,   0 zombie
%CPU0  :  0,0 us, 95,0 sy,  0,0 ni,  5,0 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st
KiB Spch:   511008 total,   445124 free,    15260 used,    50624 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used.   484112 avail Spch

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     ZEIT+ BEFEHL                                                                                        
  233 root      20   0       0      0      0 R 95,0  0,0   9:35.55 kworker/0:1
I have between 60% and 95% cpu last on this worker thread.
hean01
Re: Zyxel NAS326 - Debian / Boot from USB?
October 31, 2016 02:31PM
Here comes and updated patch for linux-4.8.4 kernel.

- Enables more cgroup features
- Enables usb3 ports on back
- Removes MMC from kernel due to bug which makes kworker running at 80% cpu

I need help to get the NAND / UBIFS work as expected.

linux-4.8.4-NAS326.patch
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: