dhcpcd移植

【目的】

移植dhcpcd的目是在AM335X开发板上使用dhcp功能,获取WAN口设备的IP,并且可以通过参数指定其matric,matric值越小,其优先级越高。如设备可以以太网,WIFI,4G上网时,可定制外网功能,以太网优先级最高,WIFI次之,4G优先级最低。

【环境】

1、  Ubuntu 16.04发行版

2、  MC183平台

3、  交叉编译器arm-linux-gnueabihf-gcc-4.7.3

【步骤】

1、下载dhcpcd-6.7.1.tar.gz源码。

2.  交叉编译dhcpcd-6.7.1.tar.gz。

解压dhcpcd-6.7.1.tar.gz

tar zvxf  dhcpcd-6.7.1.tar.gz

cd dhcpcd-6.7.1

配置:

./configure --libexecdir=/lib/dhcpcd --dbdir=/var/lib/dhcpcd

编译:

make CC=arm-linux-gnueabihf-gcc

报如下错误:

arm-linux-gnueabihf-gcc  -o dhcpcd common.o control.o dhcpcd.o duid.o eloop.o if.o if-options.o script.o dhcp-common.o dhcpcd-embedded.o if-linux.o arp.o dhcp.o ipv4.o ipv4ll.o ipv6.o ipv6nd.o dhcp6.o if-linux-wext.o auth.o compat/arc4random.o compat/arc4random_uniform.o compat/closefrom.o compat/strlcpy.o crypt/hmac_md5.o crypt/md5.o crypt/sha256.o

common.o: In function `get_monotonic':

common.c:(.text+0x6a): undefined reference to `clock_gettime'

auth.o: In function `get_next_rdm_monotonic':

auth.c:(.text+0x12): undefined reference to `clock_gettime'

collect2: error: ld returned 1 exit status

Makefile:99: recipe for target 'dhcpcd' failed

make: *** [dhcpcd] Error 1

解决方法:在config.mk当中添加如下语句,重新make,即可编译通过。

LDADD+=-lrt

交叉编译之后,所需要的文件:

dhcpcd可执行文件

dhcpcd-run-hooks  需要给其赋可执行权限

hdcpcd-hooks  dhcpcd运行行,会通过dhcpcd-run-hook,调用dhcpcd-hooks下面的脚本,如生成/etc/resolv.conf等。

如下所示为集成到系统当中的位置。其中resolv.conf.head, resolv.conf.tail为dns服务器的配置:

# cat dynamic-configure-network/etc/resolv.conf.head

nameserver 114.114.114.114

# cat dynamic-configure-network/etc/resolv.conf.tail

nameserver 8.8.8.8

├── bin

│   ├── dhcpcd

├── etc

│   ├── dhcpcd.conf

│   ├── resolv.conf.head

│   ├── resolv.conf.tail

├── lib

│   └── dhcpcd

│       ├── dhcpcd-hooks

│       │   ├── 01-test

│       │   ├── 02-dump

│       │   ├── 10-mtu

│       │   ├── 10-wpa_supplicant

│       │   ├── 15-timezone

│       │   ├── 20-resolv.conf

│       │   ├── 29-lookup-hostname

│       │   ├── 30-hostname

│       │   ├── 50-dhcpcd-compat

│       │   ├── 50-ntp.conf

│       │   ├── 50-ypbind.in

│       │   └── 50-yp.conf

│       └── dhcpcd-run-hooks

3.  测试:

获取以太网口IP地址:

dhcpcd eth0

指定默认路由的metric值

dhcpcd –m 1 eth0

如果网线没有插的话,运行dhcpcd 时,会退出,

通过指定参数-t  0,保证以网未插入时,dhcpcd服务不退出,

这样的支持以太网线的插拔时

dhcpcd –m 1 –t 0 eth0

am335x system upgrade rootfs for dhcpcd cross compile(十三)的更多相关文章

  1. am335x system upgrade rootfs for bridge-utils cross compile (十四)

    bridge-utils移植 [目的] 移植bridge-utils的目是在AM335X开发板上使用bridge功能. [环境] 1.  Ubuntu 16.04发行版 2.  MC183平台 3.  ...

  2. am335x system upgrade rootfs using yocto make rootfs(十二)

    1      Scope of Document This document describes how to make am335x arago rootfs using ycoto project ...

  3. am335x system upgrade rootfs custom service using systemd script(十七)

    1      Scope of Document systemd 是一个 Linux 系统基础组件的集合,提供了一个系统和服务管理器,运行为 PID 1 并负责启动其它程序.功能包括:支持并行化任务: ...

  4. am335x system upgrade set/get current cpufreq(二十一)

    1      Scope of Document This document describes am335x cpufreq technology insider. 2      Requireme ...

  5. am335x system upgrade kernel tf(五)

    1      Scope of Document This document describes TF hardware design 2      Requiremen 2.1     Functi ...

  6. am335x system upgrade uboot nand boot(三)

    在uboot 下初始化nand,一般需要做如下工作: 第一: 配置默认从NAND boot Index: include/configs/am335x_evm.h=================== ...

  7. am335x system upgrade uboot ethernet(二)

    系统可以通过SD卡引道之后,为了之后了调试方便 通过查看网卡的硬件设计 正常来说需要注意的有如下几点: 1) 网口 的接线方式: RMII 2) 网口的PHY地址两张网口,这里我们只需先初始化一张网卡 ...

  8. am335x system upgrade kernel ethernet(四)

    1      Scope of Document This document describes ethernet hardware design and porting KZS8081 to ubo ...

  9. am335x system upgrade kernel ec20 simcom7600ce(十一)

    1      Scope of Document This document describes 4G hardware design, support quectel ec20 4G module/ ...

随机推荐

  1. Mitsubishi (三菱) Fanuc(发那科),CNC,网口数据采集,NC程序下发(其它品牌CNC,哈斯 马扎克 兄弟等,正在开发中)

    1.话不多说,先看效果 三菱CNC Fanuc CNC 2.能采集的数据有如下: 产量,状态,轴负载,坐标,主轴转速,三个倍率(主轴倍率 进给倍率 快速倍率),进给速度,当前加工程序名/程序号,当前程 ...

  2. 【C#】上机实验五

    .设计一个控制台应用程序,定义一个MyPoint类,该类能表示二维平面空间的点,完成点类及运算符重载等相关功能.具体要求如下: ()MyPoint类中定义2个私有字段x和y及相应的构造函数. ()My ...

  3. ADO,net 实体数据模型增、删、改,浅谈

    第一步:建立ADO.net数据模型,一步步操作就行 第二步:画个简单的测试界面 第三步铺代码 using DevComponents.DotNetBar.SuperGrid; using DevCom ...

  4. C# HtmlAgilityPack爬取静态页面

    最近对爬虫很感兴趣,稍微研究了一下,利用HtmlAgilityPack制作了一个十分简单的爬虫,这个简易爬虫只能获取静态页面的Html HtmlAgilityPack简介 HtmlAgilityPac ...

  5. 直线DDA,直线和圆的Bresenham算法

    // DDA.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<Windows.h> #include<g ...

  6. wbSocket

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  7. Process.Start cmd 参数空格问题解决

    Process.Start("cmd.exe", "/c start  \"title\"  \"C:\\Program Files\\a. ...

  8. Python接口自动化基础---cookie绕过登录

    使用fiddler获取登录cookie 对比登录前和登录后的cookis 登录前 登录后: 获得cookie之后,使用cookie访问,就可以获取登录态: import requests url='h ...

  9. Thread-specific data(TSD)线程私有数据

    Thread-specific data(TSD)线程私有数据 http://blog.chinaunix.net/uid-26885237-id-3209913.html linux多线程编程中引入 ...

  10. TweenMax—ScrambleText插件 实现类似电脑破译密码的特效

    首先贴一下TweenMax的中文网:https://www.tweenmax.com.cn/ 首先先展示一下最后的效果,需要的就继续看下去: 那团乱码是会一直变的 那么如何实现上图的效果呢??? 其实 ...