No it won’t. Newer Linux kernel no longer assign fixed number to pwm controller, instead in a first come first serve manner. Hardware initialization order is non deterministic, so there is no guarantee that even with the same overlay enabled you will get same numbering all the time. We would switch to register based access for PWM, which will guarantee the device order.
We will fix this, as we are moving more products to the newer kernel. But there is no timeline yet.
I think all our boards are affected. Other vendors’ board could be affected as well, since pwm.parent_id is part of the base MRAA data type, so I think many would use it like what we did. Raspberry Pi’s implementation is register based.
There are a bunch of python PWM library. Any of them should work, since this is a standard Linux interface.
To check which PWM device is mapped to which physical pin, you can check the symbolic links under /sys/class/pwm/. They should point to some file named like pwmX@ffabcdef. The part after @ is the register address, and that is linked to the physical pin.
Newer Linux kernel no longer assign fixed number to pwm controller, instead in a first come first serve manner. Hardware initialization order is non deterministic, so there is no guarantee that even with the same overlay enabled you will get same numbering all the time
Does this mean that PIN 13 i.e PWM3 will not always correspond to /sys/class/pwmchip2 ? It can be any of pwmchip0 / pwmchip1 / pwmchip 2 ?
So we have to pass chip and channel in the periphery library
PWM3 would always be this device. You can check the name under /sys/devices/platform/ff180020.pwm/pwm/ to get the pwmchip number, then use that in Python to create the device.
Rockchip’s PWM controller only has 1 channel, so PWM(2, 0) should work.
Where in the documentation, can I find mapping of rock-pi-s PIN NO. and corresponding GPIO chip no. and Line no. ? Can you send me some link for reference?
Because periphery library asks for chip number and line number.
from periphery import GPIO
# Open GPIO /dev/gpiochip0 line 10 with input direction
gpio_in = GPIO("/dev/gpiochip0", 10, "in")
# Open GPIO /dev/gpiochip0 line 12 with output direction
gpio_out = GPIO("/dev/gpiochip0", 12, "out")
The Rockchip platform usually has 5 groups of GPIOs (also called banks): GPIO0 ~ GPIO4 (different chips will be different), each group has 32 GPIOs. Each group of GPIOs is divided into 4 groups, A/B/C/D, with 8 GPIOs in each group (0~7, also called bank_idx). So the GPIOs can be named from GPIO0_A0 to GPIO4_D7. Taking GPIO3_C5 as an example, we can deduce that its bank is 3, and its bank_idx is 21, i.e., GPIO3_C5 is the 21st GPIO in group 3.