准备工作

在OpenWrt 18.06.0之后, 需要使用Centos7编译.

1. 安装依赖软件

这是官方文档提供的依赖列表

yum install subversion binutils bzip2 gcc gcc-c++ gawk gettext flex ncurses-devel zlib-devel zlib-static make patch unzip perl-ExtUtils-MakeMaker glibc glibc-devel glibc-static quilt ncurses-libs sed sdcc intltool sharutils bison wget git-core openssl-devel xz

除此以外, 建议加上 glib2-devel

2. 编译升级gcc

Centos6自带的gcc版本只到4.4.7, 不支持c++11, 必须升级. 参考 这篇文章 升级到gcc 6.4.0

3. 导出最新源码

例如在home下的用户目录下, 新建一个lede目录, 然后在此目录下执行, 然后将source目录更名为 source_master

git clone https://git.lede-project.org/source.git

注意: 编译将在此目录下执行, 根据官方文档的要求, 路径中要避免出现空格等特殊字符, 以免编译失败

Update 2018-08-12 LEDE与原OpenWRT合并后, 代码主干URL变成了

git clone https://git.openwrt.org/openwrt/openwrt.git/

切换到tag:

$ git tag
$ git checkout -b v18.06.1 v18.06.1

配置工作

1. 当git代码库有更新时, 更新源码

git pull

2. 更新组件源

# 更新组件源
./scripts/feeds update -a
# 安装所有组件, 安装后, 在make menuconfig中才可以选择
./scripts/feeds install -a
# 安装指定组件
./scripts/feeds install <PACKAGENAME>

Update 2018-08-12: 在编译 v18.06.0 时, 出现了 time checking failed的错误

...
Checking 'wget'... ok.
Checking 'time'... failed.
Checking 'perl'... ok.
...
Build dependency: Please install GNU 'time' or BusyBox 'time' that supports -f

经检查, 检查语句是

$ grep -rnw './' -e 'that supports -f'
./include/prereq-build.mk::$(eval $(call SetupHostCommand,time,Please install GNU 'time' or BusyBox 'time' that supports -f, \
$ more include/prereq-build.mk
$(eval $(call SetupHostCommand,time,Please install GNU 'time' or BusyBox 'time' that supports -f, \
gtime --version >& | grep GNU, \
time --version >& | grep GNU, \
busybox time >& | grep -- '-f FMT'))

而 time 命令是bash shell内建的, 无法更改, 故下载了最新版的gnu time编译安装并ln -s为 gtime 命令, 这样检查就通过了

$ wget https://ftp.gnu.org/gnu/time/time-1.9.tar.gz
$ tar zxvf time-1.9.tar.gz
$ ./configure
$ make
$ sudo make install
$ ln -s /usr/local/bin/time /usr/bin/gtime

3. 设置编译目标设备以及包含的组件, 主要是两个命令

# 重置默认的设备和组件
make defconfig
# 进入配置界面
make menuconfig

使用make menuconfig时, 需要注意的

  • 常用的mt7620/7621芯片所属的target位于 Target System -> MediaTek Ralink MIPS
  • 设置之后, 除了save到.config_[device name]以外, 还需要设置到.config, 否则编译时因为.config没变, 你的设置不会生效

Update 2018-11-23:

在make menuconfig之后在开始编译之前, 现在增加了一个步骤, 在编译前进行下载

# download all dependency source files before final make, enables multi-core compilation);
make download

开始编译

1. 执行编译命令行

make -j2 V=s
# -j2 表示用2核, 根据当前机器配置而定
# V=s 表示显示详细输出

2. 如果需要后台进行, 使用

nohup make -j2 V=s > ~/lede/logs/.log >& &

Updated 2018-08-12: 编译v18.06.0, 会出现"b2a_base64() argument 1 must be string or read-only buffer, not bytearray" 错误, 经google查询发现这是python2.6的一个bug, 在python2.7以后已经修复, 但是在Centos6.8下, 多次尝试包括编译安装python2.7并alias python到python2.7依然无法将默认的python环境改为2.7, 最后放弃Centos6, 重建Centos7虚机进行编译

遇到的问题

1. 编译时因网络问题下载失败

自行下载文件后放到dl目录下

2. 编译transmission时出现 config.status: error: cannot find input file: `po/Makefile.in.in' 错误

这是因为没安装glib2-devel

设备测试

1. 极路由二 HC5761
使用 r5040-f98f83e版本代码编译, 工作正常
  问题: 除了5GHz的wlan. 在目前的kernel 4.9.x 上尚未找到解决办法.

2. 小米路由MINI
使用 r5040-f98f83e版本代码编译, 工作正常

3. NeWiFi D1
使用 r5040-f98f83e版本代码编译, 工作正常
  问题: 不能软重启(即在Luci界面或命令行通过reboot重启), 经查是因为32M flash带来的问题, 可以通过补丁修复, 不过无所谓了...

Update 2018-08-02:

NeWiFi D1不能reboot的原因是其闪存MX25L25635F被系统当成了MX25L25635E来处理, MX25L25635F是支持无状态4字节读写的, 但是MX25L25635E不支持. 因为这两个型号使用的是同样的硬件ID, 所以系统无法区分.

http://lists.infradead.org/pipermail/lede-bugs/2018-April/007687.html : "The Newifi D1 has most likely a MX25L25635**F**. But the MX25L25635E and MX25L25635F share the same "hardware id" 0xc22019, therefore can't be distinguished and are handled as MX25L25635E by the kernel. The MX25L25635F supports stateless 4-byte read and write (you can use SPI_NOR_4B_OPCODES). Where the MX25L25635E does **not** support any stateless 4-byte command."

对应的补丁在 https://forum.lede-project.org/t/newifi-d1-unable-to-reboot/7910/10 . 补丁修改的是 drivers/mtd/spi-nor/spi-nor.c 文件, 对于内核版本为4.14的, 具体的操作是在编译前, 创建一个0101-d1-reboot.patch, 放到 target/linux/ramips/patches-4.14 目录下.

Update 2018-11-23:

把make menuconfig里面勾选的自定义项都记录一下

Base System
-*- block-mount........................... Block device mounting and checking
<*> blockd......................................... Block device automounting Kernel modules
Filesystems
<*> kmod-fs-ext4..................................... EXT4 filesystem support │ │
<*> kmod-fs-msdos................................... MSDOS filesystem support │ │
-*- kmod-fs-nfs................................ NFS filesystem client support │ │
-*- kmod-fs-nfs-common......................... Common NFS filesystem modules │ │
<*> kmod-fs-nfs-v3............................ NFS3 filesystem client support │ │
<*> kmod-fs-nfs-v4............................ NFS4 filesystem client support │ │
<*> kmod-fs-ntfs..................................... NTFS filesystem support │ │
-*- kmod-fs-vfat..................................... VFAT filesystem support │
Native Language Support
<*> kmod-nls-cp936......................... Codepage 936 (Simplified
<*> Other language support
USB Support
<*> kmod-usb-ohci............................... Support for OHCI controllers │ │
-*- kmod-usb-storage..................................... USB Storage support │ │
<*> kmod-usb-storage-extras.................... Extra drivers for usb-storage │ │
<*> kmod-usb-uhci............................... Support for UHCI controllers │ │
<*> kmod-usb2................................... Support for USB2 controllers │ │
<*> kmod-usb3................................... Support for USB3 controllers │ │ Luci
Collections
<*> luci................... LuCI interface with Uhttpd as Webserver (default)
Modules
Translations
<*> Chinese (zh-cn)
<*> English
Applications
<*> luci-app-adblock................................ LuCI support for Adblock
<*> luci-app-aria2.................................... LuCI Support for Aria2
<*> luci-app-samba.................... Network Shares - Samba SMB/CIFS module │ │
<*> luci-app-shsdowsocks-libev............ LuCI Support for shsdowsocks-libev
<*> luci-app-statistics
<*> luci-app-qos
<*> luci-app-transmission...................... LuCI Support for Transmission
<*> luci-app-upnp................. Universal Plug & Play configuration module Network
BitTorrent
<*> transmission-daemon-openssl............. BitTorrent client (with OpenSSL) │ │
<*> transmission-remote-openssl............. BitTorrent client (with OpenSSL) │ │
<*> transmission-web........................ BitTorrent client (webinterface) │ │
File Transfer
<*> aria2....................................... lightweight download utility │ │
Aria2 Configuration ---> │
SSL Library (OpenSSL) ---> │ │
[*] Enable Bittorrent Support (NEW) │ │
[*] Enable JSON-RPC over WebSocket Support (NEW)
<*> vsftpd............................... Fast and secure FTP server (no TLS)
<*> wget............... Non-interactive network downloader (with SSL support)
Web Servers/Proxies
-*- shsdowsocks-libev-config................ shsdowsocks-libev config scripts │ │
<*> shsdowsocks-libev-ss-local.................... shsdowsocks-libev ss-local │ │
-*- shsdowsocks-libev-ss-redir.................... shsdowsocks-libev ss-redir │ │
<*> shsdowsocks-libev-ss-rules.................... shsdowsocks-libev ss-rules │ │
<*> shsdowsocks-libev-ss-server.................. shsdowsocks-libev ss-server │ │
<*> shsdowsocks-libev-ss-tunnel.................. shsdowsocks-libev ss-tunnel │
<*> adblock... Powerful adblock script to block ad/abuse domains by using DNS
<*> iftop............................. display bandwith usage on an interface
<*> ipset....................................... IPset administration utility │ │
<*> ipset-dns................. A lightweight DNS forwarder to populate ipsets │ │
<*> samba36-server................................. Samba 3.6 SMB/CIFS server │ │
(-1) Maximum level of compiled-in debug messages (NEW) Utilities
Disc
<*> fdisk.................................... manipulate disk partition table
<*> gdisk............ GPT aware disk manipulation utility for interactive use
<*> hd-idle..................... Another idle-daemon for attached hard drives
<*> hdparm........................... Hard disk drive configuration utilitity
Filesystem
<*> e2fsprogs
<*> usbutils................................... USB devices listing utilities

如果需要sd/tf card支持, 还需要勾选 Kernel modules - Other modules -> kmod-mmc 、kmod-mmc-over-gpio、kmod-sdhci、kmod-sdhci-7620 最后这个sdhci-7620实测必须勾选, 编译NeWiFi D1的固件时如果不勾选这项, 启动时无内置TF卡的demsg mmc信息, 勾选后的固件就可以正确识别.

Update 2020-02-02 编译迅雷下载宝时, 容易出现Image is too big的警告, 这是因为这个型号没有正确设置image size, 对应文件是 target/linux/ramips/image/mt7621.mk
修改其中的timecloud配置, 增加IMAGE_SIZE一行

define Device/timecloud
DTS := Timecloud
IMAGE_SIZE := $(ralink_default_fw_size_16M)
DEVICE_TITLE := Thunder Timecloud
DEVICE_PACKAGES := kmod-usb3
endef
TARGET_DEVICES += timecloud

  

Centos6下编译LEDE/OpenWrt的更多相关文章

  1. CentOS6下编译安装Python2.7.6方法

    关于在CentOS6下编译安装Python2.7.6的方法非常的多了,小编以前也介绍过相关的文章了,下面一聚教程小编再来为各位介绍一下吧,希望文章能帮助到各位.   CentOS下面Python在升级 ...

  2. CentOS6 下编译安装 MySQL 5.6.26

    CentOS6下通过yum安装的MySQL是5.1版的,比较老,所以就想通过源代码安装高版本的5.6.26. 一:卸载旧版本 使用下面的命令检查是否安装有MySQL Server rpm -qa | ...

  3. Centos6下编译安装gcc6.4.0

    Centos6自带的gcc4.4.7不支持c++11, 于是编译安装最新版的gcc wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz .tar ...

  4. postgreSQL在Centos6下编译安装

    1.准备安装源 下载地址:https://www.postgresql.org/ftp/source/ 下载并解压. 2.软件编译安装 配置.检查安装环境 ./configure --prefix=/ ...

  5. centos6.7下编译安装lnmp

    很多步骤不说明了,请参照本人的centos6.7下编译安装lamp,这次的架构是nginx+php-fpm一台服务器,mysql一台服务器 (1)首先编译安装nginx: 操作命令: yum -y g ...

  6. centos6.7下 编译安装MySQL5.7

    centos6.7下编译安装MySQL5.7 准备工作 #-----依赖包及MySQL和boost安装包----- #yum包安装: shell> yum -y install gcc-c++ ...

  7. 在 Arch 下编译 OpenWRT cmcurl 问题与解决方案

    0 现象 在 Arch 下编译 OpenWRT (15.05) cmcurl 时报错: [ 28%] Linking C executable LIBCURL lib/libcmcurl.a(open ...

  8. Linux(CentOS6.5)下编译安装PHP5.6.22时报错”configure: error: ZLIB extension requires gzgets in zlib”的解决方式(确定已经编译安装Zlib,并已经指定Zlib路径)

    本文地址http://comexchan.cnblogs.com/,作者Comex Chan,尊重知识产权,转载请注明出处,谢谢!   今天在CentOS6.5下编译安装PHP时,一直报错 confi ...

  9. Centos6下Python3的编译安装

    本文转载自 Centos6下Python3的编译安装 系统环境:CentOS 6.8-Minimal 安装Python依赖包: 1 [root@Python src]# yum install zli ...

随机推荐

  1. 【keytool jarsigner工具的使用】Android 使用JDK1.7的工具 进行APK文件的签名,以及keystore文件的使用

    一个android apk的编译过程 请参考: http://www.2cto.com/kf/201312/261475.html 典型的编译过程: aapt( Android Asset Packa ...

  2. [PowerShell Utils] Automatically Change DNS and then Join Domain

    I would like to start a series of blog posts sharing PowerShell scripts to speed up our solution ope ...

  3. 超链接a标签的href与onclick中使用javascript的区别

    onclick中javascript的区别一般没用到都没注意,但出错时才有些郁闷,看文本章解释如下: 以前一直很随意,后来看.net里的linkbutton似乎是用在<a href=" ...

  4. GridViewColumn.CellTemplate

    <GridViewColumn Header="Sig" Width="210"> <GridViewColumn.CellTemplate& ...

  5. Linq-进行Json序列化的过程中出现错误解决办法

    错误截图如下: 这是因为表t_sysuser与表t_sysrole之间存在外键联系导致的 解决办法: 进入到创建的linq to sql类中,右键[属性]-将序列化模式修改为[单向]保存即可

  6. (转)Unity3D 游戏贴图(法线贴图,漫反射贴图,高光贴图)

    原帖网址http://www.u3dpro.com/read.php?tid=207  感谢jdk900网友的辛苦编写 我们都知道,一个三维场景的画面的好坏,百分之四十取决于模型,百分之六十取决于贴图 ...

  7. IDEA实现序列号接口

    idea自动生成serialVersionUID (2013-12-15 08:12:09)转载▼ Setting->Plugins 找到一个叫 GenerateSerialVersionUID ...

  8. ElasticSearch 5.X 搜索并用高亮显示

    public List<WOSearchModel> searchOrder(OrderSearchReqVO request) throws Exception{List<WOSe ...

  9. [Javascript] Check both prop exists and value is valid

    Sometime you need to check one prop exists on the object and value should not be ´null´ or ´undefine ...

  10. [Functional Programming] Create Reusable Functions with Partial Application in JavaScript

    This lesson teaches you how arguments passed to a curried function allow us to store data in closure ...