uclinux下gprs拨号成功--晚风拂柳


我用的是优龙44b0的板子
两个串口,com1接pc,com2接gprs modem
modem是教研室做的,用的西门子的MC35模块

拿到modem先在pc上做测试 pc是rh9的环境
命令行直接输入
#pppd /dev/ttyS0 115200 debug connect "chat -v ’’ ATZ OK
AT+CGDCONT=1,"IP","CMNET" OK ATD*99***1# CONNECT ’’" defaultroute
提示有默认连接之类的话 在网络设置里把eth0关闭
重新拨号成功 这里注意如果不加defaultroute选项,拨号之后要手动指定默认网关

pc测试通过 接下来往板子上试

板子编译内核时选中ppp及slip
user配置里选上pppd和chat
交叉编译通过 把编译好的内核及文件系统烧到板子里
启动进入uclinux
命令行照上面一样输入 报错
munmap of non-mmaped memory by process 21 (pppd): 0c2fcc60
google一斧子之后如下解释:
"munmap of non-mmaped memory by process X (YYY) : ZZZZ"
appears on the console

If you see the above error on the console when running a program or even
during normal operation it means that the program in question is
incorrectly freeing some memory.

The most common cause for this error is either calling free on memory that
has already been freed or with an address that was not returned by malloc,
strdup or similar functions. The program may have tried to free the same
pointer twice or may be freeing an object that was not allocated.

If the program uses mmap/munmap then it is most likely unampping a
different value to that returned by mmap.

Carefully check your programs dynamic memory usage. If that is correct then
look for possible memory corruption.
什么?内存释放出错!晕倒,想这下麻烦大了,看了pppd的代码,发现main.c里面在调
用chat子进程时用的execv(argv[0], argv);下面一行execl("/bin/sh", "sh", "-c",
program, (char *)0);则被宏定义条件关闭了,注释说On uClinux we don’t have a
full shell, just call chatprogram directly 我狂晕!看来是没有指定完整的路径,
子进程调用找不到chat程序,才导致释放内存出错。
在命令行中输入完整的路径
#pppd /dev/ttyS0 115200 debug connect "/usr/bin/chat ’’ ATZ OK
AT+CGDCONT=1,"IP","CMNET" OK ATD*99***1# CONNECT ’’"
不再出错了 窃喜:)

#ifconfig 没有ppp0
#cat /var/log/messages
<46>Jan 1 00:00:02 syslogd started: BusyBox v0.60.5 (2006.05.13-21:44+0000)
&lt;29&gt;Jan 1 00:01:55 pppd[24]: pppd 2.3.8 started by (unknown), uid 0
&lt;150&gt;Jan 1 00:01:57 chat[25]: expect (’’)
&lt;150&gt;Jan 1 00:02:42 chat[25]: alarm
&lt;150&gt;Jan 1 00:02:42 chat[25]: Failed
&lt;27&gt;Jan 1 00:02:42 pppd[24]: Connect script failed
&lt;30&gt;Jan 1 00:02:43 pppd[24]: Exit.
貌似chat读取参数不对 到水母上问了一圈
有人建议用配置文件的不要用命令行参数
于是在/etc下配置了ppp目录,添了options和chat脚本cm.chat
options内容如下:
/dev/ttyS1
115200
lock
modem
defaultroute
noauth
nocrtscts
cm.chat内容如下:
’’ ATZ OK
AT+CGDCONT=1,"IP","CMNET" OK
ATD*99***1# CONNECT ’’

再试一斧子
#pppd call cm
# cat /var/log/messages
&lt;46&gt;Jan 1 00:00:02 syslogd started: BusyBox v0.60.5 (2006.05.15-05:23+0000)
&lt;29&gt;Jan 1 00:00:17 pppd[23]: pppd 2.3.8 started by (unknown), uid 0
&lt;150&gt;Jan 1 00:00:18 chat[24]: send (ATZ^M)
&lt;150&gt;Jan 1 00:00:18 chat[24]: expect (OK)
&lt;150&gt;Jan 1 00:01:03 chat[24]: alarm
&lt;150&gt;Jan 1 00:01:03 chat[24]: Failed
&lt;27&gt;Jan 1 00:01:03 pppd[23]: Connect script failed
&lt;30&gt;Jan 1 00:01:04 pppd[23]: Exit.
modem没有回应,把com2接到另一台pc上,执行如上命令,能收到ATZ
看来com2肯定发送命令了,modem可能没有收到,这时我们的bcbc和zhaozhendong大虾出
马了,多番讨论查证终于发现问题所在:
44b0的串口连接管脚2是Tx,3是Rx,modem的串口管脚2也是Tx,3是Rx,所以pc上测试用
的直连线在44b0和modem之间连接是不能通信的,必须用交叉线,找换一根交叉线,再试
终于拨号成功
&lt;29&gt;Jan 1 00:02:26 pppd[35]: pppd 2.3.8 started by (unknown), uid 0
&lt;150&gt;Jan 1 00:02:27 chat[36]: send (ATZ^M)
&lt;150&gt;Jan 1 00:02:27 chat[36]: expect (OK)
&lt;150&gt;Jan 1 00:02:27 chat[36]: ATZ^M^M
&lt;150&gt;Jan 1 00:02:27 chat[36]: OK
&lt;150&gt;Jan 1 00:02:27 chat[36]: -- got it
&lt;150&gt;Jan 1 00:02:27 chat[36]: send (AT+CGDCONT=1,"IP","CMNET"^M)
&lt;150&gt;Jan 1 00:02:28 chat[36]: expect (OK)
&lt;150&gt;Jan 1 00:02:28 chat[36]: ^M
&lt;150&gt;Jan 1 00:02:28 chat[36]: AT+CGDCONT=1,"IP","CMNET"^M^M
&lt;150&gt;Jan 1 00:02:28 chat[36]: OK
&lt;150&gt;Jan 1 00:02:28 chat[36]: -- got it
&lt;150&gt;Jan 1 00:02:28 chat[36]: send (ATD*99***1#^M)
&lt;150&gt;Jan 1 00:02:28 chat[36]: expect (CONNECT)
&lt;150&gt;Jan 1 00:02:28 chat[36]: ^M
&lt;150&gt;Jan 1 00:02:32 chat[36]: ATD*99***1#^M^M
&lt;150&gt;Jan 1 00:02:32 chat[36]: CONNECT
&lt;150&gt;Jan 1 00:02:32 chat[36]: -- got it
&lt;150&gt;Jan 1 00:02:32 chat[36]: send (^M)
&lt;30&gt;Jan 1 00:02:32 pppd[35]: Serial connection established.
&lt;30&gt;Jan 1 00:02:32 pppd[35]: Using interface ppp0
&lt;29&gt;Jan 1 00:02:32 pppd[35]: pppd create pidfile
&lt;29&gt;Jan 1 00:02:32 pppd[35]: Connect: ppp0 &lt;--&gt; /dev/ttyS1
&lt;28&gt;Jan 1 00:02:33 pppd[35]: Will not do PAP for user
&lt;28&gt;Jan 1 00:02:33 pppd[35]: Will not do CHAP for user
&lt;29&gt;Jan 1 00:02:38 pppd[35]: local IP address 10.142.62.106
&lt;29&gt;Jan 1 00:02:38 pppd[35]: remote IP address 192.168.254.254

 

本文转自
http://www.mcublog.com/blog/blog2007/aolilyf/archives/2008/26673.html
标签词:
Jan chat BusyBox malloc ifconfig zhaozhendong 命令行参数 bcbc pppd execl

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值