Which system do you use? Android, Ubuntu, OOWOW or others?
Ubuntu 22.04.2
Which version of system do you use? Khadas official images, self built images, or others?
Official Image
Please describe your issue below:
Configure Fan (GPIO pins: 1=5V, 21=GND, 35=PWM_F)
howto
Post a console log of your issue below:
input:
echo 126 > /sys/class/gpio/export
output:
echo: I/O error
input:
echo out > /sys/class/gpio/gpio126/direction
output:
cannot create /sys/class/gpio/gpio126/direction: Directory nonexistent
For anyone interested, here is my revised setup to run the pwm fan from kksb on the vim4 by khadas:
/boot/dtb/amlogic/kvim4.dtb.overlay.env
fdt_overlays=pwm_f
/usr/local/bin/fan.sh
#!/bin/bash
TEMP_TRESHOLD=75000 # 75 celsius
LOOP_TIME=1 # 1 sec
PWM_EXPORT='/sys/class/pwm/pwmchip4/export'
PWM_PERIOD='/sys/class/pwm/pwmchip4/pwm1/period'
PWM_DUTY_CYCLE='/sys/class/pwm/pwmchip4/pwm1/duty_cycle'
PWM_ENABLE='/sys/class/pwm/pwmchip4/pwm1/enable'
CPU_TEMP='/sys/class/thermal/thermal_zone0/temp'
if [ -f $PWM_EXPORT ] ; then
[ -f $PWM_ENABLE ] || echo 1 > $PWM_EXPORT
echo 40000 > $PWM_PERIOD # 40 us -> 25 kHz
echo 40000 > $PWM_DUTY_CYCLE # max speed
while true ; do
TEMP=$(<$CPU_TEMP) # read cpu temp
if [ $TEMP -lt $TEMP_TRESHOLD ] ; then
echo 0 > $PWM_ENABLE
else
echo 1 > $PWM_ENABLE
fi
sleep $LOOP_TIME
done
fi
/etc/systemd/system/fan.service
[Unit]
Description=fan control service
After=multi-user.target
[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/fan.sh
[Install]
WantedBy=multi-user.target
chmod +x /usr/local/bin/fan.sh
systemctl daemon-reload
systemctl enable fan.service
systemctl restart fan.service
2 Likes