Bringing support for realtek-poe to mainline OpenWrt

Hi there,

As per my earlier forum post on the RTL838X (et. al.) support thread, I'd like to get realtek-poe supported in mainline OpenWrt, even if it's known that realtek-poe is not really of production-quality standardization that OpenWrt wants.

Update: After @mrnuke's work to spin realtek-poe out into its own package, I have moved the result here.

I'm looking to resolve a few issues:

  • [ ] For many users, realtek-poe shows a transition of status from Searching to unknown when a PoE-capable device is added to a port -- even though the device does not turn on.
  • [ ] realtek-poe is not available in OpenWrt by default because of code quality issues (as documented here).
    • With some code-cleanup, it should be "good enough" as an open-source reference implementation. Without a reference implementation, a cleaner, better-standardized rewrite is not really possible.

In addition, it'd be good if this product environment had some better tooling:

  • [x] Some tooling way to decode and understand frames sniffed (for situations where we do not control the agent on the CPU side of the connection, i.e. when reading what frames OEM firmware sends to set the PoE controller up).

There are larger issues in play as well:

  • [ ] There is no standardized PoE framework for OpenWrt to tack realtek-poe onto

I plan to clean this up and document my findings in this thread as I get my GS1900-24HPv1 working with realtek-poe.

Update: Sorry for the slow updates -- I've been trying to clean up servers in our space and so have lost my compiler environment until our new server's display card comes in the mail.

6 Likes

There is apparently a "poemgr" package in the packages feed meant to control the PoE on the Ubiquiti USW-Flex switch. See https://github.com/openwrt/packages/pulls?q=is%3Apr+poemgr. There are also other devices supported by OpenWrt that have PoE capability, but I'm not familiar with how it is controlled for those other devices.

@Borromini You reported here that realtek-poe on your 8-port Realtek + Broadcom-based switches stopped functioning.

@mrnuke reports that:

hurricos: I have to send these commands to the PoE ctrlr on the EWS2910P switch: https://paste.debian.net/1241353/

I'd like to work with you to clean up realtek-poe a bit further to make sure it works on the 8-port variants (I don't have any), then to test what sending that linked block above as such would do:

realtek-poe does not continue to send configuration after the initial setup, so you can actually send these frames using realtek-poe mrnuke: You should use my patches in my tree: https://github.com/hurricos/openwrt/tree/realtek-poe

Then, rework this into e.g. ubus call poe sendframe '{"frame": "0x09 0x01"}' -- that's the first frame, you are skipping the frame number, padding and checksum at the end. PLEASE let me know if this works after compiling my realtek-poe for your system.

I would be VERY interested to hear if this DOES NOT work; in particular, you can stop the realtek-poe service on your own and run /etc/bin/realtek-poe -d and collect the output.

To that last bit -- I think there is an issue with my realtek-poe -- I do iterate at one point over MAX_PORTS and not 8. I should fix this to use the currently discovered number of ports, but I don't know if it'd crash things -- @mrnuke will be giving me their crash report at some point.

@hurricos Happy to test, let me know.

My first try installing realtek-poe on the dgs-1210-10mp it got installed but booted the service as disabled and if I tried starting it it manually it just said in luci (services window) it can’t run the start command in init.d.
And no messages in the log.

Am I supposed to setup the config file in /etc/poe with all the ports for the device before starting the service? The instructions for this package is kind of non existing.

The number of ports needs to be a configuration option as some of the devices don't provide PoE on all ports. I am working on the ZyXEL GS1900-24EP which only has PoE available on the first 12 ports. Looking at the current 02_network file it uses the lan_list [defined as $(ls -1 -v -d /sys/class/net/lan* | xargs -n1 basename | xargs)] as the 2nd argument to ucidef_set_poe which is not going to work on those devices that don't have PoE available on all lan ports.

Following up on this I think that the configuration file used by poemgr is a good start to configuration. However it is missing the max_power and also power limit on each port. My TrendNET TPE-224WS (not yet supported) has PoE + on the first 4 ports and PoE on the remaining 20 ports.

How do you handle the listed non poe ports in the realtek-poe poe config file?

Do you set them as disabled?

How does it work with the SFP?

You at least need to set some, but not all. You can make do with just a few ports to start out. And specify the total power budget for your switch as well.

You don't want to add your SFP(+) ports to /etc/config/poe. No point in doing that.

Then it should at least start the service at boot with the original config file?

It should. No errors in dmesg?

Great to see that someone is working on upstream realtek-poe ! :slight_smile:

Because I want to use the small ZyXEL Switches (GS1900-8HP) in an production environment I've added some monitoring for poe via an additional prometheus-node-exporter-lua collector.
link to collector in my own fork
(stolen the initial patch from John Crispin's mailing list post; currently does not build but the .lua file can simply be copied to any openwrt machine running the prometheus-node-exporter-lua daemon)

I knew that realtek-poe would not make it upstream in this form, but I did not knew that people are having issues with it. My hope was that it would eventually land in the packages feed.
I am running a more or less stock 21.02.3 with John Crispins patch without any issues.

I would love to help upstream realtek-poe. Do you need any testers ? I currently have access to two ZyXEL GS1900-8HP and one ZyXEL GS1900-10HP.

1 Like
xxxx@xxxx-probook-450-g8:~/openwrt/dgs121010mp/tmp$ git am realtek-poe.patch
Applying: realtek-poe: add support for PoE on Realtek switches
.git/rebase-apply/patch:76: trailing whitespace.
service_triggers() {                                
warning: 1 line adds whitespace errors.

https://patchwork.ozlabs.org/project/openwrt/patch/20210511152243.1167160-1-john@phrozen.org/
Downloaded the mbox file from here.

Do you get this warning/error when trying to install the patch?
Tried to download the patch two times but the error stands.

It's a formatting warning and doesn't affect compilation or functionality. I believe it's because of patches being applied to patches so to speak, and that's probably confusing git.

1 Like

Does this poe patch need i2c packages installed?
I have used the dgs-1210-10p dts as a base but that doesn’t have i2c installed by default, only lua-rs232.

I tried i2cdetect but the command doesn’t exist.

I tried the old rtl83xx-poe and it works so I can’t understand why it is impossible to do enable, start, restart the realtek-poe?
Whatever I try it always say in Luci-Startup that the init.d function failed.
Nothing in system log or kernel log?

I am not really sure why the realtek-poe failed the first time.
I tried making a completely new buildroot and installing the patch again and this time it seems to work?

Had to make this note in the same box since only 3 posts are allowed in a row.

root@OpenWrt:/# ubus call poe info
{
        "firmware": "v24.33",
        "mcu": "Nuvoton M05xx LAN Microcontroller",
        "budget": 65.000000,
        "consumption": 16.200001,
        "ports": {
                "lan1": {
                        "priority": 2,
                        "mode": "PoE",
                        "status": "Delivering power",
                        "consumption": 2.700000
                }
        }
}

One small anomaly I find is the total consumption seems to show "max consumption" for a standard POE port (130W / 8 = 16,25W) instead of the actual total consumption which in this case would be 2.7W?

Have anyone else seen this if you change mode from PoE+ to PoE?

1 Like

I too have a GS1900-24HPv1, so I'll be delighted to help you test this. I've been running the 22.03 release candidates successfully for the past month and I'm anxious to get the POE working.

That said, I just bricked it with a dodgy custom build. Do you know if there's any way to force this thing to switch to the backup firmware partition using the reset button? Installing via the factory web interface worked well, so if I could make it boot the still existing factory firmware on the alternate partition, that would probably be the easiest way to debrick it.

Alternately, I can try to get a serial. I have a USB to RS232 DB9 adapter, and I've seen the notes on J5 in your commit, but I could use some clarification of the pinout:

Am I right in thinking that in this photo, bottom row 2nd from left is RXD, bottom middle is GND and top right is TXD?

Be careful, RS232 voltage levels can damage the target device.
You need a USB-TTL serial adapter at the correct voltage level instead.

I'm aware that usually a 3.3V USB-to-UART adaptor is the correct thing, but in the case of this particular device, if I understood Hurricos's commit here correctly, the voltage shifter to RS232 levels is present on the mainboard.