Support for RTL838x based managed switches

Thanks a bunch! Goes on the list then :slight_smile:

I finally had the time to create a PR with the latest features: packet filtering offload and L3 routing offload as well as 10G support. Please test:

I also want to draw your attention to some more exiting work by brainslayer together with @blogic building on this:

He has started with RTL931x support and Link Aggregation finally works!

6 Likes

Hi kobi,
I was able to get a serial connection to the ZyXEL GS1900-48 by manually connecting TXD,RXD and GND to a male DB9 RS232 port.

White is the switches TXD, connected to a male DB-9, pin 2 (RXD).
Black is the switches RXD, connected to a male DB-9, pin 3 (TXD).
Purple is GND, connected to GND.
Baudrate is 115200, otherwise standard settings for screen or minicom.
Autoboot is set to 1 second. Pressing space multiple times before the autoboot prompt works for me.

I'm currently compiling your master branch. I'll probably test it tomorrow.

Edwin

3 Likes

Hi,
so I've tried booting the kernel-initramfs via tftpboot. I also tried flashing it via the OEM webinterface, for which I had to patch the image Makefile (same as Default/gs1900, using UIMAGE_MAGIC and ZYXEL_VERS and a customized KERNEL_INITRAMFS, but I'm not sure whether both were necessary).
Unfortunately, the kernel hangs after random: fast init done and then comes back with random: crng init done only to freeze completely. There's no reaction to keypresses and network also does not seem to come up. The behaviour and (kernel) log is the same with both methods.

Boot log
II: Copied Preloader data from 0x9fc00000(15804B) to 0x9f000000.
II: Cleared Preloader BSS section at 0x9f003dbc(0B).
II: PLL...�II: PLL is set by SW... OK
Setting DTR
II: DRAM is set by software calibration... PASSED

DCDR(0xb8001060):0x80000000
DIDER(0xb8001050):0x80800000
MCR (0xb8001000):0x200421e0, 0x21220000, 0x65533b30, 0x05050313
DTR2(0xb8001010):0x08311000
PHY Registers(0xb8001500):
0xb8001500:0x80060730, 0x0000007f, 0xa1a00000, 0xffffffff
0xb8001510:0x00180c00, 0x00180c00, 0x001a0d00, 0x00160b00
0xb8001520:0x001a0d00, 0x00160b00, 0x001a0d00, 0x00160b00
0xb8001530:0x00180c00, 0x001a0d00, 0x00160b00, 0x00180c00
0xb8001540:0x00180c00, 0x00180c00, 0x00160b00, 0x00180c00
0xb8001550:0x00180c00, 0x00180c00, 0x001a0d00, 0x00160b00
0xb8001560:0x00180c00, 0x00160b00, 0x001a0d00, 0x00160b00
0xb8001570:0x00180c00, 0x00180c00, 0x00160b00, 0x00180c00
0xb8001580:0x00180c00, 0x00180c00, 0x00160b00, 0x00180c00
0xb8001590:0x00000000, 0x81810505, 0x02000820, 0x50505858
0xb80015a0:0x5a5a4a4a, 0x00000000, 0x00000000, 0x00000000
II: Selected DRAM model #0.
II: Copying U-Boot from 0x9fc03dbc(225728B) to 0x83f00000... OK
II: NOR SPI Flash... searching flash parameters... supported flash ID: [c22018][c22018][c22018]... detected flash ID: [c22018]... OK


U-Boot 1.0.2-svn45936 (Jan 15 2014 - 16:30:16)

Board: RTL839x CPU:750MHz LXB:200MHz MEM:400MHz
DRAM:  128 MB
SPI-F: 1x16 MB
Loading 1024B env. variables from offset 0x40000
Switch Model: ZyXEL_GS1900_48 (Port Count: 50)
Switch Chip: RTL8393M
Model Info: 83936802
### RTL8218B config - MAC ID = 0 ###
### RTL8218B config - MAC ID = 8 ###
### RTL8218B config - MAC ID = 16 ###
### RTL8218B config - MAC ID = 24 ###
### RTL8218B config - MAC ID = 32 ###
### RTL8218B config - MAC ID = 40 ###
PHY[0]: disable EEE
PHY[1]: disable EEE
PHY[2]: disable EEE
PHY[3]: disable EEE
PHY[4]: disable EEE
PHY[5]: disable EEE
PHY[6]: not supported in EEE
Net:   Net Initialization Skipped
rtl8390#0
Hit any key to stop autoboot:  1  0 
RTL839x#     setenv bootargs console=ttyS0,115200 console=ttyS1,115200 mem=128M;
RTL839x# setenv ipaddr 192.168.2.16;
RTL839x# setenv serverip 192.168.2.8;
RTL839x# rtk network on;
Enable network
Please wait for PHY init-time ...

RTL839x# tftpboot 0x84f00000 zyxel/kinit.bin
Using rtl8390#0 device
TFTP from server 192.168.2.8; our IP address is 192.168.2.16
Filename 'zyxel/kinit.bin'.
Load address: 0x84f00000
Loading: *#################################################################
	 ####################################T #############################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 ########################
done
Bytes transferred = 6066589 (5c919d hex)
RTL839x# bootm
## Booting kernel from Legacy Image at 84f00000 ...
   Image Name:   MIPS OpenWrt Linux-5.4.143
   Created:      2021-09-04   6:39:45 UTC
   Image Type:   MIPS Linux Kernel Image (gzip compressed)
   Data Size:    6066525 Bytes = 5.8 MB
   Load Address: 80000000
   Entry Point:  80000400
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK

Starting kernel ...

[    0.000000] Linux version 5.4.143 (edwin@medusa) (gcc version 10.3.0 (OpenWrt GCC 10.3.0 r17476-27a99e40f7)) #0 Sat Sep 4 06:39:45 2021
[    0.000000] RTL838X model is ffffffff
[    0.000000] RTL839X model is 83936802
[    0.000000] SoC Type: RTL8393
[    0.000000] Kernel command line: console=ttyS0,115200 console=ttyS1,115200 mem=128M 
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019555 (MIPS 34Kc)
[    0.000000] MIPS: machine is Zyxel GS1900-48
[    0.000000] Registering _machine_restart
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Using appended Device Tree.
[    0.000000] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] On node 0 totalpages: 32768
[    0.000000]   Normal zone: 288 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 32768 pages, LIFO batch:7
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32480
[    0.000000] Kernel command line: console=ttyS0,115200
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.000000] Writing ErrCtl register=00000003
[    0.000000] Readback ErrCtl register=00000003
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 114804K/131072K available (5078K kernel code, 166K rwdata, 1104K rodata, 8364K init, 199K bss, 16268K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 32
[    0.000000] random: get_random_bytes called from start_kernel+0x288/0x468 with crng_init=0
[    0.000000] timer_probe: no matching timers found
[    0.000000] CPU frequency from device tree: 700MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 5460744132 ns
[    0.000008] sched_clock: 32 bits at 350MHz, resolution 2ns, wraps every 6135667710ns
[    0.009211] Calibrating delay loop... 464.48 BogoMIPS (lpj=2322432)
[    0.076465] pid_max: default: 32768 minimum: 301
[    0.082095] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.090673] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.106989] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.118580] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.126674] pinctrl core: initialized pinctrl subsystem
[    0.133380] NET: Registered protocol family 16
[    0.170149] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512
[    0.185194] clocksource: Switched to clocksource MIPS
[    0.192286] NET: Registered protocol family 2
[    0.197506] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.206639] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.216516] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.225506] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.233804] TCP: Hash tables configured (established 1024 bind 1024)
[    0.241475] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.249175] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.257682] NET: Registered protocol family 1
[    0.420351] workingset: timestamp_bits=14 max_order=15 bucket_order=1
[    0.435447] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.442246] jffs2: version 2.2 (NAND) (SUMMARY) (ZLIB) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.475165] pinctrl-single bb001000.pinmux: 32 pins, size 4
[    0.482067] Probing RTL8231 GPIOs
[    0.485943] rtl8231_init called, MDIO bus ID: 3
[    0.496427] Probing RTL838X GPIOs
[    0.537144] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    0.545652] printk: console [ttyS0] disabled
[    0.550646] b8002000.uart: ttyS0 at MMIO 0xb8002000 (irq = 31, base_baud = 12500000) is a 16550A
[    0.561052] printk: console [ttyS0] enabled
[    0.561052] printk: console [ttyS0] enabled
[    0.570963] printk: bootconsole [early0] disabled
[    0.570963] printk: bootconsole [early0] disabled
[    0.582960] b8002100.uart: ttyS1 at MMIO 0xb8002100 (irq = 30, base_baud = 12500000) is a 16550A
[    0.734079] brd: module loaded
[    0.738160] Initializing rtl838x_nor_driver
[    0.743170] SPI resource base is b8001200
[    0.747997] Address mode is 3 bytes
[    0.752145] rtl838x_nor_init called
[    0.761297] rtl838x-nor b8001200.spi: mx25l12805d (16384 Kbytes)
[    0.768575] 7 fixed-partitions partitions found on MTD device rtl838x_nor
[    0.776709] Creating 7 MTD partitions on "rtl838x_nor":
[    0.782954] 0x000000000000-0x000000040000 : "u-boot"
[    0.789976] 0x000000040000-0x000000050000 : "u-boot-env"
[    0.797421] 0x000000050000-0x000000060000 : "u-boot-env2"
[    0.804863] 0x000000060000-0x000000160000 : "jffs"
[    0.811678] 0x000000160000-0x000000260000 : "jffs2"
[    0.818575] 0x000000260000-0x000000930000 : "runtime"
[    0.836137] 0x000000930000-0x000001000000 : "runtime2"
[    0.844088] libphy: Fixed MDIO Bus: probed
[    0.851118] Probing RTL838X eth device pdev: 87c9aa00, dev: 87c9aa10
[    0.861028] Found SoC ID: 8393: RTL8393, family 8390
[    0.867023] Using MAC 0000588bf3fe05d5
[    0.871669] libphy: rtl839x-eth-mdio: probed
[    1.558020] rtl8393_serdes_probe: id: 48
[    1.562712] Realtek RTL8393 SERDES mdio-bus:30: Detected internal RTL8390 SERDES
[    1.584358] rtl8393_serdes_probe: id: 49
[    1.589099] Realtek RTL8393 SERDES mdio-bus:31: Detected internal RTL8390 SERDES
[    1.600417] NET: Registered protocol family 10
[    1.610836] Segment Routing with IPv6
[    1.615381] NET: Registered protocol family 17
[    1.620996] 8021q: 802.1Q VLAN Support v1.8
[    1.626858] i2c-gpio i2c-gpio-0: Slow GPIO pins might wreak havoc into I2C/SMBus bus timing
[    1.637024] i2c-gpio i2c-gpio-0: using lines 184 (SDA) and 185 (SCL)
[    1.644893] i2c-gpio i2c-gpio-1: Slow GPIO pins might wreak havoc into I2C/SMBus bus timing
[    1.655066] i2c-gpio i2c-gpio-1: using lines 190 (SDA) and 191 (SCL)
[    1.662956] libphy: SFP I2C Bus: probed
[    1.667943] sfp sfp-p9: Host maximum power 1.0W
[    1.673762] libphy: SFP I2C Bus: probed
[    1.678773] sfp sfp-p10: Host maximum power 1.0W
[    2.595182] random: fast init done
[  133.795239] random: crng init done

Have a look at https://github.com/openwrt/openwrt/pull/4535 and https://gitlab.com/bkoblitz/openwrt-rtl838x/-/tree/rtl839x (I'd suggest trying to import the device specifics into the new PR#4535.

1 Like

Yes, indeed that PR#4535 was actually continuously tested with the Zyxel GS-1900-48 as my RTL839x test device. Just clone my repository, checkout branch merge_pie (which corresponds to the PR), and then add the device-specific .dts, which you can find here:

and the image makefile I use is here:

The device support is not in the PR because I do not have a way of installing the image without opening the device. There is also a fan, which I did not investigate how to control. So I unplugged it because for my tests with maybe 3 Ethernet ports and an SFP port used, a fan is very likely not necessary (and would probably have considerably driven up the number of bugs due to its annoying sound).

Here is a boot-log:

3 Likes

@anon13997276 I checked out merge_pie and then checked out the image Makefile and the dts dir from the xgs1250 branch. Boot still hangs at the same step:

Boot log
II: Copied Preloader data from 0x9fc00000(15804B) to 0x9f000000.
II: Cleared Preloader BSS section at 0x9f003dbc(0B).
II: PLL...�II: PLL is set by SW... OK
Setting DTR
II: DRAM is set by software calibration... PASSED

DCDR(0xb8001060):0x80000000
DIDER(0xb8001050):0x80800000
MCR (0xb8001000):0x200421e0, 0x21220000, 0x65533b30, 0x05050313
DTR2(0xb8001010):0x08311000
PHY Registers(0xb8001500):
0xb8001500:0x80060730, 0x0000007f, 0xa1a00000, 0xffffffff
0xb8001510:0x00180c00, 0x00180c00, 0x001a0d00, 0x00180c00
0xb8001520:0x001a0d00, 0x00160b00, 0x001a0d00, 0x00160b00
0xb8001530:0x00180c00, 0x001a0d00, 0x00160b00, 0x00180c00
0xb8001540:0x00180c00, 0x00180c00, 0x00160b00, 0x00180c00
0xb8001550:0x00180c00, 0x00180c00, 0x001a0d00, 0x00160b00
0xb8001560:0x00180c00, 0x00160b00, 0x001a0d00, 0x00160b00
0xb8001570:0x00180c00, 0x00180c00, 0x00160b00, 0x00180c00
0xb8001580:0x00180c00, 0x00180c00, 0x00160b00, 0x00180c00
0xb8001590:0x00000000, 0x89810525, 0x20202020, 0x5050505a
0xb80015a0:0x5a5a4a4a, 0x00000000, 0x00000000, 0x00000000
II: Selected DRAM model #0.
II: Copying U-Boot from 0x9fc03dbc(225728B) to 0x83f00000... OK
II: NOR SPI Flash... searching flash parameters... supported flash ID: [c22018][c22018][c22018]... detected flash ID: [c22018]... OK


U-Boot 1.0.2-svn45936 (Jan 15 2014 - 16:30:16)

Board: RTL839x CPU:750MHz LXB:200MHz MEM:400MHz
DRAM:  128 MB
SPI-F: 1x16 MB
Loading 1024B env. variables from offset 0x40000
Switch Model: ZyXEL_GS1900_48 (Port Count: 50)
Switch Chip: RTL8393M
Model Info: 83936802
### RTL8218B config - MAC ID = 0 ###
### RTL8218B config - MAC ID = 8 ###
### RTL8218B config - MAC ID = 16 ###
### RTL8218B config - MAC ID = 24 ###
### RTL8218B config - MAC ID = 32 ###
### RTL8218B config - MAC ID = 40 ###
PHY[0]: disable EEE
PHY[1]: disable EEE
PHY[2]: disable EEE
PHY[3]: disable EEE
PHY[4]: disable EEE
PHY[5]: disable EEE
PHY[6]: not supported in EEE
Net:   Net Initialization Skipped
rtl8390#0
Hit any key to stop autoboot:  1  0 
RTL839x#         setenv bootargs console=ttyS0,115200 mem=128M;
RTL839x# setenv ipaddr 192.168.2.16;
RTL839x# setenv serverip 192.168.2.8;
RTL839x# rtk network on;
Enable network
Please wait for PHY init-time ...

RTL839x# tftpboot 0x84f00000 zyxel/kinit.bin;
Using rtl8390#0 device
TFTP from server 192.168.2.8; our IP address is 192.168.2.16
Filename 'zyxel/kinit.bin'.
Load address: 0x84f00000
Loading: *#################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 ######################
done
Bytes transferred = 6043794 (5c3892 hex)
RTL839x# bootm
## Booting kernel from Legacy Image at 84f00000 ...
   Image Name:   MIPS OpenWrt Linux-5.4.143
   Created:      2021-09-11   8:16:17 UTC
   Image Type:   MIPS Linux Kernel Image (gzip compressed)
   Data Size:    6043730 Bytes = 5.8 MB
   Load Address: 80000000
   Entry Point:  80000400
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK

Starting kernel ...

[    0.000000] Linux version 5.4.143 (edwin@medusa) (gcc version 10.3.0 (OpenWrt GCC 10.3.0 r17476-27a99e40f7)) #0 Sat Sep 11 08:16:17 2021
[    0.000000] RTL838X model is ffffffff
[    0.000000] RTL839X model is 83936802
[    0.000000] SoC Type: RTL8393
[    0.000000] Kernel command line: console=ttyS0,115200 mem=128M 
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019555 (MIPS 34Kc)
[    0.000000] MIPS: machine is Zyxel GS1900-48
[    0.000000] Registering _machine_restart
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Using appended Device Tree.
[    0.000000] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] On node 0 totalpages: 32768
[    0.000000]   Normal zone: 288 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 32768 pages, LIFO batch:7
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32480
[    0.000000] Kernel command line: console=ttyS0,115200
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.000000] Writing ErrCtl register=000297f0
[    0.000000] Readback ErrCtl register=000297f0
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 114868K/131072K available (5122K kernel code, 169K rwdata, 1116K rodata, 8240K init, 199K bss, 16204K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 32
[    0.000000] random: get_random_bytes called from start_kernel+0x288/0x468 with crng_init=0
[    0.000000] timer_probe: no matching timers found
[    0.000000] CPU frequency from device tree: 700MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 5460744132 ns
[    0.000008] sched_clock: 32 bits at 350MHz, resolution 2ns, wraps every 6135667710ns
[    0.009211] Calibrating delay loop... 464.48 BogoMIPS (lpj=2322432)
[    0.076462] pid_max: default: 32768 minimum: 301
[    0.082092] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.090664] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.106681] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.118269] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.126369] pinctrl core: initialized pinctrl subsystem
[    0.133084] NET: Registered protocol family 16
[    0.169923] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512
[    0.184951] clocksource: Switched to clocksource MIPS
[    0.192078] NET: Registered protocol family 2
[    0.197302] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.206432] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.216309] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.225302] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.233598] TCP: Hash tables configured (established 1024 bind 1024)
[    0.241266] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.248968] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.257471] NET: Registered protocol family 1
[    0.419211] workingset: timestamp_bits=14 max_order=15 bucket_order=1
[    0.434198] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.441062] jffs2: version 2.2 (NAND) (SUMMARY) (ZLIB) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.473534] pinctrl-single bb001000.pinmux: 32 pins, size 4
[    0.480440] Probing RTL8231 GPIOs
[    0.484265] rtl8231_init called, MDIO bus ID: 3
[    0.491168] Probing RTL838X GPIOs
[    0.534614] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    0.543161] printk: console [ttyS0] disabled
[    0.548224] b8002000.uart: ttyS0 at MMIO 0xb8002000 (irq = 31, base_baud = 12500000) is a 16550A
[    0.558561] printk: console [ttyS0] enabled
[    0.558561] printk: console [ttyS0] enabled
[    0.568497] printk: bootconsole [early0] disabled
[    0.568497] printk: bootconsole [early0] disabled
[    0.580493] b8002100.uart: ttyS1 at MMIO 0xb8002100 (irq = 30, base_baud = 12500000) is a 16550A
[    0.730716] brd: module loaded
[    0.734724] Initializing rtl838x_nor_driver
[    0.739803] SPI resource base is b8001200
[    0.744581] Address mode is 3 bytes
[    0.748763] rtl838x_nor_init called
[    0.757896] rtl838x-nor b8001200.spi: mx25l12805d (16384 Kbytes)
[    0.765157] 7 fixed-partitions partitions found on MTD device rtl838x_nor
[    0.773261] Creating 7 MTD partitions on "rtl838x_nor":
[    0.779535] 0x000000000000-0x000000040000 : "u-boot"
[    0.786542] 0x000000040000-0x000000050000 : "u-boot-env"
[    0.793941] 0x000000050000-0x000000060000 : "u-boot-env2"
[    0.801475] 0x000000060000-0x000000160000 : "jffs"
[    0.808269] 0x000000160000-0x000000260000 : "jffs2"
[    0.815193] 0x000000260000-0x000000930000 : "runtime"
[    0.832549] 0x000000930000-0x000001000000 : "runtime2"
[    0.840938] libphy: Fixed MDIO Bus: probed
[    0.848178] Probing RTL838X eth device pdev: 87c9aa00, dev: 87c9aa10
[    0.872290] Found SoC ID: 8393: RTL8393, family 8390
[    0.878270] Using MAC 0000588bf3fe05d5
[    0.883141] libphy: rtl839x-eth-mdio: probed
[    1.572281] rtl8393_serdes_probe: id: 48
[    1.577038] Realtek RTL8393 SERDES mdio-bus:30: Detected internal RTL8390 SERDES
[    1.598602] rtl8393_serdes_probe: id: 49
[    1.603297] Realtek RTL8393 SERDES mdio-bus:31: Detected internal RTL8390 SERDES
[    1.614613] NET: Registered protocol family 10
[    1.624917] Segment Routing with IPv6
[    1.629454] NET: Registered protocol family 17
[    1.635166] 8021q: 802.1Q VLAN Support v1.8
[    1.641034] i2c-gpio i2c-gpio-0: Slow GPIO pins might wreak havoc into I2C/SMBus bus timing
[    1.651210] i2c-gpio i2c-gpio-0: using lines 184 (SDA) and 185 (SCL)
[    1.659134] i2c-gpio i2c-gpio-1: Slow GPIO pins might wreak havoc into I2C/SMBus bus timing
[    1.669300] i2c-gpio i2c-gpio-1: using lines 190 (SDA) and 191 (SCL)
[    1.677215] libphy: SFP I2C Bus: probed
[    1.682135] sfp sfp-p9: Host maximum power 1.0W
[    1.688006] libphy: SFP I2C Bus: probed
[    1.692955] sfp sfp-p10: Host maximum power 1.0W
[    2.594937] random: fast init done
[  133.794996] random: crng init done

I noticed in the boot log you posted that your GS1900-48 runs a different u-boot version (2.0.0.59413 (Jul 08 2015 - 10:01:28)) than mine (U-Boot 1.0.2-svn45936 (Jan 15 2014 - 16:30:16)). Also, your kernel prints
[ 0.000000] RTL839X model is 83936806,
while mine prints
[ 0.000000] RTL839X model is 83936802.

Looking at the Zyxel web-page there seems to be only one model of the GS1900-48, with only one firmware download. So the difference is not in something that is configured at compile-time such as GPIOs, but in something that is auto-detected and for this the CPU-model is a good candidate. I'll go through their source code to look at whether this might cause differences. Looks like

is a bit simplistic :wink:

So, I figured out that the revision of the RTL8393 chips is given by the last digit of the model number divided by 2.
This gives in your case revision "B" (A is 0) and in mine "D" (because I have version 3).
Unfortunately, it looks as if there is a bigger difference in the features of Chip models < Revision C, one seems to be related to the 10GPort, the other to the PMASK table (it seems broken in revisions < C).

Could you try the following:
In target/linux/realtek/files-5.4/drivers/net/dsa/rtl83xx/rtl839x.c edit function
rtl839x_write_mcast_pmask
to do nothing by commenting everything in {} out with /* */
and in function rtl839x_write_read_pmask
return 0x001fffffffffffff and comment everything else out?

If this does not work, you would need to help me figure out where it hangs by putting pr_info() into the code until you find the place it hangs.

May be the same issue as Switch-M48eG PN28480K.

bootlog


U-Boot 2011.12.46351-1.00.09-svn5722 (Mar 12 2015 - 20:08:54)

Board: RTL839x CPU:700MHz LXB:200MHz MEM:400MHz
DRAM:  128 MB
SPI-F: 1x32 MB
Loading 65536B env. variables from offset 0x80000
#### Periphery Devices Init Successfully #### 
Switch Model: RTL8393M_8218B_8218FB_2SFP (Port Count: 48)
Switch Chip: RTL8393M
Model Info: 83936802
### RTL8218B config - MAC ID = 0 ###
### RTL8218B config - MAC ID = 8 ###
### RTL8218B config - MAC ID = 16 ###
### RTL8218B config - MAC ID = 24 ###
### RTL8218B config - MAC ID = 32 ###
### RTL8218FB config - MAC ID = 40 ###
PHY[0]: disable EEE
PHY[1]: disable EEE
PHY[2]: disable EEE
PHY[3]: disable EEE
PHY[4]: disable EEE
PHY[5]: disable EEE
RTL839x# # rtk network on
Enable network
Please wait for PHY init-time ...

RTL839x# # tftp 0x81000000
*** Warning: no boot file name; using '0101A8C0.img'
Using rtl8390#0 device
TFTP from server 192.168.1.111; our IP address is 192.168.1.1
Filename '0101A8C0.img'.
Load address: 0x81000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ############################################
done
Bytes transferred = 6362748 (61167c hex)
RTL839x# # bootm
## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   MIPS OpenWrt Linux-5.4.143
   Created:      2021-09-12  13:37:17 UTC
   Image Type:   MIPS Linux Kernel Image (gzip compressed)
   Data Size:    6362684 Bytes = 6.1 MB
   Load Address: 80000000
   Entry Point:  80000400
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK

Starting kernel ...

[    0.000000] Linux version 5.4.143 (musashino205@TAIHA.NET) (gcc version 10.3.0 (OpenWrt GCC 10.3.0 r17396+47-98eb95dd00)) #0 Sun Sep 12 13:37:17 2021
[    0.000000] RTL838X model is ffffffff
[    0.000000] RTL839X model is 83936802
[    0.000000] SoC Type: RTL8393
[    0.000000] Kernel command line: 
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019555 (MIPS 34Kc)
[    0.000000] MIPS: machine is Panasonic Switch-M48eG PN28480K
[    0.000000] Registering _machine_restart
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Using appended Device Tree.
[    0.000000] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] On node 0 totalpages: 32768
[    0.000000]   Normal zone: 288 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 32768 pages, LIFO batch:7
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32480
[    0.000000] Kernel command line: console=ttyS0,9600
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.000000] Writing ErrCtl register=0001fd86
[    0.000000] Readback ErrCtl register=0001fd86
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 113520K/131072K available (5156K kernel code, 191K rwdata, 1168K rodata, 9476K init, 199K bss, 17552K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 32
[    0.000000] random: get_random_bytes called from start_kernel+0x288/0x468 with crng_init=0
[    0.000000] timer_probe: no matching timers found
[    0.000000] CPU frequency from device tree: 700MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 5460744132 ns
[    0.000008] sched_clock: 32 bits at 350MHz, resolution 2ns, wraps every 6135667710ns
[    0.102036] Calibrating delay loop... 464.48 BogoMIPS (lpj=2322432)
[    0.243325] pid_max: default: 32768 minimum: 301
[    0.304248] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.400321] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.510664] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.638977] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.728466] pinctrl core: initialized pinctrl subsystem
[    0.797699] NET: Registered protocol family 16
[    0.889654] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512
[    1.019532] clocksource: Switched to clocksource MIPS
[    1.086319] NET: Registered protocol family 2
[    1.142687] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    1.238227] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    1.347629] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    1.448405] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    1.541205] TCP: Hash tables configured (established 1024 bind 1024)
[    1.625003] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    1.710824] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    1.802783] NET: Registered protocol family 1
[    2.108820] workingset: timestamp_bits=14 max_order=15 bucket_order=1
[    2.200297] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    2.275960] jffs2: version 2.2 (NAND) (SUMMARY) (ZLIB) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    2.434125] pinctrl-single bb000004.pinmux: 32 pins, size 4
[    2.506796] Probing RTL838X GPIOs
[    2.592639] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    2.676288] printk: console [ttyS0] disabled
[    2.731406] b8002000.uart: ttyS0 at MMIO 0xb8002000 (irq = 31, base_baud = 12500000) is a 16550A
[    2.847078] printk: console [ttyS0] enabled
[    2.847078] printk: console [ttyS0] enabled
[    2.957124] printk: bootconsole [early0] disabled
[    2.957124] printk: bootconsole [early0] disabled
[    3.081814] b8002100.uart: ttyS1 at MMIO 0xb8002100 (irq = 30, base_baud = 12500000) is a 16550A
[    3.351180] brd: module loaded
[    3.391738] Initializing rtl838x_nor_driver
[    3.446885] SPI resource base is b8001200
[    3.499680] Address mode is 4 bytes
[    3.545536] rtl838x_nor_init called
[    3.596596] rtl838x-nor b8001200.spi: mx25l25635e (32768 Kbytes)
[    3.675848] 8 fixed-partitions partitions found on MTD device rtl838x_nor
[    3.765294] Creating 8 MTD partitions on "rtl838x_nor":
[    3.834097] 0x000000000000-0x000000080000 : "u-boot"
[    3.900564] 0x000000080000-0x000000090000 : "u-boot-env"
[    3.971649] 0x000000090000-0x0000000a0000 : "u-boot-env2"
[    4.043847] 0x0000000a0000-0x000000100000 : "sysinfo"
[    4.111452] 0x000000100000-0x000000e00000 : "fs_reserved"
[    4.183652] 0x000000e00000-0x000001e00000 : "firmware"
[    4.268353] 0x000001e00000-0x000001f00000 : "vlog_data"
[    4.338306] 0x000001f00000-0x000002000000 : "elog_data"
[    4.409086] libphy: Fixed MDIO Bus: probed
[    4.465363] Probing RTL838X eth device pdev: 87ca4800, dev: 87ca4810
[    4.557479] Found SoC ID: 8393: RTL8393, family 8390
[    4.622894] Using MAC 0000005040101ab6
[    4.672330] libphy: rtl839x-eth-mdio: probed
[    5.482638] NET: Registered protocol family 10
[    5.546024] Segment Routing with IPv6
[    5.594322] NET: Registered protocol family 17
[    5.653138] 8021q: 802.1Q VLAN Support v1.8
[    5.708991] i2c-gpio i2c-gpio-0: Slow GPIO pins might wreak havoc into I2C/SMBus bus timing
[    5.819498] i2c-gpio i2c-gpio-0: using lines 23 (SDA) and 22 (SCL)
[    5.901178] i2c-gpio i2c-gpio-1: Slow GPIO pins might wreak havoc into I2C/SMBus bus timing
[    6.011613] pca953x 1-0020: using no AI
[    6.063773] pca953x 1-0075: using no AI
[    6.115478] GPIO line 492 (ext-switch-reset) hogged as output/high
[    6.197274] GPIO line 494 (portled-sregister-reset) hogged as output/high
[    6.287329] i2c-gpio i2c-gpio-1: using lines 9 (SDA) and 8 (SCL)
[    6.929560] random: fast init done
[  138.159580] random: crng init done

You meant rtl839x_read_mcast_pmask, right?
I compiled with the modifications. It's still the same.

Boot log
II: Copied Preloader data from 0x9fc00000(15804B) to 0x9f000000.
II: Cleared Preloader BSS section at 0x9f003dbc(0B).
II: PLL...�II: PLL is set by SW... OK
Setting DTR
II: DRAM is set by software calibration... PASSED

DCDR(0xb8001060):0x80000000
DIDER(0xb8001050):0x80800000
MCR (0xb8001000):0x200421e0, 0x21220000, 0x65533b30, 0x05050313
DTR2(0xb8001010):0x08311000
PHY Registers(0xb8001500):
0xb8001500:0x80060730, 0x0000007f, 0xa1a00000, 0xffffffff
0xb8001510:0x001a0d00, 0x001a0d00, 0x001a0d00, 0x00180c00
0xb8001520:0x001c0e00, 0x00180c00, 0x001c0e00, 0x00180c00
0xb8001530:0x00180c00, 0x001a0d00, 0x00180c00, 0x001a0d00
0xb8001540:0x001a0d00, 0x001a0d00, 0x00180c00, 0x001a0d00
0xb8001550:0x00180c00, 0x00180c00, 0x001a0d00, 0x00160b00
0xb8001560:0x00180c00, 0x00160b00, 0x001a0d00, 0x00160b00
0xb8001570:0x00180c00, 0x00180c00, 0x00160b00, 0x00180c00
0xb8001580:0x00160b00, 0x00180c00, 0x00160b00, 0x00180c00
0xb8001590:0x00000000, 0x09498696, 0xa0a01850, 0x5050acad
0xb80015a0:0x5252a5a5, 0x00000000, 0x00000000, 0x00000000
II: Selected DRAM model #0.
II: Copying U-Boot from 0x9fc03dbc(225728B) to 0x83f00000... OK
II: NOR SPI Flash... searching flash parameters... supported flash ID: [c22018][c22018][c22018]... detected flash ID: [c22018]... OK


U-Boot 1.0.2-svn45936 (Jan 15 2014 - 16:30:16)

Board: RTL839x CPU:750MHz LXB:200MHz MEM:400MHz
DRAM:  128 MB
SPI-F: 1x16 MB
Loading 1024B env. variables from offset 0x40000
Switch Model: ZyXEL_GS1900_48 (Port Count: 50)
Switch Chip: RTL8393M
Model Info: 83936802
### RTL8218B config - MAC ID = 0 ###
### RTL8218B config - MAC ID = 8 ###
### RTL8218B config - MAC ID = 16 ###
### RTL8218B config - MAC ID = 24 ###
### RTL8218B config - MAC ID = 32 ###
### RTL8218B config - MAC ID = 40 ###
PHY[0]: disable EEE
PHY[1]: disable EEE
PHY[2]: disable EEE
PHY[3]: disable EEE
PHY[4]: disable EEE
PHY[5]: disable EEE
PHY[6]: not supported in EEE
Net:   Net Initialization Skipped
rtl8390#0
Hit any key to stop autoboot:  1  0 
RTL839x#       setenv bootargs console=ttyS0,115200 mem=128M;
RTL839x# setenv ipaddr 192.168.2.16;
RTL839x# setenv serverip 192.168.2.8;
RTL839x# rtk network on;
Enable network
Please wait for PHY init-time ...

RTL839x# tftpboot 0x84f00000 zyxel/kinit.bin;
Using rtl8390#0 device
TFTP from server 192.168.2.8; our IP address is 192.168.2.16
Filename 'zyxel/kinit.bin'.
Load address: 0x84f00000
Loading: *#################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 ######################
done
Bytes transferred = 6043077 (5c35c5 hex)
RTL839x# bootm
## Booting kernel from Legacy Image at 84f00000 ...
   Image Name:   MIPS OpenWrt Linux-5.4.143
   Created:      2021-09-11   8:16:17 UTC
   Image Type:   MIPS Linux Kernel Image (gzip compressed)
   Data Size:    6043013 Bytes = 5.8 MB
   Load Address: 80000000
   Entry Point:  80000400
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK

Starting kernel ...

[    0.000000] Linux version 5.4.143 (edwin@medusa) (gcc version 10.3.0 (OpenWrt GCC 10.3.0 r17476-27a99e40f7)) #0 Sat Sep 11 08:16:17 2021
[    0.000000] RTL838X model is ffffffff
[    0.000000] RTL839X model is 83936802
[    0.000000] SoC Type: RTL8393
[    0.000000] Kernel command line: console=ttyS0,115200 mem=128M 
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019555 (MIPS 34Kc)
[    0.000000] MIPS: machine is Zyxel GS1900-48
[    0.000000] Registering _machine_restart
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Using appended Device Tree.
[    0.000000] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] On node 0 totalpages: 32768
[    0.000000]   Normal zone: 288 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 32768 pages, LIFO batch:7
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32480
[    0.000000] Kernel command line: console=ttyS0,115200
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.000000] Writing ErrCtl register=00000004
[    0.000000] Readback ErrCtl register=00000004
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 114868K/131072K available (5122K kernel code, 169K rwdata, 1116K rodata, 8240K init, 199K bss, 16204K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 32
[    0.000000] random: get_random_bytes called from start_kernel+0x288/0x468 with crng_init=0
[    0.000000] timer_probe: no matching timers found
[    0.000000] CPU frequency from device tree: 700MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 5460744132 ns
[    0.000007] sched_clock: 32 bits at 350MHz, resolution 2ns, wraps every 6135667710ns
[    0.009211] Calibrating delay loop... 464.48 BogoMIPS (lpj=2322432)
[    0.076464] pid_max: default: 32768 minimum: 301
[    0.082090] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.090663] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.107340] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.118924] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.127023] pinctrl core: initialized pinctrl subsystem
[    0.133736] NET: Registered protocol family 16
[    0.170738] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512
[    0.185800] clocksource: Switched to clocksource MIPS
[    0.192943] NET: Registered protocol family 2
[    0.198175] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.207306] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.217178] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.226170] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.234468] TCP: Hash tables configured (established 1024 bind 1024)
[    0.242136] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.249837] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.258344] NET: Registered protocol family 1
[    0.422096] workingset: timestamp_bits=14 max_order=15 bucket_order=1
[    0.437146] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.443947] jffs2: version 2.2 (NAND) (SUMMARY) (ZLIB) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.477215] pinctrl-single bb001000.pinmux: 32 pins, size 4
[    0.484047] Probing RTL8231 GPIOs
[    0.487928] rtl8231_init called, MDIO bus ID: 3
[    0.494733] Probing RTL838X GPIOs
[    0.540625] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    0.549183] printk: console [ttyS0] disabled
[    0.554177] b8002000.uart: ttyS0 at MMIO 0xb8002000 (irq = 31, base_baud = 12500000) is a 16550A
[    0.564589] printk: console [ttyS0] enabled
[    0.564589] printk: console [ttyS0] enabled
[    0.574495] printk: bootconsole [early0] disabled
[    0.574495] printk: bootconsole [early0] disabled
[    0.586527] b8002100.uart: ttyS1 at MMIO 0xb8002100 (irq = 30, base_baud = 12500000) is a 16550A
[    0.738409] brd: module loaded
[    0.742423] Initializing rtl838x_nor_driver
[    0.747496] SPI resource base is b8001200
[    0.752276] Address mode is 3 bytes
[    0.756468] rtl838x_nor_init called
[    0.765567] rtl838x-nor b8001200.spi: mx25l12805d (16384 Kbytes)
[    0.772842] 7 fixed-partitions partitions found on MTD device rtl838x_nor
[    0.780977] Creating 7 MTD partitions on "rtl838x_nor":
[    0.787243] 0x000000000000-0x000000040000 : "u-boot"
[    0.794232] 0x000000040000-0x000000050000 : "u-boot-env"
[    0.801712] 0x000000050000-0x000000060000 : "u-boot-env2"
[    0.809260] 0x000000060000-0x000000160000 : "jffs"
[    0.816088] 0x000000160000-0x000000260000 : "jffs2"
[    0.822942] 0x000000260000-0x000000930000 : "runtime"
[    0.840451] 0x000000930000-0x000001000000 : "runtime2"
[    0.848874] libphy: Fixed MDIO Bus: probed
[    0.856117] Probing RTL838X eth device pdev: 87c9aa00, dev: 87c9aa10
[    0.880200] Found SoC ID: 8393: RTL8393, family 8390
[    0.886171] Using MAC 0000588bf3fe05d5
[    0.891046] libphy: rtl839x-eth-mdio: probed
[    1.580963] rtl8393_serdes_probe: id: 48
[    1.585658] Realtek RTL8393 SERDES mdio-bus:30: Detected internal RTL8390 SERDES
[    1.607282] rtl8393_serdes_probe: id: 49
[    1.611973] Realtek RTL8393 SERDES mdio-bus:31: Detected internal RTL8390 SERDES
[    1.623281] NET: Registered protocol family 10
[    1.633692] Segment Routing with IPv6
[    1.638235] NET: Registered protocol family 17
[    1.643845] 8021q: 802.1Q VLAN Support v1.8
[    1.649639] i2c-gpio i2c-gpio-0: Slow GPIO pins might wreak havoc into I2C/SMBus bus timing
[    1.659807] i2c-gpio i2c-gpio-0: using lines 184 (SDA) and 185 (SCL)
[    1.667733] i2c-gpio i2c-gpio-1: Slow GPIO pins might wreak havoc into I2C/SMBus bus timing
[    1.677896] i2c-gpio i2c-gpio-1: using lines 190 (SDA) and 191 (SCL)
[    1.685747] libphy: SFP I2C Bus: probed
[    1.690725] sfp sfp-p9: Host maximum power 1.0W
[    1.696588] libphy: SFP I2C Bus: probed
[    1.701538] sfp sfp-p10: Host maximum power 1.0W
[    2.605786] random: fast init done
[  133.805843] random: crng init done

Would you show me where I have to put it?

@anon13997276 @musashino's patch worked. Boot log

Going to do some testing now.

I couldn't flash the sysupgrade after tftpbooting the ramdisk:

Sun Sep 12 15:58:44 UTC 2021 upgrade: Sending signal TERM to ntpd (3551)
[   81.320966] rtl83xx_fib4_del: found a route with id 3, nh-id 0
[   81.327953] rtl83xx-switch switch@bb000000: unknown nexthop, id 0
Sun Sep 12 15:58:48 UTC 2021 upgrade: Sending KILL to remaining processes ...
[   91.439890] sh (3664): drop_caches: 3
Sun Sep 12 15:58:54 UTC 2021 upgrade: Switching to ramdisk...
Sun Sep 12 15:58:57 UTC 2021 upgrade: Performing system upgrade...
[   93.670147] sh (3664): drop_caches: 3
Could not open mtd device: firmware
Can't open device for writing!
cat: write error: Broken [   93.700976] reboot: Restarting system
p[   93.705374] System restart.

It looks like sysupgrade is not aware of the partition layout and firmware is just a generic placeholder:

root@OpenWrt:/# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 00040000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00010000 00010000 "u-boot-env2"
mtd3: 00100000 00010000 "jffs"
mtd4: 00100000 00010000 "jffs2"
mtd5: 006d0000 00010000 "runtime"
mtd6: 006d0000 00010000 "runtime2"

So you mean that instead of 64 in this patch:

we should be using only 52? Did you try 56? Because that would be the maximum number that the RTL839x can support.
Maybe there is a different solution, because in principle this should not hang, just because there is nothing on that bus at a given PHY-id...

I think you need to just rename the partition "runtime" to "firmware" in rtl8393_zyxel_gs1900-48.dts .
Have a look how this is done in rtl8380_zyxel_gs1900.dtsi

To be honest, I have no idea about it...

No I didn't, I'll try :slight_smile:

I tried to use 56 instead of 52, but the kernel hangs. I've also tried to skip 52 while scanning phys in mdio_bus.c in kernel, but hangs when trying to scan phy 53.

from modified mdio_bus.c:

	for (i = 0; i < PHY_MAX_ADDR; i++) {
		if (i == 52) {
			dev_info(&bus->dev, "skipping phy 52\n");
			continue;
		}
		if ((bus->phy_mask & (1 << i)) == 0) {
			struct phy_device *phydev;

			phydev = mdiobus_scan(bus, i);
			dev_info(&bus->dev, "scanned phy %d\n", i);
			if (IS_ERR(phydev) && (PTR_ERR(phydev) != -ENODEV)) {
				err = PTR_ERR(phydev);
				goto error;
			}
		}
	}

bootlog on Switch-M48eG PN28480K (PHY_MAX_ADDR=56, skip 52)

U-Boot 2011.12.46351-1.00.09-svn5722 (Mar 12 2015 - 20:08:54)

Board: RTL839x CPU:700MHz LXB:200MHz MEM:400MHz
DRAM:  128 MB
SPI-F: 1x32 MB
Loading 65536B env. variables from offset 0x80000
#### Periphery Devices Init Successfully #### 
Switch Model: RTL8393M_8218B_8218FB_2SFP (Port Count: 48)
Switch Chip: RTL8393M
Model Info: 83936802
### RTL8218B config - MAC ID = 0 ###
### RTL8218B config - MAC ID = 8 ###
### RTL8218B config - MAC ID = 16 ###
### RTL8218B config - MAC ID = 24 ###
### RTL8218B config - MAC ID = 32 ###
### RTL8218FB config - MAC ID = 40 ###
PHY[0]: disable EEE
PHY[1]: disable EEE
PHY[2]: disable EEE
PHY[3]: disable EEE
PHY[4]: disable EEE
PHY[5]: disable EEE
RTL839x# # rtk network on
Enable network
Please wait for PHY init-time ...

RTL839x# # tftp 0x81000000
*** Warning: no boot file name; using '0101A8C0.img'
Using rtl8390#0 device
TFTP from server 192.168.1.111; our IP address is 192.168.1.1
Filename '0101A8C0.img'.
Load address: 0x81000000
Loading: T #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ############################################
done
Bytes transferred = 6362670 (61162e hex)
RTL839x# # bootm
## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   MIPS OpenWrt Linux-5.4.143
   Created:      2021-09-12  13:37:17 UTC
   Image Type:   MIPS Linux Kernel Image (gzip compressed)
   Data Size:    6362606 Bytes = 6.1 MB
   Load Address: 80000000
   Entry Point:  80000400
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK

Starting kernel ...

[    0.000000] Linux version 5.4.143 (musashino205@TAIHA.NET) (gcc version 10.3.0 (OpenWrt GCC 10.3.0 r17396+47-98eb95dd00)) #0 Sun Sep 12 13:37:17 2021
[    0.000000] RTL838X model is ffffffff
[    0.000000] RTL839X model is 83936802
[    0.000000] SoC Type: RTL8393
[    0.000000] Kernel command line: 
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019555 (MIPS 34Kc)
[    0.000000] MIPS: machine is Panasonic Switch-M48eG PN28480K
[    0.000000] Registering _machine_restart
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Using appended Device Tree.
[    0.000000] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] On node 0 totalpages: 32768
[    0.000000]   Normal zone: 288 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 32768 pages, LIFO batch:7
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32480
[    0.000000] Kernel command line: console=ttyS0,9600
[    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.000000] Writing ErrCtl register=00039f95
[    0.000000] Readback ErrCtl register=00039f95
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 113520K/131072K available (5156K kernel code, 191K rwdata, 1168K rodata, 9476K init, 199K bss, 17552K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 32
[    0.000000] random: get_random_bytes called from start_kernel+0x288/0x468 with crng_init=0
[    0.000000] timer_probe: no matching timers found
[    0.000000] CPU frequency from device tree: 700MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 5460744132 ns
[    0.000008] sched_clock: 32 bits at 350MHz, resolution 2ns, wraps every 6135667710ns
[    0.102037] Calibrating delay loop... 464.48 BogoMIPS (lpj=2322432)
[    0.243327] pid_max: default: 32768 minimum: 301
[    0.304252] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.400322] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.510702] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.639082] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.728569] pinctrl core: initialized pinctrl subsystem
[    0.797804] NET: Registered protocol family 16
[    0.889752] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512
[    1.019612] clocksource: Switched to clocksource MIPS
[    1.086427] NET: Registered protocol family 2
[    1.142792] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    1.238330] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    1.347735] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    1.448510] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    1.541310] TCP: Hash tables configured (established 1024 bind 1024)
[    1.625110] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    1.710929] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    1.802890] NET: Registered protocol family 1
[    2.108905] workingset: timestamp_bits=14 max_order=15 bucket_order=1
[    2.200345] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    2.275960] jffs2: version 2.2 (NAND) (SUMMARY) (ZLIB) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    2.434263] pinctrl-single bb000004.pinmux: 32 pins, size 4
[    2.506900] Probing RTL838X GPIOs
[    2.592854] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    2.676503] printk: console [ttyS0] disabled
[    2.731615] b8002000.uart: ttyS0 at MMIO 0xb8002000 (irq = 31, base_baud = 12500000) is a 16550A
[    2.847287] printk: console [ttyS0] enabled
[    2.847287] printk: console [ttyS0] enabled
[    2.957332] printk: bootconsole [early0] disabled
[    2.957332] printk: bootconsole [early0] disabled
[    3.082025] b8002100.uart: ttyS1 at MMIO 0xb8002100 (irq = 30, base_baud = 12500000) is a 16550A
[    3.352441] brd: module loaded
[    3.393097] Initializing rtl838x_nor_driver
[    3.448239] SPI resource base is b8001200
[    3.500931] Address mode is 4 bytes
[    3.546787] rtl838x_nor_init called
[    3.597325] rtl838x-nor b8001200.spi: mx25l25635e (32768 Kbytes)
[    3.676580] 8 fixed-partitions partitions found on MTD device rtl838x_nor
[    3.766025] Creating 8 MTD partitions on "rtl838x_nor":
[    3.834828] 0x000000000000-0x000000080000 : "u-boot"
[    3.901270] 0x000000080000-0x000000090000 : "u-boot-env"
[    3.972370] 0x000000090000-0x0000000a0000 : "u-boot-env2"
[    4.044591] 0x0000000a0000-0x000000100000 : "sysinfo"
[    4.112288] 0x000000100000-0x000000e00000 : "fs_reserved"
[    4.184483] 0x000000e00000-0x000001e00000 : "firmware"
[    4.269052] 0x000001e00000-0x000001f00000 : "vlog_data"
[    4.339056] 0x000001f00000-0x000002000000 : "elog_data"
[    4.409873] mdio_bus fixed-0: scanned phy 0
[    4.464968] mdio_bus fixed-0: scanned phy 1
[    4.519984] mdio_bus fixed-0: scanned phy 2
[    4.575020] mdio_bus fixed-0: scanned phy 3
[    4.630062] mdio_bus fixed-0: scanned phy 4
[    4.685097] mdio_bus fixed-0: scanned phy 5
[    4.740139] mdio_bus fixed-0: scanned phy 6
[    4.795175] mdio_bus fixed-0: scanned phy 7
[    4.850219] mdio_bus fixed-0: scanned phy 8
[    4.905252] mdio_bus fixed-0: scanned phy 9
[    4.960294] mdio_bus fixed-0: scanned phy 10
[    5.016477] mdio_bus fixed-0: scanned phy 11
[    5.072664] mdio_bus fixed-0: scanned phy 12
[    5.128848] mdio_bus fixed-0: scanned phy 13
[    5.185035] mdio_bus fixed-0: scanned phy 14
[    5.241221] mdio_bus fixed-0: scanned phy 15
[    5.297404] mdio_bus fixed-0: scanned phy 16
[    5.353591] mdio_bus fixed-0: scanned phy 17
[    5.409776] mdio_bus fixed-0: scanned phy 18
[    5.465961] mdio_bus fixed-0: scanned phy 19
[    5.522148] mdio_bus fixed-0: scanned phy 20
[    5.578330] mdio_bus fixed-0: scanned phy 21
[    5.634517] mdio_bus fixed-0: scanned phy 22
[    5.690703] mdio_bus fixed-0: scanned phy 23
[    5.746889] mdio_bus fixed-0: scanned phy 24
[    5.803075] mdio_bus fixed-0: scanned phy 25
[    5.859260] mdio_bus fixed-0: scanned phy 26
[    5.915445] mdio_bus fixed-0: scanned phy 27
[    5.971631] mdio_bus fixed-0: scanned phy 28
[    6.027814] mdio_bus fixed-0: scanned phy 29
[    6.084002] mdio_bus fixed-0: scanned phy 30
[    6.140187] mdio_bus fixed-0: scanned phy 31
[    6.196369] mdio_bus fixed-0: scanned phy 32
[    6.252557] mdio_bus fixed-0: scanned phy 33
[    6.308741] mdio_bus fixed-0: scanned phy 34
[    6.364928] mdio_bus fixed-0: scanned phy 35
[    6.421113] mdio_bus fixed-0: scanned phy 36
[    6.477297] mdio_bus fixed-0: scanned phy 37
[    6.533483] mdio_bus fixed-0: scanned phy 38
[    6.589669] mdio_bus fixed-0: scanned phy 39
[    6.645853] mdio_bus fixed-0: scanned phy 40
[    6.702040] mdio_bus fixed-0: scanned phy 41
[    6.758223] mdio_bus fixed-0: scanned phy 42
[    6.814410] mdio_bus fixed-0: scanned phy 43
[    6.870597] mdio_bus fixed-0: scanned phy 44
[    6.926780] mdio_bus fixed-0: scanned phy 45
[    6.982967] mdio_bus fixed-0: scanned phy 46
[    7.039157] mdio_bus fixed-0: scanned phy 47
[    7.095337] mdio_bus fixed-0: scanned phy 48
[    7.151523] mdio_bus fixed-0: scanned phy 49
[    7.207706] mdio_bus fixed-0: scanned phy 50
[    7.263893] mdio_bus fixed-0: scanned phy 51
[    7.320076] mdio_bus fixed-0: skipping phy 52
[    7.377408] mdio_bus fixed-0: scanned phy 53
[    7.433596] mdio_bus fixed-0: scanned phy 54
[    7.489781] mdio_bus fixed-0: scanned phy 55
[    7.545959] libphy: Fixed MDIO Bus: probed
[    7.602229] Probing RTL838X eth device pdev: 87ca4800, dev: 87ca4810
[    7.694367] Found SoC ID: 8393: RTL8393, family 8390
[    7.759789] Using MAC 0000005040101ab6
[    7.809229] mdio_bus mdio-bus: skipping phy 52
[    7.867774] libphy: rtl839x-eth-mdio: probed
[    8.675882] NET: Registered protocol family 10
[    8.739312] Segment Routing with IPv6
[    8.787623] NET: Registered protocol family 17
[    8.846539] 8021q: 802.1Q VLAN Support v1.8
[    8.902401] i2c-gpio i2c-gpio-0: Slow GPIO pins might wreak havoc into I2C/SMBus bus timing
[    9.012889] i2c-gpio i2c-gpio-0: using lines 23 (SDA) and 22 (SCL)
[    9.094600] i2c-gpio i2c-gpio-1: Slow GPIO pins might wreak havoc into I2C/SMBus bus timing
[    9.205114] pca953x 1-0020: using no AI
[    9.257268] pca953x 1-0075: using no AI
[    9.308974] GPIO line 492 (ext-switch-reset) hogged as output/high
[    9.390773] GPIO line 494 (portled-sregister-reset) hogged as output/high
[    9.480819] i2c-gpio i2c-gpio-1: using lines 9 (SDA) and 8 (SCL)
[    9.579440] mdio_bus rtl838x slave mii-0: scanned phy 0
[    9.648298] random: fast init done
[    9.708091] mdio_bus rtl838x slave mii-0: scanned phy 1
[    9.792398] mdio_bus rtl838x slave mii-0: scanned phy 2
[    9.876275] mdio_bus rtl838x slave mii-0: scanned phy 3
[    9.960560] mdio_bus rtl838x slave mii-0: scanned phy 4
[   10.044437] mdio_bus rtl838x slave mii-0: scanned phy 5
[   10.128741] mdio_bus rtl838x slave mii-0: scanned phy 6
[   10.213021] mdio_bus rtl838x slave mii-0: scanned phy 7
[   10.296910] mdio_bus rtl838x slave mii-0: scanned phy 8
[   10.381186] mdio_bus rtl838x slave mii-0: scanned phy 9
[   10.465063] mdio_bus rtl838x slave mii-0: scanned phy 10
[   10.550625] mdio_bus rtl838x slave mii-0: scanned phy 11
[   10.635772] mdio_bus rtl838x slave mii-0: scanned phy 12
[   10.721345] mdio_bus rtl838x slave mii-0: scanned phy 13
[   10.806464] mdio_bus rtl838x slave mii-0: scanned phy 14
[   10.892028] mdio_bus rtl838x slave mii-0: scanned phy 15
[   10.977588] mdio_bus rtl838x slave mii-0: scanned phy 16
[   11.063171] mdio_bus rtl838x slave mii-0: scanned phy 17
[   11.148714] mdio_bus rtl838x slave mii-0: scanned phy 18
[   11.234277] mdio_bus rtl838x slave mii-0: scanned phy 19
[   11.319416] mdio_bus rtl838x slave mii-0: scanned phy 20
[   11.404564] mdio_bus rtl838x slave mii-0: scanned phy 21
[   11.489791] mdio_bus rtl838x slave mii-0: scanned phy 22
[   11.574838] mdio_bus rtl838x slave mii-0: scanned phy 23
[   11.660435] mdio_bus rtl838x slave mii-0: scanned phy 24
[   11.745993] mdio_bus rtl838x slave mii-0: scanned phy 25
[   11.831560] mdio_bus rtl838x slave mii-0: scanned phy 26
[   11.916717] mdio_bus rtl838x slave mii-0: scanned phy 27
[   12.002259] mdio_bus rtl838x slave mii-0: scanned phy 28
[   12.087402] mdio_bus rtl838x slave mii-0: scanned phy 29
[   12.172968] mdio_bus rtl838x slave mii-0: scanned phy 30
[   12.258546] mdio_bus rtl838x slave mii-0: scanned phy 31
[   12.344085] mdio_bus rtl838x slave mii-0: scanned phy 32
[   12.429710] mdio_bus rtl838x slave mii-0: scanned phy 33
[   12.515211] mdio_bus rtl838x slave mii-0: scanned phy 34
[   12.600779] mdio_bus rtl838x slave mii-0: scanned phy 35
[   12.686350] mdio_bus rtl838x slave mii-0: scanned phy 36
[   12.771913] mdio_bus rtl838x slave mii-0: scanned phy 37
[   12.857064] mdio_bus rtl838x slave mii-0: scanned phy 38
[   12.942602] mdio_bus rtl838x slave mii-0: scanned phy 39
[   13.028162] mdio_bus rtl838x slave mii-0: scanned phy 40
[   13.113746] mdio_bus rtl838x slave mii-0: scanned phy 41
[   13.198867] mdio_bus rtl838x slave mii-0: scanned phy 42
[   13.284006] mdio_bus rtl838x slave mii-0: scanned phy 43
[   13.369156] mdio_bus rtl838x slave mii-0: scanned phy 44
[   13.454304] mdio_bus rtl838x slave mii-0: scanned phy 45
[   13.539432] mdio_bus rtl838x slave mii-0: scanned phy 46
[   13.624571] mdio_bus rtl838x slave mii-0: scanned phy 47
[   13.695407] mdio_bus rtl838x slave mii-0: scanned phy 48
[   13.766106] mdio_bus rtl838x slave mii-0: scanned phy 49
[   13.836805] mdio_bus rtl838x slave mii-0: scanned phy 50
[   13.907504] mdio_bus rtl838x slave mii-0: scanned phy 51
[   13.977470] mdio_bus rtl838x slave mii-0: skipping phy 52
[  142.639659] random: crng init done

Could you try to figure out where it actually hangs. I guess it goes into mdiobus_scan(), which will probably try to identify PHYs on the MDIO/SMI bus. My present working assumption is that the hardware on some SoCs is not able to handle such requests. Could you follow this down into the driver code until you hit some register calls (sw_w32()/sw_r32())? Unfortunately my two 839x switches are not affected, so I am not able to test.

Side remark: I managed yesterday to enable 10GBit on the 3 Zyxel XGS1250-12 ports and it works together with my QNAP 10GBit PCI card :smile: Now I am on the 10GBit fibre port...

5 Likes

OK, I'll try :wink:

2 Likes

I tried to find, the kernel hangs while reading phy id in get_phy_id in phy_device.c.

mdiobus_scan (mdio_bus.c) -> get_phy_device (phy_device.c) -> get_phy_id (phy_device.c)

rtl839x_read_phy in dsa/rtl83xx/rt839x.c is called to read id and hangs at do-while loop for reading bit 0 in RTL839X_PHYREG_ACCESS_CTRL.

modified rtl839x_read_phy
int rtl839x_read_phy(u32 port, u32 page, u32 reg, u32 *val)
{
	u32 v;

	if (port >= 50)
		pr_info("In %s: port %d, page %04x, reg %04x, val %04x\n",
			__func__, port, page, reg, val);
	if (port > 63 || page > 4095 || reg > 31)
		return -ENOTSUPP;

	mutex_lock(&smi_lock);

	sw_w32_mask(0xffff0000, port << 16, RTL839X_PHYREG_DATA_CTRL);
	if (port >= 50)
		pr_info("  wrote RTL839X_PHYREG_DATA_CTRL\n");
	v = reg << 5 | page << 10 | ((page == 0x1fff) ? 0x1f : 0) << 23;
	sw_w32(v, RTL839X_PHYREG_ACCESS_CTRL);
	if (port >= 50)
		pr_info("  wrote RTL839X_PHYREG_ACCESS_CTRL\n");

	sw_w32(0x1ff, RTL839X_PHYREG_CTRL);
	if (port >= 50)
		pr_info("  wrote RTL839X_PHYREG_CTRL\n");

	v |= 1;
	sw_w32(v, RTL839X_PHYREG_ACCESS_CTRL);
	if (port >= 50)
		pr_info("  wrote RTL839X_PHYREG_ACCESS_CTRL\n");

	do {
	} while (sw_r32(RTL839X_PHYREG_ACCESS_CTRL) & 0x1);
	if (port >= 50)
		pr_info("  exit RTL839X_PHYREG_ACCESS_CTRL loop\n");

	*val = sw_r32(RTL839X_PHYREG_DATA_CTRL) & 0xffff;

	mutex_unlock(&smi_lock);
	return 0;
}

log
[   14.092471] mdio_bus rtl838x slave mii-0: scanned phy 48
[   14.163169] mdio_bus rtl838x slave mii-0: scanned phy 49
[   14.233068] In rtl839x_read_phy: port 50, page 0000, reg 0002, val 87dedbfc
[   14.324794]   wrote RTL839X_PHYREG_DATA_CTRL
[   14.380977]   wrote RTL839X_PHYREG_ACCESS_CTRL
[   14.439448]   wrote RTL839X_PHYREG_CTRL
[   14.489901]   wrote RTL839X_PHYREG_ACCESS_CTRL
[   14.548379]   exit RTL839X_PHYREG_ACCESS_CTRL loop
[   14.611455] In rtl839x_read_phy: port 50, page 0000, reg 0003, val 87dedbfc
[   14.703184]   wrote RTL839X_PHYREG_DATA_CTRL
[   14.759360]   wrote RTL839X_PHYREG_ACCESS_CTRL
[   14.817840]   wrote RTL839X_PHYREG_CTRL
[   14.868294]   wrote RTL839X_PHYREG_ACCESS_CTRL
[   14.926772]   exit RTL839X_PHYREG_ACCESS_CTRL loop
[   14.989848] mdio_bus rtl838x slave mii-0: scanned phy 50
[   15.059795] In rtl839x_read_phy: port 51, page 0000, reg 0002, val 87dedbfc
[   15.151520]   wrote RTL839X_PHYREG_DATA_CTRL
[   15.207696]   wrote RTL839X_PHYREG_ACCESS_CTRL
[   15.266177]   wrote RTL839X_PHYREG_CTRL
[   15.316627]   wrote RTL839X_PHYREG_ACCESS_CTRL
[   15.375108]   exit RTL839X_PHYREG_ACCESS_CTRL loop
[   15.438181] In rtl839x_read_phy: port 51, page 0000, reg 0003, val 87dedbfc
[   15.529914]   wrote RTL839X_PHYREG_DATA_CTRL
[   15.586087]   wrote RTL839X_PHYREG_ACCESS_CTRL
[   15.644568]   wrote RTL839X_PHYREG_CTRL
[   15.695018]   wrote RTL839X_PHYREG_ACCESS_CTRL
[   15.753498]   exit RTL839X_PHYREG_ACCESS_CTRL loop
[   15.816574] mdio_bus rtl838x slave mii-0: scanned phy 51
[   15.886524] In rtl839x_read_phy: port 52, page 0000, reg 0002, val 87dedbfc
[   15.978249]   wrote RTL839X_PHYREG_DATA_CTRL
[   16.034425]   wrote RTL839X_PHYREG_ACCESS_CTRL
[   16.092904]   wrote RTL839X_PHYREG_CTRL
[   16.143355]   wrote RTL839X_PHYREG_ACCESS_CTRL
(hang)