Welcome! Log In Create A New Profile

Advanced

Debian on Zyxel NAS326

Posted by Kirsch 
Re: Zyxel NAS326 - Debian / Boot from USB?
January 19, 2017 04:51AM
Looks like I also need to incorporate some of my old patch to control the HDD LEDs light individually. And also USB activity LED.

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



Edited 2 time(s). Last edit at 01/19/2017 05:56AM by bodhi.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 20, 2017 03:49AM
To get the fan speed and CPU temperature:

apt-get install i2c-tools

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

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
January 21, 2017 03:33AM
I've uploaded kernel package linux-4.9.0-mvebu-tld-8 package:
http://forum.doozan.com/read.php?2,32146,32146#msg-32146

This tarball has a complete patch for building kernel. And also the deb packages and DTBs for installation.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 10:37AM
bodhi, thanks for assembling everything together. A bit of testing on my side.

I wasn't able to boot zImage-4.9.0-mvebu-tld-8 directly (it doesn't have DTB attached, right?):
Marvell>> ext2load usb 0:1 0x1000000 /zImage-4.9.0-mvebu-tld-8
4466616 bytes read in 567 ms (7.5 MiB/s)
Marvell>> bootz 0x1000000
*  kernel: cmdline image address = 0x01000000

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

Error: unrecognized/unsupported machine ID (r1 = 0x00000210).

Available machine support:

ID (hex)        NAME
ffffffff        Generic DT based system
ffffffff        Marvell Armada 39x (Device Tree)
ffffffff        Marvell Armada 380/385 (Device Tree)
ffffffff        Marvell Armada 375 (Device Tree)
ffffffff        Marvell Armada 370/XP (Device Tree)
ffffffff        Marvell Dove

Please check your kernel config and/or bootloader.

But, anyways I wanted to try linux-4.9.0-mvebu-tld-8.patch first - so testing with my freshly compiled 4.9.0 (linux-4.9.tar.xz), nas326_defconfig (without tun, netfilter, fuse, nfs - I'll add that later) + dtb + my initramfs (it's from ubuntu 16.04) + rootfs from ubuntu 16.04 armhf on usb stick:

1. Power button works, shuts down the box completely

2. Copy and Reset buttons are safe to press - no reaction found :) /var/log/kern.log is also blank. So they don't trigger anything.

Update I found it - in kernel menuconfig -> Device drivers -> Power supply class support - can enable/disable both Power and Reboot actions.

3. All LEDs are always off. I have 2 HDDs inserted, but neither read nor write access is not covered by leds. Actually I always wanted leds to be off - so I'd prefer leaving it this way even if it's not right.

Update: Device drivers -> Led support -> Led trigger support -> Led IDE disk trigger (CONFIG_LEDS_TRIGGER_IDE_DISK) was disabled. After enabling, hdd leds blink on disk activity. So this works! Also, bodhi, kernel 4.9 has 'LED Trigger support' section, so patching drivers/leds/Kconfig is probably an overkill.

4. HDD1, HDD2, USB power works perfectly via DTS - old misc.c patch is not needed anymore

Update Not so smooth with rear USB 3.0 port - somehow usb flash with rootfs only boots when inserted into front USB.

5. I tested MTD write - it works, so it's possible to flash new kernels without rebooting to U-boot (let me write a short guide - will be in the next post)

Also, while I was loading kernels and initrd's, U-boot decided to switch the default boot partition. Now it autoboots from kernel1 (earlier it always was kernel2). How it happened:

*** Booting kernel from kernel 2 @0x08700000 ***
USB2.0 0: Host Mode
USB3.0 0: Host Mode
USB3.0 1: Host Mode
Board configuration detected:
Net:   
|  port  | Interface | PHY address  |
|--------|-----------|--------------|
| egiga0 |   RGMII   |     0x01     |
egiga0 [PRIME]
Hit any key to stop autoboot:  0 

---------- THESE COMMANDS ENTERED BY ME --------------
Marvell>> mw.l f1018140 003c8800
Marvell>> usb reset
(Re)start USB...
Marvell>> ext2load usb 0:1 0x2000000 /boot/initrd.img-4.4.0-34-generic
31865396 bytes read in 1355 ms (22.4 MiB/s)
Marvell>> ext2load usb 0:1 0x1000000 /zImage-4.9.0-mvebu-tld-8
4466616 bytes read in 567 ms (7.5 MiB/s)
Marvell>> bootz 0x1000000 0x2000000
---------- THESE COMMANDS ENTERED BY ME END --------------

*  kernel: cmdline image address = 0x01000000
Wrong Ramdisk Image Format
Ramdisk image is corrupt or invalid
Erasing Nand...
Writing to Nand... done
*** change boot partition to kernel1 ***
resetting ...

BootROM - 1.73
Booting from NAND flash

General initialization - Version: 1.0.0
Detected Device ID 6810
High speed PHY - Version: 2.0

Init RD NAS topology board SerDes lanes topology details:
 | Lane #  | Speed |  Type       |
 --------------------------------
 |   0    |  06   |  SATA0      |
 |   1    |  05   |  USB3 HOST0 |
 |   2    |  06   |  SATA1      |
 |   5    |  05   |  USB3 HOST1 |
 --------------------------------
High speed PHY - Ended Successfully
DDR3 Training Sequence - Ver TIP-1.26.0
mvSysEnvGetTopologyUpdateInfo: TWSI Read failed
DDR3 Training Sequence - Switching XBAR Window to FastPath Window 
DDR3 Training Sequence - Ended Successfully
Not detected suspend to RAM indication
BootROM: Image checksum verification PASSED

 __   __                      _ _
|  \/  | __ _ _ ____   _____| | |
| |\/| |/ _` | '__\ \ / / _ \ | |
| |  | | (_| | |   \ V /  __/ | |
|_|  |_|\__,_|_|    \_/ \___|_|_|
         _   _     ____              _
        | | | |   | __ )  ___   ___ | |_ 
        | | | |___|  _ \ / _ \ / _ \| __| 
        | |_| |___| |_) | (_) | (_) | |_ 
         \___/    |____/ \___/ \___/ \__| 
 ** LOADER **


U-Boot 2013.01-svn48023 (Oct 13 2015 - 09:25:56) Marvell version: 2014_T3.0p6

Board: RD-NAS-88F6820-DDR3
SoC:   MV88F6810 Rev A0
       running 1 CPUs
CPU:   ARM Cortex A9 MPCore (Rev 1) LE
       CPU 0
       CPU    @ 1332 [MHz]
       L2     @ 666 [MHz]
       TClock @ 250 [MHz]
       DDR    @ 666 [MHz]
       DDR 32 Bit Width, FastPath Memory Access, DLB Enabled, ECC Disabled
DRAM:  512 MiB

Map:   Code:                    0x1fed0000:0x1ff95d60
       BSS:                     0x1ffef2b4
       Stack:                   0x1f9cff20
       Heap:                    0x1f9d0000:0x1fed0000
       U-Boot Environment:      0x00200000:0x00280000 (NAND)

NAND:  256 MiB
MMC:   mv_sdh: 0
Erasing Nand...
Writing to Nand... done
*** Booting kernel from kernel 1 @0x00E00000 ***
USB2.0 0: Host Mode
USB3.0 0: Host Mode
USB3.0 1: Host Mode
Board configuration detected:
Net:   
|  port  | Interface | PHY address  |
|--------|-----------|--------------|
| egiga0 |   RGMII   |     0x01     |
egiga0 [PRIME]
Hit any key to stop autoboot:  0

Seems I'll be storing my kernels into kernel 1 @0x00E00000 now :)



Edited 2 time(s). Last edit at 01/22/2017 12:46PM by rr4m.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 10:53AM
MTD write testing. NAS326 partition structure:
# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00020000 "U-Boot"
mtd1: 00200000 00020000 "U-Boot env"
mtd2: 00a00000 00020000 "Config"
mtd3: 00f00000 00020000 "Kernel-1"
mtd4: 06a00000 00020000 "RootFS-1"
mtd5: 00f00000 00020000 "Kernel-2"
mtd6: 06a00000 00020000 "RootFS-2"

Never write to mtd0, mtd1 and mtd2!!! Or your NAS will be bricked. And it doesn't support kwboot serial booting as we know.

0. MTD partitions can be read and written both with U-boot shell and after booting linux, just from bash.

1. Install mtd-utils package (Ubuntu/Debian)
# apt-get install mtd-utils

2. Before you start, backup all mtd partitions:
# nanddump -f mtd0_backup /dev/mtd0
# nanddump -f mtd1_backup /dev/mtd1
# nanddump -f mtd2_backup /dev/mtd2
# nanddump -f mtd3_backup /dev/mtd3
# nanddump -f mtd4_backup /dev/mtd4
# nanddump -f mtd5_backup /dev/mtd5
# nanddump -f mtd6_backup /dev/mtd6

3. Writing into NAND requires 2 steps - filling memory with 'ones' (erase) + writing your data. Let's write fresh kernel + initramfs + dtb file into Kernel-1 partition (/dev/mtd3)
# flash_eraseall /dev/mtd3
flash_eraseall has been replaced by `flash_erase <mtddev> 0 0`; please use it
Erasing 128 Kibyte @ ee0000 -- 100 % complete 

# nandwrite -p /dev/mtd3 /boot/zImage_4.9.5_with_initrd_dtb
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
....
Writing data to block 67 at offset 0x860000

If your box auto-boots from Kernel-1 - flash your kernel to /dev/mtd3
If your box auto-boots from Kernel-2 - flash to /dev/mtd5
Or don't flash if you're not sure - manual booting from U-boot console is still a good option.

4. If you did it right, after reboot you'll have a fresh kernel running
# uname -a
Linux nas328 4.9.5 #1 SMP Sun Jan 22 16:04:27 UTC 2017 armv7l armv7l armv7l GNU/Linux

5. Restoring the original partition looks like (-p option is not needed):
# flash_eraseall /dev/mtd3
# nandwrite /dev/mtd3 mtd3_backup



Edited 1 time(s). Last edit at 01/22/2017 11:14AM by rr4m.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 11:13AM
4.9.5 kernel for NAS326 - see below



Edited 2 time(s). Last edit at 01/22/2017 04:32PM by rr4m.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 03:15PM
Let's control leds. List available:
ls -1 /sys/class/leds
nsa326:red:copy
nsa326:red:sata1
nsa326:red:sata2
nsa326:red:sys
nsa326:white:copy
nsa326:white:sata1
nsa326:white:sata2
nsa326:white:sys
nsa326:white:usb

Turn on COPY RED LED
> sudo -s
# echo 1 >/sys/class/leds/nsa326\:red\:copy/brightness

Turn off COPY RED LED
# echo 0 >/sys/class/leds/nsa326\:red\:copy/brightness

See available triggers (current is [none])
# cat /sys/class/leds/nsa326\:red\:copy/trigger
[none] kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock timer disk-activity ide-disk1 ide-disk2 heartbeat

Attach heartbeat to SYSTEM WHITE LED
# echo heartbeat >/sys/class/leds/nsa326\:white\:sys/trigger

Check the triggers for HDD1 and HDD2 white leds:
# cat /sys/class/leds/nsa326\:white\:sata1/trigger 
none kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock timer disk-activity [ide-disk1] ide-disk2 heartbeat
# cat /sys/class/leds/nsa326\:white\:sata2/trigger 
[none] kbd-scrolllock kbd-numlock kbd-capslock kbd-kanalock kbd-shiftlock kbd-altgrlock kbd-ctrllock kbd-altlock kbd-shiftllock kbd-shiftrlock kbd-ctrlllock kbd-ctrlrlock timer disk-activity ide-disk1 ide-disk2 heartbeat

Assign ide-disk2 trigger to WHITE HDD2 LED
# echo ide-disk2 > /sys/class/leds/nsa326\:white\:sata2/trigger

Remove trigger from WHITE HDD2 LED, assign disk activity to RED HDD2 LED
# echo ide-disk2 > /sys/class/leds/nsa326\:red\:sata2/trigger
# echo none > /sys/class/leds/nsa326\:white\:sata2/trigger



Edited 1 time(s). Last edit at 01/22/2017 05:09PM by rr4m.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 03:25PM
rr4m,

Thanks for testing the patch. There are quite a bit here to go through each item :)

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



Edited 1 time(s). Last edit at 01/22/2017 04:13PM by bodhi.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 03:56PM
rr4m,

> I wasn't able to boot zImage-4.9.0-mvebu-tld-8
> directly (it doesn't have DTB attached, right?):

It does not have DTB in it.

> Error: unrecognized/unsupported machine ID (r1 =
> 0x00000210).
>

Missing DTB.

> 1. Power button works, shuts down the box
> completely

Cool!

>
> 2. Copy and Reset buttons are safe to press - no
> reaction found :) /var/log/kern.log is also blank.
> So they don't trigger anything.

Ah. Let me test it. I have not tried, but since the GPIO inputs were populated correctly by the kernel, I thought that this should be OK.

> Update I found it - in kernel menuconfig ->
> Device drivers -> Power supply class support - can
> enable/disable both Power and Reboot actions.
>

Are you sure that it is related to the buttons?

>
> 3. All LEDs are always off. I have 2 HDDs
> inserted, but neither read nor write access is not
> covered by leds. Actually I always wanted leds to
> be off - so I'd prefer leaving it this way even if
> it's not right.

This should work with my config (there are several switches need to be turned on).

> works! Also, bodhi, kernel 4.9 has 'LED Trigger
> support' section, so patching
> drivers/leds/Kconfig is probably an
> overkill.

It's not an overkill :) because the patch enabled the HDD LED to be triggered individually (ide_disk1, ide_disk2). The mainline code triggers all HDD LEDs even if only one is accessed.

>
> 4. HDD1, HDD2, USB power works perfectly via DTS -
> old misc.c patch is not needed anymore
>

Cool!

> Update Not so smooth with rear USB 3.0 port
> - somehow usb flash with rootfs only boots when
> inserted into front USB.
>

Let me see. Check your config to see if XHCI is compiled into the kernel?

> 5. I tested MTD write - it works, so it's possible
> to flash new kernels without rebooting to U-boot
> (let me write a short guide - will be in the next
> post)
>

Cool!

> Also, while I was loading kernels and initrd's,
> U-boot decided to switch the default boot
> partition. Now it autoboots from kernel1 (earlier
> it always was kernel2). How it happened:

> Seems I'll be storing my kernels into kernel 1
> @0x00E00000 now :)

It always does this when the magic byte is not recognized. So when you flash the new kernel, you also need to make sure that the "next boot from" is the new kernel. This is where it always reset the bootcmd to stock. This looks like a coding error on Zyxel part. They did not do enough to switch kernel (just blindly rewriting the boocmd each time)

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 04:02PM
rr4m,

> MTD write testing. NAS326 partition structure:
>
> # cat /proc/mtd
> dev:    size   erasesize  name
> mtd0: 00200000 00020000 "U-Boot"
> mtd1: 00200000 00020000 "U-Boot env"
> mtd2: 00a00000 00020000 "Config"
> mtd3: 00f00000 00020000 "Kernel-1"
> mtd4: 06a00000 00020000 "RootFS-1"
> mtd5: 00f00000 00020000 "Kernel-2"
> mtd6: 06a00000 00020000 "RootFS-2"
>
>
> Never write to mtd0, mtd1 and mtd2!!! Or your NAS
> will be bricked. And it doesn't support kwboot
> serial booting as we know.
>
> 0. MTD partitions can be read and written both
> with U-boot shell and after booting linux, just
> from bash.
>
> 1. Install mtd-utils package (Ubuntu/Debian)
>
> # apt-get install mtd-utils
>
>
> 2. Before you start, backup all mtd partitions:
>
> # nanddump -f mtd0_backup /dev/mtd0
> # nanddump -f mtd1_backup /dev/mtd1
> # nanddump -f mtd2_backup /dev/mtd2
> # nanddump -f mtd3_backup /dev/mtd3
> # nanddump -f mtd4_backup /dev/mtd4
> # nanddump -f mtd5_backup /dev/mtd5
> # nanddump -f mtd6_backup /dev/mtd6
>
>
> 3. Writing into NAND requires 2 steps - filling
> memory with 'ones' (erase) + writing your data.
> Let's write fresh kernel + initramfs + dtb file
> into Kernel-1 partition (/dev/mtd3)
>
> # flash_eraseall /dev/mtd3
> flash_eraseall has been replaced by `flash_erase
> <mtddev> 0 0`; please use it
> Erasing 128 Kibyte @ ee0000 -- 100 % complete 
> 
> # nandwrite -p /dev/mtd3
> /boot/zImage_4.9.5_with_initrd_dtb
> Writing data to block 0 at offset 0x0
> Writing data to block 1 at offset 0x20000
> ....
> Writing data to block 67 at offset 0x860000
>
>
> If your box auto-boots from Kernel-1 - flash your
> kernel to /dev/mtd3
> If your box auto-boots from Kernel-2 - flash to
> /dev/mtd5
> Or don't flash if you're not sure - manual
> booting from U-boot console is still a good
> option
.
>
> 4. If you did it right, after reboot you'll have a
> fresh kernel running
>
> # uname -a
> Linux nas328 4.9.5 #1 SMP Sun Jan 22 16:04:27 UTC
> 2017 armv7l armv7l armv7l GNU/Linux
>
>
> 5. Restoring the original partition looks like (-p
> option is not needed):
>
> # flash_eraseall /dev/mtd3
> # nandwrite /dev/mtd3 mtd3_backup
>

Well done :)

One thing I would change is this command:
nanddump -f mtd0_backup /dev/mtd0
We should specify the options explicitly ( --obmitoob, --noecc, ...). Default options are not clear (older nandwrite or nanddump have different options).

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



Edited 1 time(s). Last edit at 01/22/2017 04:15PM by bodhi.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 04:12PM
rr4m,

> zImage_4.9.5_initramfs_dtb + patch, defconfig,
> howto's and build scripts are in archive. Feel
> free to test and use.
>

I'm experimenting a different way, but has not got it working yet. If you could, look into CONFIG_INITRAMFS_SOURCE. We could extract the cpio from initrd.img and put this path in the config. So: build the kernel zImage andn initrd.img, and then extract cpio, put it where the build can find it, change config to point to that cpio, rebuild to get the initramfs embbedded inside zImage.

This way we don't need to modify the Makefile. Just build kernel a different way using 2nd version of the config.

> Update: bug found - on boot kernel cannot
> find USB stick with rootfs, when it plugged into
> rear usb 3.0 socket. Only boots when plugged to
> front usb. Never happened on 4.8.15 and older.
> After booting all 3 usb ports work.

I'm almost certain that the kernel config has something to do with this.

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



Edited 1 time(s). Last edit at 01/22/2017 04:17PM by bodhi.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 04:31PM
Okay, final result - my version of kernel 4.9.5:

+built with bodhi's linux-4.9.0-mvebu-tld-8.patch (includes latest armada-380-zyxel-nas326.dts)
+hdd1 and hdd2 activity leds blink now (added 'linux,default-trigger = "ide-disk2";' into dts + enabled LED disk trigger in kernel config - Device Drivers -> LED Support -> LED Trigger Support -> LED Disk Trigger)
+kernel comes with full Netfilter, incl conntrack+nat+mangle tables for ipv4/ipv6, TUN/TAP, Fuse, NFS enabled
+Netfilter LED action enabled - you can try it
+I left old misc.c power patch - problem with rear USB 3.0 gone. Seems those ports need early power on. Now I can boot using usb stick on rear side, as before - tested several times.

Archive includes ready to use /boot/zImage_4.9.5_initramfs_dtb, /lib/modules, patches, my defconfig, initramfs.cpio.gz (from ubuntu, it's embedded into zImage already), script that (re)builds that kernel, docs and howto's

nas326_4.9.5_kernel_20170123.tar.gz - md5 - 35b09629155daeb7281ed97323294584



Edited 1 time(s). Last edit at 01/22/2017 05:23PM by rr4m.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 04:57PM
bodhi,

Quote
bodhi
Device drivers -> Power supply class support - can
> enable/disable both Power and Reboot actions.
>
Are you sure that it is related to the buttons?

Lemme check.... I'm wrong:
Device Drivers -> Board level reset or power off -> GPIO power-off driver (this one is for front Power button + power off pin) - it's enabled in your config and works.
Device Drivers -> Board level reset or power off -> GPIO restart driver - this one is for reset I suppose (disabled in your config, but my kernel comes with it enabled)

Quote
bodhi
> Update Not so smooth with rear USB 3.0 port
> - somehow usb flash with rootfs only boots when
> inserted into front USB.
>
Let me see. Check your config to see if XHCI is compiled into the kernel?

I just recompiled with old power patch (misc.c decompress - which turns on HDDs and USB power early) - problem gone. My defconfig was the same I used for 4.8.15 and 4.9.2 - so it's not XHCI related. It's a power-on thing.
Without this patch rear USB ports also work - but only after system is booted.

Quote
bodhi
This looks like a coding error on Zyxel part. They did not do enough to switch kernel (just blindly rewriting the boocmd each time)

Same as hdd/usb power on in decompress - a dirty hook :)

Quote
bodhi
look into CONFIG_INITRAMFS_SOURCE

I tried but wasn't able to make it work either (okay - almost made it work). So I wrote a script, that rebulds a kernel for me (nas326_compile_kernel.sh - in my archive above). It compiles modules, pushes them inside initramfs.cpio.gz, then makes zImage + combines it with initramfs.cpio.gz (via modified kernel-x.x-source/usr/Makefile) + attaches dtb.

Final result (zImage_initramfs_dtb) can be flashed into nand kernel-1 or kernel2. And you can pass root=LABEL=rootfs (or root=/dev/sda1) via U-boot bootargs - /init script inside initramfs.cpi.gz will parse that and boot your system from your partition.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 05:39PM
rr4m,

> I just recompiled with old power patch (misc.c
> decompress - which turns on HDDs and USB power
> early) - problem gone. My defconfig was the same I
> used for 4.8.15 and 4.9.2 - so it's not XHCI
> related. It's a power-on thing.

True.

> Without this patch rear USB ports also work - but
> only after system is booted.

I think I know why.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 07:28PM
Here is the new DTS and DTB.

The buttons Power, Copy, Reset should work correctly now.

Note: it is safe to experiment. In the new kernel, these buttons only work for real if you have set it up with a key daemon such as esekeyd, or or other old style input daemons. Otherwise, it will do nothing when you push them.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Attachments:
open | download - armada-380-zyxel-nas326.dts (8.8 KB)
open | download - armada-380-zyxel-nas326.dtb (17.8 KB)
Re: Zyxel NAS326 - Debian / Boot from USB?
January 22, 2017 11:42PM
rr4m,

Another DTS update. This should ensure the USB3 ports to be active at boot time and be the rootfs.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Attachments:
open | download - armada-380-zyxel-nas326.dtb (18.1 KB)
open | download - armada-380-zyxel-nas326.dts (9.3 KB)
Re: Zyxel NAS326 - Debian / Boot from USB?
January 23, 2017 06:04AM
bodhi, thanks for update! I rebuilt 4.9.5 with new DTS, without mics.c patch. My setup - 2 HDD disks (/dev/sda, /dev/sdb) + USB flash drive with Ubuntu 16.04 ARMHF (/dev/sdc1, label=rootfs).

1. Plugged flash drive with rootfs into front USB - it boots without any problem - 4.9.5_front_usb_boot_success.txt
While booting, if finds all drives (sda, sdb, sdc) and all partitions and passes the control to /dev/sdc1 rootfs.

2. Plugged flash drive with rootfs into rear USB - boot process stuck - it only finds /dev/sda and /dev/sdb. As a result - it falls to initramfs BusyBox shell - 4.9.5_rear_usb_boot_fail.txt

After it fell into busybox, I re-inserted usb flash (same rear port) - and kernel found it:

[   22.400979] random: fast init done
[   23.006880] random: crng init done


BusyBox v1.22.1 (Ubuntu 1:1.22.0-15ubuntu1) built-in shell (ash)
Enter 'help' for a list of built-in commands.

(initramfs) ls -la /dev/sd*
brw-------    1    8,  19 /dev/sdb3
brw-------    1    8,  18 /dev/sdb2
brw-------    1    8,  17 /dev/sdb1
brw-------    1    8,  16 /dev/sdb
brw-------    1    8,   3 /dev/sda3
brw-------    1    8,   2 /dev/sda2
brw-------    1    8,   1 /dev/sda1
brw-------    1    8,   0 /dev/sda
(initramfs) 


 ----- After re-inserting USB flash drive (to same port - plug out, plug in) ------

173.401396] usb 3-1: new SuperSpeed USB device number 2 using xhci-hcd
[  173.433218] usb-storage 3-1:1.0: USB Mass Storage device detected
[  173.440951] scsi host2: usb-storage 3-1:1.0
[  174.482139] scsi 2:0:0:0: Direct-Access     SanDisk  Ultra Fit        1.00 PQ: 0 ANSI: 6
[  174.491996] sd 2:0:0:0: [sdc] 60062500 512-byte logical blocks: (30.8 GB/28.6 GiB)
[  174.505735] sd 2:0:0:0: [sdc] Write Protect is off
[  174.510817] sd 2:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[  174.527574]  sdc: sdc1
[  174.531924] sd 2:0:0:0: [sdc] Attached SCSI removable disk

ls -la /dev/sd*
brw-------    1    8,  33 /dev/sdc1
brw-------    1    8,  32 /dev/sdc
brw-------    1    8,  19 /dev/sdb3
brw-------    1    8,  18 /dev/sdb2
brw-------    1    8,  17 /dev/sdb1
brw-------    1    8,  16 /dev/sdb
brw-------    1    8,   3 /dev/sda3
brw-------    1    8,   2 /dev/sda2
brw-------    1    8,   1 /dev/sda1
brw-------    1    8,   0 /dev/sda
(initramfs)

3. I tried to boot from rear USB port about 10 times and once got a success - flash drive was inserted into the rear port, that is closer to fan. Kernel managed to catch sda, sdb and sdc and booted. So I'm 100% sure it's a hardware problem - system needs a little delay between powering on rear usb and accessing it.

4. One more idea - I thought that HDDs eat too much power on start (when motors start spinning) and rear usb just doesn't get enough power in that moment. So I ejected both HDDs but problem stayed. Still 90% fail booting from rear USB.

5. So, as far as I want my rootfs to sit on the rear side, I'm keeping misc.c power patch - for USB power only, which gives me a necessary delay. Bodhi, you can remove usb3_phy and usb3_power sections - as far as we only have one GPIO pin, that turns on power on all usb ports, having usb2_power handler is enough.



Edited 1 time(s). Last edit at 01/23/2017 06:10AM by rr4m.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 23, 2017 01:24PM
rr4m,

It is your USB drive. There were many reports in the forum about this Ultra Fit 32GB version. Even on USB 2.0 ports, it gave inconsistent booting results. The Ultra Fit 32GB is very troublesome for booting! I'd recommend avoiding it (until people find a right quirk setting for this drive).

I have an Ultra Fit 64GB, and it boots consistently on this box rear USB 3.0 ports with the new DTS.

I'll see if I can use a spare USB 3.0 HDD drive and boot with that (to see if it has enough power).

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



Edited 1 time(s). Last edit at 01/23/2017 01:26PM by bodhi.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 23, 2017 01:28PM
rr4m,

> Bodhi, you can remove usb3_phy and
> usb3_power sections - as far as we only
> have one GPIO pin, that turns on power on all usb
> ports, having usb2_power handler is enough.

You're right. That would be enough. The regulator is stil needed.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
January 23, 2017 01:43PM
I thought it might be my SanDisk Ultra Fit 32GB, yea - quite possible.

---
Testing gpio-beeper (it's doesn't beep, but rather makes 'click-clack' sound - may be it's not a beeper at all?!):

1. Kernel config - add Input device support -> Miscellaneous devices -> Generic GPIO Beeper support

2.DTS - add below gpio-poweroff:
beeper: beeper {
       compatible = "gpio-beeper";
       gpios = <&gpio0 19 GPIO_ACTIVE_HIGH>;
};

3. Install 'beep'. Let's 'click-clack' every second
# apt-get install beep
# watch -n 1 beep

ToDo List:
gpio-restart
gpio-fan
Re: Zyxel NAS326 - Debian / Boot from USB?
January 23, 2017 01:48PM
Quote

Testing gpio-beeper (it's doesn't beep, but rather makes 'click-clack' sound - may be it's not a beeper at all?!):


:) It does not seem to be a gpio-beeper. The Zyxel boxes seem to lack a conventional way to activate buzzer.

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



Edited 1 time(s). Last edit at 01/23/2017 01:50PM by bodhi.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 23, 2017 05:33PM
> I thought it might be my SanDisk Ultra Fit 32GB,
> yea - quite possible.

It is the problem. Might be the controller bug in this 32G version.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
January 24, 2017 01:07AM
I've released the Debian rootfs:
http://forum.doozan.com/read.php?2,32146,32146#msg-32146

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
January 24, 2017 11:01AM
Quote
bodhi
:) It does not seem to be a gpio-beeper. The Zyxel boxes seem to lack a conventional way to activate buzzer.

I just unscrewed the box (another time) - it is a buzzer indeed, and it 'click-clack's :). Model HY-07 HYCOM, it's + pin is connected to MPP19 (GPIO0 pin19)

Also - fan. Nas326 has 3-pin fan (GND, VCC, Sensor). There's way to turn it off and on - you need to change values of 2 GPIO pins (this drops VCC line from +12V to +0.5V and the fan stops - measured with multimeter):

Fan off (update - it also powers off ethernet!):
gpio0 pin24 -> 1
gpio1 pin19 -> 0

Fan off can be tested in U-boot console:
mw.l f1018100 05200000
mw.l f1018140 00348000

Fan on:
gpio1 pin19 -> 1
gpio0 pin24 -> can be any value

Board reboot:
gpio0 pin24 -> 1
gpio1 pin19 -> 0
gpio0 pin24 -> 0

Default values:
gpio0 pin24 -> 0
gpio1 pin19 -> 1
Just in case anyone finds that info useful or has an idea how to use it.



Edited 3 time(s). Last edit at 01/25/2017 09:12AM by rr4m.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 24, 2017 03:41PM
rr4m,

> I just unscrewed the box (another time) - it is a
> buzzer indeed, and it 'click-clack's :).

No wonder why nobody has made it work on the NSA325/NSA310s :))

>
> Also - fan. Nas326 has 3-pin fan (GND, VCC,
> Sensor). There's way to turn it off and on - you
> need to change values of 2 GPIO pins (this drops
> VCC line from +12V to +0.5V and the fan stops -
> measured with multimeter):
>
>
> Fan off:
> gpio0 pin24 -> 1
> gpio1 pin19 -> 0
> 
> Fan off can be tested in U-boot console:
> mw.l f1018100 05200000
> mw.l f1018140 00348000
> 
> Fan on:
> gpio1 pin19 -> 1
> gpio0 pin24 -> can be any value
> 
> Board reboot:
> gpio0 pin24 -> 1
> gpio1 pin19 -> 0
> gpio0 pin24 -> 0
> 
> Default values:
> gpio0 pin24 -> 0
> gpio1 pin19 -> 1
>
> Just in case anyone finds that info useful or has
> an idea how to use it.

Excellent! Very useful. I think we could write a script to turn it off if only using 2.5" HDD inside and start it when the temp gets to certain value (with i2cget like I posted above). This small fan is little too noisy, and the 2.5" HDDs don't generate much heat.

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



Edited 1 time(s). Last edit at 01/24/2017 03:43PM by bodhi.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 24, 2017 04:31PM
Having a script for temperature would be cool! How I see it:

1. gpio0 pin24 must be set to 1 - let's call it 'Unlock fan control'. Can we add it to voltage regulators in dts with default value of 1 on boot?

2. gpio1 pin19 - we can add it to LEDs section, as 'nsa326:fan'. Then it would be possible to set it's 'brightness' to 1 (fan on), 0 (fan off), or even attach a timer, which will switch it with specified delay (via /sys/class/leds/<device>/delay_{on,off} in milliseconds), as it covered in kernel leds-class docs - with delay_on, delay_off it's even possible to set speed.

Should be easy to make and easy to use!

But, gpio0 pin24 should never be changed to 0, when gpio1 pin19 is 0 - this reboots the board :)

**update 20170125** - this method not only stops fan, but turns down ethernet power. Bad luck.



Edited 4 time(s). Last edit at 01/25/2017 09:11AM by rr4m.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 24, 2017 06:04PM
We can do the GPIO. However, i2cset might just be easier to set the fan speed to very low value? I have not tried to experiement with it. i2cget works so i2cset has potentials.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
January 24, 2017 11:38PM
I've added the installation instruction in the release thread.

Quote

Zyxel NAS326 Installation
Updated 24 Jan 2017

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Zyxel NAS326 - Debian / Boot from USB?
January 25, 2017 09:10AM
Fan control update. Turning it off also takes down the ethernet power :) Sooo, seems we won't have temperature regulation feature.

Buzzer update - it works. fgrepping zyxel sources revealed some bits of info - trunk/build/fs.initrd/sbin/buzzer_beep.sh

#!/bin/sh
## buzzer_beep.sh - beep N times

usage()
{       
        echo
        echo -e "\033[031mUsage: `basename $0` <beep times>\033[0m"
        echo
}


if [ "$1" != "" ]; then
        COUNT=$1
else
        usage
        exit 1
fi


if [ ${COUNT} -ge 30 ]; then
        FOREVER=1
fi


# # BUZZER: GPIO 19
# # Set Blink Enable Register
# devmem 0xf1018108 32 0x00080000

# # Set Blink Counter to A
# #                         *
# devmem 0xf1018120 32 0x00000000

while [ "${COUNT}" != "0" ]; 
do
        # Set Blink Enable Register
        devmem2 0xf1018108 w 0x00080000

        # Set Blink Counter to A
        #                         *
        devmem2 0xf1018120 w 0x00000000

        # Set ON/OFF duration
        # - ON duration for Blink Counter A
        devmem2 0xF10181C0 w 0x0000BC00
        # - OFF duration for Blink Counter A
        devmem2 0xf10181C4 w 0x0000BC00
        #msleep 500
        #usleep 500000
        sleep 1

        # Clear Blink Enable Regoster
        devmem2 0xf1018108 w 0x00000000

        if [ "${FOREVER}" != "1" ]; then
                COUNT=$((COUNT-1))
        fi
        #msleep 500
        #usleep 500000
        sleep 1
done

# Clear Blink Enable Regoster
devmem2 0xf1018108 w 0x00000000

exit 0

How to test:
> sudo apt-get install devmem2
> sudo ./buzzer_beep.sh 3



Edited 1 time(s). Last edit at 01/25/2017 03:52PM by rr4m.
Re: Zyxel NAS326 - Debian / Boot from USB?
January 25, 2017 06:25PM
rr4m,

Good find! another dirty hack from Zyxel :)

BTW, one thing that we have not figured out is which MCU this box has, I don't recall.

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