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. warning: LF will be replaced by CRLF in application.yml. The file will have its origina解决方法

    环境: windows提交时报错如图所示: 原因是存在符号转义问题 windows中的换行符为 CRLF, 而在linux下的换行符为LF,所以在执行add . 时出现提示,解决办法: git con ...

  2. Logrotate滚动openresty日志

    一.摘要 Linux服务器上我们用Logrotate来分割归档日志文件,结合crond我们可以指定每天在某个时间自动整理日志等文档.本文主要说明了Centos下Logrotate的使用和配置的方法. ...

  3. FastDFS安装指南

    FastDFS安装指南 提前准备好的文件资料: 1.FastDFS--tracker安装 1.1 FastDFS安装环境 FastDFS是C语言开发,建议在linux上运行,本教程使用Centos7. ...

  4. 论文笔记 XGBoost: A Scalable Tree Boosting System

    XGBoost是boosting算法的其中一种.Boosting算法的思想是将许多弱分类器集成在一起形成一个强分类器,其更关注与降低基模型的偏差.XGBoost是一种提升树模型(Gradient bo ...

  5. sql 数据库实时增量更新

    ---一下sql可以添加到作业中每秒执行一次   数据过多会消耗性能 --数据表如下,其中字段pid mid time price_type是一个组合主键--pid mid time price pr ...

  6. Mongodb 学习笔记(三) .net core SDK

    首先添加 Nuget包  MongoDB.Driver 创建一个Model. public class Student { public ObjectId _id { get; set; } publ ...

  7. 【面试突击】- SpringMVC那些事(一)

    1.什么是Spring MVC ?简单介绍下你对springMVC的理解? Spring MVC是一个基于MVC架构的用来简化web应用程序开发的应用开发框架,它是Spring的一个模块,无需中间整合 ...

  8. tkinter 按钮响应函数传值

    tkinter 中的Button组件的响应函数如何传入参数,可能非常困扰新手,这里记录一下. 步骤: 1. 写好响应函数(形参设置好) 2. 在Button command 设置形式:command ...

  9. javascript_18-Array 数组

    数组 数组-引用类型,JavaScript中的内置对象 Array对象的属性 length 获取数组的长度(元素个数) 检测数组 instanceof Array.isArray() //h5新增 常 ...

  10. keil5工程移植到IAR工程

    keil5工程移植到IAR工程 一. 软件版本 MDK-ARM Professional  Version: 5.14.0.0 IAR 8.1 移植工程:基于正点原子开发板建立的STM32F407ZG ...