am335x system upgrade rootfs for dhcpcd cross compile(十三)

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

原文地址:https://www.cnblogs.com/lianghong881018/p/10129682.html

时间: 2024-10-11 20:22:31

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

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

1      Scope of Document This document describes am335x cpufreq technology insider. 2      Requiremen 2.1     Function Requirement How to get current cpufreq, and to change cpufreq. Learning Processor Clocking Control(PPC) Interface Specification, le

am335x system upgrade usb wifi rtl8188eus(十九)

1      Scope of Document This document describes how to port rtl8188eus driver to linux 4.14.y design. 2      Requiremen 2.1     Function Requirement Suport usb wifi rtl8188eus working in sta mode under linux 4.14.y kernel version 2.2     Performance

cross compile vlc 播放器

上一篇文章介绍了如何交叉编译 FFmpeg ,继续介绍  VLC播放器  交叉编译 . 首先下载 vlc 源码  我用的是 2.2.6  地址 : http://mirrors.neusoft.edu.cn/videolan/vlc/2.2.6/vlc-2.2.6.tar.xz  解压,进入目录. 然后  设置 ffmpeg路径  ,上一章把ffmpeg 装在了   --prefix=/exports/rfs/usr   对应得在 交叉工具 脚本 中添加 export PKG_CONFIG_PA

Cross compile perl

Alex Suykov had do some work for this purpose, and my compile script is based on her patch. Steps Step 1: Download perl source code from perl's official site, such as: wget http://www.cpan.org/src/5.0/perl-5.20.2.tar.gz Step 2: Download the correspon

static cross compile gtk-2.16.6+gtk-directfb+arm-linux (arm-linux-gcc-3.4.4+glib-2.3.5)

----------------------------------------------------------------------- In Ubuntu 10.4 Desktop and "root" login apt-get install build-essential libncurses5-dev apt-get install autoconf apt-get install libtool apt-get install gettext apt-get inst

cross compile the libusb and examples

[Author: Bo Shen <[email protected]>] Assume you have the cross toolchain installed on your Linux host, here I use ubuntu 12.04 with arm-linux-gnueabihf-gcc installed. (if not, here is the command) --->8--- For the SoC support hard float point $

kali set proxy and system upgrade

1. pip install shadowsocks sslocal -c /etc/shadowsock/shadowsocks.json -d start error: AttributeError: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup 用vim打开文件:vim /usr/local/lib/python2.7/dist-packages/shadowsock

build-qt.sh(Cross compile in Linux for Windows)

#!/bin/bash set -e MINGW=${MINGW:-${ARCH:-x86_64}-w64-mingw32} PREFIX=${PREFIX:-usr} WORKSPACE=${WORKSPACE:-$(pwd)} TARGET=${TARGET:-${WORKSPACE}} WINREQ=${WINREQ:-${TARGET}/${PREFIX}} BUILD_NUMBER=${BUILD_NUMBER:-0} ARCH=${ARCH:-${MINGW%%-*}} BINDIR

[cross compile]cygwin和mingw

Unix下编译通过的C代码,在win32下编译是不能通过的 ,当然Unix 和win32的API都是符合标准C,也就是说,大多数函数调用在unix和win32下是相同的.但是,unix有自己一些独特的API(如fork,spawn,signals,select,sockets等),如果代码中使用了这些API,在win32下当然找不到对应的库.    但是,这些API的功能在win32中也能实现,也许你已经发现了一个能让window编译Unix风格代码的方法:    1.修改编译器,让window