what's the best way to have the kernel create device files for builtin driver?
Linux - Embedded & Single-board computerThis forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
what's the best way to have the kernel create device files for builtin driver?
I have a simple driver (linux on iMX6) that I've been testing as a module. I do the typical insmod/mknod steps to install it, then I have a simple application that tests the driver. That works fine. Next I moved the driver to the kernel as a builtin, so there's no longer a need to run insmod; however, I am still manually doing the "mknod /dev/mydrvr" commands to allow the test program to access the device. I can certainly create the /dev/mydrvr nodes using mknod in a /etc/init.d script; however, googling implies there are better ways to do this (sysfs, udev, etc...). Is there a preferred way of doing this for embedded linux?
Thanks in advance,
Ed
There are several choices. If your kernel is built with devtmpfs support, then registering the device will create the dev. If you are running udev, you can write a udev rule to create the device. If you have a fixed set of devices, so no need for one of these dynamic /dev solutions, then you can make the dev node in init scripts similar to how /dev/null and /dev/zero are created. There's nothing wrong with scripts.
Ok, thanks for the response, now you have me wondering...
First...
Looking at my config I see DEVTMPFS and SYSFS are both enabled. There is no /dev/tmpfs (or anything similar). I assume that means I have udev running? If yes, does that mean I can just add /etc/udev and create a rules.d file to do this?
Second...
I'm ok with just using a script to install the module and the /dev/ files at startup.
Is that a reasonable way to run a system if I never remove the module?
For personal use, that sounds fine. Just don't ever forgot what you did so you can redo it when / if you do a fresh install or upgrade. Perhaps document the manual bits in the code and as output to modinfo. If it's something that's going to be distributed as part of a distro you want to use udev and other how everyone else does it-ness.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.