I have a video online of the VF2 controlling a PWM Led and a Servo.
(I include a 5v level converter circuit for the servo in the description.)
Controlling PWM led’s and servos is fairly easy and well documented using the visionfive2.gpio
package; which itself mirrors the RPI.GPIO
package.
Which is fine; but I actually needed to control PWM channels from userland on my MangoPI MQ Pro (also a risc-v based system).
Not having a ‘architecture specific’ *.gpio
package for the MQ Pro I decided to make my own architecture-neutral userland PWM control system that will work with any kernel driver implementing the legacy /sys/class/pwm
api.
The ‘key’ feature of the video and code above is that it also works (and has been tested on) Raspberry PI’s and the MQ Pro; eg chipsets from SciFive, Broadcom and Allwinner.
The VF2 in the video is running on the 202409 release; and using the two PWM pins mapped by the stock device tree.
My code only controls the hardware timers, it does not do any device tree setup and cannot map pins itself, so if you want to use all 8 of the timers available on the VF2 you will need a custom device tree or overlays.
Not strictly VF2 related but still risc-v; Associated with this I have a guide for modifying DT’s on the MQ pro (it’s a bit of a niche board, my guide covers ubuntu install using a lycheeRV image, and then ‘fixing’ the device tree for the MQ pro)