printk in Android

2,321 views
Skip to first unread message

perumal316

unread,
Jan 5, 2010, 4:01:00 AM1/5/10
to Android Linux Kernel Development
Hi,

Currently when I printk kernel messages it is only viewable through
the terminal, but if in a phone/emulator any idea how do I view the
kernel messages?

Thanks in Advance,
Perumal

Tim Bird

unread,
Jan 5, 2010, 3:10:16 PM1/5/10
to android...@googlegroups.com
perumal316 wrote:
> Hi,
>
> Currently when I printk kernel messages it is only viewable through
> the terminal, but if in a phone/emulator any idea how do I view the
> kernel messages?

Use dmesg. The kernel printk messages are stored in a ring
buffer, and are accessible after boot using this standard linux
tool. Toolbox provides 'dmesg', as does busybox.
-- Tim

=============================
Tim Bird
Architecture Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Corporation of America
=============================

hedwin

unread,
Jan 5, 2010, 4:37:37 PM1/5/10
to android...@googlegroups.com
Perumal

Within the android emulation check if you have a "dev tools" package. That has a "terminal emulation" inside. Starting this will
open a shell. This way you should be able to a dmesg within the emulation itself

Hedwin


dmitriy moskvitin

unread,
Jan 5, 2010, 8:45:22 PM1/5/10
to Android Linux Kernel Development
"cat /proc/kmsg", if you have root-privileges

On Jan 6, 6:37 am, hedwin <hedwin.kon...@gmail.com> wrote:
> Perumal
>
> Within the android emulation check if you have a "dev tools" package. That
> has a "terminal emulation" inside. Starting this will
> open a shell. This way you should be able to a dmesg within the emulation
> itself
>
> Hedwin
>

> On Tue, Jan 5, 2010 at 9:10 PM, Tim Bird <tim.b...@am.sony.com> wrote:
> > perumal316 wrote:
> > > Hi,
>
> > > Currently when I printk kernel messages it is only viewable through
> > > the terminal, but if in a phone/emulator any idea how do I view the
> > > kernel messages?
>
> > Use dmesg.  The kernel printk messages are stored in a ring
> > buffer, and are accessible after boot using this standard linux
> > tool.  Toolbox provides 'dmesg', as does busybox.
> >  -- Tim
>
> > =============================
> > Tim Bird
> > Architecture Group Chair, CE Linux Forum
> > Senior Staff Engineer, Sony Corporation of America
> > =============================
>
> > --

> > unsubscribe: android-kerne...@googlegroups.com<android-kernel%2Bunsu...@googlegroups.com>
> > website:http://groups.google.com/group/android-kernel
>
>

perumal316

unread,
Jan 7, 2010, 12:13:35 AM1/7/10
to Android Linux Kernel Development
Hi All,

Thanks for the input. But I am currently writing a module for Android.
In module programming there is only printk but is it possible to show
the kernel messages to the users? Meaning the user who will be using
the Android phone with the module will be shown the kernel messages.

Regards,
Perumal

Greg KH

unread,
Jan 7, 2010, 9:56:14 AM1/7/10
to android...@googlegroups.com
On Wed, Jan 6, 2010 at 9:13 PM, perumal316 <perum...@gmail.com> wrote:
> Hi All,
>
> Thanks for the input. But I am currently writing a module for Android.
> In module programming there is only printk but is it possible to show
> the kernel messages to the users? Meaning the user who will be using
> the Android phone with the module will be shown the kernel messages.

Not directly from the kernel, no, Linux does not work that way, sorry.

Why do you feel that a user would want to see a kernel message directly
anyway?

What type of kernel code are you writing?

thanks,

greg k-h

perumal316

unread,
Jan 7, 2010, 9:23:32 PM1/7/10
to Android Linux Kernel Development

I am writing a kernel module which prints out a message each time a
system call is being made. I want to show these messages to user.

On Jan 7, 10:56 pm, Greg KH <gre...@gmail.com> wrote:

perumal316

unread,
Jan 7, 2010, 10:25:06 PM1/7/10
to Android Linux Kernel Development

Is it possible to write to file in kernel programming?

Dianne Hackborn

unread,
Jan 7, 2010, 10:33:11 PM1/7/10
to android...@googlegroups.com
Er...  I suspect you want to how them to the -developer-, not the user, in which case they should be perfectly fine using the shell and dmesg to see the, shouldn't they?




--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Greg KH

unread,
Jan 7, 2010, 10:39:15 PM1/7/10
to android...@googlegroups.com
On Thu, Jan 7, 2010 at 6:23 PM, perumal316 <perum...@gmail.com> wrote:
>
> I am writing a kernel module which prints out a message each time a
> system call is being made. I want to show these messages to user.

No, you really don't want to do ever do that. Remember, the user made
the system
call in the first place, why would you want to just tell the user what they know
they just did.

So again, you can not do this for a good reason.

thanks,

greg k-h

perumal316

unread,
Jan 7, 2010, 10:40:00 PM1/7/10
to Android Linux Kernel Development
Actually I want to show to user, but if in the phone if there any way
where these messages can be shown to them without them have to go to
terminal and dmesg?

On Jan 8, 11:33 am, Dianne Hackborn <hack...@android.com> wrote:
> Er...  I suspect you want to how them to the -developer-, not the user, in
> which case they should be perfectly fine using the shell and dmesg to see
> the, shouldn't they?
>
>
>
> On Thu, Jan 7, 2010 at 6:23 PM, perumal316 <perumal...@gmail.com> wrote:
>
> > I am writing a kernel module which prints out a message each time a
> > system call is being made. I want to show these messages to user.
>
> > On Jan 7, 10:56 pm, Greg KH <gre...@gmail.com> wrote:
> > > On Wed, Jan 6, 2010 at 9:13 PM, perumal316 <perumal...@gmail.com> wrote:
> > > > Hi All,
>
> > > > Thanks for the input. But I am currently writing a module for Android.
> > > > In module programming there is only printk but is it possible to show
> > > > the kernel messages to the users? Meaning the user who will be using
> > > > the Android phone with the module will be shown the kernel messages.
>
> > > Not directly from the kernel, no, Linux does not work that way, sorry.
>
> > > Why do you feel that a user would want to see a kernel message directly
> > > anyway?
>
> > > What type of kernel code are you writing?
>
> > > thanks,
>
> > > greg k-h
>
> > --

> > unsubscribe: android-kerne...@googlegroups.com<android-kernel%2Bunsu...@googlegroups.com>


> > website:http://groups.google.com/group/android-kernel
>
> --
> Dianne Hackborn
> Android framework engineer

> hack...@android.com

Greg KH

unread,
Jan 7, 2010, 10:40:52 PM1/7/10
to android...@googlegroups.com
On Thu, Jan 7, 2010 at 7:25 PM, perumal316 <perum...@gmail.com> wrote:
>
> Is it possible to write to file in kernel programming?

Yes, but again, you do not want to do that.

Go read the kernelnewbies.org site for why.

http://kernelnewbies.org/FAQ/WhyWritingFilesFromKernelIsBad

I suggest reading up on that site for other questions you are going to
have after
this one :)

good luck,

greg k-h

Greg KH

unread,
Jan 7, 2010, 10:42:11 PM1/7/10
to android...@googlegroups.com
On Thu, Jan 7, 2010 at 7:40 PM, perumal316 <perum...@gmail.com> wrote:
> Actually I want to show to user, but if in the phone if there any way
> where these messages can be shown to them without them have to go to
> terminal and dmesg?

On the android platform, no, there isn't, unless you write an application that
monitors the system log messages and displays them to the user.

But go back and see my other response as to why this is foolish
(i.e. the user knows they made the call, why tell them again?)

good luck,

greg k-h

Reply all
Reply to author
Forward
0 new messages