Bringing support for realtek-poe to mainline OpenWrt

If uboot-envtools has been patched for your device, you can do it both from OpenWrt and the OEM firmware.

# fw_setsys bootpartition 1
# reboot

On my GS1900-10HP e.g.:

# cat /etc/fw_sys.config 
/dev/mtd2 0x0 0x1000 0x10000

The factory Zyxel OEM firmware 2.70 has auto POE on every port out of the box on GS1900-24HPv1. Tested all ports POE functionality before going to OpenWrt 22.03-rc3 and trying realtek-poe (both hurricos and original), but couldn't get it working /running with just scp files ubus doesn't report anything.

Anyone a realtek opkg package for 22.03-rc4 or does the original firmware also needs patches besides installing the realtek package?

1 Like

I built mine using the ImageBuilder for 22.03-rc1, I didn't apply any patches to the source tree besides adding my local packages feed.

Edit:

This worked. I'm back to stock and PoE is working properly there.

Opened mine a while ago and there is indeed a STM 32F100 and 6x BCM59111 inside the GS1900-24HPv1.

Try this realtek-poe package please. Built against 22.03 HEAD a few days ago.

1 Like

What's different to a package built from https://github.com/hurricos/realtek-poe?

It's the 'vanilla' code posted by blogic a while ago to Patchwork, with just a single patch on top by hurricos to make debugging more verbose. Nothing more.

And it works on both my Realtek PoE switches :wink:. Not to detract from hurricos' effort, far from it. But if it works for someone, then it might help establishing a baseline.

The realtek-poe repo is mostly @mrnuke's effort, to be clear. We're hoping to separate the package out through the package feed so that the maintainers are willing to merge it.

3 Likes

@andyboeh @walterav Have you shared debugging output with @hurricos and @mrnuke? Procedure as described here.

# /etc/init.d/poe stop; /etc/init.d/poe disable; realtek-poe -d

In case it would help any, PoE config of my GS1900-8HP v1:

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   '1'
        option id       '5'
        option name     'lan5'
        option poe_plus '1'
        option priority '2'

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

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

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

OK, unfortunately, it doesn't install on my -rc1 build because of failed dependencies - with a few hacks I succeeded to start it. Apart from the fact that it now displays 'Legacy', nothing has changed - PoE state is still "unknown" if a PoE device is connected.

OK. Try killing the service and running it with debugging as explained. Maybe the output helps.

In the past I did disable one of the poe packages before trying the other, but it only reported about the process status running...

@andyboeh
What dependency cli foo did you do to trick installing the ipk file? Mine errors on rc3 about ubus and rc4 about ubox and architecture differences:

opkg install libubus
Package libubus20220601 (2022-06-01-2bebf93c-1) installed in root is up to date.
opkg install libubox
Package libubox20220515 (2022-05-15-d2223ef9-1) installed in root is up to date.

opkg install realtek-poe_1_mips_4kec.ipk --force-depends #tried also other force options
Unknown package 'realtek-poe'.
Collected errors:
 * pkg_hash_check_unresolved: cannot find dependency libubox20211120 for realtek-poe
 * pkg_hash_fetch_best_installation_candidate: Packages for realtek-poe found, but incompatible with the architectures configured
 * opkg_install_cmd: Cannot install package realtek-poe.

Quite a quick and dirty solution:
I placed the file to /tmp/realtek-poe.ipk and then I unpacked it manually using tar zxpf realtek-poe.ipk and afterwards tar zxf data.tar.gz. Next I manually moved the files to the required destination (it's just 3 files, /etc/init.d/poe, /etc/config/poe and /usr/bin/realtek-poe).

Upon starting, it complained about an unresolved symbol in libubus2022*.so, so I just created a symlink from the libubus2022*.so that was already there (in /lib IIRC). You will probably get a similar error with libubox.

2 Likes

Sorry, packages are from June 6th and in the meantime a libubox bump got pushed. Will recompile and upload a newer one. My apologies.

1 Like

Just followed @andyboeh his advice and indeed got the ubox error just cp/renamed it and now alot of debug info:

cat /var/sysinfo/board_name 
zyxel,gs1900-24hp-v1

cat /etc/os-release 
NAME="OpenWrt"
VERSION="22.03.0-rc4"
ID="openwrt"
ID_LIKE="lede openwrt"
PRETTY_NAME="OpenWrt 22.03.0-rc4"
VERSION_ID="22.03.0-rc4"
HOME_URL="https://openwrt.org/"
BUG_URL="https://bugs.openwrt.org/"
SUPPORT_URL="https://forum.openwrt.org/"
BUILD_ID="r19426-2b1941e47d"
OPENWRT_BOARD="realtek/rtl838x"
OPENWRT_ARCH="mips_4kec"
OPENWRT_TAINTS=""
OPENWRT_DEVICE_MANUFACTURER="OpenWrt"
OPENWRT_DEVICE_MANUFACTURER_URL="https://openwrt.org/"
OPENWRT_DEVICE_PRODUCT="Generic"
OPENWRT_DEVICE_REVISION="v0"
OPENWRT_RELEASE="OpenWrt 22.03.0-rc4 r19426-2b1941e47d"

md5sum /usr/bin/realtek-poe 
a6374f7e670c59f127ab89ffbc6e43f9  /usr/bin/realtek-poe

/usr/bin# ./realtek-poe -d #borromini version 
TX -> 0x20 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x18
Get system info 
RX -> 0x20 0x01 0x02 0x18 0x00 0xe1 0x11 0x11 0x00 0x01 0x01 0x40
Get system info 
TX -> 0x17 0x02 0x02 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x13
Set power management mode 
RX -> 0x17 0x02 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x11
Set power management mode 
TX -> 0x18 0x03 0x00 0x00 0x00 0x00 0x00 0xff 0xff 0xff 0xff 0x17
Set global power budget 
RX -> 0x18 0x03 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x14
Set global power budget 
TX -> 0x06 0x04 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x02
Set global port enable 
RX -> 0x06 0x04 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x02
Set global port enable 
TX -> 0x18 0x05 0x00 0x02 0x8a 0x00 0x3c 0xff 0xff 0xff 0xff 0xe1
Set global power budget 
RX -> 0x18 0x05 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x16
Set global power budget 
TX -> 0x1a 0x06 0x00 0x02 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x1b
Set port priority 
RX -> 0x1a 0x06 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x19
Set port priority 
TX -> 0x1c 0x07 0x00 0x05 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x21
Set port power-up mode 
RX -> 0x1c 0x07 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x1c
Set port power-up mode 
TX -> 0x15 0x08 0x00 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x17
Set port power limit type 
RX -> 0x15 0x08 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x16
Set port power limit type 
TX -> 0x13 0x09 0x00 0x02 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x17
Set disconnect type 
RX -> 0x13 0x09 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x15
Set disconnect type 
TX -> 0x11 0x0a 0x00 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x15
Set classification enable 
RX -> 0xfe 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xf4
Request checksum n/a Request frame checksum was incorrect 
TX -> 0x10 0x0b 0x00 0x03 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x17
Set detection type 
RX -> 0x10 0x0b 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x14
Set detection type 
TX -> 0x00 0x0c 0x00 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x06
Set port enable 
RX -> 0x00 0x0c 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x05
Set port enable 
TX -> 0x00 0x0d 0x01 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x07
Set port enable 
RX -> 0x00 0x0a 0x01 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x07
Set port enable 
TX -> 0x00 0x0e 0x02 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x09
Set port enable 
RX -> 0x00 0x0e 0x02 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x09
Set port enable 
TX -> 0x00 0x0f 0x03 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x0b
Set port enable 
RX -> 0x00 0x0f 0x03 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x0b
Set port enable 
TX -> 0x00 0x10 0x04 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x0d
Set port enable 
RX -> 0x00 0x10 0x04 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x0a
Set port enable 
TX -> 0x00 0x11 0x05 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x0f
Set port enable 
RX -> 0x00 0x11 0x05 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x0f
Set port enable 
TX -> 0x00 0x12 0x06 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x11
Set port enable 
RX -> 0x00 0x12 0x06 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x11
Set port enable 
TX -> 0x00 0x13 0x07 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x13
Set port enable 
RX -> 0x00 0x13 0x07 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x13
Set port enable 
TX -> 0x23 0x14 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x2e
Get power statistics 
RX -> 0x23 0x14 0x00 0x00 0x00 0x00 0x07 0x02 0xff 0xff 0xff 0x3d
Get power statistics 
TX -> 0x2a 0x15 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x37
Get port overview 
RX -> 0x2a 0x15 0x00 0x11 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0xc0
Get port overview 
TX -> 0x26 0x16 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x34
Get extended port config 
RX -> 0x26 0x16 0x00 0x01 0x01 0x4d 0x02 0x00 0xff 0xff 0xff 0x8a
Get extended port config 
TX -> 0x30 0x17 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x3f
Get port measurements 
RX -> 0x30 0x17 0x00 0x00 0x00 0x00 0x00 0x00 0xcc 0x00 0x00 0x13
Get port measurements 
TX -> 0x26 0x18 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x37
Get extended port config 
RX -> 0x26 0x18 0x01 0x00 0x00 0x4d 0x00 0x01 0xff 0xff 0xff 0x8a
Get extended port config 
TX -> 0x30 0x19 0x01 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x42
Get port measurements 
RX -> 0x30 0x19 0x01 0x00 0x00 0x00 0x00 0x00 0xce 0x00 0x00 0x18
Get port measurements 
TX -> 0x26 0x1a 0x02 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x3a
Get extended port config 
RX -> 0x26 0x1a 0x02 0x00 0x00 0x4d 0x00 0x02 0xff 0xff 0xff 0x8e
Get extended port config 
TX -> 0x30 0x1b 0x02 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x45
Get port measurements 
RX -> 0x30 0x1b 0x02 0x00 0x00 0x00 0x00 0x00 0xce 0x00 0x00 0x1b
Get port measurements 
TX -> 0x26 0x1c 0x03 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x3d
Get extended port config 
RX -> 0x26 0x1c 0x03 0x00 0x00 0x4d 0x00 0x03 0xff 0xff 0xff 0x92
Get extended port config 
TX -> 0x30 0x1d 0x03 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x48
Get port measurements 
RX -> 0x30 0x1d 0x03 0x00 0x00 0x00 0x00 0x00 0xce 0x00 0x00 0x1e
Get port measurements 
TX -> 0x26 0x1e 0x04 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x40
Get extended port config 
RX -> 0x26 0x1e 0x04 0x00 0x00 0x4d 0x00 0x04 0xff 0xff 0xff 0x96
Get extended port config 
TX -> 0x30 0x1f 0x04 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x4b
Get port measurements 
RX -> 0x30 0x1f 0x04 0x00 0x00 0x00 0x00 0x00 0xca 0x00 0x00 0x1d
Get port measurements 
TX -> 0x26 0x20 0x05 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x43
Get extended port config 
RX -> 0x26 0x20 0x05 0x00 0x00 0x4d 0x00 0x05 0xff 0xff 0xff 0x9a
Get extended port config 
TX -> 0x30 0x21 0x05 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x4e
Get port measurements 
RX -> 0x30 0x21 0x05 0x00 0x00 0x00 0x00 0x00 0xc9 0x00 0x00 0x1f
Get port measurements 
TX -> 0x26 0x22 0x06 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x46
Get extended port config 
RX -> 0x26 0x22 0x06 0x00 0x00 0x4d 0x00 0x06 0xff 0xff 0xff 0x9e
Get extended port config 
TX -> 0x30 0x23 0x06 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x51
Get port measurements 
RX -> 0x30 0x23 0x06 0x00 0x00 0x00 0x00 0x00 0xcb 0x00 0x00 0x24
Get port measurements 
TX -> 0x26 0x24 0x07 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x49
Get extended port config 
RX -> 0x26 0x24 0x07 0x00 0x00 0x4d 0x00 0x07 0xff 0xff 0xff 0xa2
Get extended port config 
TX -> 0x30 0x25 0x07 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x54
Get port measurements 
RX -> 0x30 0x25 0x07 0x00 0x00 0x00 0x00 0x00 0xca 0x00 0x00 0x26
Get port measurements 
TX -> 0x26 0x26 0x08 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x4c
Get extended port config 
RX -> 0x26 0x26 0x08 0x00 0x00 0x4d 0x00 0x08 0xff 0xff 0xff 0xa6
Get extended port config 
TX -> 0x30 0x27 0x08 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x57
Get port measurements 
RX -> 0x30 0x27 0x08 0x00 0x00 0x00 0x00 0x00 0xcc 0x00 0x00 0x2b
Get port measurements 
TX -> 0x26 0x28 0x09 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x4f
Get extended port config 
RX -> 0x26 0x28 0x09 0x00 0x00 0x4d 0x00 0x09 0xff 0xff 0xff 0xaa
Get extended port config 
TX -> 0x30 0x29 0x09 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x5a
Get port measurements 
RX -> 0x30 0x29 0x09 0x00 0x00 0x00 0x00 0x00 0xcc 0x00 0x00 0x2e
Get port measurements 
TX -> 0x26 0x2a 0x0a 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x52
Get extended port config 
RX -> 0xfe 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xf4
Request checksum n/a Request frame checksum was incorrect 
TX -> 0x30 0x2b 0x0a 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x5d
Get port measurements 
RX -> 0xfe 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xf4
Request checksum n/a Request frame checksum was incorrect 
TX -> 0x26 0x2c 0x0b 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x55
Get extended port config 
RX -> 0x26 0x2c 0x0b 0x00 0x00 0x4d 0x00 0x0b 0xff 0xff 0xff 0xb2
Get extended port config 
TX -> 0x30 0x2d 0x0b 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x60
Get port measurements 
RX -> 0x30 0x2d 0x0b 0x00 0x00 0x00 0x00 0x00 0xcc 0x00 0x00 0x34
Get port measurements 
TX -> 0x26 0x2e 0x0c 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x58
Get extended port config 
RX -> 0x26 0x2e 0x0c 0x00 0x00 0x4d 0x00 0x0c 0xff 0xff 0xff 0xb6
Get extended port config 
TX -> 0x30 0x2f 0x0c 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x63
Get port measurements 
RX -> 0x30 0x2f 0x0c 0x00 0x00 0x00 0x00 0x00 0xca 0x00 0x00 0x35
Get port measurements 
TX -> 0x26 0x30 0x0d 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x5b
Get extended port config 
RX -> 0x26 0x30 0x0a 0x00 0x00 0x4d 0x00 0x0a 0xff 0xff 0xff 0xba
Get extended port config 
TX -> 0x30 0x31 0x0d 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x66
Get port measurements 
RX -> 0x30 0x31 0x0a 0x00 0x00 0x00 0x00 0x00 0xcb 0x00 0x00 0x39
Get port measurements 
TX -> 0x26 0x32 0x0e 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x5e
Get extended port config 
RX -> 0x26 0x32 0x0e 0x00 0x00 0x4d 0x00 0x0e 0xff 0xff 0xff 0xbe
Get extended port config 
TX -> 0x30 0x33 0x0e 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x69
Get port measurements 
RX -> 0x30 0x33 0x0e 0x00 0x00 0x00 0x00 0x00 0xcb 0x00 0x00 0x3c

That output is not from @hurricos's realtek-poe repo, but an older version. We (think we) fixed the checksum issues. Do you have a way to build the package from github , and give that a try?

1 Like

Correct its this older version?

@walterav If it's not working altogether then there's no added value in debugging it further, as there's no baseline to establish between the older version and the current code. Was worth a try.

Can you run the same commands with the package built from the GitHub repo?

Not for tonight, but will probably combine it with a 22.03.x buildroot for Mikrotik hex-POE as well but no eta yet. Thanks so far for the input.

1 Like

The package from the gihub repo should support the same commands, yes.

The "fix" I'm interested in is the newline conversion fix. That's why checksumming fails on packets with 0x0a or 0x0d. That causes some commands to get rejected, and gets an incomplete configuration.

1 Like