RE: Does register_chrdev function make device file under /dev ?
Hi, Valdis, Yes, I understand shell is a user program. I just added some uart print to see what's happening. (while trying to open a shell on LCD using USB keyboard..) When I see it n fbcon_scroll function(one of console switch functions which connect to bit blit functions)(in drivers/video/console/fbcon.c) while some printks are scrolled up on the LCD, the vc_data is using tty null (vc->port.tty->name is null) then at some point changes to tty1. This is even when I set "console=tty0 " in the boot argument. When I set "console=tty1 ", it's the same. This is when I remvoed /etc/inittab file so that defulat inittab is put in place by busybox... I understand busybox init starts shells on tty2,tty3,and tty4. So the output is using tty1. In input side, when I use print (to uart) on kbd_keycoad function(drivers/tty/vt/keyboard.c), and press any key, I can see the vc->port.tty->name is tty1. (vc is of type vc_data). So the input is connected to tty1 (same as output). But I don't see any change on the LCD at that state (as I press the keyboard). Any idea? any suggestion will be appreciated. I don't know how to assign tty and how to make the fbconsole(or vc on it) to appear on the LCD so to speak. regards, Chan ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org<mailto:Kernelnewbies@kernelnewbies.org> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies From : "valdis.kletni...@vt.edu" Sent : 2014-03-12 21:14:49 ( +09:00 ) To : Kim Chan Cc : Kernel , kernelnewbies@kernelnewbies.org Subject : Re: Does register_chrdev function make device file under /dev ? On Tue, 11 Mar 2014 08:01:26 -, Kim Chan said: > To my understanding, device file is needed when a user program wants to > access the device and we don't need to generate the device file for us to use > the device in kernel. Is my understanding correct? Right. You don't need to generate the device file because you shouldn't be accessing the device in a file-like manner from inside the kernel. > I am trying to open a shell on my LCD (is it going to be tty2 That's userspace, not kernel access. ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Does register_chrdev function make device file under /dev ?
On Tue, 11 Mar 2014 08:01:26 -, Kim Chan said: > To my understanding, device file is needed when a user program wants to > access the device and we don't need to generate the device file for us to use > the device in kernel. Is my understanding correct? Right. You don't need to generate the device file because you shouldn't be accessing the device in a file-like manner from inside the kernel. > I am trying to open a shell on my LCD (is it going to be tty2 That's userspace, not kernel access. pgp1FTlZNga7b.pgp Description: PGP signature ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
RE: Does register_chrdev function make device file under /dev ?
Hi, Mandeep, Thanks for clearing some things for me. For accessing the device in kernel code, I think maybe we can use the /proc or /sys file system. (I remember seeing people saying something like that.. correct me if I'm wrong) > I think you need to point getty or a shell to the correct tty before you > can see o/p on the screen. Do you know which device file you're supposed > to create for the LCD? If so, just use that in your inittab. > Something like: > > ::askfirst:-/bin/sh > The problem is, after the final sys_execve() which executes /sbin/init of the ramdisk, I cannot see any shell coming up so I cannot use getty command. Using some prints on separate uart print routine, I can see from the kbd_event function the key value is going to current vc which is using tty1. The key value is then handed to put_queue function where the character is somehow copied to tty buffer. Flush_to_ldisc is scheduled for it and it will probably get passed on to the virtual console. Added to this, there is a notifier_call_chain and the notifier block is registered by vcs_poll_data_get function which I don't know weather is necessary or not. So one of my questions is if vcs is necessary for my case. (I guess not. There is no other notifier blocks registered) I gathered without inittab (I don't use inittab which should be ok for most cases) the assumed default inittab tty2::askfirst:-/bin/sh tty3::askfirst:-/bin/sh tty4::askfirst:-/bin/sh is being applied by the busybox so there maybe 3 shells on tty2,tty3, and tty4 running somewhere. But even if there are shells running I don't know how to switch to those ttys. I tried using Ctrl-Alt F2 (or F3, F4) using the USB keyboard to switch to tty2,3,4 to see if any shell comes up on the LCD but couldn't see it. I tried using inittab with no avail before. I hope somebody could point me on what should be checked. Any hint will be appreciated. Regards, Chan > -Original Message- > From: Mandeep Sandhu [mailto:mandeepsandhu@gmail.com] > Sent: Tuesday, March 11, 2014 6:01 PM > To: Chan Kim > Cc: Kernel; kernelnewbies@kernelnewbies.org > Subject: Re: Does register_chrdev function make device file under /dev ? > > On Tue, Mar 11, 2014 at 1:31 PM, Kim Chan wrote: > > > > Yeah, I know mknod command. I just wanted to know if the > > register_chrdev makes the file or not. > > It doesn't. Also note that this is the old way of registering a char > device. New code should use cdev_add() etc. > > > To my understanding, device file is needed when a user program wants > > to access the device and we don't need to generate the device file for > > us to use the device in kernel. Is my understanding correct? > > Yes, device nodes are needed for userspace code to access a device (the > good ol "devices are also files" Unix paradigm! :)). > > I'm not sure how an in-kernel access will work (maybe via directly getting > the corresponding cdec structure). > > > > > For example, busybox (a user program) starts shell on tty2-4 by > > default. (as the assumed default inittab below) > > tty2::askfirst:-/bin/sh tty3::askfirst:-/bin/sh > > tty4::askfirst:-/bin/sh I have had some mknod commands before in > > /etc/init.d/rcS to make tty2~tty4 device files, but when I remove them > > for test, I can see busybox (almost sure it's coming from busybox) > > complaining that it cannot find the tty2~tty4 device files. > > Correct. You will have to create those nodes manually. > > > > > I am trying to open a shell on my LCD (is it going to be tty2 ? I > > don't > > know) and I'm not sure if I have to make vcs1 vcs2 vcs3 files. And I > > don't know how to switch to LCD shell. during the boot, the texts come > > out on the LCD but I cannot see the texts (printf) from busybox. and > > cannot see the shell on LCD. When I press the keyboad, it looks like > > it's connected to tty1(I can see using prints on uart window). Can > > anybody tell me some direction? > > I think you need to point getty or a shell to the correct tty before you > can see o/p on the screen. Do you know which device file you're supposed > to create for the LCD? If so, just use that in your inittab. > Something like: > > ::askfirst:-/bin/sh > > HTH, > -mandeep > > > > > > From : "Kernel" > > Sent : 2014-03-11 14:44:09 ( +09:00 ) > > To : Kim Chan > > Cc : kernelnewbies@kernelnewbies.org > > Subject : Re: Does register_chrdev function make device file under /dev ? > > > > > > > > On Mar 10, 2014, at 10:25 PM, 김찬 wrote: > > > > Hi, > > >
Re: Does register_chrdev function make device file under /dev ?
On Tue, Mar 11, 2014 at 1:31 PM, Kim Chan wrote: > > Yeah, I know mknod command. I just wanted to know if the register_chrdev > makes the file or not. It doesn't. Also note that this is the old way of registering a char device. New code should use cdev_add() etc. > To my understanding, device file is needed when a user program wants to > access the device and we don't need to generate the device file for us to > use the device in kernel. Is my understanding correct? Yes, device nodes are needed for userspace code to access a device (the good ol "devices are also files" Unix paradigm! :)). I'm not sure how an in-kernel access will work (maybe via directly getting the corresponding cdec structure). > > For example, busybox (a user program) starts shell on tty2-4 by default. (as > the assumed default inittab below) > tty2::askfirst:-/bin/sh > tty3::askfirst:-/bin/sh > tty4::askfirst:-/bin/sh > I have had some mknod commands before in /etc/init.d/rcS to make tty2~tty4 > device files, but when I remove them for test, I can see busybox (almost > sure it's coming from busybox) complaining that it cannot find the tty2~tty4 > device files. Correct. You will have to create those nodes manually. > > I am trying to open a shell on my LCD (is it going to be tty2 ? I don't > know) and I'm not sure if I have to make vcs1 vcs2 vcs3 files. And I don't > know how to switch to LCD shell. during the boot, the texts come out on the > LCD but I cannot see the texts (printf) from busybox. and cannot see the > shell on LCD. When I press the keyboad, it looks like it's connected to > tty1(I can see using prints on uart window). Can anybody tell me some > direction? I think you need to point getty or a shell to the correct tty before you can see o/p on the screen. Do you know which device file you're supposed to create for the LCD? If so, just use that in your inittab. Something like: ::askfirst:-/bin/sh HTH, -mandeep > > From : "Kernel" > Sent : 2014-03-11 14:44:09 ( +09:00 ) > To : Kim Chan > Cc : kernelnewbies@kernelnewbies.org > Subject : Re: Does register_chrdev function make device file under /dev ? > > > > On Mar 10, 2014, at 10:25 PM, 김찬 wrote: > > Hi, > > This should be a basic question. > Does the regisetr_chrdev function make the device file under /dev directory? > I am running linux on our embedded system and inside vcs_init, > register_chrdev is called as below. > > int __init vcs_init(void) > { > unsigned int i; > if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops)) > panic("unable to get major %d for vcs device", VCS_MAJOR); > > I can see the function is returning ok but I don't see any vcs* file under > /dev. > Does it only register the device on /sys or /proc directory and not under > /dev? > Thanks in advance. > > Chan > > > > You have to create a device file using 'mknod' > > Ex: mknod -m 666 /dev/vcs c > > > ___ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > > ___ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
RE: Does register_chrdev function make device file under /dev ?
Yeah, I know mknod command. I just wanted to know if the register_chrdev makes the file or not. To my understanding, device file is needed when a user program wants to access the device and we don't need to generate the device file for us to use the device in kernel. Is my understanding correct? For example, busybox (a user program) starts shell on tty2-4 by default. (as the assumed default inittab below) tty2::askfirst:-/bin/sh tty3::askfirst:-/bin/sh tty4::askfirst:-/bin/sh I have had some mknod commands before in /etc/init.d/rcS to make tty2~tty4 device files, but when I remove them for test, I can see busybox (almost sure it's coming from busybox) complaining that it cannot find the tty2~tty4 device files. I am trying to open a shell on my LCD (is it going to be tty2 ? I don't know) and I'm not sure if I have to make vcs1 vcs2 vcs3 files. And I don't know how to switch to LCD shell. during the boot, the texts come out on the LCD but I cannot see the texts (printf) from busybox. and cannot see the shell on LCD. When I press the keyboad, it looks like it's connected to tty1(I can see using prints on uart window). Can anybody tell me some direction? From : "Kernel" Sent : 2014-03-11 14:44:09 ( +09:00 ) To : Kim Chan Cc : kernelnewbies@kernelnewbies.org Subject : Re: Does register_chrdev function make device file under /dev ? On Mar 10, 2014, at 10:25 PM, 김찬 mailto:c...@etri.re.kr>> wrote: Hi, This should be a basic question. Does the regisetr_chrdev function make the device file under /dev directory? I am running linux on our embedded system and inside vcs_init, register_chrdev is called as below. int __init vcs_init(void) { unsigned int i; if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops)) panic("unable to get major %d for vcs device", VCS_MAJOR); I can see the function is returning ok but I don't see any vcs* file under /dev. Does it only register the device on /sys or /proc directory and not under /dev? Thanks in advance. Chan You have to create a device file using 'mknod' Ex: mknod -m 666 /dev/vcs c ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org<mailto:Kernelnewbies@kernelnewbies.org> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Does register_chrdev function make device file under /dev ?
> On Mar 10, 2014, at 10:25 PM, 김찬 wrote: > > Hi, > > This should be a basic question. > Does the regisetr_chrdev function make the device file under /dev directory? > I am running linux on our embedded system and inside vcs_init, > register_chrdev is called as below. > > int __init vcs_init(void) > { > unsigned int i; > if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops)) > panic("unable to get major %d for vcs device", VCS_MAJOR); > > I can see the function is returning ok but I don't see any vcs* file under > /dev. > Does it only register the device on /sys or /proc directory and not under > /dev? > Thanks in advance. > > Chan > You have to create a device file using 'mknod' Ex: mknod -m 666 /dev/vcs c > ___ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Does register_chrdev function make device file under /dev ?
Hi, This should be a basic question. Does the regisetr_chrdev function make the device file under /dev directory? I am running linux on our embedded system and inside vcs_init, register_chrdev is called as below. int __init vcs_init(void) { unsigned int i; if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops)) panic("unable to get major %d for vcs device", VCS_MAJOR); I can see the function is returning ok but I don't see any vcs* file under /dev. Does it only register the device on /sys or /proc directory and not under /dev? Thanks in advance. Chan ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies