Frank
July 23, 2020, 1:57am
4
@parumsancto Ihave test it just now . It work fine . Maybe you should use the least release firmware
https://dl.khadas.com/Firmware/VIM2/Ubuntu/EMMC/VIM2_Ubuntu-xfce-bionic_Linux-4.9_arm64_EMMC_V20191231.7z
and check with those command
khadas@Khadas:~$ fdtget /boot/dtb/kvim2_linux.dtb /pwm@c1108640 status
okay
khadas@Khadas:~$ fdtget /boot/dtb/kvim2_linux.dtb /pwm@c11086c0 status
okay
2 Likes
OK, I install VIM2_Ubuntu-xfce-bionic_Linux-4.9_arm64_EMMC_V20191231.img.
Then enable pwm@c1108640
root@Khadas:~# fdtput -t s /dtb.img /pwm@c1108640 status okay
and reboot.
After that
root@Khadas:~# fdtget /boot/dtb/kvim2_linux.dtb /pwm@c1108640 status
okay
root@Khadas:~# fdtget /boot/dtb/kvim2_linux.dtb /pwm@c11086c0 status
okay
Then I try:
root@Khadas:~# echo 1 > /sys/class/pwm/pwmchip4/export
root@Khadas:~# echo 1000000 > /sys/class/pwm/pwmchip4/pwm1/period
root@Khadas:~# echo 500000 > /sys/class/pwm/pwmchip4/pwm1/duty_cycle
root@Khadas:~# echo 1 > /sys/class/pwm/pwmchip4/pwm1/enable
but nothing changed - no meander on pin 35!
Frank
July 24, 2020, 1:13am
6
@parumsancto not /sys/class/pwm/pwmchip4
, it’s /sys/class/pwm/pwmchip0
root@Khadas:~# echo 1 > /sys/class/pwm/pwmchip0/export
root@Khadas:~# echo 1000000 > /sys/class/pwm/pwmchip0/pwm1/period
root@Khadas:~# echo 500000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle
root@Khadas:~# echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable
No meander.
Is it normal?
gpio pwm 18 512
warn : (pwmWrite):THis function is not supported by KHADAS Board.
Command “gpio write [pin] [1\0]” works normal.
Frank
July 24, 2020, 10:24am
8
parumsancto:
root@Khadas:~# echo 1 > /sys/class/pwm/pwmchip0/export
root@Khadas:~# echo 1000000 > /sys/class/pwm/pwmchip0/pwm1/period
root@Khadas:~# echo 500000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle
root@Khadas:~# echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable
No meander.
Is it normal?
Are your physical pins surely connected? I have test it yesterday, It work fine . How did you confirm whether it took effect ?
I was connected an oscilloscope to pins 40 and 35. And in parallel was connected LED through resistor (200 Ohm).
After “echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable” no meander on oscilloscope and LED don’t light. If connect anode to pin 20 (not 35) then LED light britely.
Frank
July 27, 2020, 1:16am
10
@parumsancto You can’t see the light flickering at this frequency, you should only connect an oscilloscope to view.If you can’t adjust the parameters of the oscilloscope, you can use the auto mode
Yes, but I can see different brightness on different duty cycle. Now I see nothing: no light and no meander on oscilloscope.
What other ways to control PWM_D pin?
Frank
July 27, 2020, 8:12am
12
@parumsancto
root@Khadas:/home/khadas# echo 1 > /sys/class/pwm/pwmchip0/export
root@Khadas:/home/khadas# echo 1000000 > /sys/class/pwm/pwmchip0/pwm1/period
root@Khadas:/home/khadas# echo 500000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle
root@Khadas:/home/khadas# echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable
Did you follow my steps to test ?
1 Like
Frank
July 27, 2020, 8:53am
14
@parumsancto Do your oscilloscope and the board share the same GND?
Yes. I can see some signals on other pins, but not on pin 35.
Frank
July 27, 2020, 9:10am
16
@parumsancto Have you made any changes to the board? Except for the hardware problem, I can’t think of other reasons
No. I just install VIM2_Ubuntu-xfce-bionic_Linux-4.9_arm64_EMMC_V20191231.img via USB_Burning_Tool_v2.2.0, then boot to ubuntu, connect via ssh, tunrn on pwm “fdtput -t s /dtb.img /pwm@c1108640 status okay”, reboot and do Using PWM_D on VIM2 - #13 by parumsancto
I’ll get a new one VIM2 in a couple of weeks. I’ll try the same actions on new one board.
Is there any way to control PWM_D pin width wiringPI library functions?
Frank
July 27, 2020, 9:52am
19
Upload linux-dtb-amlogic-4.9_0.9.2_arm64.deb to /home/khadas and install
root@Khadas:/home/khadas# dpkg -i linux-dtb-amlogic-4.9_0.9.2_arm64.deb
(Reading database … 108291 files and directories currently installed.)
Preparing to unpack linux-dtb-amlogic-4.9_0.9.2_arm64.deb …
Unpacking linux-dtb-amlogic-4.9 (0.9.2) over (0.8.1) …
Setting up linux-dtb-amlogic-4.9 (0.9.2) …
root@Khadas:/home/khadas# reboot now
Trying use PWM_D
root@Khadas:~# echo 1 > /sys/class/pwm/pwmchip0/export
root@Khadas:~# echo 1000000 > /sys/class/pwm/pwmchip0/pwm1/period
root@Khadas:~# echo 500000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle
root@Khadas:~# echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable
and I see
Trying change duty cycle
root@Khadas:~# echo 800000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle
Looks like working.
2 Likes
Frank
July 28, 2020, 1:14am
21
@parumsancto OK, We already know the reason
What is the reason? Why PWM_D didn’t work?
Why gpio pwm [18] [1-1024] didn’t work?
Frank
July 28, 2020, 11:19am
23
@parumsancto wiringPi in khadas board not supprts Hardware PWM, just software PWM .
Because the pin control use for PWM_D not configiure in dts.