先安装
sudo apt-get install socat
vm虚拟机中添加串口,类型为socket(named pipe)
/tmp/testsocket
vmx配置文件为
serial1.present = "TRUE"
serial1.fileType = "pipe"
serial1.fileName = "/tmp/testsocket"
serial1.tryNoRxLoss = "TRUE
运行虚拟机,判断是tyS0还是ttyS1
研发机 输入 sudo socat -d -d /tmp/testsocket tcp-listen:9999
另一个终端输入
telnet 127.0.0.1 9999
虚拟机中输入
root@OpenWrt:~# echo whatever > /dev/ttyS0
root@OpenWrt:~# echo whatever > /dev/ttyS1
然后 看看telnet 有无数据输出,判断是
tyS0还是ttyS1
因为openwrt的ttyS0已经被console使用了
openwrt内核的编译
make kernel_menuconfig
mount /dev/sda1 /mnt
cd /mnt/boot/grub
/mnt/boot/grub# vi grub.cfg
添加
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 --rtscts=off
terminal_input console serial; terminal_output console serial
set default="1"
set timeout="10"
set root='(hd0,msdos1)'
menuentry "OpenWrt" {
linux /boot/vmlinuz root=PARTUUID=ec015777-02 rootfstype=ext4 rootwait console=tty0 console=ttyS0,115200n8 noinitrd
}
menuentry "OpenWrtgdb" {
linux /boot/vmlinuz root=PARTUUID=ec015777-02 rootfstype=ext4 rootwait console=tty0 noinitrd kgdboc=ttyS1,115200n8 kgdbwait
}
menuentry "OpenWrt (failsafe)" {
linux /boot/vmlinuz failsafe=true root=PARTUUID=ec015777-02 rootfstype=ext4 rootwait console=tty0 console=ttyS0,115200n8 noinitrd
}
然后
reboot
运行
sudo socat -d -d /tmp/testsocket tcp-listen:9999
如果成功的话,我们可以看到类似这样的输出
2017/03/17 16:51:20 socat[17958] N opening connection to AF=1 "/tmp/testsocket"
2017/03/17 16:51:20 socat[17958] N successfully connected from local address AF=1 "\xE5\xDD\xED\x7E"
2017/03/17 16:51:20 socat[17958] N successfully connected via
2017/03/17 16:51:20 socat[17958] N listening on AF=2 0.0.0.0:9999
/vm/openwrt/openwrt/build_dir/target-x86_64_glibc-2.22/linux-x86_64
gdb ./vmlinux
target remote localhost:9999
运行 c
可以看到虚拟机中openwrt启动
阅读(2741) | 评论(0) | 转发(0) |