Additional PWM Channels on Tinker Board

Hello,

I would like to use the PWM2 and PWM3 outputs on my Tinker Board. Yet, from the default configuration on the host BalenaOS I can see that these are disabled on the device tree. Also on sysfs I have only one pwm control available - pwmchip0, corresponding to the separate pin located south with the SPDIF one. So, is there a way for me to enable these two additional channels that are on PIN32 and PIN33 among the GPIOs?

Thanks a lot!

Hi

Are you familiar with device tree overlays and parameters? If you are, you can take a look at Advanced boot settings - Balena Documentation

The device dashboard allows you to specify device trees or parameters that need to be loaded for a particular device, which can help you pick the right pin configuration. One necessary condition is that those should exist in the image

Well, I’m actually new to this. I’ve already read the link you supplied, yet I still don’t know where to start from. It seems the config.txt file is a Raspberry Pi specific configuration file. On my Tinker Board version of BalenaOS, there’s a config.json under /mnt/boot I suppose it’s for similar use. Yet, I have no idea where and what to add into this file. If you may, please kindly explain the details to me. Thanks in advance!

Finally tackled this issue by decompiling and editing the device tree file. The two truly useful links are Sensors and Data Logging with Embedded Linux - The Ultimate Guide Part 1 and Raspberry Pi Documentation - Configuration. The second link is for Raspberry Pi, yet it’s still a good reference point. Just remember the device endpoints are different, so consult the decompiled file entires rather than copy-paste’s.

Below is a simple Dockerfile you can use to decompile the .dtb file into .dts file, which you could edit and recompile back into .dtb to replace the original one. Remember that device trees are architecture INDEPENDENT, so it’d be more convenient to copy the .dtb file from card and edit it on your dev computer. Just bind mount a folder from your local machine when you docker run the image,

FROM alpine:latest
RUN apk update \
    && apk add --upgrade dtc
ENTRYPOINT [ "/bin/ash" ]

Then run the following,

dtc -I dtb -O dts -o dt-blob.dts rk3288-miniarm.dtb # For decompilation.

dtc -I dts -O dtb -o rk3288-miniarm.dtb dt-blob.dts # For recompilation.

Generating a standalone overlay file might be a better option, yet for quick dev tests, direct modifications are OK, as I’ve tested.

Suggestion is integrating the key contents from the first example link into the documentation @anujdeshpande had mentioned above.

That’s great news! Being able to edit a device tree is definitely a huge help when dealing with sensors and peripherals communicating over GPIO. Glad you were able to figure it out.

If you want to share your edits too, I’m sure it would help if another user is having the same issue, or maybe it could be merged into BalenaOS.

Anyway, thanks for letting us know. Good luck with your project!

Maybe later when our project is settled down I’d be able to peel the parts related to BalenaOS off and upload them to GitHub :wink:

That would be great