How to access PWM using sysfs on Android

I am working with the DragonBoard 410C using Android 5.1.1 build 99, the latest update from 96Boards working out how to use the GPIO pins using sysfs interface.

I currently have a Kotlin library that allows me to manipulate the GPIO pins and the user LEDs. I’m now investigating how to use the PWM.

My understanding is that physical pin 28 can be configured as either a GPIO pin (GPIO 910 under Android) or as a PWM pin.

From the 96Board documentation there is a description of using sysfs for PWM under Linux however it doesn’t seem to apply to Android.

Controlling PWM from Userspace

# Export PWM 0
$ echo 0 | sudo tee /sys/class/pwm/pwmchip0/export

# Set frequency to 100KHz (value in nanoseconds)
$ echo 10000 | sudo tee /sys/class/pwm/pwmchip0/pwm0/period

# Set 50% duty cycle (value in nanoseconds)
$ echo 5000 | sudo tee /sys/class/pwm/pwmchip0/pwm0/duty_cycle

# Enable PWM 0
$ echo 1 | sudo tee /sys/class/pwm/pwmchip0/pwm0/enable

When I use adb shell from my Windows 10 laptop host to look through the Android file space, I do not see a pwm folder in the /sys/class folder.

I have found differences between Linux and Android file system for example the sysfs interface when accessing the user LEDs differs.

How do I access the PWM capabilities of the DragonBoard 410 C using the sysfs interface?

Well, I would suppose that the reason would be that the ancient and totally unsupported android versions like that are built from qualcomm/CAF source, whereas the documentation will be more in reference to newer upstream kernels.

Try building a modern Android for it, and you probably will get the interfaces you are expecting there to be with the updated kernel.

How do I build a modern Android for the DragonBoard 410C?

Start with this link, which is also out of date;

And read more in this forum.