LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This 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


Reply
  Search this Thread
Old 03-14-2014, 09:59 AM   #1
elsutjr
LQ Newbie
 
Registered: Feb 2014
Posts: 18

Rep: Reputation: Disabled
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
 
Old 03-14-2014, 10:14 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
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.
 
1 members found this post helpful.
Old 03-14-2014, 10:44 AM   #3
elsutjr
LQ Newbie
 
Registered: Feb 2014
Posts: 18

Original Poster
Rep: Reputation: Disabled
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?

Thanks,
Ed
 
Old 03-14-2014, 02:06 PM   #4
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
$ mount | grep -i "devtmpfs"

udev will be using that filesystem.

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.
 
1 members found this post helpful.
Old 03-14-2014, 02:12 PM   #5
elsutjr
LQ Newbie
 
Registered: Feb 2014
Posts: 18

Original Poster
Rep: Reputation: Disabled
Ok, thanks much.
I have things working fine with init.d scripts, but I'll look into udev...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to create symbolic link to device file from driver AnkurTank Linux - Kernel 2 03-25-2013 09:04 AM
how can we dynamically create the device node for character driver. Inba Linux - Kernel 3 08-30-2011 07:42 PM
dynamically create/delete device nodes by driver prakashgkk Linux - Newbie 1 04-16-2010 05:18 PM
how to create a device driver for user applications trkecea Programming 3 02-07-2010 09:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 09:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration