您的位置 首页 IOT

2410开发板上完成DHCP主动获取IP地址

前提:系统已经实现DNS(即使用ping通)。1.在内核中添加以下选项:Networking—>NetworkingsupportNetworkingoptions—>…

条件:体系现已完成DNS(即运用ping 通)。

1.在内核中增加以下选项:
Networking—>

  • Networking support
    Networking options—>
    Packet socket //增加.装备CONFIG_PACKET
    [ * ] IP: DHCP support //增加
    [ * ] Network packet filtering (replaces ipchains)—> //增加,后体面选项可不选,装备CONFIG_NETFILTER
    阐明:若没选 Packet socket, [ * ] Network packet filtering (replaces ipchains)—>选项,在履行udhcpc指令时呈现如下过错:
    ~ # udhcpc
    udhcpc (v0.9.9-pre) started
    udhcpc[208]: udhcpc (v0.9.9-pre) started

    FATAL: couldnt listen on socket, Address family not supported by protocol
    udhcpc[208]: FATAL: couldnt listen on socket, Address family not supported by protocol
    2.Busybox中增加以下选项:
    Networking Utilities—>
    udhcp Server/Client—>
    [] udhcp Server (udhcpd) //在此不作服务端,故不选。生成udhcpd指令

  • udhcp Client (udhcpc) //生成udhcpc指令
    [ ] Lease display utility (dumpleases)
    [ ] Log udhcp messages to syslog (instead of stdout)
    [ ] Compile udhcp with noisy debugging messages
    busybox没编译相应选项,也可从网上下载相应文件,用arm-linux穿插编译得到udhcpd,udhcpc指令copy到usr/sbin下就能够了。
    我从 网上下的udhcp_0.9.8cvs20050303.orig.tar.gz文件
    解压后修正Makefile文件
    在19行增加CROSS_COMPILE=arm-linux-
    注释12行的COMBINED_BINARY=1,不然不生成udhcpc指令。
    3.建相关装备文件
    从busybox的examples/udhcp/下copysimple.script文件到开发板/usr/share/udhcpc/下,偏重命名为default.script,udhcp_0.9.8cvs20050303.orig.tar.gz中也有这样的文件。
    [root@localhost root]# vi usr/share/udhcpc/default.script
    #!/bin/sh

    # udhcpc script edited by Tim Riker

    [ -z “$1” ] && echo “Error: should be called from udhcpc” && exit 1

    RESOLV_CONF=”/etc/resolv.conf”
    [ -n “$broadcast” ] && BROADCAST=”broadcast $broadcast”
    [ -n “$subnet” ] && NETMASK=”netmask $subnet”

    case “$1” in
    deconfig)
    /sbin/ifconfig $interface 0.0.0.0
    ;;

    renew|bound)
    /sbin/ifconfig $interface $ip $BROADCAST $NETMASK

    if [ -n “$router” ] ; then
    echo “deleting routers”
    while route del default gw 0.0.0.0 dev $interface ; do
    :
    done
    for i in $router ; do
    route add default gw $i dev $interface
    done
    fi

    echo -n > $RESOLV_CONF
    [ -n “$domain” ] && echo search $domain >> $RESOLV_CONF
    for i in $dns ; do
    echo adding dns $i
    echo nameserver $i >> $RESOLV_CONF
    done
    ;;
    esac

    exit 0

    4.重启开发板,履行udhcpc就可主动获取IP地址了,以下是履行udhcpc的输出信息:

    ~ # udhcpc
    udhcpc (v0.9.9-pre) started
    udhcpc[228]: udhcpc (v0.9.9-pre) started

    Sending discover…
    udhcpc[228]: Sending discover…

    Sending select for 192.168.1.109…
    udhcpc[228]: Sending select for 192.168.1.109…

    Lease of 192.168.1.109 obtained, lease time 86400
    udhcpc[228]: Lease of 192.168.1.109 obtained, lease time 86400

    deleting routers
    route: SIOC[ADD|DEL]RT: No such process
    adding dns 192.168.0.1
    ~ # ping www.baidu.com
    PING www.a.shifen.com (220.181.38.4): 56 data bytes
    64 bytes from 220.181.38.4: icmp_seq=0 ttl=52 time=1219.0 ms
    [1] + Stopped ping www.baidu.com

    5.如果是双网卡必须用参数指明
    例:udhcpc-ieth1

===============================================
今日在我的2410上搞定摄像头。穿插编译gspca驱动,装备linux2.6.20.3使其支撑V4L,不必挑选linux2.6自带的ZC0301驱动。发现能够搞定,可是2410功能穿插,640*480的VGA输出,摄像头分辨率巨细不能设太大,不然很慢。我设定为176*144.

今日趁便上busybox.net看了看,发现稳定版现已到1.5.1,所以从头把我现在用的1.4.2换成1.5.1。
发现本来ls -l /dev呈现segment fault的BUG消除了!
趁便加上了dhcp client的支撑。看了写材料,办法:

在KERNEL中需要将 Packet socket和IP: DHCP support编译进内核或编译成模块。在编译Busybox时把 Networking Utilities下udhcp Server/Client中的 udhcp Client (udhcpc)选上。
要害点要把examples/udhcp/simple.script 脚本文件做为default.script拷贝到/usr/share/udhcpc/default.script

运转udhcpc
~ # udhcpc
udhcpc (v1.5.1) started
Sending discover…
Sending select for 59.64.134.99…
Sending select for 59.64.134.99…
Sending select for 59.64.134.99…
Lease of 59.64.134.99 obtained, lease time 10800
deleting routers
route: SIOC[ADD|DEL]RT: No such process
adding dns 211.68.71.4
adding dns 211.68.71.5
adding dns 202.106.196.115
adding dns 202.106.0.20

然后能够运用tftp指令下载和上传文件,主机的ip为192.168.1.105,下载自己tftp服务器下的led.ko文件,先在主机上树立tftp服务器,在开发板上输入下面的指令,能够将led.ko文件下载到当时目录下。
#tftp -g -r led.ko 192.168.1.105
tftp运用阐明如下:
Usage: tftp [OPTION]… HOST [PORT]
Transfers a file from/to a tftp server using “octet” mode.
Options:
-l FILE Local FILE
-r FILE Remote FILE
-g Get file
-p Put file
-b SIZE Transfer blocks of SIZE octets

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/yingyong/iot/275721.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部