Marek
Marek

Reputation: 31

How to display linux printk() messages in virtual console (tty1)

I'm trying to solve problem with linux printk() messages (Linux raspberrypi 3.6.11+ #87 PREEMPT Fri Feb 7 00:17:11 CET 2014 armv6l GNU/Linux).
What I have is a kernel module which implements unlocked_ioctl function from struct file_operations. When I call this function from user space with specified cmd=CMD_PRINTK, the following code is executed:

   case CMD_PRINTK:
   {
         printk(KERN_EMERG    "TEST KERN_EMERG\n");
         printk(KERN_ALERT    "TEST KERN_ALERT\n");
         printk(KERN_CRIT     "TEST KERN_CRIT\n");
         printk(KERN_ERR      "TEST KERN_ERR\n");
         printk(KERN_WARNING  "TEST KERN_WARNING\n");
         printk(KERN_NOTICE   "TEST KERN_NOTICE\n");
         printk(KERN_INFO     "TEST KERN_INFO\n");
         printk(KERN_DEBUG    "TEST KERN_DEBUG\n");
   }

What I was expecting is that amount of displayed messages will depend on second value of

root@raspberrypi:/mnt/raspberrypi/linux/linux/mod# *cat /proc/sys/kernel/printk*
7   **4**   1   7

But what I observe is only the first message "TEST KERN_EMERG\n" which is printed by syslogd btw on every virtual terminal (pts/1...)

In kernel command line I've specified the console as tty1

root@raspberrypi:/mnt/raspberrypi/linux/linux/mod# *cat /proc/cmdline*

dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1824 bcm2708_fb.fbheight=984 bcm2708.boardrev=0x3 bcm2708.serial=0xf8900c76 smsc95xx.macaddr=B8:27:EB:90:0C:76 dwc_otg.lpm_enable=0 **console=/dev/tty1** root=/dev/nfs nfsroot=192.168.1.102:/home/borys/rpi_rootfs ip=192.168.1.103:192.168.1.102:192.168.1.1:255.255.255.0:rpi:eth0:off rootfstype=nfs

I tried to use minicom to connect to /dev/tty1 but still I cannot observe any messages displayed there.
I tried to kill syslogd but it didn't help.

At the moment I think that I don't understand something about virtual terminals. I had setup with STLinux platform and console specified as serial port (/dev/ttyAS0) and I was able to connect with serial cable from my host computer and I saw all printk() messages.

Can someone explain how to display kernel printk() messages in virtual terminal via minicom connection?
Is it possible at all?
Will it be possible to control printk() messages verbosity then?

Updated: 05.05.2014

My colleague found first mistake in my cmdline. It should be

**console=tty1**

not

**console=/dev/tty1**

because filesystem is not available at the moment of cmdline parsing. After this change I can see debugs in virtual terminal and using dmesg -n x as suggested by oakad below, I can change its verbosity.

This is almost but not certainly what I wanted actually. The one thing which I'm still missing is the connection to vitural terminal tty1 via minicom.

Currenlty I can see kernel logs only on the screen connected to my raspberry pi or via serial interface ttyAMA0.

Additionally when I run my test on PC I can see kernel debugs if I switch to virtual console via Alt+Ctrl+n where n is the number of virtual console.

What I would like to have is for example: ssh session to raspbery pi in which I start minicom and specify tty1 as a port. The same in case of PC I would like to start xterm (/dev/pts/n) in which I start minicom and specify tty1 as a port.

Unfortunatelly both, in case of rasberry Pi and in case of PC I cannot see kernel debugs in such minicom session. In case of raspberry Pi I tried to send file from minicom and I saw it was working - file content was displayed in display connected directly to rasberry pi. Unfortuanatelly logs from rasberry to minicom are not transferred or are stucked somewhere. Does anyone could tell me if such method for kernel logs display is possible at all?

Upvotes: 3

Views: 4194

Answers (1)

oakad
oakad

Reputation: 7585

You can set your console "verbosity" level with dmesg -n x, where x is the name of the "minimal" message priority you want printed out to the console. Try saying dmesg -n debug to see everything on the console, KERN_DEBUG messages included.

Upvotes: 1

Related Questions