during change from 3.8 kernel to 4.14 I struggled with an issue regarding PWMSS accessed by PRU.
On old kernel I load overlay am33xx_pwm to activate the PWMSS.
I verified this with: devmem2 0x483000000 (base address of PWMSS0)
With 4.14 kernel I get ‘bus error’ when I execute same ‘devmem2 0x483000000’
Also PRU have no access to PWMSS.
But loading the am33xx_pwm seems succesful, at least the sysfs folder is populated with pwm folders.
I wasn’t able to get access to the PWM registers from the ARM side (same bus error), but the PRU can still access them fine. For what I was doing a few weeks ago, I used the normal linux PWM devices to enable the PWM pin, but then used the PRU to configure the registers and such. Seemed to work OK.
I really just use the cape-universal. I use the /sys stuff to export the pin as pwm. I also use the sysfs interface to setup initial PWM values (period/duty_cycle/enable) and after that, the PRU seems to be able to manipulate the PWM registers to change the dutyscycles and such as needed.
@Daniel:
Thanks for your hints. In my 4.14-bone kernel the pwm devices are already exported when overlay is loaded.
So I have to echo values to period, duty-cycle and enable to start PWM. In my case eCAP2(PWMSS2)
After that PRU has also access to ECAP2.
A little bit ugly procedure…
@TJF
I had also the idea to enable clock for PWMSS2 via enabling control module bit.
But writing to “pwmss_ctrl Register” 0x44E10664 didn’t change behaviour.
Maybe I have to write also to “CM_PER_EPWMSS2_CLKCTRL Register” at 0x44E000D8?
Thanks for your input!
AFAIR the PRU cannot write to PWMSS-0 SS when the tbclk isn’t enabled.
That’s wrong, sorry.
I had also the idea to enable clock for PWMSS2 via enabling control module bit.
But writing to “pwmss_ctrl Register” 0x44E10664 didn’t change behaviour.
How do you write? The PRU has no write access to that adress (just fails, no message). It needs the ARM in supervisor mode (kernel module).
Maybe I have to write also to “CM_PER_EPWMSS2_CLKCTRL Register” at 0x44E000D8?
Sure, this reg must contain the value 2. The PRU can write.
Regards
PS: You could use the loadable kernel module from libpruio to fix this issue. First, it enables all PWM module clocks [0-2] (like in 3.8 kernel). And later you can adapt the setting via sysfs (to synchonize PWM modules). Just install the libpruio-lkm package from Arends PPA. Find details at
AFAIR the PRU cannot write to PWMSS-0 SS when the tbclk isn’t enabled.
That’s wrong, sorry.
No problem
I had also the idea to enable clock for PWMSS2 via enabling control module bit.
But writing to “pwmss_ctrl Register” 0x44E10664 didn’t change behaviour.
How do you write? The PRU has no write access to that adress (just fails, no message). It needs the ARM in supervisor mode (kernel module).
You are completely right. After some reading, I found that in AM335x TRM:
Note: For writing to the control module registers, the MPU will need to be in privileged mode of operation
and writes will not work from user mode.
I assumed if PRU has access to global memory, I could write everywhere but that’s obviously wrong.
Also thanks for the link to libpruio. Impressive work!
All in all getting PWMSS to work in 4.x was a much harder than expected.
Hopefully usage of SPI is less complicated…