Open The-First-King opened 2 days ago
@The-First-King
Hello
I just tested it and found no problem.
You may need to update your kernel to the latest version.
pi@raspberrypi:~/x729-script $ uname -a Linux raspberrypi 6.6.51+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.51-1+rpt3 (2024-10-08) aarch64 GNU/Linux pi@raspberrypi:~/x729-script $
The fan is running normally.
Hello,
I am using Ubuntu 24.04 Server.
:~$ uname -a
Linux userver 6.8.0-1015-raspi #17-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 11 14:12:16 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
When I power on my setup, I notice that the FAN is not rotating. I am not using accumulator batteries at the moment on the X729 board.
https://github.com/user-attachments/assets/1fd516a0-a284-40c2-b31a-5daef570b38f
We have tested Ubuntu 21.10 on RPi4 and the script works. OS is changing, kernel is changing, we need some time to test the script on Ubuntu 24.10 server on RPi 5 and update it We recommend you to use the Raspberry Pi official OS bookworm
I have tried with the Raspberry Pi official OS bookworm and it works. However, it is strange why it is not working with the Raspberry Pi official Ubuntu Server 24.04.1. If you could share some ideas, it would be highly appreciated. Thank you.
admin@raspberrypi:~ $ cat /boot/firmware/config.txt
# For more options and information see
# http://rptl.io/configtxt
# Some settings may impact device functionality. See link above for details
# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Additional overlays and parameters are documented
# /boot/firmware/overlays/README
# Automatically load overlays for detected cameras
camera_auto_detect=1
# Automatically load overlays for detected DSI displays
display_auto_detect=1
# Automatically load initramfs files, if found
auto_initramfs=1
# Enable DRM VC4 V3D driver
dtoverlay=vc4-kms-v3d
max_framebuffers=2
# Don't have the firmware create an initial video= setting in cmdline.txt.
# Use the kernel's default instead.
disable_fw_kms_setup=1
# Run in 64-bit mode
arm_64bit=1
# Disable compensation for displays with overscan
disable_overscan=1
# Run as fast as firmware / board allows
arm_boost=1
[cm4]
# Enable host mode on the 2711 built-in XHCI USB controller.
# This line should be removed if the legacy DWC2 controller is required
# (e.g. for USB device mode) or if USB support is not required.
otg_mode=1
[cm5]
dtoverlay=dwc2,dr_mode=host
[all]
usb_max_current_enable=1
dtoverlay=pwm-2chan,pin2=13,func2=4
admin@raspberrypi:~ $ uname -a
Linux raspberrypi 6.6.51+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.51-1+rpt3 (2024-10-08) aarch64 GNU/Linux
admin@raspberrypi:~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- 36 -- -- -- -- -- -- -- -- --
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
admin@raspberrypi:~ $ sudo apt install -y gpiod
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
gpiod is already the newest version (1.6.3-1+b3).
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
admin@raspberrypi:~ $ git clone https://github.com/geekworm-com/x729-script
Cloning into 'x729-script'...
remote: Enumerating objects: 75, done.
remote: Counting objects: 100% (75/75), done.
remote: Compressing objects: 100% (52/52), done.
remote: Total 75 (delta 35), reused 58 (delta 22), pack-reused 0 (from 0)
Receiving objects: 100% (75/75), 16.36 KiB | 2.34 MiB/s, done.
Resolving deltas: 100% (35/35), done.
admin@raspberrypi:~ $
admin@raspberrypi:~ $
admin@raspberrypi:~ $ cd x729-script
admin@raspberrypi:~/x729-script $ chmod +x *.sh
admin@raspberrypi:~/x729-script $ sed -i 's/xPWR.sh 0 5 12/xPWR.sh 4 5 12/g' x729-pwr.service
admin@raspberrypi:~/x729-script $ sed -i 's/pwmchip0/pwmchip2/g' x729-fan.sh
admin@raspberrypi:~/x729-script $ sudo cp -f ./x729-fan.sh /usr/local/bin/
admin@raspberrypi:~/x729-script $ sudo cp -f ./x729-fan.service /lib/systemd/system
admin@raspberrypi:~/x729-script $ sudo systemctl daemon-reload
admin@raspberrypi:~/x729-script $ sudo systemctl enable x729-fan
Created symlink /etc/systemd/system/multi-user.target.wants/x729-fan.service → /lib/systemd/system/x729-fan.service.
admin@raspberrypi:~/x729-script $ sudo systemctl start x729-fan
admin@raspberrypi:~/x729-script $ sudo cp -f ./xPWR.sh /usr/local/bin/
admin@raspberrypi:~/x729-script $ sudo cp -f x729-pwr.service /lib/systemd/system
admin@raspberrypi:~/x729-script $ sudo systemctl daemon-reload
admin@raspberrypi:~/x729-script $ sudo systemctl enable x729-pwr
Created symlink /etc/systemd/system/multi-user.target.wants/x729-pwr.service → /lib/systemd/system/x729-pwr.service.
admin@raspberrypi:~/x729-script $ sudo systemctl start x729-pwr
admin@raspberrypi:~/x729-script $ sudo cp -f ./xSoft.sh /usr/local/bin/
admin@raspberrypi:~/x729-script $ echo "alias x729off='sudo /usr/local/bin/xSoft.sh 0 26'" >> ~/.bashrc
admin@raspberrypi:~/x729-script $ source ~/.bashrc
admin@raspberrypi:~/x729-script $ x729off
Your device will be shutting down in 2 seconds...
admin@raspberrypi:~/x729-script $
Broadcast message from root@raspberrypi (Tue 2024-11-26 09:39:31 EST):
The system will power off now!
admin@raspberrypi:~ $ sudo systemctl status x729-fan.service
● x729-fan.service - Daemon to monitor and control fan speed
Loaded: loaded (/lib/systemd/system/x729-fan.service; enabled; preset: enabled)
Active: active (running) since Tue 2024-11-26 09:41:19 EST; 6min ago
Main PID: 588 (bash)
Tasks: 2 (limit: 9252)
CPU: 188ms
CGroup: /system.slice/x729-fan.service
├─ 588 bash /usr/local/bin/x729-fan.sh
└─3468 sleep 5
Nov 26 09:41:32 raspberrypi x729-fan.sh[588]: Fan speed changed to 45, temp is 40.80
Nov 26 09:41:42 raspberrypi x729-fan.sh[588]: Fan speed changed to 40, temp is 39.15
Nov 26 09:41:52 raspberrypi x729-fan.sh[588]: Fan speed changed to 45, temp is 39.70
Nov 26 09:42:02 raspberrypi x729-fan.sh[588]: Fan speed changed to 40, temp is 38.60
Nov 26 09:42:27 raspberrypi x729-fan.sh[588]: Fan speed changed to 45, temp is 39.70
Nov 26 09:42:42 raspberrypi x729-fan.sh[588]: Fan speed changed to 40, temp is 39.15
Nov 26 09:47:05 raspberrypi x729-fan.sh[588]: Fan speed changed to 45, temp is 40.25
Nov 26 09:47:10 raspberrypi x729-fan.sh[588]: Fan speed changed to 40, temp is 38.05
Nov 26 09:47:20 raspberrypi x729-fan.sh[588]: Fan speed changed to 45, temp is 40.25
Nov 26 09:47:30 raspberrypi x729-fan.sh[588]: Fan speed changed to 40, temp is 39.15
admin@raspberrypi:~ $
On the Raspberry Pi official OS bookworm:
admin@raspberrypi:~ $ uname -a
Linux raspberrypi 6.6.51+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.51-1+rpt3 (2024-10-08) aarch64 GNU/Linux
admin@raspberrypi:~ $ sudo cat /sys/kernel/debug/pwm
platform/1f00098000.pwm, 4 PWM devices
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-1 (sysfs ): requested enabled period: 500000 ns duty: 200000 ns polarity: normal
pwm-2 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-3 ((null) ): period: 0 ns duty: 0 ns polarity: normal
platform/107d517a80.pwm, 2 PWM devices
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-1 ((null) ): period: 0 ns duty: 0 ns polarity: normal
On the Raspberry Pi official Ubuntu Server 24.04.1:
admin@raspberrypi: ~$ uname -a
Linux userver 6.8.0-1015-raspi #17-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 11 14:12:16 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
admin@raspberrypi: ~$ sudo cat /sys/kernel/debug/pwm
0: platform/1f00098000.pwm, 4 PWM devices
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-1 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-2 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-3 ((null) ): period: 0 ns duty: 0 ns polarity: normal
1: platform/107d517a80.pwm, 2 PWM devices
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-1 ((null) ): period: 0 ns duty: 0 ns polarity: normal
If I'm correct, it looks that the PWM driver hasn't been included into Ubuntu kernel.
admin@raspberrypi:~$ sudo dmesg | grep pwm
[ 3734.504501] rpi-pwm 1f00098000.pwm: failed to get clock rate
admin@raspberrypi:~$ lsmod | grep pwm
pwm_brcmstb 12288 1
pwm_rp1 12288 0
admin@raspberrypi:~$ sudo modprobe pwm
modprobe: FATAL: Module pwm not found in directory /lib/modules/6.8.0-1015-raspi
Yes, I also tested the Ubuntu 21.04 version yesterday and found that it does not work. Can you leave me an email? or you can email to support@geekworm.com.
I add a pythone file (sample/pwm_fan_control_gpiod.py) to control pwm fan on ubuntu 24.04 server, and it can works.
Before that, you need to install the libgpiod library using the following command.
sudo apt install gpiod
sudo apt install python3-libgpiod
Then run the command python3 pwm_fan_control_gpiod.py
to make PWM fan work properly.
PS: I actually used ChatGPT
to help me do this.
There is an error in the "Configuring Different gpipchip number and pwmchip number for Raspberry Pi 5 hardware" section at https://wiki.geekworm.com/X729-script web page.
sed -i 's/pwmchip0/pwmchip2/g' x729-fan.sh
This command is changing pwmchip0 to pwmchip2 value in the x729-fan.sh script. It is incorrect because the Pi 5 board is using pwmchip0 as shown below:
Also, it can be proved according to the journal log where it is clearly seen that the service is failing with error.
I have changed pwmchip2 back to pwmchip0 in the x729-fan.sh script, but the fan is not working.
Could you assist please if the problem with the fan itself or if the script is not working as expected? This is a new x729 board that I recently received.