Installing LEDE on NSA325

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.

As far as I know it is not possible to change/control the fan speed. It is control by "some" chip and the parameters cannot be changed. E.g in model NSA310 the fan can be control