Using realtek-poe on DGS-1210-10P revision F3

I have a D-Link DGS-1210-10P (revision F3) running OpenWRT snapshot.

When I use realtek-poe to talk to the PoE controller on /dev/ttyS1, it does not seem to turn on PoE. I'm including the output from realtek-poe -d below.

realtek-poe: TX -> 20 01 ff ff ff ff ff ff ff ff ff 18
realtek-poe: RX <- 20 01 61 ff ff ff ff ff ff ff ff 7a
realtek-poe: TX -> 17 02 02 ff ff ff ff ff ff ff ff 13
realtek-poe: RX <- 17 02 61 ff ff ff ff ff ff ff ff 72
realtek-poe: TX -> 02 03 00 ff ff ff ff ff ff ff ff fd
realtek-poe: RX <- 02 03 00 ff ff ff ff ff ff ff ff fd
realtek-poe: TX -> 18 04 00 06 a4 00 aa ff ff ff ff 6c
realtek-poe: RX <- 18 04 00 ff ff ff ff ff ff ff ff 14
realtek-poe: TX -> 13 05 7f 02 ff ff ff ff ff ff ff 92
realtek-poe: RX <- 13 05 ff ff ff ff ff ff ff ff ff 0f
realtek-poe: TX -> 10 06 7f 03 ff ff ff ff ff ff ff 91
realtek-poe: RX <- 10 06 01 ff ff ff ff ff ff ff ff 0f
realtek-poe: TX -> 1a 07 00 02 ff ff ff ff ff ff ff 1c
realtek-poe: RX <- 1a 07 61 ff ff ff ff ff ff ff ff 7a
realtek-poe: TX -> 1c 08 00 03 ff ff ff ff ff ff ff 20
realtek-poe: RX <- 1c 08 61 ff ff ff ff ff ff ff ff 7d
realtek-poe: TX -> 11 09 00 01 ff ff ff ff ff ff ff 14
realtek-poe: RX <- 11 09 00 ff ff ff ff ff ff ff ff 12
realtek-poe: TX -> 15 0a 00 01 ff ff ff ff ff ff ff 19
realtek-poe: RX <- 15 0a 00 00 ff ff ff ff ff ff ff 18
realtek-poe: TX -> 00 0b 00 01 ff ff ff ff ff ff ff 05
realtek-poe: RX <- 00 0b 00 ff ff ff ff ff ff ff ff 03
realtek-poe: TX -> 23 0c ff ff ff ff ff ff ff ff ff 26
realtek-poe: RX <- 23 0c 61 ff ff ff ff ff ff ff ff 88
realtek-poe: TX -> 28 0d 00 01 01 01 02 01 03 01 ff 3e
realtek-poe: RX <- 28 0d 61 ff ff ff ff ff ff ff ff 8e
realtek-poe: Invalid port status packet (port=97)
realtek-poe: TX -> 26 0e 00 ff ff ff ff ff ff ff ff 2c
realtek-poe: RX <- 26 0e 61 ff ff ff ff ff ff ff ff 8d
realtek-poe: TX -> 30 0f 00 ff ff ff ff ff ff ff ff 37
realtek-poe: RX <- 30 0f 61 ff ff ff ff ff ff ff ff 98
(from here on, commands 0x23, 0x26, 0x28 and 0x30 repeat with similar outputs)

Notice the complaints about an invalid port number in response to command 0x28 ("get all port status"). Going by the documentation here, my feeling is that 0x61 it is some kind of error code, and not a port number. It also pops up in response to command 0x1a earlier.

Interestingly, when I change the port ID in /etc/config/poe from 1 to 2...

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

... the PoE device on the other end of the line turns on! The error about port 97 remains, however:

realtek-poe: TX -> 20 01 ff ff ff ff ff ff ff ff ff 18
realtek-poe: RX <- 20 01 61 ff ff ff ff ff ff ff ff 7a
realtek-poe: TX -> 17 02 02 ff ff ff ff ff ff ff ff 13
realtek-poe: RX <- 17 02 61 ff ff ff ff ff ff ff ff 72
realtek-poe: TX -> 02 03 00 ff ff ff ff ff ff ff ff fd
realtek-poe: RX <- 02 03 00 ff ff ff ff ff ff ff ff fd
realtek-poe: TX -> 18 04 00 06 a4 00 aa ff ff ff ff 6c
realtek-poe: RX <- 18 04 00 ff ff ff ff ff ff ff ff 14
realtek-poe: TX -> 13 05 7f 02 ff ff ff ff ff ff ff 92
realtek-poe: RX <- 13 05 ff ff ff ff ff ff ff ff ff 0f
realtek-poe: TX -> 10 06 7f 03 ff ff ff ff ff ff ff 91
realtek-poe: RX <- 10 06 01 ff ff ff ff ff ff ff ff 0f
realtek-poe: TX -> 1a 07 01 02 ff ff ff ff ff ff ff 1d
realtek-poe: RX <- 1a 07 61 ff ff ff ff ff ff ff ff 7a
realtek-poe: TX -> 1c 08 01 03 ff ff ff ff ff ff ff 21
realtek-poe: RX <- 1c 08 61 ff ff ff ff ff ff ff ff 7d
realtek-poe: TX -> 11 09 01 01 ff ff ff ff ff ff ff 15
realtek-poe: RX <- 11 09 00 ff ff ff ff ff ff ff ff 12
realtek-poe: TX -> 15 0a 01 01 ff ff ff ff ff ff ff 1a
realtek-poe: RX <- 15 0a 01 00 ff ff ff ff ff ff ff 19
realtek-poe: TX -> 00 0b 00 00 ff ff ff ff ff ff ff 04
realtek-poe: RX <- 00 0b 00 ff ff ff ff ff ff ff ff 03
realtek-poe: TX -> 00 0c 01 01 ff ff ff ff ff ff ff 07
realtek-poe: RX <- 00 0c 00 ff ff ff ff ff ff ff ff 04
realtek-poe: TX -> 23 0d ff ff ff ff ff ff ff ff ff 27
realtek-poe: RX <- 23 0d 61 ff ff ff ff ff ff ff ff 89
realtek-poe: TX -> 28 0e 00 01 01 01 02 01 03 01 ff 3f
realtek-poe: RX <- 28 0e 61 ff ff ff ff ff ff ff ff 8f
realtek-poe: Invalid port status packet (port=97)
realtek-poe: TX -> 26 0f 00 ff ff ff ff ff ff ff ff 2d
realtek-poe: RX <- 26 0f 61 ff ff ff ff ff ff ff ff 8e
realtek-poe: TX -> 30 10 00 ff ff ff ff ff ff ff ff 38
realtek-poe: RX <- 30 10 61 ff ff ff ff ff ff ff ff 99
realtek-poe: TX -> 26 11 01 ff ff ff ff ff ff ff ff 30
(again, commands 0x23, 0x26, 0x28 and 0x30 repeat with similar outputs)

Does anybody have a recommendation on how to proceed with debugging? I suppose I could go out and buy a logic analyzer to snoop the traffic between the stock firmware and the controller, although I'm a bit hesitant to do this as I have no experience with these kinds of things.

Before going to a logic analyzer, I would check what happens if you enable all the PoE ports. @svanheule, @hurricos, do you have handy a known working realtek-poe config for the DGS-1210-10P ?

I would also look at the output of
ubus call poe info

I sadly don't own one. @hanno -- you'd be best served grabbing that logic analyzer and working against Svanheule's docs: https://svanheule.net/switches/software/broadcom_poe_control_protocol?s[]=poe

I don't have config handy...

But, if you trust /etc/board.json to be correct regarding PoE info, you could use the script from https://github.com/Hurricos/realtek-poe/pull/31/commits/43d5a8bd20edfa79e3a492d952c263f2c856f1dd to generate a basic valid config. You'll nee to move/remove /etc/config/poe first though.

Hi gents, thanks for the responses! I wasn't expecting this to get any attention still, but this is all very helpful.

For now, the output of ubus call poe info looks like this:

{
        "firmware": "v255.255",
        "budget": 170.000000,
        "consumption": 2508.699951,
        "ports": {
                "lan1": {
                        "priority": 2,
                        "status": "unknown"
                }
        }
}

This is based on the config in my first post.

Maybe instead of getting a logic analyzer, I could connect a Raspberry Pi to the UART header and snoop it that way? My impression is that it's the same kind of interface as the serial UART header I had to use to install OpenWRT in the first place.

Thanks! I'm going to be away for a bit, but I think I'll try this first when I get back.

While is it a UART like any other, you need two input lines if you want to snoop traffic. Otherwise you can only follow traffic in one direction using the Rx line of you RPi. Probably best to also add a series resistor to limit current flowing to/from you sniffer (although Rx should be high impedance input).

@hanno, Do you have pictures of the insides? I think your switch may have a Realtek PSE instead of Broadcom.

Alright! I'll give it a try; I think I can try to convince my Pi to expose a second UART interface.

Interesting - I'll try and make some pictures when I get back home (some time next week).

I finally got around to taking the thing apart and taking pictures of the inside. Here they are.


Yup, that's a Realtek PSE. realtek-poe support for it is still a work in progress [1]

[1] https://github.com/Hurricos/realtek-poe/pull/35

Sweet! Do you reckon I could give that branch a go? I'm happy to beta-test this, unless you think it needs some more polishing first.

There should be a github action that builds a package. It's only for snapshot though. Not sure if it installs on 23.05

So I finally got around to testing the package on that branch. I upgraded my device to snapshot and installed the .ipk without any problem.

No luck in talking to the PoE controller, however. With the same /etc/config/poe as above, I am getting the following output from realtek-poe -d:

realtek-poe: TX -> 00 01 01 ff ff ff ff ff ff ff ff fa
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 12 01 ff ff ff ff ff ff ff ff 0d
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 18 01 ff ff ff ff ff ff ff ff 13
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 1e 01 ff ff ff ff ff ff ff ff 19
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 24 01 ff ff ff ff ff ff ff ff 1f
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 2a 01 ff ff ff ff ff ff ff ff 25
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 30 01 ff ff ff ff ff ff ff ff 2b
realtek-poe: RX <- 00 e0 00 00 e0 00 00 00 00 00 00 00
realtek-poe: received reply with bad checksum
realtek-poe: TX -> 41 31 ff ff ff ff ff ff ff ff ff 69
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 36 01 ff ff ff ff ff ff ff ff 31
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 3c 01 ff ff ff ff ff ff ff ff 37
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 42 01 ff ff ff ff ff ff ff ff 3d
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 48 01 ff ff ff ff ff ff ff ff 43
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 4e 01 ff ff ff ff ff ff ff ff 49
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 54 01 ff ff ff ff ff ff ff ff 4f
realtek-poe: RX <- 00 00 00 00 e0 e0 e0 00 e0 00 00 e0
realtek-poe: received reply with bad checksum
realtek-poe: TX -> 41 55 ff ff ff ff ff ff ff ff ff 8d
realtek-poe: RX <- 00 00 00 00 00 00 00 00 00 00 00 00
realtek-poe: received reply with bad command id
realtek-poe: TX -> 50 56 00 ff ff ff ff ff ff ff ff 9e
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 5f 01 ff ff ff ff ff ff ff ff 5a
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 65 01 ff ff ff ff ff ff ff ff 60
realtek-poe: No bueno, no responsp
realtek-poe: TX -> 02 6b 01 ff ff ff ff ff ff ff ff 66

Neither of my PoE devices get any power as a result of these commands.

Is there anything else you recommend?

The "no response" message indicates there's no reply to our messages, which look to be valid from the trace. This branch defaults to 115200 baud, which could be the issue. I recently added a -s flag to my development branch to use 19200 baud. I would try that first.

OK, that does improve things: the responses come in, but the error about invalid port statuses is still there. This time, it's in response to command 0x50 rather than 0x28, but going by the source code on your branch I think that comes down to the same command. Here's the output of realtek-poe -s -d:

realtek-poe: RX <- 00 01 00 ff ff ff ff ff ff ff ff f9
realtek-poe: TX -> 47 02 01 ff ff ff ff ff ff ff ff 42
realtek-poe: RX <- 47 02 00 ff 01 ff ff ff ff ff ff 43
realtek-poe: TX -> 02 03 00 ff ff ff ff ff ff ff ff fd
realtek-poe: RX <- 02 03 00 ff ff ff ff ff ff ff ff fd
realtek-poe: TX -> 40 04 ff ff ff ff ff ff ff ff ff 3b
realtek-poe: RX <- 40 04 ff 08 01 01 38 10 12 04 1c c7
realtek-poe: TX -> 40 05 ff ff ff ff ff ff ff ff ff 3c
realtek-poe: RX <- 40 05 ff 08 01 01 38 10 12 04 1c c8
realtek-poe: TX -> 10 06 02 ff ff ff ff ff ff ff ff 10
realtek-poe: RX <- 10 06 00 ff ff ff ff ff ff ff ff 0e
realtek-poe: TX -> 04 07 00 06 a4 00 aa ff ff ff ff 5b
realtek-poe: RX <- 04 07 00 00 ff ff ff ff ff ff ff 04
realtek-poe: TX -> 15 08 00 02 ff ff ff ff ff ff ff 18
realtek-poe: RX <- 15 08 00 00 ff ff ff ff ff ff ff 16
realtek-poe: TX -> 0c 09 00 03 ff ff ff ff ff ff ff 11
realtek-poe: RX <- 0c 09 00 00 ff ff ff ff ff ff ff 0e
realtek-poe: TX -> 08 0a 00 01 ff ff ff ff ff ff ff 0c
realtek-poe: RX <- 08 0a 00 00 ff ff ff ff ff ff ff 0b
realtek-poe: TX -> 12 0b 00 01 ff ff ff ff ff ff ff 17
realtek-poe: RX <- 12 0b 00 00 ff ff ff ff ff ff ff 16
realtek-poe: TX -> 01 0c 00 01 ff ff ff ff ff ff ff 07
realtek-poe: RX <- 01 0c 00 00 ff ff ff ff ff ff ff 06
realtek-poe: TX -> 41 0d ff ff ff ff ff ff ff ff ff 45
realtek-poe: RX <- 41 0d 00 00 06 a4 00 00 00 ff ff f6
realtek-poe: TX -> 50 0e 00 ff ff ff ff ff ff ff ff 56
realtek-poe: RX <- 50 0e 61 ff ff ff ff ff ff ff ff b7
realtek-poe: Invalid port status packet (port=97)
realtek-poe: TX -> 48 0f 00 ff ff ff ff ff ff ff ff 4f
realtek-poe: RX <- 48 0f 00 01 01 02 00 02 00 ff ff 5b
realtek-poe: TX -> 49 10 00 ff ff ff ff ff ff ff ff 51
realtek-poe: RX <- 49 10 00 03 01 96 02 20 07 ff ff 1a
realtek-poe: TX -> 44 11 00 ff ff ff ff ff ff ff ff 4d
realtek-poe: RX <- 44 11 00 00 00 00 00 00 bc 00 00 11
realtek-poe: TX -> 41 12 ff ff ff ff ff ff ff ff ff 4a
realtek-poe: RX <- 41 12 00 00 06 a4 00 00 00 ff ff fb
realtek-poe: TX -> 50 13 00 ff ff ff ff ff ff ff ff 5b
realtek-poe: RX <- 50 13 61 ff ff ff ff ff ff ff ff bc
realtek-poe: Invalid port status packet (port=97)
realtek-poe: TX -> 48 14 00 ff ff ff ff ff ff ff ff 54
realtek-poe: RX <- 48 14 00 01 01 02 00 02 00 ff ff 60
realtek-poe: TX -> 49 15 00 ff ff ff ff ff ff ff ff 56
realtek-poe: RX <- 49 15 00 03 01 96 02 20 07 ff ff 1f
realtek-poe: TX -> 44 16 00 ff ff ff ff ff ff ff ff 52
realtek-poe: RX <- 44 16 00 00 00 00 00 00 bc 00 00 16
realtek-poe: TX -> 41 17 ff ff ff ff ff ff ff ff ff 4f
realtek-poe: RX <- 41 17 01 2c 06 a4 00 00 00 ff ff 2d
realtek-poe: TX -> 50 18 00 ff ff ff ff ff ff ff ff 60
realtek-poe: RX <- 50 18 61 ff ff ff ff ff ff ff ff c1
realtek-poe: Invalid port status packet (port=97)
realtek-poe: TX -> 48 19 00 ff ff ff ff ff ff ff ff 59
realtek-poe: RX <- 48 19 00 01 01 02 00 02 00 ff ff 65
realtek-poe: TX -> 49 1a 00 ff ff ff ff ff ff ff ff 5b
realtek-poe: RX <- 49 1a 00 03 01 96 02 20 07 ff ff 24
realtek-poe: TX -> 44 1b 00 ff ff ff ff ff ff ff ff 57
realtek-poe: RX <- 44 1b 00 00 00 00 00 00 bc 00 00 1b
realtek-poe: TX -> 41 1c ff ff ff ff ff ff ff ff ff 54
realtek-poe: RX <- 41 1c 01 2c 06 95 00 00 0e ff ff 31
realtek-poe: TX -> 50 1d 00 ff ff ff ff ff ff ff ff 65
realtek-poe: RX <- 50 1d 61 ff ff ff ff ff ff ff ff c6
realtek-poe: Invalid port status packet (port=97)

Maybe the chip I have speaks yet another dialect?

The invalid port status is a known issue. Command 0x50 works on EnGenius, and only on EnGenius. We had the same issue in the BCM dialect.

What I need at this point is a serial trace (Rx and Tx) of the vendor firmware. There are a few initialization commands that I am unsure of. The trace would also tell us what port status command is being used.

OK, I can try and get that. It's going to take a while though, but I'll report back once I have something.

OK, so I gave this a go tonight. I do not have a logic analyzer, so I hooked up two Raspberry Pis to J9 on the switch (using the documentation here), and I read out /dev/ttyS0.

I did not have a good way of wiring the GND of both Pis directly to the GND of J9, so I connected GND on the first Pi to GND on the switch's J9, and GND on the second Pi to (another) GND on the first Pi. This is probably not a great idea, but without this the second Pi only recorded gibberish.

Here are two dumps (run through od -x -w12 --endian=big). I started recording these before plugging in the switch, so they show what I was able to observe from a cold boot.

They are a bit more messy than I would have liked, but this is my first time doing anything like this, so I do not have a good baseline of what to expect.

If I squint I can make out some 12-byte sequences that look like frames, especially when the system has booted. For instance, the SoC tends to send the following frames:

4b00 ffff ffff ffff ffff ff42
4301 00ff ffff ffff ffff ff3c
4302 01ff ffff ffff ffff ff3e
4301 00ff ffff ffff ffff ff3c
4302 01ff ffff ffff ffff ff3e
4101 ffff ffff ffff ffff ff39

to which the PoE circuit responds with something like

4b00 0202 8a00 4640 1000 006f
4301 0061 1061 1061 1061 1008
4302 0161 1061 1061 1061 100a
4301 0061 1061 1061 1061 1008
4302 0161 1061 1061 1061 100a
4101 0000 028a 0000 00ff ffcc

I can't really make heads or tails of the stuff at the beginning though - but maybe you can.

I hope this is useful. Let me know if there's something else I can try!

That's actually quite helpful.

4b ss : get power management config
43 ss 00 : get 4port status starting with group 0
41 ss : get system power

Those are all query commands. The interesting ones are the 0x and 1x, which do the system configuration. the capture is a bit de-synchronized, but it's easy to figure out the commands.

Most don't use the full 12-bytes, so there is a lot of ff ff ff csum, folllowed by the next command. I have most of the commands decoded (https://github.com/Hurricos/realtek-poe/issues/25).

EDIT: @hanno , there's a new artifact on github. It won't get power, but fixes the status reporting. It should tell us why power is disabled.

Hey, sorry - I missed your last edit. I'll make some time next weekend to give the new artifact a go, and will report back!

In the mean time, I cleaned up the somewhat desynchronized trace I posted earlier:

I basically ran a sliding window and kept all of the non-overlapping chunks with a valid checksum.

On a somewhat related note, I had was able to try realtek-poe on a ZyXEL GS1900-8HP earlier this week, and it seems to work quite well. Hats off to you and the other developers :slight_smile: .