dolphs Posted March 19, 2022 Posted March 19, 2022 Hi, Based on this topic it should be possible to open PWM0 and PWM1 on a RockpiS, Yet I like to do the same thing on a Rockpi4A+ ( fdtfile=rockchip/rk3399-rock-pi-4a-plus.dtb ), in order to enable the fan on a PoE HAT Without any overlay it shows: root@rockpi-4a:/sys/class/pwm# ls /sys/class/pwm/ -la total 0 drwxr-xr-x 2 root root 0 Mar 19 05:20 . drwxr-xr-x 71 root root 0 Mar 19 05:20 .. lrwxrwxrwx 1 root root 0 Mar 19 05:20 pwmchip0 -> ../../devices/platform/ff420020.pwm/pwm/pwmchip0 I tried some of radxa's suggestions using their " rockpi-poe.dtbo " overlay ( user_overlays=rockpi-poe ) and indeed that makes the fan spinning up like crazy, but alas unable to control the fan, due to missing libmraa. However the overlay mentioned does seem to open two additional PWM's, thus PWM0 till 2. root@rockpi-4a:~# ls /sys/class/pwm/ -la total 0 drwxr-xr-x 2 root root 0 Mar 19 05:36 . drwxr-xr-x 71 root root 0 Mar 19 05:36 .. lrwxrwxrwx 1 root root 0 Mar 19 05:36 pwmchip0 -> ../../devices/platform/ff420000.pwm/pwm/pwmchip0 lrwxrwxrwx 1 root root 0 Mar 19 05:36 pwmchip1 -> ../../devices/platform/ff420010.pwm/pwm/pwmchip1 lrwxrwxrwx 1 root root 0 Mar 19 05:36 pwmchip2 -> ../../devices/platform/ff420020.pwm/pwm/pwmchip2 I was wondering if this is WIP, or should is it possible already to enable pwm with a built-in armbian overlay, was unable to retrieve anything in that direction from: /boot/dtb/rockchip/overlays except for " overlays=w1-gpio " but perhaps there is another way? [ 6.207083] OF: /onewire@0: could not get #gpio-cells for /vop@ff900000/port/endpoint@1 [ 6.207102] w1-gpio onewire@0: gpio_request_one (ext_pullup_enable_pin) failed [ 6.207105] w1-gpio: probe of onewire@0 failed with error -22 PS I am not demandig anything, just asking about PoE HAT status ( controllable fan ) in current armbian ( edge, kernel 5.16.x ) and if this is WIP? thanks! 0 Quote
dolphs Posted March 22, 2022 Author Posted March 22, 2022 I compiled a small HOWTO to get this going with kernel 5.16 on a Rockpi4+ sudo su - apt update && apt -y install git build-essential swig4.0 python3-dev libnode-dev cmake libjson-c-dev Grab "user overlay" from radxa: mkdir -p /boot/overlay-user cd /boot/overlay-user curl -sL https://rock.sh/rockpi-poe-dtbo -o rockpi-poe.dtbo nano /boot/armbianEnv.txt user_overlays=rockpi-poe exit Compile mraa packages cd /home/[user] git clone https://github.com/eclipse/mraa mkdir mraa/build cd mraa/build cmake .. make -j7 #depends on cores available+1 sudo make install Spoiler --- < snip snip > [ 97%] Linking C executable mraa-i2c [ 98%] Linking CXX executable iio_cpp [100%] Linking C executable mraa-gpio [100%] Built target mraa-i2c [100%] Built target uart_ow_cpp [100%] Built target mraa-gpio [100%] Built target iio_cpp --- --- <snip snip> [ 92%] Built target uart_ow_cpp [ 95%] Built target mraa-uart [ 97%] Built target mraa-i2c [100%] Built target mraa-gpio Install the project... -- Install configuration: "" -- Installing: /usr/local/include/mraa.h -- Installing: /usr/local/include/mraa.hpp <snip snip> -- Installing: /usr/local/share/mraa/examples/c++/spi.cpp -- Installing: /usr/local/share/mraa/examples/c++/pwm.cpp -- Installing: /usr/local/share/mraa/examples/c++/led.cpp -- Installing: /usr/local/bin/mraa-gpio -- Set runtime path of "/usr/local/bin/mraa-gpio" to "" -- Installing: /usr/local/bin/mraa-i2c -- Set runtime path of "/usr/local/bin/mraa-i2c" to "" -- Installing: /usr/local/bin/mraa-uart -- Set runtime path of "/usr/local/bin/mraa-uart" to "" --- Install PoE package and enable its service sudo su #view /etc/ld.so.conf.d/libc.conf ldconfig # add /usr/local/lib libraries to " LD_LIBRARY_PATH " cd /tmp wget https://cos.setq.me/rockpi/deb/rockpi-poe-0.13.deb dpkg -i rockpi-poe-0.13.deb systemctl enable rockpi-poe.service reboot After reboot the fan should spin up like mad and after little while it slows down ( off ) : root@rockpi-4a:~# systemctl status rockpi-poe.service ● rockpi-poe.service - Rockpi PoE-FAN Loaded: loaded (/lib/systemd/system/rockpi-poe.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2022-03-22 11:19:06 UTC; 11min ago Main PID: 659 (python3) Tasks: 1 (limit: 4464) Memory: 11.7M CPU: 264ms CGroup: /system.slice/rockpi-poe.service └─659 /usr/bin/python3 /usr/bin/rockpi-poe.py start Mar 22 11:19:06 rockpi-4a systemd[1]: Started Rockpi PoE-FAN. Mar 22 11:19:08 rockpi-4a libmraa[659]: libmraa version v2.2.0-11-gd7ae171 initialised by user 'root' with EUID 0 Mar 22 11:19:08 rockpi-4a libmraa[659]: gpio: platform doesn't support chardev, falling back to sysfs Mar 22 11:19:08 rockpi-4a libmraa[659]: libmraa initialised for platform 'ROCK Pi 4' of type 20 0 Quote
tparys Posted March 27, 2022 Posted March 27, 2022 If the sysfs pwm device is showing up, I'm not following why you'd need libmraa to access it? If you'd like to have fewer moving parts, you should be able to do this entirely via DTB. I posted something similar for the fan on the NanoPI M4 metal case. https://forum.armbian.com/topic/17022-automatic-kernel-control-of-nanopi-m4-m4v2-metal-case-fan/ It was based on some earlier work the Kobol guys did for one of their NAS systems. You basically define the PWM as a fan control, give it a few operating levels, and tell the kernel that it's a cooling device for the CPUs. I also learned that depending on the PWM frequency, it can also create audible tones, which may or may not be desirable. You can also have it play music too, should you be so entertained ... https://forum.armbian.com/topic/19050-playing-with-a-fan-on-an-nanopi-m4v2/ 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.