Jump to content

Kernel logs on UART console


otousama

Recommended Posts

Hi there, while trying to solve the issue with OPi PC and rtl8188 (thread link) I managed to get console on the UART interface, nice feature considering my networking issues, btw is there a way to output the kernel messages (dmesg like) to the UART console in real time? I'm asking cos the issue that I'm trying to fix involves system freeze + automatic reboot and I would like to see the logs during the event.

I already tried to mess with printk, but it's very likely I've done something wrong.

Link to comment
Share on other sites

If you log in on this console, executing

dmesg -w

on this console will give you real-time dmesg output until reboot/crash occurs.

 

Also you can experiment with kernel command line in boot.cmd/boot.scr, setting "console=ttyS0 loglevel=6" and disabling login on this console (sudo systemctl disable serial-getty@ttyS0) should put all kernel messages to ttyS0 (console available on separate 3-pin header). In case you use high enough loglevel (like 6 or 7), I would recommend increasing scrollback buffer size in your terminal application or enabling logging to file.

Link to comment
Share on other sites

I tried to use

dmesg -w

but all I get is the normal dmesg output, it doesn't wait for new messages.

       -w, --follow
              Wait for new messages.  This feature is supported only  on  sysâ€
              tems with a readable /dev/kmsg (since kernel 3.5.0).

OK, sorry, didn't have any devices with legacy kernel to test this, and looked at help message rather than in man page. Since legacy kernel version is 3.4.x this won't work and you'll have to use the other method.

Link to comment
Share on other sites

So, I've hooked up the OPi via ssh and changed the boot.cmd file as follow

#setenv bootargs "console=tty1 root=/dev/mmcblk0p1 rootwait rootfstype=ext4 cgroup_enable=memory swapaccount=1 panic=10 consoleblank=0 enforcing=0 loglevel=${verbosity}"
setenv bootargs "console=tty0 root=/dev/mmcblk0p1 rootwait rootfstype=ext4 cgroup_enable=memory swapaccount=1 panic=10 consoleblank=0 enforcing=0 loglevel=6"

then compiled boot.scr

sudo mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
Image Name:
Created:      Thu Aug 25 00:28:49 2016
Image Type:   ARM Linux Script (uncompressed)
Data Size:    2442 Bytes = 2.38 kB = 0.00 MB
Load Address: 00000000
Entry Point:  00000000
Contents:
   Image 0: 2434 Bytes = 2.38 kB = 0.00 MB

and lastly disabled login on tty0

sudo systemctl disable serial-getty@ttyS0

After a reboot on the uart console I got the usual booting messages then nothing else, no login prompt (as excepted) but also no dmesg output.

I think I may have modified the boot.cmd file incorrectly, it's the first time messing with these settings, sorta flying blind here.

 

Link to comment
Share on other sites

ahhhh spot on! It seems that in my lazines I just copy-pasted the original line and forgot to add the sneaky S...

 

Thanks to both of you, I can now get back to my original wifi issue (the never ending cycle, fix one, break two).

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines