Support for RTL838x based managed switches

Hey there Borromini,

I added some additional translation to realtek-poe -d, and I'm noticing that I get some errors from the MCU. I'm wondering whether this is related to the inability of realtek-poe to bring ports actually up?

:
TX -> 0x1a 0x09 0x03 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x20
Set port priority 
RX -> 0x1a 0x09 0x03 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x1f
Set port priority 
TX -> 0x1c 0x0a 0x03 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x23
Set port power-up mode 
RX -> 0xfe 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xf4
Request checksum n/a Request frame checksum was incorrect 
TX -> 0x15 0x0b 0x03 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x1d
Set port power limit type 
RX -> 0x15 0x0b 0x03 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x1c
Set port power limit type 
:

Is there any code you'd like me to try? I can see how it behaves and report back, but I have no C skills whatsoever unfortunately. But happy to help where I can.

If you're able to compile it, here's a copy of realtek-poe's main.c; see if you get the same "Request checksum" issues.

https://paste.c-net.org/StingsWinnings

1 Like

Alternatively, just copy this to your /usr/bin/realtek-poe: https://paste.c-net.org/ReturnedDiploma

I can recompile the binary package, thanks! Just grabbed your code and diffed it out of curiosity :slightly_smiling_face:.

It's running rather late here so I won't be able to try this tonight still (European time), but I will report back to you in the next days. Will keep you posted!

@hurricos Beat me up, but with your code changes it just seems to work again somehow :face_with_open_eyes_and_hand_over_mouth:. Not sure if realtek-poe -d is supposed to return the prompt, it didn't print anything new when I plugged in a second PoE client. This is with your code (on 22.03):

root@OpenWrt:~# ubus call poe info
{
	"firmware": "v17.1",
	"mcu": "ST Micro ST32F100 Microcontroller",
	"budget": 70.000000,
	"consumption": 6.200000,
	"ports": {
		"lan1": {
			"priority": 2,
			"mode": "Legacy",
			"status": "Delivering power",
			"consumption": 3.100000
		},
		"lan2": {
			"priority": 2,
			"mode": "Legacy",
			"status": "Delivering power",
			"consumption": 3.100000
		},
		"lan3": {
			"priority": 2,
			"mode": "Legacy",
			"status": "Searching"
		},
		"lan4": {
			"priority": 2,
			"mode": "PoE",
			"status": "Searching"
		}
	}
}
root@OpenWrt:~# realtek-poe -d
Failed to add object: Invalid argument
TX -> 0x20 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x18
Get system info

Configuration:

root@OpenWrt:~# cat /etc/config/poe 
config global
	option budget	'70'

config port
	option enable	'1'
	option id	'1'
	option name	'lan1'
	option poe_plus	'1'
	option priority	'2'

config port
        option enable   '1'
        option id       '2'
        option name     'lan2'
        option poe_plus '1'
        option priority '2'

config port
        option enable   '1'
        option id       '3'
        option name     'lan3'
        option poe_plus '1'
        option priority '2'

config port
        option enable   '1'
        option id       '4'
        option name     'lan4'
        option poe_plus '1'
        option priority '2'

config port
        option enable   '0'
        option id       '5'
        option name     'lan5'
        option poe_plus '1'
        option priority '2'

config port
        option enable   '0'
        option id       '6'
        option name     'lan6'
        option poe_plus '1'
        option priority '2'

config port
        option enable   '0'
        option id       '7'
        option name     'lan7'
        option poe_plus '1'
        option priority '2'

config port
        option enable   '0'
        option id       '8'
        option name     'lan8'
        option poe_plus '1'
        option priority '2'

Is there any way to download OpenWRT for xgs1210?

Hey there -- you must actually stop the other realtek-poe from running in order for realtek-poe -d to actually show anything.

That is, /etc/init.d/poe stop; /etc/init.d/poe disable; realtek-poe -d.

I'm also currently in the process of cherry-picking commits to compile a new image for my xgs1010-12

I think, you need at least these 3 commits from @yarrick (https://github.com/yarrick/openwrt/commits/xgs1210) for the xgs1210 to show up in menuconfig, and declare partitions and i2c:

  • c26a70792c59bfed050f6f11332b23f80f10b446
  • d4f254ddfd40e15ea9645580ef29388e1c116fef
  • 6069036dc4c99ed6e0373dfcfc9b9a89e96a2eee

I think, most/all of the remaining changes in the other commits have been rolled into the commits targeting the xgs1250 by (i think) @blogic, and have already? arrived in master. I'm currently building with the 3 cherrypicks above, and'll check if it boots later today.

That image booted, but no ethernet link.
I also then cherry-picked:

  • 7c0eb56eb06f73939bca64395ccf6cec70c7b7a4
  • 3e4d838fb8bf23a081c65dca2565b28fe199b491

this boots, and has functioning network on ports 1-8, but sysupgrade fails.
(I think, this is because sysupgrade wants partition 'firmware', while the partition name is 'firmware1'. I'll look into it tomorrow)
Did you get further @DienoX ?

I obviously did not do that :person_facepalming:. This is just from running realtek-poe -d as you instructed. I did notice the first PoE client coming up, the second one stays down for whatever reason. Weird stuff.

Only have PoE enabled on the first four ports of my GS1900-8HP v1, but ubus prints port 2 as disabled despite it being set to enabled in /etc/config/poe :confused:.

root@OpenWrt:~# ubus call poe info
{
	"firmware": "v17.1",
	"mcu": "ST Micro ST32F100 Microcontroller",
	"budget": 70.000000,
	"consumption": 3.100000,
	"ports": {
		"lan1": {
			"priority": 2,
			"mode": "Legacy",
			"status": "Delivering power",
			"consumption": 3.100000
		},
		"lan2": {
			"priority": 2,
			"mode": "Legacy",
			"status": "Disabled"
		},
		"lan3": {
			"priority": 2,
			"mode": "Legacy",
			"status": "Disabled"
		},
		"lan4": {
			"priority": 2,
			"mode": "Legacy",
			"status": "Searching"
		}
	}
}

I don't have this device yet. Before buying, I analyzed OpenWRT compatibility, hence my question. But in the end I decided to buy because the 1250 is quite similar so the support will be available.

Has anyone actually tried this with workin result on F1 hardware?

A can manually scan the switches and control the LED’s if I use the gpiochip451 so the hardware works. But gpio1 that are specified in the dts files doesn’t do anything and nothing works with this definition.
And I really doesn’t see any connection in the dts definition for gpio1 and gpiochip451?

The GS1900-48 has an unpopulated eJTAG header, but most of the SMD resistors were already in place. I've added a header and made some other small modifications, resulting in:

$ openocd -f ./ft232h.cfg 
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
jtag_ntrst_delay: 500

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 10000 kHz
Warn : There are no enabled taps.  AUTO PROBING MIGHT NOT WORK!!
Info : JTAG tap: auto0.tap tap/device found: 0x00001001 (mfg: 0x000 (<invalid>), part: 0x0001, ver: 0x0)
Info : JTAG tap: auto1.tap tap/device found: 0x00000001 (mfg: 0x000 (<invalid>), part: 0x0000, ver: 0x0)
Warn : AUTO auto0.tap - use "jtag newtap auto0 tap -irlen 5 -expected-id 0x00001001"
Warn : AUTO auto1.tap - use "jtag newtap auto1 tap -irlen 5 -expected-id 0x00000001"

It finds two devices in the JTAG chain! The RTL8393M in this device configures these pins to the JTAG function by (hardware) default. Same should be valid for RTL93xx devices, so maybe this can help with debugging in the future.

Edit: @anon13997276 the XGS1250-12 and XGS1210-12 also have an eJTAG header that is disabled in the same way. I've added the mod details on the wiki, but haven't actually tested them.

Edit more: Created a JTAG page on the wiki. The config file allows to halt and resume the CPU (u-boot console hangs and then resumes), so I guess that's a good starting point :slight_smile:

Via OpenOCD (telnet):

��������Open On-Chip Debugger
> reset
reset
JTAG tap: otto.switchcore tap/device found: 0x00001001 (mfg: 0x000 (<invalid>), part: 0x0001, ver: 0x0)
JTAG tap: otto.cpu tap/device found: 0x00000001 (mfg: 0x000 (<invalid>), part: 0x0000, ver: 0x0)

> halt
halt
target halted in MIPS32 mode due to debug-request, pc: 0x9f000bec

> otto.cpu mdb 0xb8003500 0x20
otto.cpu mdb 0xb8003500 0x20
0xb8003500: ff ff ff 00 00 00 00 00 00 00 00 00 06 c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

> resume
resume

And in the U-Boot console:

RTL839x# md.b 0xb8003500 0x20
b8003500: ff ff ff 00 00 00 00 00 00 00 00 00 06 c0 00 00    ................
b8003510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
4 Likes

Just FYI, I have just tried openwrt master on my ZyXEL GS1900-8HP v2, and I believe the flooding issue is still present. (With the default openwrt configuration of all ports on VLAN 1, packets destined for the switch are flooded to all ports.)

Do you mean packets addressed to one of the switch'es own mac addresses? I guess that could still be an issue. I must admit I haven't looked closely at those. Wouldn't notice since it can't be that many packets (or the ethernet driver would go bananas)

The major flooding issue, where traffic to any mac adress was flooded, is fixed for me at least. Currently running an image based on commit 34fd5e325af5. Anything more recent should also be fine AFAICS.

Yeah, packets addressed to one of the switch'es own mac addresses. e.g. when accessing the openwrt web interface from one port, can see the HTTP packets etc flooded out another port. I guess this isn't a big issue if the major flooding issue has been resolved.

Hmm. I can't reproduce that.

Did a quick test in my current environment by snooping on a device connected to a GS1900-10HP port being member of the switch management VLAN, while pinging the switch on another port. I see no obvious leakage. Unicast packets to or from the switch are not forwarded on the port I snoop on.

EDIT: Come to think of it: Could this be a VLAN 1 related issue? This VLAN is somehow "special". I use a different VLAN for management and stay away from VLAN 1 for all purposes (used to be considered Best Practice 20 years ago - for the exact reason that so many devices treat it as "special", by default at least)

EDIT2: Nope, it's related to tagging for some reason. If I configure VLAN 1 as tagged on the snooping port (this is harder than expected since you first need to add another PVID untagged VLAN and then delete and re-add VLAN 1), then I don't see any leakage.

There's definitely something fishy going on here...

I just tried VLAN 2, but it appears to have the same flooding problem for me. I'm running openwrt from the initramfs image (haven't flashed it), if it makes a difference.

Argh! And now I'm unable to reproduce that effect too. No matter how I change VLAN 1 on the snooping port I still see the leakage.

You have managed to reproduce the flooding? That's good. at least