Support for RTL838x based managed switches

Hi,
I have coded basic support for the RTL838X SoCs which are used on many low-end managed switches, see https://gitlab.com/bkoblitz/openwrt-rtl838x

At present, there is rudimentary support for the
Zyxel GS1900-10HP (8 Gig + 2 SFP, 128MB RAM / 32MB flash)
and the
D-Link DGS-1210-16 (16 Gig + 4 SFP, 128MB RAM / 32MB flash)
managed low-end switches. This port is base on the GPL-dumps for the
D-Link DGS-1210 and the TP-Link 2500G. There is no datasheet available
for the RTL838X platform.

RTL838x chips are found on many managed switches with 10-20 ports. The larger
sibling RTL8390/2 is found on 28 to 52 port switches.

So far, drivers are provided for

  • Basic SoC setup: timers, IRQ, including Device Tree support for memory and
    CPU-Speed configuration, flash partitions
  • An SPI driver to access the NOR flash, single speed, write disabled on purpose
  • An Ethernet driver for the RTL838x
  • A DSA switch driver with port isolation
  • PHY drivers for the internal RTL8218B Ethernet and RTL8380 SFP ports

TODO:

  • Test flash write access, support flash quad read speed:
    doable, U-Boot code under GPL
  • Access to PoE features: doable, as configured by 2nd UART on RTL838x,
    some code under GPL available
  • port based VLAN: "speaking" register names in GPLed header available,
    seems doable
  • support for switch featuers in graphical LuCI
  • MIPS16 support: according to Realtek the SoC supports MIPS16e
  • Support more PHYs: external RTL8218b, RTL8214FC for 20-port switches:
    GPL U-Boot code available
  • GPIO support: U-Boot code partially available
  • Support for external LED serial drivers: some U-Boot code available
  • Support for RTL839x? GPL code available, very similar to 8380 but
    don't have hardware
  • Better support for ethtool settings
  • More advanced switch features: dynamic VLAN, switch-based filtering,
    traffic shaping: very little code available, only register names

Known BUGS:

  • Many dublicate ACKs seen on Ethernet
  • Fibre speed is read out wrong
  • DSA API incomplete
  • Port statistics not reset on boot
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    0.000000] Linux version 4.19.93 (birger@AMDDesktop) (gcc version 8.3.0 (OpenWrt GCC 8.3.0 r11958-830e4bdd9e)) #0 Tue Mar 17 16:37:15 2020
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] prom_init called
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] model is 83806800
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] SoC Type: RTL8380
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Kernel command line: console=ttyS0,115200 mem=128M loglevel=15 root=/dev/ram0 debug
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] bootconsole [early0] enabled
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] CPU0 revision is: 00019070 (MIPS 4KEc)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] plat_mem_setup called
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] OF: fdt: search "chosen", depth: 0, uname:
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] OF: fdt: search "chosen", depth: 1, uname: cpus
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] OF: fdt: search "chosen", depth: 2, uname: cpu@0
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] OF: fdt: search "chosen", depth: 1, uname: memory@0
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] OF: fdt: search "chosen", depth: 1, uname: chosen
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] OF: fdt: Looking for initrd properties...
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] OF: fdt: Command line is: console=ttyS0,115200 mem=128M
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] OF: fdt: dt_root_size_cells = 1
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] OF: fdt: dt_root_addr_cells = 1
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] OF: fdt: memory scan node memory@0, reg size 8,
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] OF: fdt:  - 0 ,  8000000
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] MIPS: machine is Zyxel GS1900-10HP Switch
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Registering _machine_restart
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    0.000000] NO PCI device found
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Determined physical RAM map:
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000]  memory: 08000000 @ 00000000 (usable)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] User-defined physical RAM map:
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000]  memory: 08000000 @ 00000000 (usable)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Initrd not found or empty - disabling initrd
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] device_tree_init called
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Using appended Device Tree.
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] OF: fdt:  <- unflatten_device_tree()
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    0.000000] Primary instruction cache 16kB, VIPT, 4-way, linesize 16 bytes.
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    0.000000] Primary data cache 16kB, 2-way, VIPT, cache aliases, linesize 16 bytes
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Zone ranges:
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000]   Normal   [mem 0x0000000000000000-0x0000000007ffffff]
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Movable zone start for each node
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Early memory node ranges
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] On node 0 totalpages: 32768
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000]   Normal zone: 288 pages used for memmap
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000]   Normal zone: 0 pages reserved
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000]   Normal zone: 32768 pages, LIFO batch:7
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    0.000000] random: get_random_bytes called from start_kernel+0x98/0x4a8 with crng_init=0
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.000000] pcpu-alloc: [0] 0
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 32480
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    0.000000] Kernel command line: console=ttyS0,115200 mem=128M
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] Memory: 116624K/131072K available (4044K kernel code, 168K rwdata, 904K rodata, 7804K init, 197K bss, 14448K reserved, 0K cma-reserved)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] NR_IRQS: 128
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    0.000000] In arch_init_irq, status register 1010c300
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    0.000000] Done setting up IRQ: 10107c00
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] CPU frequency from device tree: 500000000
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] CPU Clock: 500 MHz
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    0.000000] rtl838x_serial_init: cpu_freq: 500000000 baud 115200
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    0.000000] In mips_clockevent_init ++++++++++++
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    0.000000] calling r4k_clockevent_init
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041786 ns
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.000016] sched_clock: 32 bits at 250MHz, resolution 4ns, wraps every 8589934590ns
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.008632] console [ttyS0] enabled
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.016164] bootconsole [early0] disabled
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.025014] Calibrating delay loop... 498.89 BogoMIPS (lpj=2494464)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.091909] pid_max: default: 32768 minimum: 301
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.097519] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.104822] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.122867] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.133752] futex hash table entries: 256 (order: -1, 3072 bytes)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.140782] pinctrl core: initialized pinctrl subsystem
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.147866] NET: Registered protocol family 16
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.159138] OF: of_platform_populate()
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.163277] OF:  starting at: /
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.166798] OF: of_platform_bus_create() - skipping /cpus, no compatible prop
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.174625] OF: of_platform_bus_create() - skipping /memory@0, no compatible prop
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.182878] OF: of_platform_bus_create() - skipping /chosen, no compatible prop
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.190897] OF: of_platform_bus_create() - looking at /cpuintc, has compatible prop
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.199345] OF: of_platform_bus_create() - looking at /cpuintc, creating device
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.207693] OF: of_platform_bus_create() - looking at /spi@b8001200, has compatible prop
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.216664] OF: of_platform_bus_create() - looking at /spi@b8001200, creating device
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.225519] OF: of_platform_bus_create() - looking at /ethernet@0xbb000000, has compatible prop
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.235159] OF: of_platform_bus_create() - looking at /ethernet@0xbb000000, creating device
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.244418] OF: not all legacy IRQ resources mapped for ethernet
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.251391] OF: of_platform_bus_create() - looking at /switch0@0, has compatible prop
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    0.259986] OF: of_platform_bus_create() - looking at /switch0@0, creating device
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.326960] clocksource: Switched to clocksource MIPS
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.335544] NET: Registered protocol family 2
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.341947] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.350609] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.358377] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.365393] TCP: Hash tables configured (established 1024 bind 1024)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.372989] UDP hash table entries: 256 (order: 0, 4096 bytes)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.379557] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.387376] NET: Registered protocol family 1
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    0.953706] Crashlog allocated RAM at address 0x3f00000
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.964729] workingset: timestamp_bits=14 max_order=15 bucket_order=1
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.991450] squashfs: version 4.0 (2009/01/31) Phillip Lougher
Tue Mar 17 16:37:19 2020 kern.info kernel: [    0.997939] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
Tue Mar 17 16:37:19 2020 kern.info kernel: [    1.090147] io scheduler noop registered
Tue Mar 17 16:37:19 2020 kern.info kernel: [    1.094466] io scheduler deadline registered (default)
Tue Mar 17 16:37:19 2020 kern.info kernel: [    1.218019] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
Tue Mar 17 16:37:19 2020 kern.info kernel: [    1.225299] serial8250: ttyS0 at MMIO 0x0 (irq = 39, base_baud = 12327200) is a 16550A
Tue Mar 17 16:37:19 2020 kern.info kernel: [    1.627119] brd: module loaded
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    1.631520] rtl838x-nor b800120.spi: device is not dma coherent
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    1.638119] rtl838x-nor b800120.spi: device is not behind an iommu
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.644944] Initializing rtl838x_nor_driver
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.649588] Initializing rtl838x_nor_driver 1
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.654382] Initializing rtl838x_nor_driver 2
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.659190] Initializing rtl838x_nor_driver 3
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.663985] Initializing rtl838x_nor_driver 4
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.668809] Initializing rtl838x_nor_driver 5
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.673582] rtl838x_nor_init called
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.677440] In spi_init
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.680121] In spi_enter_sio
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.683275] spi_write_disable: sfcsr_val = 40000000,SFDR = 04000000
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.683287] spi_read_id: rdid,sfcsr_val = 40000000,SFDR = 9f000000
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.697090] rdid,sfcsr_val = 70000000
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.701101] Buffer 2018c220
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.704148] Flash ID: ffc22018
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.707539] In rtl838x_nor_read_reg: opcode 9f, len 6
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.713076] c2
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.713081] 20
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.715087] 18
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.717147] c2
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.719157] 20
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.721161] 18
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.723196] In rtl838x_nor_write_reg, opcode 6, len 0
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.730780] In rtl838x_nor_write_reg, opcode 1, len 1
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.736308]   data: 0
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.738840] In rtl838x_nor_read_reg: opcode 5, len 1
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.744275] 03
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.747800] In rtl838x_nor_read_reg: opcode 5, len 1
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.755250] 00
Tue Mar 17 16:37:19 2020 kern.info kernel: [    1.755280] rtl838x-nor b800120.spi: mx25l12805d (16384 Kbytes)
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.763855] ------------- Got size: 1000000
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    1.768558] 7 fixed-partitions partitions found on MTD device rtl838x_nor
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    1.775994] Creating 7 MTD partitions on "rtl838x_nor":
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    1.781800] 0x000000000000-0x000000040000 : "u-boot"
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    1.789544] 0x000000040000-0x000000050000 : "u-boot-env"
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    1.797647] 0x000000050000-0x000000060000 : "u-boot-env2"
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    1.805762] 0x000000060000-0x000000160000 : "jffs"
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    1.813330] 0x000000160000-0x000000260000 : "jffs2"
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    1.821081] 0x000000260000-0x000000930000 : "runtime"
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    1.828904] 0x000000930000-0x000001000000 : "runtime2"
Tue Mar 17 16:37:19 2020 kern.info kernel: [    1.837983] libphy: Fixed MDIO Bus: probed
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    1.842646] rtl838x-switch 0.switch0: device is not dma coherent
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    1.849333] rtl838x-switch 0.switch0: device is not behind an iommu
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.856250] Probing RTL838X switch device
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.860757] Found RTL8380M
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.863733] Chip version B
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.866751] Error registering switch: -517
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    1.871608] rtl838x-eth bb000000.ethernet: device is not dma coherent
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    1.878769] rtl838x-eth bb000000.ethernet: device is not behind an iommu
Tue Mar 17 16:37:19 2020 kern.info kernel: [    1.886167] Probing RTL838X eth device
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.895243] In rtl838x_set_mac_address 87c1fc80 810005ec
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.901157] Found mdio node
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    1.904237] Allocated mdio bus
Tue Mar 17 16:37:19 2020 kern.info kernel: [    1.907942] libphy: mdio: probed
Tue Mar 17 16:37:19 2020 kern.info kernel: [    2.241446] NET: Registered protocol family 10
Tue Mar 17 16:37:19 2020 kern.info kernel: [    2.258306] Segment Routing with IPv6
Tue Mar 17 16:37:19 2020 kern.info kernel: [    2.262527] NET: Registered protocol family 17
Tue Mar 17 16:37:19 2020 kern.info kernel: [    2.268386] 8021q: 802.1Q VLAN Support v1.8
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    2.275922] rtl838x-switch 0.switch0: device is not dma coherent
Tue Mar 17 16:37:19 2020 kern.debug kernel: [    2.282622] rtl838x-switch 0.switch0: device is not behind an iommu
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.289606] Probing RTL838X switch device
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.294058] Found RTL8380M
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.297083] Chip version B
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.300128] Powering on fibre ports & reset
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.304723] SDS power down value: 3
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.332588] FF8 register: aaaaaaaf
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.336340] SDS power down value now: 3f
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.340742] Phy on MAC 8: ca40
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.354246] PHY ID: 6275
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.357068] Found internal RTL8218B
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.360893] IPD: 0
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.363154] PHY status: 1140
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    2.366301] Resetting PHY 8
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    4.954708] PHY 8 successfully patched
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    4.958906] > 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    4.967540] > 10000100 10000200 10000400 10000800 10001000 10002000 10004000 10008000
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    4.976121] > 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    4.984745] > 11000000 1fffffff 14000000 1fffffff  500ff00
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    4.990799] rtl8300_enable_phy_polling
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    6.066988] Please wait until PHY is settled
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.410761] libphy: dsa slave smi: probed
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    7.417845] PHY-write: addr 8 0 1140
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.431983] rtl838x-switch 0.switch0 lan1 (uninitialized): PHY [mdio-bus:08] driver [Generic PHY]
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    7.445715] PHY-write: addr 9 0 1140
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.459964] rtl838x-switch 0.switch0 lan2 (uninitialized): PHY [mdio-bus:09] driver [Generic PHY]
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    7.473793] PHY-write: addr 10 0 1140
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.488470] rtl838x-switch 0.switch0 lan3 (uninitialized): PHY [mdio-bus:0a] driver [Generic PHY]
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    7.502200] PHY-write: addr 11 0 1140
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.516876] rtl838x-switch 0.switch0 lan4 (uninitialized): PHY [mdio-bus:0b] driver [Generic PHY]
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    7.530806] PHY-write: addr 12 0 1140
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.545484] rtl838x-switch 0.switch0 lan5 (uninitialized): PHY [mdio-bus:0c] driver [Generic PHY]
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    7.559738] PHY-write: addr 13 0 1140
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.574405] rtl838x-switch 0.switch0 lan6 (uninitialized): PHY [mdio-bus:0d] driver [Generic PHY]
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    7.588148] PHY-write: addr 14 0 1140
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.602392] rtl838x-switch 0.switch0 lan7 (uninitialized): PHY [mdio-bus:0e] driver [Generic PHY]
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    7.616217] PHY-write: addr 15 0 1140
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.630890] rtl838x-switch 0.switch0 lan8 (uninitialized): PHY [mdio-bus:0f] driver [Generic PHY]
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    7.643007] PHY-write: addr 24 0 1140
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.647148] rtl838x-switch 0.switch0 lan9 (uninitialized): PHY [mdio-bus:18] driver [Generic PHY]
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    7.659663] PHY-write: addr 26 0 1140
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.663719] rtl838x-switch 0.switch0 lan10 (uninitialized): PHY [mdio-bus:1a] driver [Generic PHY]
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    7.724424] rtl838x_adjust_link, port 28
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.728852] DSA: tree 0 setup
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.821565] Freeing unused kernel memory: 7804K
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    7.826546] This architecture does not have kernel memory protection.
Tue Mar 17 16:37:19 2020 kern.info kernel: [    7.833666] Run /init as init process
Tue Mar 17 16:37:19 2020 user.info kernel: [    8.011765] init: Console is alive
Tue Mar 17 16:37:19 2020 user.info kernel: [    8.045348] kmodloader: loading kernel modules from /etc/modules-boot.d/*
Tue Mar 17 16:37:19 2020 user.info kernel: [    8.054416] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
Tue Mar 17 16:37:19 2020 user.info kernel: [    8.067674] init: - preinit -
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    8.418584] random: jshn: uninitialized urandom read (4 bytes read)
Tue Mar 17 16:37:19 2020 kern.notice kernel: [    8.461427] random: jshn: uninitialized urandom read (4 bytes read)
Tue Mar 17 16:37:19 2020 kern.warn kernel: [    8.524018] rtl838x_eth_open called 87c1fc80, ring a7000000
Tue Mar 17 16:37:19 2020 kern.warn kernel: [   11.932058] in rtl838x_eth_stop 87c1fc80
Tue Mar 17 16:37:19 2020 user.info kernel: [   11.954890] procd: - early -
Tue Mar 17 16:37:19 2020 user.info kernel: [   14.150904] procd: - ubus -
Tue Mar 17 16:37:19 2020 kern.notice kernel: [   14.168741] random: ubusd: uninitialized urandom read (4 bytes read)
Tue Mar 17 16:37:19 2020 kern.notice kernel: [   14.208399] random: ubusd: uninitialized urandom read (4 bytes read)
Tue Mar 17 16:37:19 2020 kern.notice kernel: [   14.216248] random: ubusd: uninitialized urandom read (4 bytes read)
Tue Mar 17 16:37:19 2020 user.info kernel: [   14.226592] procd: - init -
Tue Mar 17 16:37:19 2020 user.info kernel: [   15.118885] kmodloader: loading kernel modules from /etc/modules.d/*
Tue Mar 17 16:37:19 2020 kern.info kernel: [   15.289322] xt_time: kernel timezone is -0000
Tue Mar 17 16:37:19 2020 kern.info kernel: [   15.382469] PPP generic driver version 2.4.2
Tue Mar 17 16:37:19 2020 kern.info kernel: [   15.400131] NET: Registered protocol family 24
Tue Mar 17 16:37:19 2020 user.info kernel: [   15.414179] urngd: v1.0.1 started.
Tue Mar 17 16:37:19 2020 user.info kernel: [   15.465432] kmodloader: done loading kernel modules from /etc/modules.d/*
Tue Mar 17 16:37:19 2020 kern.notice kernel: [   15.614542] random: crng init done
Tue Mar 17 16:37:19 2020 kern.notice kernel: [   15.618380] random: 5 urandom warning(s) missed due to ratelimiting
Tue Mar 17 16:37:21 2020 user.notice dnsmasq: DNS rebinding protection is active, will discard upstream RFC1918 responses!
Tue Mar 17 16:37:21 2020 user.notice dnsmasq: Allowing 127.0.0.0/8 responses
Tue Mar 17 16:37:22 2020 daemon.info dnsmasq[1855]: started, version 2.80 cachesize 150
Tue Mar 17 16:37:22 2020 daemon.info dnsmasq[1855]: DNS service limited to local subnets
Tue Mar 17 16:37:22 2020 daemon.info dnsmasq[1855]: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP no-DHCPv6 no-Lua TFTP no-conntrack no-ipset no-auth no-DNSSEC no-ID loop-detect inotify dumpfile
Tue Mar 17 16:37:22 2020 daemon.info dnsmasq[1855]: using local addresses only for domain test
Tue Mar 17 16:37:22 2020 daemon.info dnsmasq[1855]: using local addresses only for domain onion
Tue Mar 17 16:37:22 2020 daemon.info dnsmasq[1855]: using local addresses only for domain localhost
Tue Mar 17 16:37:22 2020 daemon.info dnsmasq[1855]: using local addresses only for domain local
Tue Mar 17 16:37:22 2020 daemon.info dnsmasq[1855]: using local addresses only for domain invalid
Tue Mar 17 16:37:22 2020 daemon.info dnsmasq[1855]: using local addresses only for domain bind
Tue Mar 17 16:37:22 2020 daemon.info dnsmasq[1855]: using local addresses only for domain lan
Tue Mar 17 16:37:22 2020 daemon.warn dnsmasq[1855]: no servers found in /tmp/resolv.conf.d/resolv.conf.auto, will retry
Tue Mar 17 16:37:22 2020 daemon.info dnsmasq[1855]: read /etc/hosts - 4 addresses
Tue Mar 17 16:37:22 2020 daemon.info dnsmasq[1855]: read /tmp/hosts/dhcp.cfg01411c - 0 addresses
Tue Mar 17 16:37:51 2020 authpriv.info dropbear[1910]: Not backgrounding
Tue Mar 17 16:37:52 2020 user.notice : Added device handler type: 8021ad
Tue Mar 17 16:37:52 2020 user.notice : Added device handler type: 8021q
Tue Mar 17 16:37:52 2020 user.notice : Added device handler type: macvlan
Tue Mar 17 16:37:52 2020 user.notice : Added device handler type: veth
Tue Mar 17 16:37:52 2020 user.notice : Added device handler type: bridge
Tue Mar 17 16:37:52 2020 user.notice : Added device handler type: Network device
Tue Mar 17 16:37:52 2020 user.notice : Added device handler type: tunnel
Tue Mar 17 16:37:55 2020 daemon.notice procd: /etc/rc.d/S50uhttpd: 4+0 records in
Tue Mar 17 16:37:55 2020 daemon.notice procd: /etc/rc.d/S50uhttpd: 4+0 records out
Tue Mar 17 16:37:55 2020 daemon.notice procd: /etc/rc.d/S50uhttpd: Generating RSA private key, 2048 bit long modulus
Tue Mar 17 16:37:56 2020 daemon.notice netifd: Interface 'loopback' is enabled
Tue Mar 17 16:37:56 2020 daemon.notice netifd: Interface 'loopback' is setting up now
Tue Mar 17 16:37:56 2020 daemon.notice netifd: Interface 'loopback' is now up
Tue Mar 17 16:37:56 2020 daemon.notice netifd: Network device 'lo' link is up
Tue Mar 17 16:37:56 2020 daemon.notice netifd: Interface 'loopback' has link connectivity
Tue Mar 17 16:38:07 2020 daemon.notice procd: /etc/rc.d/S50uhttpd: Generating selfsigned certificate with subject 'C=ZZ,ST=Somewhere,L=Unknown,O=OpenWrtdf501f0b,CN=OpenWrt,' and validity 20200317163755-20220317163755
Tue Mar 17 16:38:09 2020 user.notice ucitrack: Setting up /etc/config/network reload dependency on /etc/config/dhcp
Tue Mar 17 16:38:09 2020 user.notice ucitrack: Setting up /etc/config/network reload dependency on /etc/config/radvd
Tue Mar 17 16:38:09 2020 user.notice ucitrack: Setting up /etc/config/wireless reload dependency on /etc/config/network
Tue Mar 17 16:38:09 2020 user.notice ucitrack: Setting up /etc/config/firewall reload dependency on /etc/config/luci-splash
Tue Mar 17 16:38:09 2020 user.notice ucitrack: Setting up /etc/config/firewall reload dependency on /etc/config/qos
Tue Mar 17 16:38:09 2020 user.notice ucitrack: Setting up /etc/config/firewall reload dependency on /etc/config/miniupnpd
Tue Mar 17 16:38:09 2020 user.notice ucitrack: Setting up /etc/config/dhcp reload dependency on /etc/config/odhcpd
Tue Mar 17 16:38:10 2020 user.notice ucitrack: Setting up non-init /etc/config/fstab reload handler: /sbin/block mount
Tue Mar 17 16:38:10 2020 user.notice ucitrack: Setting up /etc/config/system reload trigger for non-procd /etc/init.d/led
Tue Mar 17 16:38:10 2020 user.notice ucitrack: Setting up /etc/config/system reload dependency on /etc/config/luci_statistics
Tue Mar 17 16:38:10 2020 user.notice ucitrack: Setting up /etc/config/system reload dependency on /etc/config/dhcp
Tue Mar 17 16:38:12 2020 daemon.info procd: - init complete -
Tue Mar 17 16:38:13 2020 daemon.info urandom_seed[2344]: Seed saved (/etc/urandom.seed)
Tue Mar 17 16:38:23 2020 daemon.notice netifd: Interface 'loopback' is now down
Tue Mar 17 16:38:23 2020 daemon.notice netifd: Interface 'loopback' is disabled
Tue Mar 17 16:38:23 2020 daemon.notice netifd: Network device 'lo' link is down
Tue Mar 17 16:38:23 2020 daemon.notice netifd: Interface 'loopback' has link connectivity loss
Tue Mar 17 16:39:19 2020 daemon.err uhttpd[2152]: luci: accepted login on / for root from 192.168.1.150
Tue Mar 17 16:39:49 2020 auth.err passwd: password for root changed by roottype or paste code here

I would need some help in setting up a basic initial port configuration under OpenWRT for a switch using entirely DSA. Is there some documentation for that?

I also don't understand much about TCP transmissions. The duplicate ACKs don't seem to be due to transmission errors, instead I seem to make a mistake with the network API.

4 Likes

https://gitlab.com/bkoblitz/openwrt-rtl838x

404 :slight_smile:

Sorry, ynezz, my mistake. Fixed now. Thanks for the interest. I am really curious to get your opinion on whether this might be interesting to add into OpenWRT at some point.

Sorry, is fixed now.

Birger

Hi, I tried in my Abaniact AML2-17GP (RTL8382, 17ports) and succeeded to boot.
Thank you for your great work!

repo: https://github.com/musashino-build/openwrt/tree/tgtadd/rtl838x

bootlog
U-Boot 2011.12.46351 (Mar 14 2014 - 16:33:56)

Board: RTL838x CPU:500MHz LXB:200MHz MEM:300MHz
DRAM:  128 MB
SPI-F: 1x32 MB
Loading 65536B env. variables from offset 0x80000
Switch Model: RTL8382M_INTPHY_8218B_8214FC_DEMO (Port Count: 17)
Switch Chip: RTL8382M
0. [0xbb00a000] 0. val = 0x2f39eb3f
0. [0xbb00a000] 1. val = 0x2f396b3f
0. val = 0x00ffff00
**************************************************
### Error chip ID = 0x0000ffff ###
**************************************************
#### RTL8218B config - MAC ID = 8 ####
Now Internal PHY
**************************************************
#### RTL8218B config - MAC ID = 16 ####
Now External 8218B
**************************************************
**** RTL8214FC config - MAC ID = 24 ****
Now External 8214FC
Net:   Net Initialization Skipped
rtl8380#0
Hit any key to stop autoboot:  0 
RTL838x# # rtk network on
Enable network
Force port28 link up 1G
Please wait for PHY init-time ...

RTL838x# # tftp 0x81000000
*** Warning: no boot file name; using '0101A8C0.img'
Using rtl8380#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 = 4210745 (404039 hex)
RTL838x# # toom
Unknown command 'toom' - try 'help'
RTL838x# # bootm
## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   MIPS OpenWrt Linux-4.19.108
   Created:      2020-03-19   9:20:16 UTC
   Image Type:   MIPS Linux Kernel Image (gzip compressed)
   Data Size:    4210681 Bytes = 4 MB
   Load Address: 80000000
   Entry Point:  80000400
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK

Starting kernel ...

[    0.000000] Linux version 4.19.108 (musashino205@TAIHA.NET) (gcc version 8.3.0 (OpenWrt GCC 8.3.0 r12648-9446317ef0)) #0 Thu Mar 19 09:20:16 2020
[    0.000000] prom_init called
[    0.000000] model is 83826800 
[    0.000000] SoC Type: RTL8382
[    0.000000] Kernel command line: 
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019070 (MIPS 4KEc)
[    0.000000] plat_mem_setup called 
[    0.000000] MIPS: machine is INABA Abaniact AML2-17GP
[    0.000000] Registering _machine_restart
[    0.000000] NO PCI device found
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 08000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] device_tree_init called
[    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] random: get_random_bytes called from start_kernel+0x98/0x4a8 with crng_init=0
[    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)
[    0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Memory: 118928K/131072K available (4048K kernel code, 171K rwdata, 904K rodata, 5492K init, 197K bss, 12144K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 128
[    0.000000] In arch_init_irq, status register 1010f700
[    0.000000] Done setting up IRQ: 10107c00
[    0.000000] CPU frequency from device tree: 500000000
[    0.000000] CPU Clock: 500 MHz
[    0.000000] rtl838x_serial_init: cpu_freq: 500000000 baud 38400
[    0.000000] In mips_clockevent_init ++++++++++++
[    0.000000] calling r4k_clockevent_init
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041786 ns
[    0.000015] sched_clock: 32 bits at 250MHz, resolution 4ns, wraps every 8589934590ns
[    0.008631] console [ttyS0] enabled
[    0.008631] console [ttyS0] enabled
[    0.016235] bootconsole [early0] disabled
[    0.016235] bootconsole [early0] disabled
[    0.025167] Calibrating delay loop... 498.89 BogoMIPS (lpj=2494464)
[    0.092123] pid_max: default: 32768 minimum: 301
[    0.097751] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.105118] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.123981] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.134988] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.142071] pinctrl core: initialized pinctrl subsystem
[    0.149181] NET: Registered protocol family 16
[    0.220307] clocksource: Switched to clocksource MIPS
[    0.228862] NET: Registered protocol family 2
[    0.235303] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes)
[    0.244042] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.251887] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.258963] TCP: Hash tables configured (established 1024 bind 1024)
[    0.266618] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.273252] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.281083] NET: Registered protocol family 1
[    0.644305] Crashlog allocated RAM at address 0x3f00000
[    0.655338] workingset: timestamp_bits=14 max_order=15 bucket_order=1
[    0.681648] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.688117] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.781153] io scheduler noop registered
[    0.785509] io scheduler deadline registered (default)
[    0.902529] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
[    0.909861] serial8250: ttyS0 at MMIO 0x0 (irq = 39, base_baud = 12442400) is a 16550A
[    1.309933] brd: module loaded
[    1.314486] Initializing rtl838x_nor_driver
[    1.319133] Initializing rtl838x_nor_driver 1
[    1.324036] Initializing rtl838x_nor_driver 2
[    1.328852] Initializing rtl838x_nor_driver 3
[    1.333730] Initializing rtl838x_nor_driver 4
[    1.338554] Initializing rtl838x_nor_driver 5
[    1.343411] rtl838x_nor_init called
[    1.347273] In spi_init
[    1.349962] In spi_enter_sio
[    1.353198] spi_write_disable: sfcsr_val = 40000000,SFDR = 04000000
[    1.353213] spi_read_id: rdid,sfcsr_val = 40000000,SFDR = 9f000000 
[    1.367103] rdid,sfcsr_val = 70000000
[    1.371212] Buffer 2019c220
[    1.374302] Flash ID: ffc22019
[    1.377672] In rtl838x_nor_read_reg: opcode 9f, len 6
[    1.383293] c2  
[    1.383301] 20  
[    1.385333] 19  
[    1.387355] c2  
[    1.389378] 20  
[    1.391460] 19  
[    1.393548] In rtl838x_nor_write_reg, opcode 6, len 0
[    1.401203] In rtl838x_nor_write_reg, opcode 1, len 1
[    1.406783]   data: 0
[    1.409289] In rtl838x_nor_read_reg: opcode 5, len 1
[    1.414818] 03  
[    1.418229] In rtl838x_nor_read_reg: opcode 5, len 1
[    1.425854] 00  
[    1.425871] In rtl838x_nor_write_reg, opcode b7, len 0
[    1.433635] rtl838x-nor b800120.spi: mx25l25635e (32768 Kbytes)
[    1.440177] ------------- Got size: 2000000
[    1.444917] 7 fixed-partitions partitions found on MTD device rtl838x_nor
[    1.452499] Creating 7 MTD partitions on "rtl838x_nor":
[    1.458309] 0x000000000000-0x000000080000 : "u-boot"
[    1.465981] 0x000000080000-0x000000090000 : "u-boot-env"
[    1.474083] 0x000000090000-0x0000000a0000 : "SYSINFO"
[    1.481882] 0x0000000a0000-0x0000004a0000 : "JFFS2_CFG"
[    1.489734] 0x0000004a0000-0x0000005a0000 : "JFFS2_LOG"
[    1.497833] 0x0000005a0000-0x0000012d0000 : "RUNTIME"
[    1.505625] 0x0000012d0000-0x000002000000 : "RUNTIME2"
[    1.514632] libphy: Fixed MDIO Bus: probed
[    1.519370] Probing RTL838X switch device
[    1.523959] Found RTL8382M
[    1.526957] Chip version B
[    1.530012] Error registering switch: -517
[    1.534950] Probing RTL838X eth device
[    1.544104] In rtl838x_set_mac_address 87c1fc80 810005f4
[    1.549993] Found mdio node
[    1.553158] Allocated mdio bus
[    1.556879] libphy: mdio: probed
[    1.889633] NET: Registered protocol family 10
[    1.906532] Segment Routing with IPv6
[    1.910885] NET: Registered protocol family 17
[    1.916594] 8021q: 802.1Q VLAN Support v1.8
[    1.924236] Probing RTL838X switch device
[    1.928742] Found RTL8382M
[    1.931822] Chip version B
[    1.934895] Powering on fibre ports & reset
[    1.939532] SDS power down value: 20
[    1.967527] FF8 register: efffffff
[    1.971368] SDS power down value now: 3f
[    1.975770] Phy on MAC 8: ca40
[    1.989299] PHY ID: 6275
[    1.992145] Found internal RTL8218B
[    1.996003] IPD: 0
[    1.998281] PHY status: 1140
[    2.001508] Resetting PHY 8
[    4.587311] PHY 8 successfully patched
[    4.591546] > 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff
[    4.600207] > 10000100 10000200 10000400 10000800 10001000 10002000 10004000 10008000
[    4.608912] > 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff 1fffffff
[    4.617628] > 11000000 1fffffff 14000000 1fffffff  500ff00
[    4.623737] rtl8300_enable_phy_polling
[    5.700333] Please wait until PHY is settled
[    7.043045] libphy: dsa slave smi: probed
[    7.050154] rtl838x-switch 0.switch0 lan1 (uninitialized): PHY [mdio-bus:08] driver [Generic PHY]
[    7.063902] rtl838x-switch 0.switch0 lan2 (uninitialized): PHY [mdio-bus:09] driver [Generic PHY]
[    7.077861] rtl838x-switch 0.switch0 lan3 (uninitialized): PHY [mdio-bus:0a] driver [Generic PHY]
[    7.092145] rtl838x-switch 0.switch0 lan4 (uninitialized): PHY [mdio-bus:0b] driver [Generic PHY]
[    7.106419] rtl838x-switch 0.switch0 lan5 (uninitialized): PHY [mdio-bus:0c] driver [Generic PHY]
[    7.120164] rtl838x-switch 0.switch0 lan6 (uninitialized): PHY [mdio-bus:0d] driver [Generic PHY]
[    7.134117] rtl838x-switch 0.switch0 lan7 (uninitialized): PHY [mdio-bus:0e] driver [Generic PHY]
[    7.148397] rtl838x-switch 0.switch0 lan8 (uninitialized): PHY [mdio-bus:0f] driver [Generic PHY]
[    7.160962] rtl838x-switch 0.switch0 lan9 (uninitialized): PHY [mdio-bus:18] driver [Generic PHY]
[    7.173192] rtl838x-switch 0.switch0 lan10 (uninitialized): PHY [mdio-bus:1a] driver [Generic PHY]
[    7.233982] rtl838x_adjust_link, port 28
[    7.238352] DSA: tree 0 setup
[    7.305376] Freeing unused kernel memory: 5492K
[    7.310476] This architecture does not have kernel memory protection.
[    7.317595] Run /init as init process
[    7.495359] init: Console is alive
[    7.528255] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    7.536441] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    7.551004] init: - preinit -
[    7.923681] random: jshn: uninitialized urandom read (4 bytes read)
[    7.966154] random: jshn: uninitialized urandom read (4 bytes read)
[    8.028574] rtl838x_eth_open called 87c1fc80, ring a7700000
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
[   12.435045] in rtl838x_eth_stop 87c1fc80
[   12.457989] procd: - early -
[   14.644237] procd: - ubus -
[   14.662094] random: ubusd: uninitialized urandom read (4 bytes read)
[   14.701765] random: ubusd: uninitialized urandom read (4 bytes read)
[   14.709674] random: ubusd: uninitialized urandom read (4 bytes read)
[   14.720088] procd: - init -
Please press Enter to activate this console.
[   15.545640] kmodloader: loading kernel modules from /etc/modules.d/*
[   15.745418] xt_time: kernel timezone is -0000
[   15.829315] PPP generic driver version 2.4.2
[   15.852417] NET: Registered protocol family 24
[   15.918664] kmodloader: done loading kernel modules from /etc/modules.d/*
[   15.937933] urngd: v1.0.2 started.
[   16.103759] random: crng init done
[   16.107542] random: 5 urandom warning(s) missed due to ratelimiting
[   49.274367] rtl838x_eth_open called 87c1fc80, ring a7700000
[   49.595126] in rtl838x_eth_stop 87c1fc80
[   49.600731] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   49.843697] rtl838x_eth_open called 87c1fc80, ring a7700000
[   50.349932] in rtl838x_eth_stop 87c1fc80
[   50.368489] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready



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

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r12648-9446317ef0
 -----------------------------------------------------
=== 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@OpenWrt:/#

Wow. That's cool. I bet though only 8 ports work, because only those are served by the internal 8218BPHY. The external 8218B and 8214FC are not supported yet. If you want to do this yourself, the GPL dump for this can be found at
https://tsd.dlink.com.tw/downloads2008list.asp?t=1&OS=GPL&SourceType=download&pagetype=S

and then you get:

/Downloads/dgs1210/DGS-1210-16/sdk/rtk-sdk/src/hal/phy$ ls
identify.c  phy_8208.c        phy_8212f.c  phy_8214f.c   phy_8214fb_patch.c  phy_8218b.c        phy_8328.c  phy_8389.c  phy_common.c
phy_8201.c  phy_8208_patch.c  phy_8214c.c  phy_8214fb.c  phy_8218.c          phy_8218b_patch.c  phy_8380.c  phy_8390.c  phy_probe.c

From this one needs a phy_read, a phy_write and a phy_setup routine currently to end up in rtl838x_sw.conf. But of course the cleaner solution is to put it into the phy drivers directory of the linux kernel code.

1 Like

Hi,
the port made quite a bit of progress (thanks also to musashino!) and the D-Link DGS-1210-16 can now be installed with OpenWRT and has happily performed its duty as main router for some days without a hickup. The diff to the inital post is:

  • Full r/w support for 16/32MB NOR flash in 3 and 4 addressing modes
  • GPIO driver added
  • Migrated ethernet driver from phylib to phylink
  • Added VLAN support (very little testing)
  • Support for EEE (might work, no test device that shows the actual status)
  • Interrupt driven link change detection
  • PHY drivers for 8218B (int/ext) and 8214FC, some PHY autodetection
  • Support for TP/FIBRE comboports, e.g. "ethtool -s lan17 port fibre" enables SFP port
  • Ethernet driver now stable and optimized
  • autodetection of DSA switch configuration at first boot for /etc/board.json and /etc/config/network
  • some LuCI support for the DSA switch
  • L2 functionality mostly done (mac-aging), FDB table manipulation missing)
  • sysupgrade works

I added some rudimentary LuCI support for the DSA switch:

but UI is ugly and does not really work well with the 20 ports of the switch:

I think the rtl838x port is now stable enough to replace the oem firmware with similar functionality level, there are plenty of switches which could be ported quickly to OpenWRT: all the D-Link DGS-1210 (up to 20 ports, larger ones with up to 52 ports use RTL8390 chip), Zyxel 19xx and TP-link T2xxxx series.

Code can be found at https://github.com/rtk-owlab/openwrt/tree/tgtadd/rtl838x_bk
The sysupgrade image can be directly flashed over the kernel and adjoining jffs partition of the D-Link DGS-1210-16. Make sure you have a serial connection! The image for the Zyxel should also work but is not tested.

5 Likes

Excellent work! I have a TRENDnet TPE-224WS 24-Port PoE Switch which appears to use the same SOC (See my entry on WikiDevi). I'm currently using the switch, but might be able to temporarily replace it with an old Netgear in order to try adapting your firmware.

Ray

Thanks. I did not put any explicit support for the RTL8332 in. I dont have one of these devices. But I can see that the GPL dumps for the RTL838x have support for that chip. A good way to start is to look at the GPL dumps from D-Link. In the various dumps for the DGS-1210-16 I can see the chip explicitly mentioned with support from booting up to the NIC.
Birger

Just downloaded the GPL Source for the TPE-224WS. Couldn't find it when I looked after making the WikiDevi entry, but it was easy enough to locate today.

From what I can see on the device, you should be able to do an initial trial with one of the initramfs images from the code so far, pick one with the right serial line speed. You need to interrupt the u-boot bootloader on the serial console, then enable networking with the command "rtk network on", tftp the initramfs into RAM and simply issue "bootm" to start the image. Don't expect too much as it will probably fail the moment the processor is verified, but at least you will get already some output on the console. If you then add a check in files-5.4/arc/mips/rtl838x/prom.c for the processor, you should already be a step further.

Birger

I just looked through the U-Boot GPL dump for the DGS-1210-16 and the RTL8332 is treated there as a variant of the RTL8380. If the checks for the soc are adapted to also accept that chip, the code should simply work. The biggest work is likely to add support for the 2 external PHYs of the TPE, but I can see that the initialization code for both (8214b and 8208) can be found in the DGS GPL dump -- after all U-Boot needs to initialize the PHYs to allow you to do TFTP.

Birger

In the latest git, detection of the RTL8332 was added. Loading an image now should fail in a more interesting way than simply to refuse to work.
I can add PHY support for the 8214b and 8208 if you sends me the dmesg lines showing their probed device-ids. These PHYs exist in so many variants, I would like to add the right ones.

I won't be able to do much with this for a couple of weeks. Going out of town for a wedding, and then I'll need to replace the switch with another PoE swith I have before I can start playing with it's firmware. Also discovered a couple of D-Link switches in my collection DGS-1210-10P Ver A1 and a DGS-1210-24 Ver A1. The other TRENDnet is Marvell based, the Netgears all seem to be Broadcom and the TP-Link I haven't been able to determine what SOC it uses.

I actually also have a D-Link DGS-1210-10P which is currently hooked up to a logic analyzer in order to understand the PoE protocol. There is a Nuvoton ARM-Chip on the board which seems to monitor the Broadcom PoE chip using SPI. The RTL8380M on the Board then talks with the Nuvoton ARM SoC using a binary serial 19200 8N1 connection. The board even has 2 extra pin-headers: one to program the ARM chip using SWD, the other to listen in on the serial connection. There are only about 20 bytes sent every second (normally monitoring data which is always the same) in both directions but I am lacking inspiration what exactly could be exchanged...
I bet also the other D-Link has either an RTL8332 or RTL8382, the DGS-1210-16 I have has an RTL8382 and works already quite nicely with OpenWRT. It could have an RTL8390, though, which is in the same state of non-support as the RTL8332. Enjoy the wedding!

I managed to mostly decode the protocol for PoE for the DLink DGS-1210-10P. The following script does the trick:

#!/usr/bin/lua
local rs = require "luars232"

-- port_name = "/dev/ttyUSB0"
port_name = "/dev/ttyS1"

out = io.stderr
	
function initSerial(p)
	local e, p = rs.open(p)
	if e ~= rs.RS232_ERR_NOERROR then
		-- handle error
		out:write(string.format("can't open serial port '%s', error: '%s'\n",
				port_name, rs.error_tostring(e)))
		return
	end

	assert(p:set_baud_rate(rs.RS232_BAUD_19200) == rs.RS232_ERR_NOERROR)
	assert(p:set_data_bits(rs.RS232_DATA_8) == rs.RS232_ERR_NOERROR)
	assert(p:set_parity(rs.RS232_PARITY_NONE) == rs.RS232_ERR_NOERROR)
	assert(p:set_stop_bits(rs.RS232_STOP_1) == rs.RS232_ERR_NOERROR)
	assert(p:set_flow_control(rs.RS232_FLOW_OFF)  == rs.RS232_ERR_NOERROR)

	out:write(string.format("OK, port open with values '%s'\n", tostring(p)))

	return p
end

function receive(pCon)
--	local reply = {0x20, 0x01, 0x00, 0x08, 0x00, 0xe1, 0x21, 0x18, 0x01, 0x02, 0x21, 0x67}
	local reply = {}
	local retries = 0

	while table.getn(reply) < 12 and retries < 4 do
		-- Read up to 12 byte response, timeout 400ms
		err, data_read, size = pCon:read(12, 400)
		assert(err == rs.RS232_ERR_NOERROR)
--		io.write(string.format("-> [%2d]:", string.len(data_read)))
		for i = 1, string.len(data_read) do
			table.insert(reply, string.byte(string.sub(data_read, i, i)))
--			io.write(string.format(" %02x", reply[i]))
		end
--		io.write("\n")
		retries = retries + 1
	end
	if table.getn(reply) ~= 12 then
		return(nil)
	end
	local sum = 0
	for i = 1, 11 do
		sum = sum + reply[i]
	end
	if sum % 256 ~= reply[12] then
		print ("Checksum error!")
		return(nil)
	end
	return(reply)
end

function sendCommand(pCon, cmd)
	while table.getn(cmd) < 11 do
		table.insert(cmd, 0xff)
	end
	local sum = 0
	for i,v in ipairs(cmd) do
		sum = sum + v
	end
	table.insert(cmd, sum % 256)
	local c_string = ""
	for i = 1, 12 do
		c_string = c_string .. string.char(cmd[i])
	end
	err, len_written = pCon:write(c_string)
	assert(err == rs.RS232_ERR_NOERROR)

	local reply = receive(pCon)
	if reply then
		if (reply[1] == cmd[1] and reply[2] == cmd[2]) then
--			io.write("valid: ")
--			dumpReply(reply)
			return(reply)
		end
	end
	return(nil)
end

function dumpReply(reply)
	io.write("Reply: ")
	for i,v in ipairs(reply) do
		io.write(string.format(" %02x", v))
	end
	io.write("\n");
end
	
function getStatus(pCon)
	local cmd = {0x20, 0x01}
	local reply = sendCommand(pCon, cmd)
	if not reply then return(nil) end
	-- returns status, PoEExtVersion, PoEVersion, state2
	return({reply[5], reply[6], reply[7], reply[10]})
end

function disablePort(pCon, port)
	local cmd = {0x00, port, port, 0x00}
	-- disable command is always sent twice
	sendCommand(pCon, cmd)
	sendCommand(pCon, cmd)
end

function enablePort(pCon, port)
	local cmd = {0x00, port, port, 0x01}
	sendCommand(pCon, cmd)
end

function setPortRelPrio(pCon, port, prio)
	local cmd = {0x1d, 0x00, port, prio}
	sendCommand(pCon, cmd)
end

function setGlobalPowerBudget(pCon, maxPower, guard)
	-- maxPower and guard Watts
	local cmd = {0x18, 0x01, 0x00}
	table.insert(cmd, math.floor(maxPower * 10 / 256))
	table.insert(cmd, math.floor(maxPower * 10) % 256)
	table.insert(cmd, math.floor(guard * 10 / 256))
	table.insert(cmd, math.floor(guard * 10) % 256)
	sendCommand(pCon, cmd)
end

function setPowerLowAction(pCon, disableNext)
	local cmd = {0x17, 0x00}
	if disableNext then
		table.insert(cmd, 0x04)
	else
		table.insert(cmd, 0x02)
	end
	sendCommand(pCon, cmd)
end
	
function getPowerStat(pCon)
	local cmd = {0x23, 0x01}
	local reply = sendCommand(pCon, cmd)
	if not reply then return(nil) end
	local watts = (reply[3] * 256 + reply[4]) / 10.0
	return(watts)
end

function getPortPower(pCon, port)
	local cmd = {0x30, 0x01, port}
	local reply = sendCommand(pCon, cmd)
	if not reply then return(nil) end
	local watts = (reply[10] * 256 + reply[11]) / 10.0
	local mamps = reply[6] * 256 + reply[7]
	return({watts, mamps})
end

function getPortOverview(pCon)
	local cmd = {0x2a, 0x01, 0x00}
	local reply = sendCommand(pCon, cmd)
	if not reply then return(nil) end
	local s = { }
	for i = 4, 11 do
		if reply[i] == 0x10 then
			s[i-3] = "off"
		end
		if reply[i] == 0x11 then
			s[i-3] = "enabled"
		end 
		if reply[i] > 0x11 then
			s[i-3] = "active"
		end
	end
	return(s)
end

-- Priority for power: 3: High, 2: Normal, 1: Low?
function setPortPriority(pCon, port, prio)
	local cmd = {0x1a, port, port, prio}
	local reply = sendCommand(pCon, cmd)
	if not reply then return(nil) end
	return(unpack(reply, 4, 11))
end

function getPortPowerLimits(pCon, port)
	local cmd = {0x26, 0x01, port}
	local reply = sendCommand(pCon, cmd)
	if not reply then return(nil) end
	return(answer)
end

function startupPoE(pCon)
	local reply = nil
	reply = getStatus(pCon)
	
	
	setGlobalPowerBudget(pCon, 0, 0)
	setPowerLowAction(pCon, nil)
	-- do something unknown
	sendCommand(pCon, {0x06, 0x00, 0x01})
	for i = 0, 7 do
		disablePort(pCon, i)
	end
	-- do something unknown
	sendCommand(pCon, {0x02, 0x00, 0x01})

	for i = 0, 7 do
		disablePort(pCon, i)
	end
	-- do something unknown
	sendCommand(pCon, {0x02, 0x00, 0x01})

	for i = 0, 7 do
		setPortRelPrio(pCon, i, 7-i)
	end
	-- use monitor command 25
	sendCommand(pCon, {0x25, 0x01})
	
	setGlobalPowerBudget(pCon, 65.0, 7.0)
	getPowerStat(pCon)
	-- -> 23 01 00 00 02 44 00 02 ff ff 00 6a
	
	-- Set 4 unknown port properties:
	for i = 0, 7 do
		sendCommand(pCon, {0x11, i, i, 0x01})
		sendCommand(pCon, {0x13, i, i, 0x02})
		sendCommand(pCon, {0x15, i, i, 0x01})
		sendCommand(pCon, {0x10, i, i, 0x03})
	end
	for i = 0, 7 do
		enablePort(pCon, i)
	end

end	

local p = initSerial(port_name)
-- startupPoE(p)
local s = { }
while 1 do
	reply = getStatus(p)
--	dumpReply(reply)
	io.write(string.format("Total power: %f W\n", getPowerStat(p)))
	s = getPortOverview(p)
	io.write("Port state: ")
	for i = 1, 8 do
		io.write(string.format("%d: %s  ", i, s[i]))
	end
	io.write("\n")
	for i = 1, 8 do
		if s[i] == "active" then
			local r = getPortPower(p, i-1)
			io.write(string.format("Port %d: %f Watt, %d mA\n", i, r[1], r[2]))
		end
	end
	io.write("\n")
	os.execute("sleep " .. tonumber(2))
end

It gives the following result when first turning on all ports and then plugging a small switch into the first Ethernet port:

root@OpenWrt:/tmp# cat /proc/cpuinfo 
system type             : RTL8380
machine                 : D-Link DGS-1210-10p
processor               : 0
cpu model               : MIPS 4KEc V7.0
BogoMIPS                : 498.89
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 32
extra interrupt vector  : yes
hardware watchpoint     : yes, count: 2, address/irw mask: [0x0fff, 0x0fff]
isa                     : mips1 mips2 mips32r1 mips32r2 mips64r1 mips64r2
ASEs implemented        : mips16
Options implemented     : tlb 4kex 4k_cache 32fpr prefetch mcheck ejtag llsc dc_aliases perf_cntr_intr_bit
shadow register sets    : 1
kscratch registers      : 0
package                 : 0
core                    : 0
VCED exceptions         : not available
VCEI exceptions         : not available

root@OpenWrt:/tmp# ./serial.lua 
OK, port open with values 'device: /dev/ttyS1, baud: 19200, data bits: 8, parity: none, stop bits: 1, flow control: off'
Total power: 0.300000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 0.300000 Watt, 6 mA

Total power: 0.300000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 0.300000 Watt, 6 mA

Total power: 0.300000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 0.300000 Watt, 6 mA

Total power: 0.300000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 0.300000 Watt, 6 mA

Total power: 0.300000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 0.300000 Watt, 6 mA

Total power: 1.600000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 1.900000 Watt, 36 mA

Total power: 2.500000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.500000 Watt, 47 mA

Total power: 2.300000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.200000 Watt, 42 mA

Total power: 2.600000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.600000 Watt, 50 mA

Total power: 2.600000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.600000 Watt, 49 mA

Total power: 2.700000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.700000 Watt, 52 mA

Total power: 2.700000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.700000 Watt, 52 mA

Total power: 2.400000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.400000 Watt, 46 mA

Total power: 2.400000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.700000 Watt, 52 mA

Total power: 2.600000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.700000 Watt, 52 mA

Total power: 3.000000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.900000 Watt, 55 mA

Total power: 3.000000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 3.000000 Watt, 57 mA

Total power: 3.000000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.800000 Watt, 53 mA

Total power: 2.900000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.900000 Watt, 55 mA

Total power: 2.900000 W
Port state: 1: active  2: enabled  3: enabled  4: enabled  5: enabled  6: enabled  7: enabled  8: enabled  
Port 1: 2.900000 Watt, 54 mA

Terminated

Not an easy to find one, indeed, but some google hacking can get you there :wink: https://manualzz.com/doc/31627850/draft-datasheet

If you want the PDF drop me an email (this username at klondike.es) and I'll send it to you :slight_smile:

1 Like

Thanks for the link. I managed to download the .pdf. Very useful to understand the background!
From the latest GPL drops and from
https://www.realtek.com/en/products/communications-network-ics/category/managed-switch-controller
one can see that there are more recent additions to the family, apart from the RTL839x there is now an RTL930x and RTL931x family targeting small office and ambitious home users with mult-gigabit switches. Have you by any chance see any datasheets of those?

I haven't found any datasheets for these yet, sorry.

Do you know if anybody has tried to reach Realtek about this? They may be the first ones interested into getting Linux support for their own products.

I have not contacted Realtek myself and am not aware of anyone having done that so far. My impression is that Realtek is very secretive about what they do. Having those datasheets would be very cool, however, especially to understand the advanced L2 and L3 features.
For the 838x and 839x the situation is not so bad because there are u-boot GPL dumps which cover basic network drivers, all the code to set the PHYs up and code to work with the GPIOs and flash. Since basically every switch manufacturer from Allnet to Zyxel has these devices in their lines of web-managed switches and the hardware configurations are all based on the same demo-boards, it is possible to stitch things together. What is mostly missing, and in clear violation of the GPL, are the Linux adaptations for these chips. For example the GPL dump for the Netgear GS728TPv2 shows a lot of hints about MIPS architecture adaptations and USB drivers but all interesting files are left out. My impression is that their understanding of the GPL is that if you can put it into a separate source file, you don't need to distribute the source code :wink:
For the 9300 and 9310 there is absolutely no u-boot GPL code apart from register names, although I am sure u-boot always gets linked together into one big binary blob. Supporting these devices in OpenWRT could be interesting, since they cover the range of managed multi-gig switches people now start putting into their basements to have the Ethernet bandwidth for WiFi Wave 6 devices.