Jump to content

PWM for PoE Hat


jaysonsantos

Recommended Posts

Hey there, had anyone any success enabling PWM to control a PoE hat [1]?

I tried a few overlays but no luck.

 

```

rock-3a-worker-1:overlay:# cat /boot/armbianEnv.txt
verbosity=1
bootlogo=false
overlay_prefix=rk35xx
fdtfile=rockchip/rk3568-rock-3a.dtb
rootdev=UUID=f0751d3c-c5c2-4ced-a989-772c2ad130a4
rootfstype=ext4
overlays=w1-gpio i2c7 i2c8
extraboardargs=nvme_core.default_ps_max_latency_us=0
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

```

 

I also built mraa with the following:

 

```

IMRAA=ON FTDI4222=OFF BUILDCPP=ON BUILDTESTS=ON BUILDSWIG=ON USBPLAT=ON ONEWIRE=ON INSTALLTOOLS=ON BUILDSWIGPYTHON=ON \
      bash -c "./scripts/run-cmake.sh && make -Cbuild install"

```

but it won't show anything on gpio or pwm

```

mraa-gpio list
No Pins

```

Any other ideas there?

[1] Pinout ->  https://wiki.radxa.com/ROCKPI_23W_PoE_HAT 

Link to comment
Share on other sites

I found the answer on radxa's forum [1] by amazingfate.

In order to make it, you need to enable amazingfate's overlay and then control the pwm, which can be done like this:

 

wget https://raw.githubusercontent.com/radxa/kernel/stable-4.19-rock3/arch/arm64/boot/dts/rockchip/overlay/rk3568-pwm8-m0-fan.dts
armbian-add-overlay rk3568-pwm8-m0-fan.dts

sudo cat > /etc/systemd/system/fan-control.service <<EOF
[Service]
RemainAfterExit=true
ExecStart=bash -exc '\
echo 0 > /sys/devices/platform/fe6f0000.pwm/pwm/pwmchip*/export || true; \
echo 10000 > /sys/devices/platform/fe6f0000.pwm/pwm/pwmchip*/pwm0/period && \
echo 5000 > /sys/devices/platform/fe6f0000.pwm/pwm/pwmchip*/pwm0/duty_cycle && \
echo normal > /sys/devices/platform/fe6f0000.pwm/pwm/pwmchip*/pwm0/polarity && \
echo 1 > /sys/devices/platform/fe6f0000.pwm/pwm/pwmchip*/pwm0/enable'
ExecStop=bash -exc 'echo 0 > /sys/devices/platform/fe6f0000.pwm/pwm/pwmchip*/pwm0/enable'

[Install]
WantedBy=multi-user.target
EOF

systemctl enable fan-control.service

reboot # so the overlay gets applied and the service start

 

[1] https://forum.radxa.com/t/armbian-for-rock-3a-unofficial-build-with-mainline-kernel/9434/45

Link to comment
Share on other sites

On 7/3/2022 at 4:46 PM, jaysonsantos said:

I found the answer on radxa's forum [1] by amazingfate.

In order to make it, you need to enable amazingfate's overlay and then control the pwm, which can be done like this:

 

wget https://raw.githubusercontent.com/radxa/kernel/stable-4.19-rock3/arch/arm64/boot/dts/rockchip/overlay/rk3568-pwm8-m0-fan.dts
armbian-add-overlay rk3568-pwm8-m0-fan.dts

sudo cat > /etc/systemd/system/fan-control.service <<EOF
[Service]
RemainAfterExit=true
ExecStart=bash -exc '\
echo 0 > /sys/devices/platform/fe6f0000.pwm/pwm/pwmchip*/export || true; \
echo 10000 > /sys/devices/platform/fe6f0000.pwm/pwm/pwmchip*/pwm0/period && \
echo 5000 > /sys/devices/platform/fe6f0000.pwm/pwm/pwmchip*/pwm0/duty_cycle && \
echo normal > /sys/devices/platform/fe6f0000.pwm/pwm/pwmchip*/pwm0/polarity && \
echo 1 > /sys/devices/platform/fe6f0000.pwm/pwm/pwmchip*/pwm0/enable'
ExecStop=bash -exc 'echo 0 > /sys/devices/platform/fe6f0000.pwm/pwm/pwmchip*/pwm0/enable'

[Install]
WantedBy=multi-user.target
EOF

systemctl enable fan-control.service

reboot # so the overlay gets applied and the service start

 

[1] https://forum.radxa.com/t/armbian-for-rock-3a-unofficial-build-with-mainline-kernel/9434/45

You have missed out the replace active with default in the dts file :)

Edited by oneofthemany
found the issue and wanted to inform the author
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines