Installing LEDE on NSA325

I always installed uboot from inside uboot (or from stock firmware).

The command should be correct, but the tool will not work because the uboot partition is marked read-only inside OpenWrt.

You must add mtd-rw package in your firmware to ignore this limitation, see it here in packages repository/feed https://github.com/openwrt/packages/blob/master/kernel/mtd-rw/Makefile

use the uboot file called "u-boot.kwb". The other two don't work, I don't know why. There is no u-boot.trx for kirkwood.

@bobafetthotmail
This is an issue with uboot 2018.3 with 2017.09 it load fine. Thanks a lot for you help

U-Boot 2018.03 (Jun 05 2018 - 19:54:00 +0000)
ZyXEL NSA310 1-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  256 MiB
WARNING: Caches not enabled
NAND:  128 MiB
MMC:
Loading Environment from NAND... OK
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
PHY reset timed out
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0
unexpected character 'b' at the end of partition
Error initializing mtdparts!
incorrect device type in ubi
Partition ubi not found!
Error, no UBI device/partition selected!
Wrong Image Format for bootm command
Error occured, error code = 112
ERROR: can't get kernel image!
NSA310> usb reset
resetting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 3 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
NSA310> fatload usb 0 0x1000000 u-boot.kwb
541748 bytes read in 53 ms (9.7 MiB/s)
NSA310> nand erase 0x00000 0x100000

NAND erase: device 0 offset 0x0, size 0x100000
Erasing at 0xe0000 -- 100% complete.
OK
NSA310> nand write 0x1000000 0x00000 0x100000

NAND write: device 0 offset 0x0, size 0x100000
 1048576 bytes written: OK
NSA310> reset
resetting ...
▒

U-Boot 2017.09 (Jan 31 2018 - 13:43:12 +0000)
ZyXEL NSA310 1-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  256 MiB
WARNING: Caches not enabled
NAND:  128 MiB
MMC:
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0
Error: egiga0 address not set.

PHY reset timed out
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0
ubi0: attaching mtd1
ubi0: scanning is finished
ubi0: attached mtd1 (name "mtd=2", size 126 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
ubi0: VID header offset: 512 (aligned 512), data offset: 2048
ubi0: good PEBs: 1009, bad PEBs: 5, corrupted PEBs: 0
ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 603085179
ubi0: available PEBs: 0, total reserved PEBs: 1009, PEBs reserved for bad PEB handling: 15
Read 0 bytes from volume kernel to 800000
No size specified -> Using max size (2193408)
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   ARM OpenWrt Linux-4.14.48
   Created:      2018-06-08  10:19:49 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2103426 Bytes = 2 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.48 (kofec@E5420Mint) (gcc version 7.3.0 (OpenWrt GCC 7.3.0 r6394-359273d)) #0 Tue Jun 5 19:54:00 2                                                                                    018
[    0.000000] CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=0005397f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] OF: fdt: Machine model: ZyXEL NSA310b
[    0.000000] Memory policy: Data cache writeback

Ok I think I found the culprit.

U-Boot 2018.03 (Jun 05 2018 - 19:54:00 +0000)
ZyXEL NSA310 1-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  256 MiB
WARNING: Caches not enabled
NAND:  128 MiB
MMC:   
Loading Environment from NAND... *** Warning - bad CRC, using default environment

Failed (-5)
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
Error: egiga0 address not set.

PHY reset timed out
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0 
unexpected character 'b' at the end of partition
Error initializing mtdparts!
incorrect device type in ubi
Partition ubi not found!
Error, no UBI device/partition selected!
Wrong Image Format for bootm command
Error occured, error code = 112
ERROR: can't get kernel image!
NSA310> printenv
baudrate=115200
bootcmd=ubi part ubi; ubi read 0x800000 kernel; bootm 0x800000
bootdelay=3
console=console=ttyS0,115200
ethact=egiga0
ipaddr=192.168.1.1
mtdids=nand0=orion_nand
mtdparts=mtdparts=orion_nand:0x0c0000(uboot),0x80000(uboot_env),0x7ec0000(ubi)bootargs_root=
serverip=192.168.1.2
stderr=serial
stdin=serial
stdout=serial

Environment size: 357/131068 bytes

Note the
mtdparts=mtdparts=orion_nand:0x0c0000(uboot),0x80000(uboot_env),0x7ec0000(ubi)bootargs_root=

Yeah, that's wrong.

And it explains the error message


U-Boot 2018.03 (Jun 05 2018 - 19:54:00 +0000)
ZyXEL NSA310 1-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  256 MiB
WARNING: Caches not enabled
NAND:  128 MiB
MMC:   
Loading Environment from NAND... OK
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
Error: egiga0 address not set.

PHY reset timed out
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0 
unexpected character 'b' at the end of partition
Error initializing mtdparts!
incorrect device type in ubi
Partition ubi not found!
Error, no UBI device/partition selected!
Wrong Image Format for bootm command
Error occured, error code = 112
ERROR: can't get kernel image!

"unexpected character 'b' at the end of partition". That's the "bootargs_root=" that got appended there.

If in uboot console I write

NSA310> setenv mtdparts 'mtdparts=orion_nand:0x0c0000(uboot),0x80000(uboot_env),0x7ec0000(ubi)'
NSA310> saveenv

Then it boots correctly.

Will go find where this typo is in the source and send a PR.

Ok, PR with fix is here https://github.com/openwrt/openwrt/pull/1027 Please test and report if it works for you too.

Your fix is fine. Thanks.

U-Boot 2017.09 (Jan 31 2018 - 13:43:12 +0000)
ZyXEL NSA310 1-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  256 MiB
WARNING: Caches not enabled
NAND:  128 MiB
MMC:
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0
Error: egiga0 address not set.

PHY reset timed out
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0
NSA310>
NSA310>
NSA310> usb reset
resetting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 3 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
NSA310> fatload usb 0 0x1000000 u-boot.kwb
reading u-boot.kwb
621348 bytes read in 50 ms (11.9 MiB/s)
NSA310> nand erase 0x00000 0x100000

NAND erase: device 0 offset 0x0, size 0x100000
Erasing at 0xe0000 -- 100% complete.
OK
NSA310> nand write 0x1000000 0x00000 0x100000

NAND write: device 0 offset 0x0, size 0x100000
 1048576 bytes written: OK
NSA310> reset
resetting ...
▒

U-Boot 2018.03 (Jun 09 2018 - 16:42:36 +0000)
ZyXEL NSA310 1-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  256 MiB
WARNING: Caches not enabled
NAND:  128 MiB
MMC:
Loading Environment from NAND... *** Warning - bad CRC, using default environment

Failed (-5)
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
Error: egiga0 address not set.

PHY reset timed out
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0
ubi0: attaching mtd1
ubi0: scanning is finished
ubi0: attached mtd1 (name "mtd=2", size 126 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
ubi0: VID header offset: 512 (aligned 512), data offset: 2048
ubi0: good PEBs: 1009, bad PEBs: 5, corrupted PEBs: 0
ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 603085179
ubi0: available PEBs: 0, total reserved PEBs: 1009, PEBs reserved for bad PEB handling: 15
Read 0 bytes from volume kernel to 800000
No size specified -> Using max size (2193408)
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   ARM OpenWrt Linux-4.14.48
   Created:      2018-06-05  19:54:00 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2102074 Bytes = 2 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.48 (kofec@E5420Mint) (gcc version 7.3.0 (OpenWrt GCC 7.3.0 r6394-359273d)) #0 Tue Jun 5 19:54                       :00 2018
[    0.000000] CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=0005397f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] OF: fdt: Machine model: ZyXEL NSA310b
[    0.000000] Memory policy: Data cache writeback
[    0.000000] random: get_random_bytes called from start_kernel+0x70/0x41c with crng_init=0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 65024
[    0.000000] Kernel command line: console=ttyS0,115200

2 posts were split to a new topic: Support for Zyxel NSA320

Hi @bobafetthotmail I'm the OP guy of this thread it seems there's a bug on upgrading firmware. I have problem upgrading from 4.9 to 4.14 latest git trunk then I do sysupgrade I get this error.

root@LEDE-NSA325:/# sysupgrade -n -p /mnt/sda1/nsa325\ gcc8/targets/kirkwood/generic/openwrt-kirkwood-zyxel_nsa325-squashfs-sysupgrade.bin
Image not in /tmp, copying...
Device nsa325 not supported by this image
Supported devices: zyxel,nsa325
Image check 'fwtool_check_image' failed.

Anyway I've manage to upgrade it using latest snapshot of uImage.

Hi, I have update my nsa325v2 to openwrt. I face the issue with uboot:

Also good scripts:
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

http://zyxel.nas-central.org/wiki/Fan_control_(NSA325)
https://forum.doozan.com/read.php?2,27108,28116

Did you have issues booting a USB drive like described in that thread?
If you had issues and that patch fixed it, then can you open a PR with it on OpenWrt github?

Is this issue on bodhi's uboot or OpenWrt's?

I never used tftpboot command. I always do

tftp RAM-address file-name
bootm RAM-address

Yes I know but I don't think they are needed.
This can go in the nsa325 wiki page.

I have never seen CPU temp rise above 60, actually the HDD temperature is a much bigger issue.

You can read but not control the fan speed, so I don't see why I should need to read it.

If you want a to add a script that will shut down the NSA325 if the fan stops spinning or the temp increases to 80 or 112 celsius? You can do a PR for that, I'm OK with that.

Did you have issues booting a USB drive like described in that thread?

Yes
The issue was seen on stock uboot and U-Boot 2019.01 (Mar 29 2019 - 14:55:08 +0000). But It was NOt seen/fixed on U-Boot 2017.07-tld-1

If you had issues and that patch fixed it, then can you open a PR with it on OpenWrt github?

You mean propose changes ? I'm not sure if my knowledge is sufficient. I take a look and @mibodhi introduce this change in commit

In uboot repository there were few commit on this file common/usb_storage.c after release 2017.07

The uboot 2019.01 is OK to start NSA325v2 from nand. I just need to start U-Boot 2017.07-tld-1 via kwboot to first time did sysupgrade.

 99 % [....................................]
[Type Ctrl-\ + c to quit]


U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:42:03 -0700)
ZyXEL NSA325 2-Bay Power Media Server

SoC:   Kirkwood 88F6282_A1
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  128 MiB
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0 
## Error: "setenv" not defined
ubi0: attaching mtd1
ubi0: scanning is finished
UBI init error 22
Error, no UBI device/partition selected!
Wrong Image Format for bootm command
Error occured, error code = 112
ERROR: can't get kernel image!
NSA325> usb reset
resetting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 3 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
NSA325> fatload usb 0 0x800000 nsa325ram.bin
reading nsa325ram.bin
3364296 bytes read in 273 ms (11.8 MiB/s)
NSA325> bootm 0x800000
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   ARM OpenWrt Linux-4.14.109
   Created:      2019-03-29  14:55:08 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3364232 Bytes = 3.2 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.109 (buildbot@slashdirt-03) (gcc version 7.4.0 (OpenWrt GCC 7.4.0 r9753-6df5ab8)) #0 Fri Mar 29 14:55:08 2019
........................
root@OpenWrt:/tmp# wget http://downloads.openwrt.org/snapshots/targets/kirkwood/
generic/openwrt-kirkwood-zyxel_nsa325-squashfs-factory.bin
Downloading 'http://downloads.openwrt.org/snapshots/targets/kirkwood/generic/openwrt-kirkwood-zyxel_nsa325-squashfs-factory.bin'
Connecting to 148.251.78.235:80
Writing to 'openwrt-kirkwood-zyxel_nsa325-squashfs-factory.bin'
openwrt-kirkwood-zyx 100% |*******************************|  3968k  0:00:00 ETA
Download completed (4063232 bytes)
root@OpenWrt:/tmp# sysupgrade -F openwrt-kirkwood-zyxel_nsa325-squashfs-factory.
bin 
Image metadata not found
Image check 'fwtool_check_image' failed but --force given - will update anyway!
Cannot save config while running from ramdisk.
Commencing upgrade. Closing all shell sessions.
Watchdog handover: fd=3
- watchdog -
killall: telnetd: no process killed
Sending TERM to remaining processes ... ubusd logd dnsmasq netifd odhcpd ntpd 
Sending KILL to remaining processes ... 
Performing system upgrade...
ubidetach: error!: cannot detach "/dev/mtd2"
           error 19 (No such device)
ubiformat: mtd2 (nand), size 132907008 bytes (126.7 MiB), 1014 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 1013 -- 100 % complete  
ubiformat: 964 eraseblocks are supposedly empty
ubiformat: 2 bad eraseblocks found, numbers: 90, 190
ubiformat: warning!: 48 of 1012 eraseblocks contain non-UBI data
ubiformat: warning!: only 0 of 1012 eraseblocks have valid erase counter
ubiformat: erase counter 0 will be used for all eraseblocks
ubiformat: note, arbitrary erase counter value may be specified using -e option
ubiformat: use erase counter 0 for all eraseblocks
ubiformat: flashing eraseblock 30 -- 100 % complete  
ubiformat: formatting eraseblock 987[  183.078612] ubi0: attaching mtd2
ubiformat: formatting eraseblock 1013 -- 100 % complete  
[  183.254843] ubi0: scanning is finished
[  183.286479] ubi0: volume 2 ("rootfs_data") re-sized from 9 to 961 LEBs
[  183.293611] ubi0: attached mtd2 (name "ubi", size 126 MiB)
[  183.299147] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
[  183.306067] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[  183.312793] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
[  183.319614] ubi0: good PEBs: 1012, bad PEBs: 2, corrupted PEBs: 0
[  183.325744] ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
[  183.332998] ubi0: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 1254764615
[  183.342181] ubi0: available PEBs: 0, total reserved PEBs: 1012, PEBs reserved for bad PEB handling: 18
[  183.351550] ubi0: background thread "ubi_bgt0d" started, PID 2498
UBI device number 0, total 1012 LEBs (130572288 bytes, 124.5 MiB), available 0 LEBs (0 bytes), LEB size 129024 bytes (126.0 KiB)
sysupgrade successful
umount: can't unmount /dev: Resource busy
umount: can't unmount /tmp: [  183.381613] reboot: Restarting system


U-Boot 2019.01 (Mar 29 2019 - 14:55:08 +0000)
ZyXEL NSA325 2-Bay Power Media Server

SoC:   Kirkwood 88F6282_A1
DRAM:  512 MiB
NAND:  128 MiB
MMC:   
Loading Environment from NAND... OK
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0 
## Error: "setenv" not defined
ubi0: attaching mtd3
ubi0: scanning is finished
ubi0: attached mtd3 (name "ubi", size 126 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
ubi0: VID header offset: 512 (aligned 512), data offset: 2048
ubi0: good PEBs: 1012, bad PEBs: 2, corrupted PEBs: 0
ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 1254764615
ubi0: available PEBs: 0, total reserved PEBs: 1012, PEBs reserved for bad PEB handling: 18
No size specified -> Using max size (2322432)
Read 2322432 bytes from volume kernel to 00800000
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   ARM OpenWrt Linux-4.14.109
   Created:      2019-03-30   9:36:31 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2207208 Bytes = 2.1 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.109 (buildbot@slashdirt-03) (gcc version 7.4.0 (OpenWrt GCC 7.4.0 r9754-fbe2e7d)) #0 Sat Mar 30 09:36:31 2019

Regarding temperature and fan speed - In my case, the fan is quite loud (e.g compare to nsa310)
So I'm thinking about disconnect it / replace or maybe some resistor to slow down. How it looks like in your case ?
I thinking about wiki for nsa325 similar to nsa310:

Ah ok I thought you applied patches to OpenWrt u-boot.
I see the changes in the usb code of uboot in the commit you linked.
I will try to send a PR myself, and I will ask you to test a uboot I compiled, as all my USB drives work fine in uboot.

Does the uboot in the nsa310b have the same issue? I think it should. Can you try the same USB drive in the nsa310b and see if it works or not?

In my nsa325, the noise happens because it's screwed to the metal plate in the back. The fan was nearly silent if removed from the NAS. The metal plate was making a lot of noise with just a little vibration from the fan.

I placed some soft rubber between the fan and the metal plate, and used metal wire instead of the screws to hold it in place. Now it's not noisy.

I can't slow the fan down, I'm using old drives that heat a lot, I need the air movement.

Yes it would be useful.

I have test uboot 2019.01 on my NSA310 and issue was introduced with uboot 2019.01:

U-Boot 2018.03 (Jun 09 2018 - 16:42:36 +0000)
ZyXEL NSA310 1-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  256 MiB
WARNING: Caches not enabled
NAND:  128 MiB
MMC:
Loading Environment from NAND... OK
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
PHY reset timed out
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0
NSA310> usb reset
resetting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 3 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
NSA310>
resetting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 3 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
NSA310> fatload usb 0 0x1000000 u-boot.kwb
645376 bytes read in 75 ms (8.2 MiB/s)
NSA310> nand erase 0x0 0x100000
NAND erase: device 0 offset 0x0, size 0x100000
Erasing at 0xe0000 -- 100% complete.
OK
NSA310> nand write 0x1000000 0x00000 0x100000
NAND write: device 0 offset 0x0, size 0x100000
1048576 bytes written: OK
NSA310> reset
resetting ...

U-Boot 2019.01 (Feb 24 2019 - 23:07:20 +0000)
ZyXEL NSA310 1-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  256 MiB
NAND:  128 MiB
MMC:
Loading Environment from NAND... OK
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
PHY reset timed out
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0
NSA310> usb reset
resetting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... EHCI timed out on TD - token=0x80008d80
EHCI timed out on TD - token=0x80008c80
EHCI timed out on TD - token=0x80008c80
EHCI timed out on TD - token=0x80008c80
 ERROR: NOT USB_CONFIG_DESC 80
 EHCI timed out on TD - token=0x80008d80
 EHCI timed out on TD - token=0x80008c80
 EHCI timed out on TD - token=0x80008c80
 2 USB Device(s) found
 scanning usb for storage devices... 0 Storage Device(s) found
 NSA310>

Hi, I just quickly change to uboot 2019.07
and it compile (with old patches). I will test it tomorrow.
Have you consider to propose/add nsa310 do u-boot https://github.com/u-boot/u-boot ?
that we you don't have maintain it

Still the same issue but uboot is OK:

U-Boot 2019.07 (Sep 16 2019 - 14:01:42 +0000)
ZyXEL NSA310 1-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  256 MiB
NAND:  128 MiB
MMC:   
Loading Environment from NAND... OK
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
PHY reset timed out
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0 
NSA310> usb reset
resetting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... EHCI timed out on TD - token=0x80008d80
EHCI timed out on TD - token=0x80008c80
EHCI timed out on TD - token=0x80008c80
EHCI timed out on TD - token=0x80008c80
 ERROR: NOT USB_CONFIG_DESC 60
EHCI timed out on TD - token=0x80008d80
EHCI timed out on TD - token=0x80008c80
EHCI timed out on TD - token=0x80008c80
2 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
NSA310> 


U-Boot 2017.07-tld-1 (Sep 05 2017 - 00:42:03 -0700)
ZyXEL NSA325 2-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  128 MiB
In:    serial
Out:   serial
Err:   serial
Net:   egiga0
PHY reset timed out
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0 
NSA325> usb reset
resetting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 3 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
NSA325> fatload usb 0 0x1000000 uboot_nsa310_2019.07.kwb
reading uboot_nsa310_2019.07.kwb
654604 bytes read in 125 ms (5 MiB/s)
NSA325> nand erase 0x00000 0x100000

NAND erase: device 0 offset 0x0, size 0x100000
Erasing at 0xe0000 -- 100% complete.
OK
NSA325> nand write 0x1000000 0x00000 0x100000

NAND write: device 0 offset 0x0, size 0x100000
 1048576 bytes written: OK
NSA325> reset
resetting ...


U-Boot 2019.07 (Sep 16 2019 - 14:01:42 +0000)
ZyXEL NSA310 1-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  256 MiB
NAND:  128 MiB
MMC:   
Loading Environment from NAND... *** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0
Error: egiga0 address not set.

PHY reset timed out
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0 
NSA310> 
NSA310> 

U-Boot 2019.07 (Sep 16 2019 - 14:01:42 +0000)
ZyXEL NSA310 1-Bay Power Media Server

SoC:   Kirkwood 88F6281_A1
DRAM:  256 MiB
NAND:  128 MiB
MMC:   
Loading Environment from NAND... *** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   egiga0
Error: egiga0 address not set.

PHY reset timed out
MV88E1318 PHY initialized on egiga0
Hit any key to stop autoboot:  0 
ubi0: attaching mtd3
ubi0: scanning is finished
ubi0: attached mtd3 (name "ubi", size 126 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
ubi0: VID header offset: 512 (aligned 512), data offset: 2048
ubi0: good PEBs: 1009, bad PEBs: 5, corrupted PEBs: 0
ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 9/6, WL threshold: 4096, image sequence number: 603085179
ubi0: available PEBs: 0, total reserved PEBs: 1009, PEBs reserved for bad PEB handling: 15
No size specified -> Using max size (2322432)
Read 2322432 bytes from volume kernel to 00800000
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   ARM OpenWrt Linux-4.14.143
   Created:      2019-09-18   8:51:24 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2238938 Bytes = 2.1 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.143 (kofec@E5420Mint) (gcc version 7.4.0 (OpenWrt GCC 7.4.0 r10494-e05310b9b8)) #0 Mon Sep 16 08:11:59 2019
[    0.000000] CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=0005397f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] OF: fdt: Machine model: ZyXEL NSA310b

Hi,

I've got a Zyxel NSA325V1 with OpenWrt installed and it works fine but the fan is always running. I would like to know if it is possible to control the fan speed? I've run binwalk on the original firmware and found a script that seems to do fancontrol in the stock firmware. Could someone have a look and let me know if this could be used in OpenWrt?

This is the location of the script in the binwalk extracted firmware:

NSA325_V4.81(AAAJ.1)C0/_NSA325_481AAAJ1C0.bin.extracted/_587394.extracted/ext-root/etc/init.d/conf_ADT7463A.sh

And this is the content of the script:


#!/bin/sh
        #
        # Automatic Fan Controlling of ZW1050 (by CCWu 2005-05-06)
        #

        # PWMx at Min Duty Cycle while temp < T_min
        #/sbin/i2cset -y 0x0 0x2e 0x62 0xa0 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x63 0x00 b 1>/dev/null 2>/dev/null

        # PWM_min = 25%, if temp is below T_min, fan will operate with 25% duty cycle
        #/sbin/i2cset -y 0x0 0x2e 0x64 0x40 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x65 0x40 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x66 0x40 b 1>/dev/null 2>/dev/null

        # T_min = 25
        #/sbin/i2cset -y 0x0 0x2e 0x67 0x19 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x68 0x19 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x69 0x19 b 1>/dev/null 2>/dev/null

        # THERM Limit = 55 degree C, if exceeded this, fan will operate with 100% duty cycle, full speed
        #/sbin/i2cset -y 0x0 0x2e 0x6A 0x37 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x6B 0x37 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x6C 0x37 b 1>/dev/null 2>/dev/null

        # Fastest Speed calculated by all three temperature channels controls PWMx
        # (Automatic Fan Control Mode)
        # work-around: disable fan control to avoid abnormal fan speed
        #/sbin/i2cset -y 0x0 0x2e 0x5C 0xC2 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x5D 0xC2 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x5E 0xC2 b 1>/dev/null 2>/dev/null
        
        # (Manual Fan Control Mode)
        /sbin/i2cset -y 0x0 0x2e 0x5C 0xe2 b 1>/dev/null 2>/dev/null
        /sbin/i2cset -y 0x0 0x2e 0x5D 0xe2 b 1>/dev/null 2>/dev/null
        /sbin/i2cset -y 0x0 0x2e 0x5E 0xe2 b 1>/dev/null 2>/dev/null
        # Set PWMx current duty cycle
        /sbin/i2cset -y 0x0 0x2e 0x30 0x50 b 1>/dev/null 2>/dev/null
        /sbin/i2cset -y 0x0 0x2e 0x31 0x50 b 1>/dev/null 2>/dev/null
        /sbin/i2cset -y 0x0 0x2e 0x32 0x50 b 1>/dev/null 2>/dev/null

        ####################
        # Emma-2006.12.1  
        # Initialization of HW monitor interrupt

        # set ADT7463 pin 10 as /SMBALERT
        /sbin/i2cset -y 0x0 0x2e 0x78 0x1 b 1>/dev/null 2>/dev/null

        # set fan1 minimum to 0
        #i2cset -y 0x0 0x2e 0x54 0x0 b
        #i2cset -y 0x0 0x2e 0x55 0x0 b
        i2cset -y 0x0 0x2e 0x54 0xff b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x55 0xff b 1>/dev/null 2>/dev/null

        # set thermal interrupt limits, 0xb5=-75 degreeC, 0x4b=75 degreeC
        # (refer to ADT7463 dastasheet p.17)
        i2cset -y 0x0 0x2e 0x4e 0xb5 b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x4f 0x4b b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x50 0xb5 b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x51 0x4b b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x52 0xb5 b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x53 0x4b b 1>/dev/null 2>/dev/null

        # enable interrupts: Remote 1 temperature channel, local temperature channel, Remote 2 temperature channel, and fan1.
        i2cset -y 0x0 0x2e 0x74 0x0f b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x75 0xfb b 1>/dev/null 2>/dev/null

        # End of Initialization of HW monitor interrupt
        ###################

        ###################################################
        # Make sure fan speed will be greater than 2000 rpm
        #fanrpm=`cat /sys/devices/platform/i2c-0/0-002e/fan1_input`
        fanrpm=`cat /sys/bus/i2c/devices/0-002e/fan1_input`
        var=`i2cget -y 0x0 0x2e 0x30`

        while [ $fanrpm -lt 2000 ]; do
                var=$((var+0x8))
                if [ $var -gt 112 ]; then
                        break;
                fi 

                echo "fanspeed $fanrpm , pwm value $var"

                /sbin/i2cset -y 0x0 0x2e 0x30 $var b 1>/dev/null 2>/dev/null
                /sbin/i2cset -y 0x0 0x2e 0x31 $var b 1>/dev/null 2>/dev/null
                /sbin/i2cset -y 0x0 0x2e 0x32 $var b 1>/dev/null 2>/dev/null         
                sleep 1
                #fanrpm=`cat /sys/devices/platform/i2c-0/0-002e/fan1_input`
                fanrpm=`cat /sys/bus/i2c/devices/0-002e/fan1_input`
        done
        # End of fan speed adjustment
        ##################

        ###################################################
        # Start PID Fan  control
        if [ -x /sbin/fanctrld ]; then
                /bin/echo "Starting PID Fan Control.."
                /bin/nice -n 15 /sbin/fanctrld 0x0 0x2e
        fi

A quick google shows the following data sheet with the name ADT7463: https://www.onsemi.com/pub/Collateral/ADT7463-D.PDF which is a remote thermal controller and voltage monitor chip.

So it mean that we can control fan via registers ? or not ?

I don't know if it is possible to do in OpenWrt but this is what I found in the stock firmware. I don't know if this is enough info for someone more knowledgeable to write fan control code or not but I thought I would share the info anyway.

The ADT7463 chip seems to be supported by kernel driver lm85 https://www.kernel.org/doc/Documentation/hwmon/lm85 However after installing kmod-hwmon-lm85, lm-sensors does not seem to detect the sensor / fan. I guess it will need a different dtb / dts file to define the sensor / fan. I'll create a post on https://forum.doozan.com/list.php?2 and see if anybody there has an idea how to make this work.

I've checked the board and can't find a 24 pin ADT7463 chip. The only 24 pin chip is a Holtek HT66F30. So the name of the script in stock firmware is misleading and automatic fan control via lm-sensors is not going to work. I guess the only way is to write a custom script which adjusts the fan speed.