Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4116567
  • 博文数量: 447
  • 博客积分: 1241
  • 博客等级: 中尉
  • 技术积分: 5786
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-27 06:48
个人简介

读好书,交益友

文章分类

全部博文(447)

文章存档

2023年(6)

2022年(29)

2021年(49)

2020年(16)

2019年(15)

2018年(23)

2017年(67)

2016年(42)

2015年(51)

2014年(57)

2013年(52)

2012年(35)

2011年(5)

分类: 其他平台

2017-03-16 19:52:12

先安装
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启动
阅读(2644) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~