0

I am trying to debug a module for the Linux kernel. I heard that it is possible to send the console output to a serial port. I'm running Ubuntu on vmware and want to send printk message to the host. I have managed to set up a serial Connection and can send an echo to the host by typing echo > simething /dev/ttyS1 But I can't figure out how to send the output on the console to ttyS1.

My main problem is that when the module/kernel crashes the last printk-messages are lost and not even displayed, it just buffers.

4

2 回答 2

5

在来宾 Linux 内核上

sudo vim /etc/default/grub  
GRUB_CMDLINE_LINUX="console=ttyS1,115200n8 console=tty0 ignore_loglevel"
sudo update-grub  

注意:-内核参数“ignore_loglevel”会将所有内核消息打印到控制台。对调试很有用。

现在在控制台 ttyS1 上
为 Upstart 系统
启用 getty 1) 创建一个名为 /etc/init/ttyS1.conf 的文件,其中包含以下内容:

# ttyS0 - getty
#
# This service maintains a getty on ttyS1 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[12345]
stop on runlevel [!12345]

respawn
exec /sbin/getty -L 115200 ttyS1 vt102  

2)请暴发户启动getty

sudo start ttyS1  

对于系统系统

$ sudo systemctl enable serial-getty@ttyS1.service
$ sudo systemctl start serial-getty@ttyS1.service
$ sudo systemctl daemon-reload
于 2018-04-25T20:02:24.087 回答
2

尝试使用命令行 'console=ttyS1,<baud>' 引导内核,其中 <baud> 是您在 VM 设置中为该端口配置的波特率。然后内核将使用 /dev/ttyS1 作为主控制台,这就是 printk 将其所有输出发送到的地方。

于 2016-04-15T14:01:01.547 回答