This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SK-AM62P-LP: Configuring a PWM module from a User Space Application in RT Linux

Part Number: SK-AM62P-LP

Hi,

I am developing a test application that allows a user to configure one of the PWM modules from the Command Line however, I am not sure what the approach to modifying the PWM's configuration from user space is, other than using sysfs which I have been told is deprecated and replaced with character devices.

Since there isn't (to my knowledge) any entries in the device directory for PWMs does this mean a kernel module is required to create a character device that can then be used by ioctl() to configure and enable the PWM in userspace, or is there another approach already provided, that I should take with this?

Thank you,

Oliver

  • Hi,

    The thread owner is out of office till until week of Feb 17. Please ping the thread if you do not get an update during that week.

    Thank you for your patience.

    Regards,
    Harshith

  • Hello Oliver,

    As far as I am aware, you should still be able to use the sysfs interface to interact with PWMs (though I have not tested the recent SDKs).

    Are you able to change PWMs as expected by following the instructions in the Linux SDK's PWM driver docs?
    https://software-dl.ti.com/processor-sdk-linux/esd/AM62PX/latest/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/PWM.html

    Note that GPIO control has moved away from the sysfs interface. You can see the updated GPIO guidance here:
    https://software-dl.ti.com/processor-sdk-linux/esd/AM62PX/latest/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/GPIO.html 

    Regards,

    Nick

  • Hi Nick,

    Are you able to change PWMs as expected by following the instructions in the Linux SDK's PWM driver docs?

    I can configure the PWM in the command line like the docs say. I mainly just wanted to know if there was a suggested way programmatically (i.e. a specific library included in the 'Linux-devkit' sysroot, a shell script, etc).

    Note that GPIO control has moved away from the sysfs interface.

    Does this mean the PWM can be configured through the GPIO interface?

    Best Regards,

    Oliver

  • Hello Oliver,

    Does sysfs = GPIO? 

    No. Sysfs provides an interface to interact with drivers, and then the individual drivers can interact with the GPIO hardware or the PWM hardware. I have attached an AI generated summary which gives more context [1]

    Does TI have additional suggestions for controlling PWM module? 

    Not really - it depends on your usecase, and in general, I would expect you to know more about your usecase than I do.

    Keep in mind that Linux is NOT deterministic, and that Linux DOES have higher latency to respond to inputs than the R5F core (even if running RT Linux). Please refer to my AM62Px Multicore Academy article "Operating Systems" for additional thoughts:
    https://dev.ti.com/tirex/explore/node?isTheia=false&node=A__AeQyGefrI7qyqGJR.b2hjA__AM62P-ACADEMY__fp5YxRM__LATEST

    So if you are needing to adjust the PWM with precise timing or responding within a real-time constraint, then controlling the PWM from the R5F may be a better fit for the design.

    Regards,

    Nick

    [1]

    The Linux sysfs interface is a virtual filesystem that exposes kernel objects, drivers, and device information to userspace through a hierarchical directory structure (typically under /sys), allowing programs to interact with peripherals by reading from and writing to attribute files without requiring custom kernel drivers or system calls. This interface provides a standardized way to configure, control, and query hardware devices through simple file operations.

    The Linux sysfs interface is a virtual filesystem that provides a way to interact with kernel objects and drivers from userspace, with device information typically exposed through directories and attribute files under paths like /sys/class/, /sys/bus/, and /sys/devices/ [1]. It allows programs and scripts to interact with peripherals by reading from and writing to these attribute files, enabling configuration and control of hardware devices without requiring custom kernel drivers or system calls [2].

    For example, GPIO devices are made available through /sys/class/gpio [3], PWM devices through /sys/class/pwm [4], and counter devices through /sys/bus/counter/devices/ [5]. Users can control peripheral behavior by writing configuration values to attribute files (such as setting a counter ceiling value or enabling a device) and query device state by reading from these files (such as reading current count values or device names) [6].