Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kirkwood: add support for NETGEAR ReadyNAS Duo v2 #3371

Closed
wants to merge 3 commits into from

Conversation

CHKDSK88
Copy link
Contributor

@CHKDSK88 CHKDSK88 commented Aug 31, 2020

NETGEAR ReadyNAS Duo v2 is a NAS based on Marvell kirkwood SoC.

Specification:

  • Processor Marvell 88F6282 (1.6 GHz)
  • 256MB RAM
  • 128MB NAND
  • 1x GBE LAN port (PHY: Marvell 88E1318)
  • 1x USB 2.0
  • 2x USB 3.0
  • 2x SATA
  • 3x button
  • 5x leds
  • serial on J5 connector accessible from rear panel
    (115200 8N1) (VCC,TX,RX,GND) (3V3 LOGIC!)

Installation by USB + serial:

  • Copy initramfs image to fat32 usb drive
  • Connect pendrive to USB 2.0 front socket
  • Connect serial console
  • Stop booting in u-boot
  • Do:
    usb reset
    fatload usb 0:1 0x1200000 openwrt-kirkwood-netgear_readynas-duo-v2-initramfs-uImage
    setenv bootargs 'console=ttyS0,115200n8 earlyprintk'
    bootm 0x1200000
  • copy sysupgrade image via ssh.
  • run sysupgrade

Installation by TFTP + serial:

  • Setup TFTP server and copy initramfs image
  • Connect serial console
  • Stop booting in u-boot
  • Do:
    setenv serverip 192.168.1.1
    setenv ipaddr 192.168.1.2
    setenv bootargs 'console=ttyS0,115200n8 earlyprintk'
    tftpboot 0x1200000 openwrt-kirkwood-netgear_readynas-duo-v2-initramfs-uImage
    bootm 0x1200000
  • copy sysupgrade image via ssh.
  • run sysupgrade

Known issues:

  • Power button and PHY INTn pin are connected to the same GPIO. It
    causes that every network restart button is pressed in system.
    As workaround, button is used as regular BTN_1.

For more info please look at file:
RND_5.3.13_WW.src/u-boot/board/mv_feroceon/mv_hal/usibootup/usibootup.c
from Netgear GPL sources.

Tested-by: Raylynn Knight rayknight@me.com
Tested-by: Lech Perczak lech.perczak@gmail.com
Signed-off-by: Pawel Dembicki paweldembicki@gmail.com

@adschm
Copy link
Member

adschm commented Aug 31, 2020

So, this can only be flashed with serial access?

@adschm adschm added the target/kirkwood pull request/issue for kirkwood target label Aug 31, 2020
@CHKDSK88
Copy link
Contributor Author

CHKDSK88 commented Sep 1, 2020

@adschm

So, this can only be flashed with serial access?

Yes, serial is required, but without disassembling the case. It's on rear panel.

@RaylynnKnight
Copy link
Contributor

RaylynnKnight commented Sep 4, 2020

This will need clarification as to exactly what Netgear ReadyNAS v2 this is for. There are multiple Netgear ReadyNAS v2 units two of which contain a Kirkwood SOC. The Netgear Model RND-4B marketing name Netgear ReadyNAS NV+ v2 is a 4-bay NAS, The Netgear Model RND-2B marketing name Netgear ReadyNAS Duo v2 is a 2-bay NAS. Based on your description and the name used in some of the patch files this should be Netgear ReadyNAS Duo v2 to avoid confusion.

@CHKDSK88 CHKDSK88 changed the title kirkwood: add support for NETGEAR ReadyNAS v2 kirkwood: add support for NETGEAR ReadyNAS Duo v2 Sep 4, 2020
@CHKDSK88
Copy link
Contributor Author

CHKDSK88 commented Sep 4, 2020

@RaylynnKnight

Thank You. I added "Duo" to device name.

@RaylynnKnight
Copy link
Contributor

RaylynnKnight commented Sep 6, 2020

Has this been tested on an actual device? I pulled the git repository branch for CHKDSK88:netgear-readynas-v2. Did a build resulting in:

drwxr-xr-x 3 rayk rayk 4096 Sep 5 04:28 .
drwxr-xr-x 3 rayk rayk 4096 Sep 5 04:09 ..
-rw-r--r-- 1 rayk rayk 2452 Sep 5 04:09 config.buildinfo
-rw-r--r-- 1 rayk rayk 337 Sep 5 04:09 feeds.buildinfo
-rw-r--r-- 1 rayk rayk 11448926 Sep 5 04:28 openwrt-kirkwood-netgear_readynas-duo-v2-initramfs-uImage
-rw-r--r-- 1 rayk rayk 4220 Sep 5 04:28 openwrt-kirkwood-netgear_readynas-duo-v2.manifest
-rw-r--r-- 1 rayk rayk 12585771 Sep 5 04:28 openwrt-kirkwood-netgear_readynas-duo-v2-squashfs-sysupgrade.bin
drwxr-xr-x 2 rayk rayk 4096 Sep 5 04:28 packages
-rw-r--r-- 1 rayk rayk 620 Sep 5 04:28 sha256sums
-rw-r--r-- 1 rayk rayk 18 Sep 5 04:09 version.buildinfo

And then followed the "Installation by USB + serial:" instructions with the following result:

11448926 bytes read ##Marvell>> bootm 0x1200000 Booting image at 01200000 ... Image Name: ARM OpenWrt Linux-5.4.61 Created: 2020-09-04 20:10:09 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 11448862 Bytes = 10.9 MB Load Address: 00008000 Entry Point: 00008000 Verifying Checksum ... OK
And it has been hung here for over 10 minutes.

@CHKDSK88
Copy link
Contributor Author

CHKDSK88 commented Sep 6, 2020

@RaylynnKnight

Could You paste result of u-boot printenv?
Did You try compile unitramfs image with less packages?

@CHKDSK88
Copy link
Contributor Author

CHKDSK88 commented Sep 7, 2020

         __  __                      _ _
        |  \/  | __ _ _ ____   _____| | |
        | |\/| |/ _` | '__\ \ / / _ \ | |
        | |  | | (_| | |   \ V /  __/ | |
        |_|  |_|\__,_|_|    \_/ \___|_|_|
 _   _     ____              _
| | | |   | __ )  ___   ___ | |_ 
| | | |___|  _ \ / _ \ / _ \| __| 
| |_| |___| |_) | (_) | (_) | |_ 
 \___/    |____/ \___/ \___/ \__| 
 ** MARVELL BOARD: DB-88F6282A-BP LE 

U-Boot 1.1.4 (Jun 29 2012 - 16:06:40) Marvell version: 3.4.27
Netgear version: Uboot-1_1_4-NetgearDUOV3-V1009

U-Boot code: 00600000 -> 0067FFF0  BSS: -> 006D0120

Soc: MV88F1155 Rev 1 (DDR3)
CPU running @ 1600Mhz L2 running @ 533Mhz
SysClock = 533Mhz , TClock = 200Mhz 

DRAM unknown CAL  tRP = 8 tRAS = 20 tRCD=8
DRAM CS[0] base 0x00000000   size 256MB 
DRAM Total size 256MB  16bit width
Addresses 8M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (8M - 7M): Done
NAND:128 MB
Flash:  0 kB

CPU : Marvell Feroceon (Rev 1)

Streaming disabled 
Write allocate disabled


USB 0: host mode
PEX 0: PCI Express Root Complex Interface
PEX interface detected Link X1
Switch On !

Net:   egiga0 [PRIME]
Hit any key to stop autoboot:  0 
Marvell>> usb reset
(Re)start USB...
USB:   scanning bus for devices... 2 USB Device(s) found
Waiting for storage device(s) to settle before scanning...
1 Storage Device(s) found
Marvell>> fatload usb 0:1 0x1200000 openwrt-kirkwood-netgear_readynas-duo-v2-initramfs-uImage
reading openwrt-kirkwood-netgear_readynas-duo-v2-initramfs-uImage
.............................................................................................................................................................................................................................................................................................................................................................................................................

4076182 bytes read
Marvell>> bootm 0x1200000
## Booting image at 01200000 ...
   Image Name:   ARM OpenWrt Linux-5.4.61
   Created:      2020-09-04  20:10:09 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4076118 Bytes =  3.9 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.4.61 (builder@buildhost) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r13663+675-5667ccbf16)) #0 Fri Sep 4 20:10:09 2020
[    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: NETGEAR ReadyNAS Duo v2
[    0.000000] Memory policy: Data cache writeback
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 64960
[    0.000000] Kernel command line: console=ttyS0,115200n8 earlyprintk reason=normal mtdparts=nand_mtd:0x180000@0(u-boot),0x20000@0x180000(u-boot-env),0x600000@0x200000(uImage),0x1000000@0x800000(minirootfs),0x6800000@0x1800000(jffs2);
[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off

@CHKDSK88
Copy link
Contributor Author

@RaylynnKnight

Did You have time for more tests?

@CHKDSK88
Copy link
Contributor Author

CHKDSK88 commented Oct 2, 2020

Binary images, if someone would like to test:
openwrt-kirkwood-netgear_readynas-duo-v2-images.zip

@RaylynnKnight
Copy link
Contributor

You can add a Test By from me. Installed successfully.

@CHKDSK88
Copy link
Contributor Author

CHKDSK88 commented Oct 3, 2020

@RaylynnKnight

Done. Thank You.

@CHKDSK88
Copy link
Contributor Author

CHKDSK88 commented Oct 6, 2020

@adschm

Are You plan to merge it?

@RaylynnKnight
Copy link
Contributor

@adschm Any chance this could be merged soon? I have another device (Netgear ReadyNAS NV+ V2) that would extend from the support for this device.

@CHKDSK88
Copy link
Contributor Author

Rebased to current master.

@ynezz
Any chance for merge it?

@bobafetthotmail
Copy link
Contributor

@aparcar maybe you can look at this too?

Copy link
Member

@mans0n mans0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nitpicks.

mkdir -p /var/lock
touch /var/lock/fw_printenv.lock
fw_setenv bootargs 'console=ttyS0,115200n8 earlyprintk'
fw_setenv bootcmd 'nand read.e 0x1200000 0x200000 0x600000;bootm 0x1200000'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... Can we run these commands at installation time and drop these lines here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will try detect if sysupgrade is called from initramfs and run it only then. But I could test it after 2-3 months, because my device is away from me now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must think about it in the next week.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adschm @mans0n
Any ideas, how to detect if sysupgrade is running from initramfs image?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure... But I thought we can just run those commands in U-Boot shell before the tftpboot, am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just check if they match already. Either would be fine by me.

Copy link
Contributor

@Leo-PL Leo-PL Jun 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, maybe at least the "bootargs" part could be added to device tree as "chosen" property in /aliaases in device tree?
Edit: I see that those arguments are in place already, so maybe bootargs could be dropped from U-boot environment, unless they need to be cleared?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prepared new version: envs are configured only during first installation via initramfs. If someone want override it, changes wouldn't be destroyed via regular sysupgrade.

DEVICE_DTS := kirkwood-netgear_readynas_duo_v2
KERNEL_IN_UBI :=
IMAGES := sysupgrade.bin
DEVICE_PACKAGES := kmod-ata-marvell-sata kmod-fs-ext4 kmod-gpio-button-hotplug \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line exceeds 80 characters...

@@ -11,6 +11,10 @@ boot() {
path_to_hwmon='/sys/class/hwmon/hwmon0'
echo 2 > "$path_to_hwmon/pwm1_enable" # fan is on pwm1
;;
netgear,readynas-duo-v2)
path_to_hwmon='/sys/class/hwmon/hwmon0'
echo 1200 > "$path_to_hwmon/fan1_target" #set target rpm
Copy link
Member

@mans0n mans0n Jan 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I cannot add a comment on a line that is not in the diff, so I'll write this here)

# configuring (lm85/lm63) onboard temp/fan controller to run the fan on its own

Maybe we can add "g762" to (lm85/lm63), or remove it entirely.

echo 1200 > "$path_to_hwmon/fan1_target" #set target rpm

And could you add a space after #?

@mans0n
Copy link
Member

mans0n commented Jan 13, 2021

Does poweroff command work on this device?
If yes, then maybe we can link the power button to the command.
If not, then isn't it the poweroff procedure itself, not gpio-poweroff, that is buggy?

@CHKDSK88
Copy link
Contributor Author

@mans0n

Does poweroff command work on this device?

Simple poweroff cause, that it can't be turned on from button and WOL won't work. It need to reset by plug off power supply.

If yes, then maybe we can link the power button to the command.
If not, then isn't it the poweroff procedure itself, not gpio-poweroff, that is buggy?

Poweroff in stock firmware cause setting two bits (PHY register: Page 3 Reg 17 Bit 4 and RTC register: SL2(BIT5) of RS5C372a control 1 register (0xe0)) and reboot. If bootloader detect that state, it enable WOL and suspend device. Then it wait for WOL signal or button.

If gpio-poweroff is used, power button causes state, when is impossible to turn it on, without plug off the power supply.

@mans0n
Copy link
Member

mans0n commented Jan 17, 2021

So...you mean that the effect of simple poweroff and gpio-poweroff is totally same?

Asking to be sure, what is the effect of gpio-poweroff pin (gpio30)? Does the stock FW also use it?

@danitool
Copy link
Contributor

@mans0n

Does poweroff command work on this device?

Simple poweroff cause, that it can't be turned on from button and WOL won't work. It need to reset by plug off power supply.

If yes, then maybe we can link the power button to the command.
If not, then isn't it the poweroff procedure itself, not gpio-poweroff, that is buggy?

Poweroff in stock firmware cause setting two bits (PHY register: Page 3 Reg 17 Bit 4 and RTC register: SL2(BIT5) of RS5C372a control 1 register (0xe0)) and reboot. If bootloader detect that state, it enable WOL and suspend device. Then it wait for WOL signal or button.

If gpio-poweroff is used, power button causes state, when is impossible to turn it on, without plug off the power supply.

Hi @CHKDSK88, your NAS is using a marvell PHY right?, then you may need the same poweroff-restart driver I made for the LinkStation LS421DE NAS (see 59c200c). It uses the INTn at the PHY to wake up the machine, restart or power off depending on its state.

However, the PHY registers you point to don't make much sense to me.

About the RTC, probably the register has to do with the wakealarm pin interrupt, hopefully it is already cleared if a wake alarm is scheduled or not.

For testing the Linkstation poweroff-restart driver you need to add your board to the compatible list in the driver itself.

Regards
Daniel

@Leo-PL
Copy link
Contributor

Leo-PL commented Aug 8, 2021

@Leo-PL

Also, freshly build initramfs images for some reason, seem to crash very early on, even before the initial "OK" is printed. Can they be too big? With current master, initramfs-uImage weighs in 12337598 bytes for me.

Initramfs image must be small. I'm not sure what size of image is maximum for proper loading. I had the same problem when I test images prepared by @obsy from eko.one.pl.

I just rebased this PR together with my patchset, and for some strange reason, when OpenWrt boots, at the time around link establishes, a poweroff is triggered by kernel, and system turns off. This did not happen during my previous tests, and really nothing has changed in this PR, so I don't suspect it to have the problem.

I have the same problem.

One thought came to my mind. I don't have the schematics for the device - but isn't WoL working by asserting the "power button" line internally?

Exactly, it looks that is problem with LED2/INTn pin connected to power button. It could pull down power button.
I pushed partial solution of powering-off problem. Now sometimes work perfect, sometimes not. It depends, how fast phy will be configured. If gpio-hotplug is faster, then it reboot. If phy are faster, it works.

The only way is to delay start of gpio-hotplug or do some changes in phy configuration. Do You have any idea how to make it better?

Another idea: maybe we can configure this pin from U-boot somehow? We have a "phyWrite" command available there.
Also, why the note about upstream gpio-poweroff was dropped from the device tree?
Edit: I'll try this in spare time, which I don't have much today, and try bisecting the kernel using "external kernel tree" feature of build system and some automation.

@CHKDSK88
Copy link
Contributor Author

CHKDSK88 commented Aug 8, 2021

@Leo-PL

Another idea: maybe we can configure this pin from U-boot somehow? We have a "phyWrite" command available there.

I'm on holiday till next Sunday, so I will look again after 16.08.21. Maybe this will work.

Also, why the note about upstream gpio-poweroff was dropped from the device tree?

I found why author do it:
torvalds/linux@bfc2e5f

I tried multiple possible solutions. I removed it during tests of workaround. But if we use my patch to poweroff driver, this entry is useless.

Edit: I'll try this in spare time, which I don't have much today, and try bisecting the kernel using "external kernel tree" feature of build system and some automation.

Did You try Debian? I wonder, if Openwrt's netifd isn't a problem.

@Leo-PL
Copy link
Contributor

Leo-PL commented Aug 9, 2021

@Leo-PL

Another idea: maybe we can configure this pin from U-boot somehow? We have a "phyWrite" command available there.

I'm on holiday till next Sunday, so I will look again after 16.08.21. Maybe this will work.
It's likely, that I'll have time to play with this earliest next weekend as well.

Also, why the note about upstream gpio-poweroff was dropped from the device tree?

I found why author do it:
torvalds/linux@bfc2e5f

I tried multiple possible solutions. I removed it during tests of workaround. But if we use my patch to poweroff driver, this entry is useless.

Acked, makes sense.

Edit: I'll try this in spare time, which I don't have much today, and try bisecting the kernel using "external kernel tree" feature of build system and some automation.

Did You try Debian? I wonder, if Openwrt's netifd isn't a problem.

Not yet, but I wouldn't suspect netifd here. I'd be happy to run Debian on this box as well, but OpenWrt is my go-to embedded framework.

@CHKDSK88
Copy link
Contributor Author

In the meantime my poweroff patches were accepted:
https://lkml.org/lkml/2021/8/13/773

@Leo-PL
Copy link
Contributor

Leo-PL commented Aug 13, 2021

In the meantime my poweroff patches were accepted:
https://lkml.org/lkml/2021/8/13/773

Congratulations!

@Leo-PL
Copy link
Contributor

Leo-PL commented Aug 15, 2021

@CHKDSK88 I ran a bisect session on this patchset, and narrowed the problem down to this commit, actually in OpenWrt, not in kernel: 467cd37 (base-files: failsafe: Fix IP configuration) - How strange indeed it is.
Reverting it on top of of master did help.
To perform bisection, I did the following:

  1. Rebase this patchset on top of b721579. Checkout as bisect_good
  2. Remove the partial workaround in device tree with marvell,phy-init property
  3. Rebase b309248 on top of bisect_good. Checkout as bisect bad
  4. Set the unit to autoboot from TFTP from my buildserver using setenv bootcmd 'setenv ipaddr <DEVICE_IP>; setenv serverip <BUILDSERVER_IP>; tftpboot 0x1200000 openwrt-uImage; bootm 0x1200000'; saveenv; reset
  5. Prepare a symlink to build output from OpenWrt repository: cd /srv/tftp/; ln -s </path/to/build/dir>/bin/targets/kirkwood/generic/openwrt-kirkwood-netgear_readynas-duo-v2-initramfs-uImage openwrt-uImage
  6. Create a config seed for the build process as mydiffconfig:
CONFIG_TARGET_kirkwood=y
CONFIG_TARGET_kirkwood_DEVICE_netgear_readynas-duo-v2=y
CONFIG_TARGET_BOARD="kirkwood"
CONFIG_DEVEL=y
CONFIG_COLLECT_KERNEL_DEBUG=y
CONFIG_IMAGEOPT=y
CONFIG_PACKAGE_kmod-ata-core=m
CONFIG_PACKAGE_kmod-ata-marvell-sata=m
CONFIG_PACKAGE_kmod-crypto-crc32c=m
CONFIG_PACKAGE_kmod-crypto-hash=m
CONFIG_PACKAGE_kmod-fs-ext4=m
CONFIG_PACKAGE_kmod-hwmon-core=m
CONFIG_PACKAGE_kmod-hwmon-g762=m
CONFIG_PACKAGE_kmod-i2c-core=m
CONFIG_PACKAGE_kmod-lib-crc16=m
CONFIG_PACKAGE_kmod-rtc-rs5c372a=m
CONFIG_PACKAGE_kmod-scsi-core=m
CONFIG_PACKAGE_kmod-usb-xhci-hcd=m
CONFIG_PACKAGE_kmod-usb3=m

  1. Add the following snippet to ~/.ssh/config (I had this already) so we can connect to TFTP-booted image without checking host keys, etc, through SSH:
Host openwrt-recovery
        Hostname 192.168.1.1
        User root
        UserKnownHostsFile /dev/null
        StrictHostKeyChecking no
        CheckHostIP no

  1. Create test script which builds OpenWrt using this, then boots the unit through WOL and TFTP; and verifies if the issue occurs, as do_all.sh:
#!/bin/bash
cp mydiffconfig .config
make defconfig
time make -j<NUMBER_CPUS> || exit 125
wakeonlan -i <SUBNET_BROADCAST_ADDR <DEVICE_MAC>
sleep 300
ping -c 4 <NAS_HOSTNAME_OR_IP> || exit 1 #The actual test happens here
ssh -o Hostname=<NAS_HOSTNAME_OR_IP> openwrt-recovery poweroff #Prepare for next test cycle
exit 0
  1. Perform actual bisect, by executing this
git bisect start
git bisect good bisect_good
git bisect bad bisect_bad
git bisect run ./do_all.sh
  1. ...
  2. Profit! The result was this:
git bisect start
# good: [c7b79b72cc57f82552fafa0afbcf1c1f3ffa9531] Disable poweroff workaround just to be sure
git bisect good c7b79b72cc57f82552fafa0afbcf1c1f3ffa9531
# bad: [6b6550e76d7a7fdd98ae4b2d0a0b21015c978706] generic: add mac-address property for NVMEM mac addresses
git bisect bad 6b6550e76d7a7fdd98ae4b2d0a0b21015c978706
# bad: [08b4c0a2ea2ca0ae620c0c97d2add96c7aaf6a5b] Revert "dnsmasq: Update to version 2.86test3"
git bisect bad 08b4c0a2ea2ca0ae620c0c97d2add96c7aaf6a5b
# good: [c282de3e7082b4c19d319f4b77675e8ad4a12898] tools/squashfskit4: fix compilation under big endian
git bisect good c282de3e7082b4c19d319f4b77675e8ad4a12898
# bad: [867804645cfe5acec600f01e579d94dc6dbdf34a] ramips: mt7620: remove useless GMAC nodes
git bisect bad 867804645cfe5acec600f01e579d94dc6dbdf34a
# good: [7bf48240aa42c6024fee207689d062e9a9c33a9f] hostapd: make country3 option configurable
git bisect good 7bf48240aa42c6024fee207689d062e9a9c33a9f
# good: [b345fc3107ba41f419214da4212577954b2b7372] kernel: bump 5.10 to 5.10.44
git bisect good b345fc3107ba41f419214da4212577954b2b7372
# bad: [680edeacdf41f5faaeddc2174967285c8e6b26fe] base-files: failsafe: Remove the VLAN modifier from interface name
git bisect bad 680edeacdf41f5faaeddc2174967285c8e6b26fe
# good: [5dde23fb2a9e381659b575696a1588aca36a6886] kernel: Backport patch to automatically bring up DSA master when opening user port
git bisect good 5dde23fb2a9e381659b575696a1588aca36a6886
# bad: [04f42b28961402199526ade4e1ac9f57ea5c8c47] base-files: failsafe: Fix IP configuration
git bisect bad 04f42b28961402199526ade4e1ac9f57ea5c8c47
# first bad commit: [04f42b28961402199526ade4e1ac9f57ea5c8c47] base-files: failsafe: Fix IP configuration

And then reverting last commit on my local tree did indeed help!
But sadly, only partially. On full build, the problem still occurs - so I believe the issue was there from the very beginning, but was only uncovered by timing.

I guess I will rerun the bisect, but this time, include sysupgrade in the process - maybe this will pinpoint the problem more accurately.

Now, the question remains, why does this commit affect the power-up sequence.

OT: Nice thing is, that I haven't actually need to use my smart plug running https://github.com/arendst/Tasmota to perform power-cycles on the unit, but still it is a very useful tool in an embedded CI environment.

@Leo-PL
Copy link
Contributor

Leo-PL commented Aug 22, 2021

I ran another bisect session, on full image including my patches, and using sysupgrade in the process.
And that's, what came out:

git bisect start
# good: [cc923c6cd98dc0c072c1ed285654a2bfb09f878c] Disable poweroff workaround just to be sure
git bisect good cc923c6cd98dc0c072c1ed285654a2bfb09f878c
# bad: [3e9e510d14037a3d83587077b8b64f01c0ef2adf] generic: add mac-address property for NVMEM mac addresses
git bisect bad 3e9e510d14037a3d83587077b8b64f01c0ef2adf
# bad: [1e0ad195449771840ad6bcc9c5b2c40ba29b2569] Revert "dnsmasq: Update to version 2.86test3"
git bisect bad 1e0ad195449771840ad6bcc9c5b2c40ba29b2569
# good: [fda26dcbaa588a45154926351dc8a73c97249c7a] tools/squashfskit4: fix compilation under big endian
git bisect good fda26dcbaa588a45154926351dc8a73c97249c7a
# bad: [49bf7fb1f3afa5b41f1bf8261c1743e11f95dfe0] ramips: mt7620: remove useless GMAC nodes
git bisect bad 49bf7fb1f3afa5b41f1bf8261c1743e11f95dfe0
# good: [43873ff7d25637ff6fad636405b0c4ff6fdc6298] hostapd: make country3 option configurable
git bisect good 43873ff7d25637ff6fad636405b0c4ff6fdc6298
# bad: [e300ee7a0b3310b40ad5347cc80967db34f080ce] kernel: bump 5.10 to 5.10.44
git bisect bad e300ee7a0b3310b40ad5347cc80967db34f080ce
# good: [90701978b8a7446dacec0594e51549a1ac126d7f] base-files: fix enabled for services with only STOP
git bisect good 90701978b8a7446dacec0594e51549a1ac126d7f
# good: [39e9e2278e5df1142fcb1de946f5060cfb84e803] realtek: Fix buffer length calculation on RTL8380 with CRC offload
git bisect good 39e9e2278e5df1142fcb1de946f5060cfb84e803
# good: [9d5cfb79c9de08768d4449f27a223b7714bf85ee] kernel: crypto: limit crypto-hw-hifn-795x to devices with pci support
git bisect good 9d5cfb79c9de08768d4449f27a223b7714bf85ee
# first bad commit: [e300ee7a0b3310b40ad5347cc80967db34f080ce] kernel: bump 5.10 to 5.10.44

I am puzzled, because was running kernel 5.4 in my tests.
There are a few changes, that I had to do:

  1. Keep a clean initramfs image, to boot the unit through TFTP, modified to include a custom boot command:
    fw_setenv bootcmd "nand read.e 0x1200000 0x200000 0x600000; setenv bootcmd 'run bootcmd_tftp'; saveenv; bootm 0x1200000" in /target/linux/kirkwood/base-files/lib/upgrade/platform.sh, where bootcmd_tftp was the boot command for TFTP build normally used for initial installation. This causes the unit to revert to TFTP boot, once sysupgraded image is launched.
diff --git a/target/linux/kirkwood/base-files/lib/upgrade/platform.sh b/target/linux/kirkwood/base-files/lib/upgrade/platform.sh
index 5c5415baf2..f9267be8c9 100644
--- a/target/linux/kirkwood/base-files/lib/upgrade/platform.sh
+++ b/target/linux/kirkwood/base-files/lib/upgrade/platform.sh
@@ -33,7 +33,7 @@ platform_do_upgrade() {
                        mkdir -p /var/lock
                        touch /var/lock/fw_printenv.lock
                        fw_setenv bootargs 'console=ttyS0,115200n8 earlyprintk'
-                       fw_setenv bootcmd 'nand read.e 0x1200000 0x200000 0x600000;bootm 0x1200000'
+                       fw_setenv bootcmd "nand read.e 0x1200000 0x200000 0x600000; setenv bootcmd 'run bootcmd_tftp'; saveenv; bootm 0x1200000"
                fi
                nand_do_upgrade "$1"
                ;;

There is no need to include this in test images, as this variable is always set by image booted from TFTP, not the actual test image.

  1. Use slightly modified script to be executed by git bisect:
#!/bin/bash
cp mydiffconfig .config
make defconfig
time make -j8 || exit 125
wakeonlan -i 10.0.0.255 2C:B0:5D:BE:EF:DAsquashfs-sysupgrade.bin'
sleep 240

#!/bin/bash
cp mydiffconfig .config
make defconfig
time make -j<NUMBER_CPUS> || exit 125
wakeonlan -i <SUBNET_BROADCAST_ADDR <DEVICE_MAC>
sleep 240
scp -o Hostname=<NAS_IP_OR_HOSTNAME> bin/targets/kirkwood/generic/openwrt-kirkwood-netgear_readynas-duo-v2-squashfs-sysupgrade.bin openwrt-recovery:/tmp/
ssh -o Hostname=<NAS_IP_OR_HOSTNAME> openwrt-recovery 'sysupgrade -n /tmp/openwrt-kirkwood-netgear_readynas-duo-v2-squashfs-sysupgrade.bin'
sleep 240
ping -c 4 <NAS_HOSTNAME_OR_IP> || exit 1 #The actual test happens here
ssh -o Hostname=<NAS_HOSTNAME_OR_IP> openwrt-recovery poweroff #Prepare for next test cycle
exit 0

@jakub-id
Copy link

Guys, what's blocking this from getting merged? Did people involved lose interest?

@Leo-PL
Copy link
Contributor

Leo-PL commented Nov 23, 2021

@skoczko We haven't figured out a way to consistently fix the power button issue mis-triggered by PHY configuration.

@emesio
Copy link

emesio commented Nov 24, 2021

Thats a pity. Any chances for 'unofficial' build (bins)? If the power button was the only issue - then resetting it from smart plug is not a problem, and the box looks perfect for simple openwrt nas... :)

@CHKDSK88
Copy link
Contributor Author

It could be merged if any coredev accept, that power button will not close system. That's only one problem with that device...

If @adschm or @mans0n accept that temporary solution, I could prepare new version.

@Leo-PL
Copy link
Contributor

Leo-PL commented Nov 27, 2021

I agree that it's better than nothing - one could still use "poweroff" command.
@CHKDSK88 One idea struck me now - could we use a very long debounce time, like 1 second, on that line as a workaround?

@CHKDSK88
Copy link
Contributor Author

@Leo-PL

I will check it. But if it will not help, I will prepare final version without power button functionality.

@CHKDSK88
Copy link
Contributor Author

CHKDSK88 commented Dec 2, 2021

@Leo-PL
It didn't help. I will prepare version without support for power button soon.

@Leo-PL
Copy link
Contributor

Leo-PL commented Dec 2, 2021

@CHKDSK88, +1, makes total sense. Please ping me when you push update, I'll rebuild and retest.

@CHKDSK88
Copy link
Contributor Author

CHKDSK88 commented Dec 3, 2021

@Leo-PL

It's ready for testing. I hope, that's is ready for merge too.

@mans0n
Could You look at this PR in free time?

@CHKDSK88 CHKDSK88 marked this pull request as ready for review December 3, 2021 10:23
@Leo-PL
Copy link
Contributor

Leo-PL commented Dec 3, 2021

Reviewed-by: Lech Perczak lech.perczak@gmail.com
Tested-by: Lech Perczak lech.perczak@gmail.com

I noticed, that the power button inactivates, when the link is finally up after setting up interfaces. Unit properly powers off after a "poweroff" command. I'll try to look into the PHY driver in near future.

@CHKDSK88
Copy link
Contributor Author

CHKDSK88 commented Dec 3, 2021

@Leo-PL
Thanks for the help.
I can't force PHY to keep INTn pin state when PHY is resetting. I hope, that workaround is enough for merge.

@Leo-PL
Copy link
Contributor

Leo-PL commented Dec 3, 2021

Besides, do you have a datasheet for this PHY, by any chance?

@CHKDSK88
Copy link
Contributor Author

CHKDSK88 commented Dec 3, 2021

Besides, do you have a datasheet for this PHY, by any chance?

You can't find it in the internet. :/

Copy link
Member

@mans0n mans0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay.
It mostly seems good, just one nitpick:

mkdir -p /var/lock
touch /var/lock/fw_printenv.lock
fw_setenv bootargs 'console=ttyS0,115200n8 earlyprintk'
fw_setenv bootcmd 'nand read.e 0x1200000 0x200000 0x600000;bootm 0x1200000'
Copy link
Member

@mans0n mans0n Dec 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still lingering in my mind. I think this can be done manually once during the installation. We should access u-boot shell for installation anyway, why should we split the procedure?
I mean, setenv bootcmd ... && saveenv could be inserted somewhere around bootm 0x1200000 in the commit message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I removed it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then we don't need platform_check_image() change anymore, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was too fast. Now should be ok.

This patch adds kernel module for Global Mixed-mode Technology Inc
G762 and G763 fan speed PWM controller chips.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Linkstation poweroff driver was added to mvebu target, but is required
for kirkwood target too.
This commit make two changes:
- move linkstation-poweroff support patch from mvebu to generic and
replace upstream accepted version
- backport small linkstation-poweroff fix from 5.12

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
NETGEAR ReadyNAS Duo v2 is a NAS based on Marvell kirkwood SoC.

Specification:
 - Processor Marvell 88F6282 (1.6 GHz)
 - 256MB RAM
 - 128MB NAND
 - 1x GBE LAN port (PHY: Marvell 88E1318)
 - 1x USB 2.0
 - 2x USB 3.0
 - 2x SATA
 - 3x button
 - 5x leds
 - serial on J5 connector accessible from rear panel
   (115200 8N1) (VCC,TX,RX,GND) (3V3 LOGIC!)

Installation by USB + serial:
  - Copy initramfs image to fat32 usb drive
  - Connect pendrive to USB 2.0 front socket
  - Connect serial console
  - Stop booting in u-boot
  - Do:
	usb reset
        setenv bootargs 'console=ttyS0,115200n8 earlyprintk'
        setenv bootcmd 'nand read.e 0x1200000 0x200000 0x600000;bootm 0x1200000'
        saveenv
	fatload usb 0:1 0x1200000 openwrt-kirkwood-netgear_readynas-duo-v2-initramfs-uImage
	bootm 0x1200000
  - copy sysupgrade image via ssh.
  - run sysupgrade

Installation by TFTP + serial:
  - Setup TFTP server and copy initramfs image
  - Connect serial console
  - Stop booting in u-boot
  - Do:
	setenv bootargs 'console=ttyS0,115200n8 earlyprintk'
	setenv bootcmd 'nand read.e 0x1200000 0x200000 0x600000;bootm 0x1200000'
	saveenv
	setenv serverip 192.168.1.1
	setenv ipaddr 192.168.1.2
	tftpboot 0x1200000 openwrt-kirkwood-netgear_readynas-duo-v2-initramfs-uImage
	bootm 0x1200000
  - copy sysupgrade image via ssh.
  - run sysupgrade

Known issues:
  - Power button and PHY INTn pin are connected to the same GPIO. It
    causes that every network restart button is pressed in system.
    As workaround, button is used as regular BTN_1.

For more info please look at file:
RND_5.3.13_WW.src/u-boot/board/mv_feroceon/mv_hal/usibootup/usibootup.c
from Netgear GPL sources.

Tested-by: Raylynn Knight <rayknight@me.com>
Tested-by: Lech Perczak <lech.perczak@gmail.com>
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
@chunkeey
Copy link
Member

Merged. Thanks!

@chunkeey chunkeey closed this Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target/kirkwood pull request/issue for kirkwood target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants