1

I am fairly new to Linux development, and I am having some trouble finding answers to the issue I'm having.

I have a PWM-device connected to a Beaglebone (white) running Debian with kernel version 3.8.13. The Beaglebone is connected to a PWM-device, and I am able to control the device from /sys/devices/ocp.3/pwm_test_P8_13.10/. Ultimately I want to control the device using C, and I figure the best way to do this is using ioctl.

This is where my question arises: Don't I need to access the device from /dev, and if so, how would I do that when there's no pwm-entry in /dev at all? I know I can write directly to the files in [...]/pwm_test_P8_13.10/, but I am trying to avoid this if possible.

Is there any other way of approaching this?

Tom
  • 414
  • 4
  • 17
  • 1
    http://stackoverflow.com/questions/5970595/create-a-device-node-in-code – Gil Hamilton May 22 '14 at 13:09
  • 1
    To expand a little, you want to create a character device, this allows you to know when a process opens your device, and allows you to specify the function that will be invoked when ioctl is called on it. If you use the interfaces described in the link (and if your system is running the udev daemon), the device node will be created automatically for you. But, in any case, once you've registered your device's major and minor numbers, you can also just create the /dev node manually with: mknod /dev/pwm c – Gil Hamilton May 22 '14 at 13:13
  • 1
    And for more details, check out chapter 3 of http://lwn.net/Kernel/LDD3/ – Gil Hamilton May 22 '14 at 13:16

1 Answers1

1

A kernel module has been developed during GSOC2010. The driver exports a character device, but it supports ioctls as well.

Anyway, using the sysfs interface may be a valid option, in case you are not able to recompile the kernel module. If you want to do it for studying then ok go for the ioctl-based solution, but in general remember that software has to be realiable an correct, and only secondarly it has to use the feature you like most ;-)

Ottavio Campana
  • 4,088
  • 5
  • 31
  • 58