Support for RTL838x based managed switches

Port 28 is the CPU port, so that is correct and is in fact the standard message in Realtek's u-boot. Could you put the complete u-boot code somewhere you put together? And if you could figure out which PHYs sit below the heat spreaders... This is probably just a configuration issue.

Okay and CPU port should actually be which port on the front panel?

Just for completeness:

  • I took the GPL source of my device (T1600G-28TS) and the GPL source of the T2500G-10TS since it contains the dev uboot source.
  • Moved over the u-boot-2011.12/common directory.
  • Placed #define UBOOT_DEBUG in all the files using #ifdef UBOOT_DEBUG blocks
  • And basically followed your post.
  • Ended up with this u-boot.bin

I'm afraid that the heat spreaders are not going to come off without damage. There is white glue seeping out on the sides burying nearby smd stuff. If it is the same nasty glue they splodge on the connector, they really where going to town with the glue gun.

Actually, I just noticed ping utility on rtl prompt reports Using rtl8380#0 device. This may be caused because the T2500G-10TS I stole the sources from is RTL8380M based whereas my T1600G-28TS is RTL8382M based.

The PHY's are most likely 8218B since boardname of the T1600G is RTL8382M_8218B_INTPHY_8218B_8214QF_DEMO

Using the information you provided here I'm hoping to be able to figure out the SFP port configuration on the Netgear GS310TP. The show tech-support lists the following information regarding the SFP ports:

====== Fiber =================
Fiber Port Number: 2

------------ Fiber Detect
LPort  Present  MediaChg  OE Status              LOS Status
------ -------- --------- ---------------------- ----------------------
8      OE       OE        Enabled  (GPIO:EXT_14) Enabled  (GPIO:EXT_7 )
9      OE       OE        Enabled  (GPIO:EXT_13) Enabled  (GPIO:EXT_6 )

------------ Fiber Optical
LPort  I2C DEV  I2C TYPE  ID    Delay   SCK    SDA
------ -------- --------- ----- ------- ------ ------
8      0        8 BITS    0x50  1000    EXT_36 EXT_28
9      1        8 BITS    0x50  1000    EXT_36 EXT_27

------------ Fiber TX Disable
LPort  Method
------ ------
8      GPIO(EXT_28)

I'm confused by this as it appears that GPIO 28 and 36 are used for multiple purposes. I'm trying to use the ZyXel GS1900-10HP as a template for configuring the GS310TP. As it would appear that like the ZyXel switch i2C0 is used for port 9 and i2C1 for port 10. I assume the LOS Status column would correspond to the DTS los-gpio and the SDA would correspond to the sda-gpios. How would I go about determining the correct GPIO for the remaining values?

Or should I be using the D-Link DGS-1210-10P as a template instead?

Unfortunately unlike most Netgear devices the source for this switch does not appear on their GPL page.

The mapping is pretty straight forward if the vendor put the correct values there. I guess it helps comparing the GS1900-10HP tech-support output with the reulting DTS.

GS1900-10HP tech-support:

====== Fiber =================
Fiber Port Number: 2

------------ Fiber Detect
LPort  Present  MediaChg  OE Status              LOS Status
------ -------- --------- ---------------------- ----------------------
8      OE       OE        Enabled  (GPIO:EXT_26) Enabled  (GPIO:EXT_27)
9      OE       OE        Enabled  (GPIO:EXT_32) Enabled  (GPIO:EXT_33)

------------ Fiber Optical
LPort  SMI DEV  SMI TYPE  ID    Delay   SCK    SDA
------ -------- --------- ----- ------- ------ ------
8      SFP1     8 BITS    0x50  4000    EXT_25 EXT_24
9      SFP2     8 BITS    0x50  4000    EXT_31 EXT_30

------------ Fiber TX Disable
LPort  GPIO
------ ------
8      EXT_23
9      EXT_29

mapped to the GS1900-10HP DTS as:

	/* i2c of the left SFP cage: port 9 */
	i2c0: i2c-gpio-0 {
		compatible = "i2c-gpio";
		sda-gpios = <&gpio1 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
		scl-gpios = <&gpio1 25 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
		i2c-gpio,delay-us = <2>;
		#address-cells = <1>;
		#size-cells = <0>;
	};

	sfp0: sfp-p9 {
		compatible = "sff,sfp";
		i2c-bus = <&i2c0>;
		los-gpio = <&gpio1 27 GPIO_ACTIVE_HIGH>;
		tx-fault-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>;
		mod-def0-gpio = <&gpio1 26 GPIO_ACTIVE_LOW>;
		tx-disable-gpio = <&gpio1 23 GPIO_ACTIVE_HIGH>;
	};

	/* i2c of the right SFP cage: port 10 */
	i2c1: i2c-gpio-1 {
		compatible = "i2c-gpio";
		sda-gpios = <&gpio1 30 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
		scl-gpios = <&gpio1 31 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
		i2c-gpio,delay-us = <2>;
		#address-cells = <1>;
		#size-cells = <0>;
	};

	sfp1: sfp-p10 {
		compatible = "sff,sfp";
		i2c-bus = <&i2c1>;
		los-gpio = <&gpio1 33 GPIO_ACTIVE_HIGH>;
		tx-fault-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
		mod-def0-gpio = <&gpio1 32 GPIO_ACTIVE_LOW>;
		tx-disable-gpio = <&gpio1 29 GPIO_ACTIVE_HIGH>;
	};

So it's a pretty simple mapping, except for the tx-fault-gpio which I'm not sure where we got... Maybe just derived from the map showing directions and current values?

See https://www.kernel.org/doc/Documentation/devicetree/bindings/net/sff%2Csfp.txt for a description of what all these properties are, with directions and defaults where that isn't obvious

1 Like

If this is correct, that means multiple bitbanged I2C busses are "multiplexed" on the same clock line. I've seen the same on the Cisco SG220, but I don't think the kernel currently supports this.

1 Like

So the DGS-1210-10P is configured quite different from the ZyXel. Does that mean its missing full support for the SFP modules? Would setting up the GS310TP similar to the DGS-1210-10P be acceptable for the initial support?

The CPU-port is the port that allows you to contact the web-interface or ping the switch, think of it as a 29th Ethernet port (the others are internally numbered 0-27, making 28 in total), that is inside the switch and which the CPU of the switch connects to (hence the name). In fact this port is inside the silicon of the SoC.

If the ports get no link there is a second way of getting a binary into the device and booting it up. It is called ymodem and will take you on a time-travel into the IT stoneage. Check that in u-boot the command

 loady   - load binary file over serial line (ymodem mode) 

is available. Now use a terminal program with support for this protocol and set it up correctly. On Ubuntu I use

picocom --receive-cmd "ry -vv" --send-cmd "sz -vv" -b 38400 /dev/ttyUSB0

When you are in the console, issue

loady 0x84f00000 <enter>
then <CTRL-A> <CTRL-S>

Enter the filename to upload. Pick any of the existing intitramfs already there, for example the one for the GS1900-10, and boot it with bootm. It should at least boot and probably the first 8 ports work. You can change the baud rate in the u-boot to something higher, either for the console itself, or for just the loady command, if you get a time-out or your patience runs out. With a normal cable I reliably get 460800 baud, the protocol has error correction built-in, so no worries. As soon as you have one image running with the ports enabled, you could install that and then successively update it with sysupgrade until perfect.

As long as you mention it in the commit message, I don't think there shouldn't be an issue with missing features. You probably can't even implement them yet. For example, the Netgear GS110TPP doesn't implement support for ports 9 and 10, because the phy isn't (wasn't?) supported at the time that was merged.

1 Like

Sorry. missed that. Maybe play with GPIOD_FLAGS_BIT_NONEXCLUSIVE and "i2c-gpio,scl-output-only"? Can't be that hard. Like I often think before diving into a problem for weeks before giving up :slight_smile:

Actually I remember zModem :grinning:

Awesome was able to upload a few initramfs:

With d-link_dgs-1210-28-initramfs-kernel.bin i get:

RTL838x# # bootm

Starting kernel ...

Kernel panic - not syncing: broken padding

With: zyxel_gs1900-10hp-initramfs-kernel.bin i get:

RTL838x# # bootm

Starting kernel ...


port 0 patch ready fail 0
port 1 patch ready fail 0
port 2 patch ready fail 0
port 3 patch ready fail 0
port 4 patch ready fail 0
port 5 patch ready fail 0
port 6 patch ready fail 0
port 7 patch ready fail 0
port 8 patch ready fail 0
port 9 patch ready fail 0
port 10 patch ready fail 0
port 11 patch ready fail 0
port 12 patch ready fail 0
port 13 patch ready fail 0
port 14 patch ready fail 0
port 15 patch ready fail 0
port 16 patch ready fail 0
port 17 patch ready fail 0
port 18 patch ready fail 0
port 19 patch ready fail 0
port 20 patch ready fail 0
port 21 patch ready fail 0
port 22 patch ready fail 0
port 23 patch ready fail 0

***************** User Access Login ********************

User:admin
Password:

#2006-01-01 08:00:54,[User]/5/Login the CLI by admin on console.

T1600G-28TS>

Both failures sound like there is something wrong with the image the switch expects. There should be the iminfo command that shows how u-boot sees the images and whether padding and checksums are OK. Sometimes it's a magic byte missing. You could try uploading the original image from an update package of the vendor via zModem and see how this looks to u-boot.

WIth iminfo and no uploaded initramfs I get:

## Checking Image at b4100000 ...
   Legacy image found
   Verifying Checksum ... OK

b4100000 does this switch may have a different memory layout?

RTL838x# # flshow
=============== FLASH Partition Layout ===============
Index  Name       Size       Address
------------------------------------------------------
 0     boot       0xe0000    0xb4000000-0xb40dffff
 1     env        0x20000    0xb40e0000-0xb40fffff
 2     sys        0x600000   0xb4100000-0xb46fffff
 3     usrimg1    0xa00000   0xb4700000-0xb50fffff
 4     usrimg2    0xa00000   0xb5100000-0xb5afffff
 5     usrappfs   0x400000   0xb5b00000-0xb5efffff
 6     para       0x100000   0xb5f00000-0xb5ffffff
======================================================

iminfo shows information about the last image you made known to u-boot. With nothing uploaded its the one on the flash. The 0xb4100000 is actually 0x84100000 (the added bit tells the MIPS core something about how to not cache the image from the flash). Once you use zModem to upload an image, iminfo shows information about that image. You can try loading the image via zModem to 0x84100000

After explicitly setting the address at bootm it works like a charm:

RTL838x# # bootm 0x84100000

Starting kernel ...

[    0.000000] Linux version 5.4.111 (builder@buildhost) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r16046-59980f7aaf)) #0 Sun Apr 18 10:06:57 2021
[    0.000000] RTL838X model is 83826800
[    0.000000] SoC Type: RTL8382
[    0.000000] Kernel command line: console=ttyS0,38400n8 mem=126M mtdparts=spi_flash:896K(boot),128K(env),6144K(sys),10240K(usrimg1@main),10240K(usrimg2),4096K(usrappfs),1024K(para) 
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019070 (MIPS 4KEc)
[    0.000000] MIPS: machine is D-Link DGS-1210-28
[    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 16kB, VIPT, 4-way, linesize 16 bytes.
[    0.000000] Primary data cache 16kB, 2-way, VIPT, cache aliases, linesize 16 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] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 114816K/131072K available (5075K kernel code, 167K rwdata, 636K rodata, 8832K init, 207K bss, 16256K 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 0x805c0984 with crng_init=0
[    0.000000] timer_probe: no matching timers found
[    0.000000] CPU frequency from device tree: 500MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041786 ns
[    0.000022] sched_clock: 32 bits at 250MHz, resolution 4ns, wraps every 8589934590ns
[    0.025762] Calibrating delay loop... 497.66 BogoMIPS (lpj=995328)
[    0.078065] pid_max: default: 32768 minimum: 301
[    0.093834] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.117896] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.160261] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.192334] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.215042] pinctrl core: initialized pinctrl subsystem
[    0.237568] NET: Registered protocol family 16
[    0.361440] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512
[    0.411241] clocksource: Switched to clocksource MIPS
[    0.432072] NET: Registered protocol family 2
[    0.449151] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.476806] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.502043] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.525258] TCP: Hash tables configured (established 1024 bind 1024)
[    0.546981] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.568567] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.592342] NET: Registered protocol family 1
[    1.371330] random: fast init done
[    1.486733] workingset: timestamp_bits=14 max_order=15 bucket_order=1
[    1.531830] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    1.550982] jffs2: version 2.2 (NAND) (SUMMARY) (ZLIB) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    1.664954] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[    1.698822] pinctrl-single bb001000.pinmux: 32 pins, size 4
[    1.718394] Probing RTL838X GPIOs
[    1.887696] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled
[    1.917944] printk: console [ttyS0] disabled
[    1.932095] b8002000.uart: ttyS0 at MMIO 0xb8002000 (irq = 31, base_baud = 12500000) is a 16550A

Baudrate switch

[    1.957394] printk: console [ttyS0] enabled
[    1.957394] printk: console [ttyS0] enabled
[    1.967037] printk: bootconsole [early0] disabled
[    1.967037] printk: bootconsole [early0] disabled
[    1.979799] b8002100.uart: ttyS1 at MMIO 0xb8002100 (irq = 30, base_baud = 12500000) is a 16550A
[    2.594972] brd: module loaded
[    2.600006] Initializing rtl838x_nor_driver
[    2.604948] SPI resource base is b8001200
[    2.609577] Address mode is 4 bytes
[    2.613595] rtl838x_nor_init called
[    2.622334] rtl838x-nor b8001200.spi: gd25q256 (32768 Kbytes)
[    2.629139] 8 fixed-partitions partitions found on MTD device rtl838x_nor
[    2.636890] Creating 8 MTD partitions on "rtl838x_nor":
[    2.642899] 0x000000000000-0x000000080000 : "u-boot"
[    2.651911] 0x000000080000-0x0000000c0000 : "u-boot-env"
[    2.661482] 0x0000000c0000-0x000000100000 : "u-boot-env2"
[    2.670779] 0x000000100000-0x000000e80000 : "firmware"
[    2.700479] 2 uimage-fw partitions found on MTD device firmware
[    2.707316] Creating 2 MTD partitions on "firmware":
[    2.713042] 0x000000000000-0x000000600000 : "kernel"
[    2.722007] 0x000000600000-0x000000d80000 : "rootfs"
[    2.730751] mtd: device 5 (rootfs) set to be root filesystem
[    2.737395] 1 squashfs-split partitions found on MTD device rootfs
[    2.744495] 0x0000009c0000-0x000000d80000 : "rootfs_data"
[    2.753886] 0x000000e80000-0x000001000000 : "kernel2"
[    2.762877] 0x000001000000-0x000001040000 : "sysinfo"
[    2.772103] 0x000001040000-0x000001c40000 : "rootfs2"
[    2.781211] 0x000001c40000-0x000002000000 : "jffs2"
[    2.792206] libphy: Fixed MDIO Bus: probed
[    2.805869] Probing RTL838X eth device pdev: 87c99800, dev: 87c99810
[    2.837194] Found SoC ID: 8382: RTL8382, family 8380
[    2.842887] rtl8380_init_mac
[    2.846285] Using MAC 000000e04c000000
[    2.851297] libphy: rtl838x-eth-mdio: probed
[    2.967376] Phy on MAC 0: 1cc981
[    2.981375] Realtek RTL8218B (external) mdio-bus:00: Detected external RTL8218B
[    2.989702] Firmware loaded. Size 1168, magic: 83808380
[    3.866119] Realtek RTL8218B (external) mdio-bus:00: Could not patch PHY
[    3.873825] Realtek RTL8218B (external): probe of mdio-bus:00 failed with error -1
[    3.882573] rtl8218d_phy_probe: id: 0
[    4.203751] Realtek RTL8218B (internal) mdio-bus:08: Detected internal RTL8218B
[    4.212088] Firmware loaded. Size 1184, magic: 83808380
[    5.040718] Realtek RTL8218B (internal) mdio-bus:08: ERROR: Port 8 not ready for patch.
[    5.049866] Realtek RTL8218B (internal): probe of mdio-bus:08 failed with error -1
[    5.365214] rtl8218d_phy_probe: id: 16
[    5.407956] rtl8218d_phy_probe: id: 17
[    5.450920] rtl8218d_phy_probe: id: 18
[    5.493845] rtl8218d_phy_probe: id: 19
[    5.537005] rtl8218d_phy_probe: id: 20
[    5.579862] rtl8218d_phy_probe: id: 21
[    5.622753] rtl8218d_phy_probe: id: 22
[    5.665310] rtl8218d_phy_probe: id: 23
[    5.827518] NET: Registered protocol family 10
[    5.852381] Segment Routing with IPv6
[    5.856963] NET: Registered protocol family 17
[    5.862317] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[    5.877871] 8021q: 802.1Q VLAN Support v1.8
[    5.923858] Phy on MAC 0: 1cc981
[    5.937905] Realtek RTL8218B (external) rtl838x slave mii-0:00: Detected external RTL8218B
[    5.947303] Firmware loaded. Size 1168, magic: 83808380
[    6.825929] Realtek RTL8218B (external) rtl838x slave mii-0:00: Could not patch PHY
[    6.834699] Realtek RTL8218B (external): probe of rtl838x slave mii-0:00 failed with error -1
[    6.844512] rtl8218d_phy_probe: id: 0
[    7.163841] Realtek RTL8218B (internal) rtl838x slave mii-0:08: Detected internal RTL8218B
[    7.173243] Firmware loaded. Size 1184, magic: 83808380
[    7.984719] Realtek RTL8218B (internal) rtl838x slave mii-0:08: ERROR: Port 8 not ready for patch.
[    7.994935] Realtek RTL8218B (internal): probe of rtl838x slave mii-0:08 failed with error -1
[    8.306981] rtl8218d_phy_probe: id: 16
[    8.349549] rtl8218d_phy_probe: id: 17
[    8.392430] rtl8218d_phy_probe: id: 18
[    8.435129] rtl8218d_phy_probe: id: 19
[    8.477863] rtl8218d_phy_probe: id: 20
[    8.520881] rtl8218d_phy_probe: id: 21
[    8.563391] rtl8218d_phy_probe: id: 22
[    8.605819] rtl8218d_phy_probe: id: 23
[    8.905648] libphy: rtl838x slave mii: probed
[    8.947723] > 10000001 10000002 10000004 10000008 10000010 10000020 10000040 10000080
[    8.956652] > 10000100 10000200 10000400 10000800 10001000 10002000 10004000 10008000
[    8.965515] > 10010000 10020000 10040000 10080000 10100000 10200000 10400000 10800000
[    8.974375] > 11000000 12000000 14000000 18000000 1fffffff        0        0        0
[    8.983234] CPU_PORT> 1fffffff
[   11.016334] rtl83xx-switch switch@bb000000 lan1 (uninitialized): PHY [mdio-bus:00] driver [REALTEK RTL8218D]
[   11.030867] rtl83xx-switch switch@bb000000 lan2 (uninitialized): PHY [mdio-bus:01] driver [Realtek RTL8218B (external)]
[   11.046660] rtl83xx-switch switch@bb000000 lan3 (uninitialized): PHY [mdio-bus:02] driver [Realtek RTL8218B (external)]
[   11.062432] rtl83xx-switch switch@bb000000 lan4 (uninitialized): PHY [mdio-bus:03] driver [Realtek RTL8218B (external)]
[   11.078212] rtl83xx-switch switch@bb000000 lan5 (uninitialized): PHY [mdio-bus:04] driver [Realtek RTL8218B (external)]
[   11.094015] rtl83xx-switch switch@bb000000 lan6 (uninitialized): PHY [mdio-bus:05] driver [Realtek RTL8218B (external)]
[   11.109809] rtl83xx-switch switch@bb000000 lan7 (uninitialized): PHY [mdio-bus:06] driver [Realtek RTL8218B (external)]
[   11.125909] rtl83xx-switch switch@bb000000 lan8 (uninitialized): PHY [mdio-bus:07] driver [Realtek RTL8218B (external)]
[   11.142777] rtl83xx-switch switch@bb000000 lan9 (uninitialized): PHY [mdio-bus:08] driver [Generic PHY]
[   11.156892] rtl83xx-switch switch@bb000000 lan10 (uninitialized): PHY [mdio-bus:09] driver [Realtek RTL8218B (internal)]
[   11.172684] rtl83xx-switch switch@bb000000 lan11 (uninitialized): PHY [mdio-bus:0a] driver [Realtek RTL8218B (internal)]
[   11.188489] rtl83xx-switch switch@bb000000 lan12 (uninitialized): PHY [mdio-bus:0b] driver [Realtek RTL8218B (internal)]
[   11.204461] rtl83xx-switch switch@bb000000 lan13 (uninitialized): PHY [mdio-bus:0c] driver [Realtek RTL8218B (internal)]
[   11.220460] rtl83xx-switch switch@bb000000 lan14 (uninitialized): PHY [mdio-bus:0d] driver [Realtek RTL8218B (internal)]
[   11.236254] rtl83xx-switch switch@bb000000 lan15 (uninitialized): PHY [mdio-bus:0e] driver [Realtek RTL8218B (internal)]
[   11.252063] rtl83xx-switch switch@bb000000 lan16 (uninitialized): PHY [mdio-bus:0f] driver [Realtek RTL8218B (internal)]
[   11.278596] rtl83xx-switch switch@bb000000 lan17 (uninitialized): PHY [mdio-bus:10] driver [REALTEK RTL8218D]
[   11.304183] rtl83xx-switch switch@bb000000 lan18 (uninitialized): PHY [mdio-bus:11] driver [REALTEK RTL8218D]
[   11.329761] rtl83xx-switch switch@bb000000 lan19 (uninitialized): PHY [mdio-bus:12] driver [REALTEK RTL8218D]
[   11.355351] rtl83xx-switch switch@bb000000 lan20 (uninitialized): PHY [mdio-bus:13] driver [REALTEK RTL8218D]
[   11.380932] rtl83xx-switch switch@bb000000 lan21 (uninitialized): PHY [mdio-bus:14] driver [REALTEK RTL8218D]
[   11.406514] rtl83xx-switch switch@bb000000 lan22 (uninitialized): PHY [mdio-bus:15] driver [REALTEK RTL8218D]
[   11.432100] rtl83xx-switch switch@bb000000 lan23 (uninitialized): PHY [mdio-bus:16] driver [REALTEK RTL8218D]
[   11.457685] rtl83xx-switch switch@bb000000 lan24 (uninitialized): PHY [mdio-bus:17] driver [REALTEK RTL8218D]
[   11.473797] rtl83xx-switch switch@bb000000 lan25 (uninitialized): PHY [mdio-bus:18] driver [Generic PHY]
[   11.488997] rtl83xx-switch switch@bb000000 lan26 (uninitialized): PHY [mdio-bus:19] driver [Generic PHY]
[   11.504526] rtl83xx-switch switch@bb000000 lan27 (uninitialized): PHY [mdio-bus:1a] driver [Generic PHY]
[   11.519634] rtl83xx-switch switch@bb000000 lan28 (uninitialized): PHY [mdio-bus:1b] driver [Generic PHY]
[   11.533073] rtl83xx-switch switch@bb000000: configuring for fixed/internal link mode
[   11.542321] DSA: tree 0 setup
[   11.545881] LINK state irq: 20
[   11.549518] In rtl83xx_setup_qos
[   11.553256] Setting up RTL838X QoS
[   11.557172] RTL838X_PRI_SEL_TBL_CTRL(i): 00033112
[   11.562539] Current Intprio2queue setting: 00000000
[   11.568114] QM_PKT2CPU_INTPRI_MAP: 00fac688
[   11.572935] rtl838x_dbgfs_init called
[   11.797930] Freeing unused kernel memory: 8832K
[   11.803189] This architecture does not have kernel memory protection.
[   11.810500] Run /init as init process
[   11.815095] rtl83xx-switch switch@bb000000: Link is Up - 1Gbps/Full - flow control off
[   13.964250] init: Console is alive
[   14.006220] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[   14.021113] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[   14.044121] init: - preinit -
[   14.600705] random: jshn: uninitialized urandom read (4 bytes read)
[   14.763556] random: jshn: uninitialized urandom read (4 bytes read)
[   17.173682] random: jshn: uninitialized urandom read (4 bytes read)
[   17.279484] random: jshn: uninitialized urandom read (4 bytes read)
[   17.553658] random: jshn: uninitialized urandom read (4 bytes read)
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[   22.192126] procd: - early -
[   25.338295] procd: - ubus -
[   25.367986] urandom_read: 1 callbacks suppressed
[   25.368006] random: ubusd: uninitialized urandom read (4 bytes read)
[   25.397225] random: ubusd: uninitialized urandom read (4 bytes read)
[   25.406142] random: ubusd: uninitialized urandom read (4 bytes read)
[   25.426964] procd: - init -
Please press Enter to activate this console.
[   26.960770] kmodloader: loading kernel modules from /etc/modules.d/*
[   26.975467] urngd: v1.0.2 started.
[   27.137294] xt_time: kernel timezone is -0000
[   27.259745] kmodloader: done loading kernel modules from /etc/modules.d/*
[   27.338437] random: crng init done
[   27.342456] random: 1 urandom warning(s) missed due to ratelimiting



BusyBox v1.33.0 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 21.02.0-rc1, r16046-59980f7aaf
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@(none):/# 

Full bootlog here

2 Likes

Cool, great work!
I see that the RTL8214C PHY is not detected, in principle the support for that PHY is already there, but either the right configuration in the .dts is missing, or the support is broken. I think it has not been tested yet. With the information you get from the tech-support command in the OEM console you can figure out the GPIO settings for the SFP modules, @svanheule can surely help with the I2C configuration. Finally figure out how to make an image the OEM web-interface accepts (unfortunately this is the first Realtek TPLink device that would go in, so maybe understand how TPLink generally makes their images) and you are ready to submit support for the T1600G-28TS!

1 Like

Thanks so much for your great help, and everyone who chipped in during the last few days. I'll try my best and report back if I get anything.

So far I can add that GPIO47 is active high SYS LED, and Reset seems to be GPIO27/28. The ethernet port LEDs seem to be controlled as @svanheule already suggested in another way.

tech-support (same for board-info) command may be missing in OEM console:

T1600G-28TS#show tech-support
-----------------^
Error: Invalid parameter. 
1 Like

The support for the SFPs is probably not necessary for submitting support for this device, but if you are the hardware-hacking type there is another solution:


Get yourself a broken or very cheap SFP module (you can get very cheap ones for less than 10$/€), take the casing off and solder directly to the connector pins, the pinout is here http://www.schelto.com/SFP/SFP%20MSA.pdf on page 10, on page 30 you can find I2C-SDA = Mod Def 2 and SCL, Mod Def 1, Mod Def 0 is module present.

Now just test continuity between the pins of the module when plugged into an SFP port and the pins of the RTL8231 GPIO expander chip, which are readily accessible on the board. Datasheet for the RTL8231 is also online https://github.com/libc0607/Realtek_switch_hacking/blob/files/RTL8231_Datasheet_1.2.pdf

1 Like

Awesome, actually I have an SFP module which I could use for this. However, I can only see one RTL8231 and it is on the front panel. Could it be that the I2C lines of the SFP modules are directly connected to the SoC? That would make it hard to probe out. Might get lucky by tracing them on the board to just below the heatsink if they are visible and reduce the number of potential GPIOs that way?

Just for my understanding:
*I added a new device entry and devicetree file (based on the device I borrowed the initramfs from), built and loaded that initramfs (works).
*Added the phys in the DT file, there seems to be a patch error in dmesg though during boot.
*Added flash partitions, and one rtl8231. Those GPIOs show up in /sys/class/gpio.
*Next, I probably should flash that image in the first slot I guess (read something about that) to avoid uploading initramfs via ymodem.

Basically I now have to set up all the I2C buses and such in the devicetree to talk to those right? How would I go about that, for example controlling the port LEDs, since those are easily visible. I talk with the frontpanel rtl8231 also via I2C or how does this happen? I might have to dive into the rtl8231 datasheet.

What I also find strange that connecting to a port now brings the link up but a ping to the device is still not working.

What would be the fastest way to alter the DT file and test the new one on the device?

I have a DGS-1210-10P and recently had exactly the same problem: no traffic between ports, only between the CPU-port and an external port. I have no idea what goes on. I investigated everything around the port-isolation features which can be used to create this behaviour, but could not find a fault, so there seems to be something we do not understand. Likely something to do with what DLink's u-boot does.

The RTL8380 only as about 3 GPIOs that can be freely used. So the SFP port pins need to go somewhere else, which is usually an RTL8231. Another possibility is the RTL8214C PHY, which is already doing the data transfer to the SFPs. There is not much experience with this PHY.

We have not seen any 28 port RTL8380 devices in the wild, this port range is also covered by RTL8390 devices. Figuring out which phy is behind each port is notoriously tricky, because Realtek is re-using PHY-IDs and you cannot exactly figure out the phy merely by its ID, one needs to also know which port it's connected to. For this the driver uses some heuristics, which seem to fail (giving the patch error).

Probably the ports all work, though, apart the SFPs?

What you did is already most of what is needed. What would be interesting is to figure out how to flash the sysupgrade image through the original web-interface of the switch.
You also need to see how the SFP-I2C busses are connected, once you have some hardware details, help will be there to explain how to do the configuration in the .dts.