0

I'm new in kernel development driver and I'm trying to develop a Linux kernel module, using the this module information:

http://lxr.free-electrons.com/source/drivers/pwm/pwm-tiehrpwm.c

But I didn't understand how to use it. How could adapt this module or better, how to create a new module using functions contained in this file like ehrpwm_pwm_config, ehrpwm_pwm_enable?

PS:I don't want to use sysfs, I would configure the pwm signal programmatically. I'm using a Beaglebone Black board running a Debian distribution , and cape-universaln.

Thanks

dczanella
  • 1
  • 2

1 Answers1

0

You need to enable CONFIG_PWM_TIEHRPWM in your .config file of your linux-kernel. By default, CONFIG_PWM_TIEHRPWM is not set and you need to enable it as CONFIG_PWM_TIEHRPWM=y, if you want to build it as a part of kernel image, or as CONFIG_PWM_TIEHRPWM=m, if you want to build it as a LKM.

Then, build your kernel as make -j12 and insmod your module as:

#insmod /lib/modules/$uname -r/drivers/pwm/pwm_tiehrpwm.ko if you have built it as a LKM. Check Linux kernel documentation on how to configure pwm!

Sachin Mokashi
  • 415
  • 5
  • 17
  • @sachinmokashi.I had already done this step. This module is loaded with success in kernel. My doudt is how could I use it? I check the Linux documentation, but it isn't clearly explained. I don't know how to instantiate it in another module and to use the functions defined there. Do you have some tip for? – dczanella Dec 14 '16 at 13:24
  • You need to use EXPORT_SYMBOL_GPL() macro to use the functions in another module. I would suggest you read [link](http://free-electrons.com/doc/books/ldd3.pdf) Chapter 2 for better understanding of linux kernel programming – Sachin Mokashi Dec 14 '16 at 14:59
  • So I need to recompile this module to include the EXPORT_SYMBOL for each function that I want to use. What does this structure mean? static const struct pwm_ops ehrpwm_pwm_ops = {...} at line 417 of the file How does this structure work? I had thought that is possible to call this functions through its. – dczanella Dec 14 '16 at 19:02
  • @SachinMokashi, no, there is a public in-kernel API to use PWMs. – 0andriy Dec 22 '16 at 00:41