Centos6下编译lede

Posted Milton

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos6下编译lede相关的知识,希望对你有一定的参考价值。

准备工作

在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:141:$(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 2>&1 | grep GNU, \\
        time --version 2>&1 | grep GNU, \\
        busybox time 2>&1 | 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/20171011.log 2>&1 &

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的主要内容,如果未能解决你的问题,请参考以下文章

如何在CentOS6.5下编译64位的Hadoop2.x

Centos6.5下编译安装mysql 5.6

CentOS6.8下编译安装GCC

CentOS6 x64下编译TiDB

CentOS6.9 下编译安装MySQL5.7.19

Linux(CentOS6.5)下编译安装MySQL Community Server 5.7.12