Hi!
I’m trying to get PWM on at least 2 pins of a MilkV Duo256. I have only been able to get 1 pin working.
I’m running the default OS image:
$ cat /etc/os-release
NAME=Buildroot
VERSION=-g6b03c2762
ID=buildroot
VERSION_ID=2025.02
PRETTY_NAME="Buildroot 2025.02"
To get the one pin (pin#6 == GP4) working :
[root@milkv-duo]~# duo-pinmux -w GP4/PWM_5
pin GP4
func PWM_5
register: 30010d4
value: 7
[root@milkv-duo]~# echo 1 > /sys/class/pwm/pwmchip4/export
[root@milkv-duo]~# echo 256 > /sys/class/pwm/pwmchip4/pwm1/period
[root@milkv-duo]~# echo 128 > /sys/class/pwm/pwmchip4/pwm1/duty_cycle
[root@milkv-duo]~# echo 1 > /sys/class/pwm/pwmchip4/pwm1/enable
I am testing this with an LED and I can confirm I can change the brightness by changing the duty cycle.
However any other pins elude me. The Sophgo SG2002 Technical Reference Manual has a PWM section in the Peripherals Chapter. It says there are 4 PWM controllers PWM0, PWM1, PWM2 and PWM3. Each controller provides 4 independent PWM signal outputs:
• PWM0 includes PWM[0], PWM[1], PWM[2], PWM[3].
• PWM1 includes PWM[4], PWM[5], PWM[6], PWM[7].
• PWM2 includes PWM[8], PWM[9], PWM[10], PWM[11].
• PWM3 includes PWM[12], PWM[13], PWM[14], PWM[15].
duo-pinmux -l
lists only 8 PWM_? pins.
Does anyone know the mapping from SG2002 PWM[??] to MilkV Duo256 PWM_? ? How can I use them?