在Centos7上交叉编译生成OpenWrt固件

安装ss-*

获取最新的ss, 当前是

wget https://github.com/shadowsocks/shadowsocks-libev/archive/v2.5.6.tar.gz

解压后 ./configure, make, make install

设置代理

[root@u02 ~]# more /etc/shadowsocks-local.json
{
"server": "milton.somewhere.com",
,
"local_address":"127.0.0.1",
,
"password": "foobar",
,
"method": "aes-256-cfb"
}

启动本地代理

/usr/local/bin/ss-local -c /etc/shadowsocks-local.json -b 

如果要在后台启动

nohup /usr/local/bin/ss-local -c /etc/shadowsocks-local.json -b 0.0.0.0 -l 1080 > /dev/null 2>&1 &

# 检查是否成功启动
netstat -lnp|

# 加入开机自启动
echo " nohup ss-local -c /etc/shadowsocks/config.json /dev/null 2>&1 &" /etc/rc.local

# 查看后台进程
ps aux |grep ss-local

配置为git的代理

git config --global http.proxy 'socks5://127.0.0.1:1080'orgit config --local http.proxy 'socks5://127.0.0.1:18001' #这个无效, 必须用global
# 检查是否生效
git config --list

Git导出代码

# The development branch (trunk) contains everything from documentation to experimental patches.
git clone git://github.com/openwrt/openwrt.git

# 15.05 branch (Chaos Calmer)
git clone -b chaos_calmer git://github.com/openwrt/openwrt.git

# 14.07 branch (Barrier Breaker)
git clone -b barrier_breaker git://github.com/openwrt/openwrt.git

# 更新代码
git pull

(可选)下载并安装所有可用的"feeds"

cd openwrt
./scripts/feeds update -a# 中间会出很多warning, 不用管它
./scripts/feeds install -a

让OpenWrt构建系统检查缺失的package, 这里你需要选择编译的配置和目标

make menuconfig (most likely you would like to use this)
make defconfig

在make menuconfig中, 对已经选择好的配置, 最好通过save, 保存成单独的config, 否则, 在选择新的芯片类型的时候, 选择的信息就全被重置了

编译

make defconfig
sudo yum install zlib-static patch subversion
make defconfigmake menuconfig
make V=smake V=99 TARGET_DEVICES=y1

如果需要后台运行可以通过

nohup .log >& &

Proceed with build (i.e. cross-compile the downloaded sources to binaries)
\\After the cross-compilation process the trunk-directory contained over 240000 files with a total size of above 3GiB!

编译结果

编译成功后, 生成的文件可以在 <buildroot_dir>/bin 目录找到. The compiled files are additionally classified by the target platform, so e.g. a firmware built for an ar71xx device will be located in <buildroot_dir>/bin/ar71xx directory.
E.g. if your <buildroot_dir> is ~/openwrt/trunk, the binaries are in ~/openwrt/trunk/bin/ar71xx.

注: 构建中需要的库

yum install openssl-devel ncurses-devel
yum install zlib-static patch subversion

清理工作目录

# 只清理 /bin 和 /build_dir
make clean
# 只清理 /bin , /build_dir , /staging_dir , /toolchain 和 /logs
make dirclean
# 清理所有, 包括下载的feeds contents 和 package sources, 以及清除编译配置文件
make distclean

增加对新设备支持需要修改的文件

以下以MTK(ralink)芯片系列的路由为例

1. 在 target/linux/ramips/image/ 目录下能看到对应的mt7***.mk和rt****.mk文件, 这些文件会被同一目录的Makefile所引用, 需要在对应的芯片型号mk文件中添加新设备的信息, 如下, 其中DEVICE_PACKAGES是此型号默认需要安装的package

define Device/pbr-m1
  DTS := PBR-M1
  IMAGE_SIZE := $(ralink_default_fw_size_16M)
  DEVICE_TITLE := PBR-M1
  DEVICE_PACKAGES := kmod-usb3 kmod-ledtrig-usbdev kmod-ata-core kmod-ata-ahci \
        kmod-rtc-pcf8563 kmod-i2c-mt7621
endef
TARGET_DEVICES += pbr-m1

2. target/linux/ramips/base-files/etc/board.d/目录下的 01_leds 和 02_network 是用来设置设备的led灯和网口定义的

3. target/linux/ramips/base-files/lib/ramips.sh

4. target/linux/ramips/base-files/lib/upgrade/platform.sh

5. 在 target/linux/ramips/dts/ 目录下新增对应的dts或dtsi文件

Update 2017-01-19

如果编译过程中出现 config.status: error: cannot find input file: `po/Makefile.in.in' 错误, 需要安装glib2-devel

Update 2017-01-21

如果中途有下载失败的文件包, 可以手动下载后, 上传到dl目录, 再继续进行编译

交叉编译OpenWrt 定制固件的更多相关文章

  1. 使用 OpenWrt Image Generator 为 WR703N 路由器定制固件

    标题:使用 OpenWrt Image Generator 为 WR703N 路由器定制固件 之前试着自己编译固件,编译是成功了,但是在后期安装官方仓库的ipk时出现问题,因为自己编译的固件和官方固件 ...

  2. openwrt MT7620 固件编译记录

    下载,安装相关软件 git clone git@github.com:openwrt-mirror/openwrt.git sudo apt-get install gcc g++ binutils ...

  3. openwrt定制管理

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/qianguozheng/article/details/24673097 近期这个比較火,可是改了东 ...

  4. openwrt(三) 固件的烧录

    导航: 方法1: tftp: 方法2: 在线升级 方法3: BIOS烧录 方法1:TFTP 这应该是最万能的一种方法了.TFTP是一种依靠网口传送数据的一种通信协议,没错,只是传输数据,并不是烧录,所 ...

  5. openwrt装载固件

    方法1. 确定串口号以后(在设备管理器可以查看) 打开SecureCRT软件,选择串口,设置合适的波特率(我用的115200),然后快速连接, 板子通电启动,在启动的时候会提示按任意键中断,这时按下任 ...

  6. openwrt官方固件怎么中继网络

    关键一点,取消勾

  7. TL-WR703Nv1.7刷写openwrt固件

    TP-LINK TL-WR703N是一个小型的路由器,可以有线转WiFi,3G转WiFi,很多人拿它刷openwrt系统,然后可以在上面各种搞事. V1.7以前 通常刷openwrt的做法是, 下载一 ...

  8. openwrt的sysupgrade和factory固件的区别

    openwrt的固件一般分两种类型:factory原厂固件.sysupgrade固件 factory多了一些验证的东西,用于在原厂固件的基础上进行升级. 普通家用路由一般不是openwrt固件,如果要 ...

  9. OpenWRT介绍

    1. 介绍 OpenWRT是一款第三方路由器固件, 其特别在于开放性, 如它的文件系统可写, 用户可在路由器上安装需要的第三方软件.通过刷入OpenWRT, 我们可以完成如下事情 - DLNA共享 - ...

随机推荐

  1. eclipse 启动不起来(不能创建VM)

    Specifying the Java virtual machine Here is a typical Eclipse command line: eclipse -vm c:\jdk1.4.2\ ...

  2. jdbc连接遭遇RAC设备

    今天进行junit的Case回归测试,功能测试人员告知数据库ip进行了变更,于是 将jdbc连接的url进行了相应的变更如下 jdbcConnection = java.sql.DriverManag ...

  3. Android之MVC——Model通知View去更新(实用)

    下面两段标红加深的代码是重点: import android.app.Activity; import android.os.Bundle; import android.view.View; imp ...

  4. RuntimeError: Working outside of application context.

    flask执行错误: 问题:RuntimeError: Working outside of application context. 方法: from flask import Flask, cur ...

  5. HBase性能优化方法总结(转)

    原文链接:HBase性能优化方法总结(一):表的设计 本文主要是从HBase应用程序设计与开发的角度,总结几种常用的性能优化方法.有关HBase系统配置级别的优化,可参考:淘宝Ken Wu同学的博客. ...

  6. 使用SGD(Stochastic Gradient Descent)进行大规模机器学习

    原贴地址:http://fuliang.iteye.com/blog/1482002  其它参考资料:http://en.wikipedia.org/wiki/Stochastic_gradient_ ...

  7. nginx配置解决vue单页面打包文件大,首次加载慢的问题

    cnpm run build 文件过大,其中主要是vender.js有1.5M,代码部署到服务器,首次访问加载页面时比较慢,耗时6.5s左右,所以需要优化下. 1.Nginx开启gzip 找到ngin ...

  8. IOS之导航控制器

    UINavigationController是用于构建分层应用程序的主要工具,主要采用栈形式来实现视图.任何类型的视图控制器都可放入栈中.在设计导航控制器时需要指定根视图即用户看到的第一个视图.根视图 ...

  9. [置顶] 利用Global.asax的Application_Error实现错误记录,错误日志

    利用Global.asax的Application_Error实现错误记录 错误日志 void Application_Error(object sender, EventArgs e) { // 在 ...

  10. 给 TextBlock 加 ToolTip

    <TextBlock ToolTip="{Binding RelativeSource={RelativeSource Self},Path=Text}" Text=&quo ...