Deoptim Posted 53 minutes ago Posted 53 minutes ago (edited) Continuing the tradition (1, 2) of micro-optimizations for single-board computers that come into my hands. This time I optimized or rather fixed the wake-up function via USB/WoL/WWoL on the Orange Pi 5 Plus. Also got the WiFi adapter RTW8852BE/RTW8852CE working (at least those are the ones I tested). I tested exclusively on the Vendor 6.1.x kernel since the main wake-up features via USB/PCIE/GPIO1-GPIO4 only work in it. I don't currently have the ability to test the new current kernel and I doubt that Power Management will work fully there. Armbian from the official website, Vendor kernel (kernel 6.1.115-vendor-rk35xx), what does NOT work by default: 1. No WiFi modules that insert into the PCI-E M.2 socket E-Key work - fixed in dts below 2. Wake-up from USB (mouse/keyboard/even Bluetooth dongle) doesn't work - fixed in dts below 3. WoL via Ethernet (on two ports) - fixed in dts below I also conducted power consumption measurements in all these wake-up modes. Let's start with Ethernet ports (WoL won't work by default due to incomplete dts profile). You need to create an overlay file, links I've attached it to this message. To apply this overlay, you need to copy it somewhere on the single-board computer and execute the command: cd <path to rk3588-orangepi-5-plus-Wakeup-GPIO-RTC-USB-WoL-fixes.dts> sudo armbian-add-overlay rk3588-orangepi-5-plus-Wakeup-GPIO-RTC-USB-WoL-fixes.dts Reboot. (if it doesn't boot at all with it or something doesn't work, you can remove these changes from the /boot/overlay-user/ folder) Wake-up Timer Test: sudo sh -c "echo 0 > /sys/class/rtc/rtc0/wakealarm" sudo sh -c "echo `date '+%s' -d '+ 1 minutes'` > /sys/class/rtc/rtc0/wakealarm" sudo systemctl suspend (here we set wake-up in 1 minute from current time, you can choose seconds/minutes/hours and so on, maybe even days - haven't tested. Installing a battery on RTC is not necessary, Type-C power is sufficient) Power Consumption: Testing was performed on Imax B6 Evo / OWON HDS242S. Please note, power consumption of m.2 SSD, SD-card, eMMC is not accounted for here (ideally they should be powered off in sleep mode), but USB devices were not used, bare single-board computer was tested, each module will have its own consumption, especially USB-connected devices, add your values to the sleep mode consumption. Wake-up only via GPIO0 (this includes power button), RTC In this power-saving mode only the rk3588-orangepi-5-plus-Wakeup-GPIO0-RTC-only-fixes.dts profile is used, keep this in mind, it's not compatible with other dts, you need to choose only one option. I got these values: sudo shutdown -h now | 5.4V | 0.005W | 0.001A sudo systemctl suspend | 5.4V | 0.14W | 0.027A Wake-up via GPIO0, GPIO1-4, RTC, USB, WoL In this power-saving mode only the rk3588-orangepi-5-plus-Wakeup-GPIO-RTC-USB-WoL-fixes.dts profile is used, keep this in mind, it's not compatible with other dts, you need to choose only one option. sudo systemctl suspend | 5.4V | 0.27W | 0,050A RTL8125B (eth0 or eth1, can even be both): sudo ethtool -s eth0 wol g && sudo systemctl suspend | 5.4V | 0.34W | 0,063A RTW8852BE (external rtw8852be driver (rtw89 doesn't support WWoL for RTW8852BE in vendor 6.1 kernel)): sudo iw phy0 wowlan enable any && sudo systemctl suspend | 5.4V | 0.30W | 0,055A RTW8852CE (built-in rtw89 driver in the build): sudo iw phy0 wowlan enable magic-packet && sudo systemctl suspend | 5.4V | 0.27W | 0,051A My Armbian build from the official website on Vendor 6.1 kernel where rtw89 (WiFi) modules are already compiled and pre-installed in the kernel has a peculiarity that this driver supports WWoL function only for RTW8852CE - this is a slightly different chip than the official proprietary WiFi module for Orange Pi 5 Plus which uses RTW8852BE. For WWoL to work on RTW8852BE you need to install a third-party driver, for example I recommend from this source. How to use WoL, WWoL: For wired network use ip and ethtool utilities, for wireless network iw. WoL over LAN Скрытый текст 1. Find out which interface is currently active: ip a Output will be like: deoptim@orangepi5-plus:~$ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host noprefixroute valid_lft forever preferred_lft forever 2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 26:97:84:xx:xx:xx brd ff:ff:ff:ff:ff:ff 3: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000 link/ether c0:74:2b:xx:xx:x1 brd ff:ff:ff:ff:ff:ff altname enP3p49s0 4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether c0:74:2b:xx:xx:x2 brd ff:ff:ff:ff:ff:ff altname enP4p65s0 inet 192.168.1.125/24 brd 192.168.1.255 scope global dynamic noprefixroute eth1 valid_lft 23221sec preferred_lft 23221sec inet6 fd38:xxxx:xxxx:0:xxxx:xxxx:xxxx:xxxx/64 scope global temporary dynamic valid_lft 602822sec preferred_lft 84108sec inet6 fd38:xxxx:xxxx:0:xxxx:xxxx:xxxx:xxxx/64 scope global dynamic mngtmpaddr noprefixroute valid_lft 4293886216sec preferred_lft 4293886216sec inet6 fe80::xxxx:xxxx:xxxx:xxxx/64 scope link noprefixroute valid_lft forever preferred_lft forever 5: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 38:b8:00:xx:xx:xx brd ff:ff:ff:ff:ff:ff altname wlP2p33s0 inet 192.168.1.110/24 brd 192.168.1.255 scope global dynamic noprefixroute wlan0 valid_lft 23226sec preferred_lft 23226sec inet6 fd38:xxxx:xxxx:0:xxxx:xxxx:xxxx:xxxx/64 scope global temporary dynamic valid_lft 602829sec preferred_lft 83865sec inet6 fd38:xxxx:xxxx:0:xxxx:xxxx:xxxx:xxxx/64 scope global dynamic mngtmpaddr noprefixroute valid_lft 4293886216sec preferred_lft 4293886216sec inet6 fe80::xxxx:xxxx:xxxx:xxx/64 scope link noprefixroute valid_lft forever preferred_lft forever deoptim@orangepi5-plus:~$ (where for example wired interface is active on eth1 (since IP is assigned), remember or write down its MAC address c0:74:2b:xx:xx:x2) 2. Activate WoL on this interface: sudo ethtool -s eth1 wol g (many options and ways to wake up are available, g = magic-packet, other possible variants are p,u,m,b,g - see documentation) 3. Go to sleep: sudo systemctl suspend 4. Try to wake up the single-board computer using some WoL utility (Windows/Linux/Android) over local network (within your home network). WWoL over WiFi Скрытый текст 1. Find out the MAC address of your PCI-E WiFi adapter, for example with command: iw dev Output like this: deoptim@orangepi5-plus:~$ iw dev phy#0 Interface wlan0 ifindex 5 wdev 0x1 addr d0:39:57:xx:xx:xx ssid Keenetic_2A28 type managed channel 40 (5200 MHz), width: 80 MHz, center1: 5210 MHz txpower 12.00 dBm deoptim@orangepi5-plus:~$ 2. After that you can try to activate WWoL function with command: sudo iw phy0 wowlan enable magic-packet (for rtw89 driver: besides magic-packet, for RTL8852CE also supported are other wake-up variants disconnect, pattern match, they can be combined together for rtw8852be/ce driver: only any variant is available, wake-up variants are set by module parameter rtw_wakeup_event) 3. And try to sleep: sudo systemctl suspend 4. Try to wake up the single-board computer using some WoL utility (Windows/Linux/Android) over local network (within your home network). External Drivers: For RTW8852BE/RTW8852CE and others there are fairly recent drivers (at the time of writing this manual), here's a brief instruction on how to install them on Orange Pi 5 Plus. Скрытый текст 1. Install dependencies: sudo apt update sudo apt install build-essential linux-headers-vendor-rk35xx make dkms git 2. Pre-add rtw89 driver to blacklist (for example for CE), work via wired network for now: edit as root /boot/armbianEnv.txt in parameter extraargs= add to existing parameters "modprobe.blacklist=rtw89_core,rtw89_pci,rtw89_8852с,rtw89_8852сe" without quotes 3. Clone repository with driver: git clone --depth 1 https://github.com/saloonatic/realtek_wifi_driver.git 4. Navigate to path depending on which module you have, for example: cd realtek_wifi_driver/rtl8852ce/ 5. Edit Makefile and add at the beginning of file: ARCH=arm64 find parameters and set =y or =n for them: Цитата CONFIG_PCI_RTW_MSI = n CONFIG_WIFI_MONITOR = y CONFIG_RTW_DEBUG = n CONFIG_PROC_DEBUG = n CONFIG_WOWLAN = y CONFIG_WAKEUP_TYPE = 0x05 If you want two virtual interfaces for one card (wlan0 and wlan1), for example if you want AP+STA (client + access point but only on the same channel) or STA+STA (two networks with backup internet but only on the same channel), then also enable option: Цитата CONFIG_CONCURRENT_MODE = y 6. Create file default-editor.txt: echo nano > default-editor.txt 7. Run installation: sudo ./install-driver.sh Should compile and install driver without problems and reboot. Issues: Скрытый текст There are problems with built-in WiFi driver rtw89 for RTW8852BE/RTW8852CE (at the time of writing this post: 6.1.115-vendor-rk35xx). The first problem is that in the official dts profile for Orange Pi 5 Plus there is a "rockchip,skip-scan-in-resume" parameter in the section for pcie2x1l0 (M.2 E-key) - this is a harmful parameter. Even without using WWoL function, due to this option the driver doesn't exit from regular sleep correctly. Either it's necessary to edit the main dts file (which is dangerous) and remove this parameter, or get out of this situation with a script after wake-up of the following type: sudo nano /lib/systemd/system-sleep/fix-wifi.sh #!/bin/bash case $1/$2 in post/*) echo "Waking up from suspend..." # Or remove "rockchip,skip-scan-in-resume" option in main dts profile, # or use this Bug workaround # Force reset of PCI device after sleep # (to know your controller address use "lspci" tool) echo 1 | tee /sys/bus/pci/devices/0002\:21\:00.0/reset ;; esac sudo chmod +x /lib/systemd/system-sleep/fix-wifi.sh The second problem lies in using WWoL on rtw89 - if once after reboot it will wake from magic-packet, but the second time (if not rebooted) it won't wake up and kernel will hang - these are bugs of rtw89 itself. An acceptable way out of this situation as mentioned is to use external driver, when using these drivers, it doesn't matter whether there is "rockchip,skip-scan-in-resume" parameter in main dts or not, you don't need to edit it. https://www.mediafire.com/file/g0pk7x36hjjg2rq/rk3588-orangepi-5-plus-Wakeup-GPIO-RTC-USB-WoL-fixes.dts/file https://www.mediafire.com/file/try189vgfxydqvt/rk3588-orangepi-5-plus-Wakeup-GPIO0-RTC-only-fixes.dts/file Original Link 4PDA Edited 49 minutes ago by Deoptim 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.