openwrt源码的编译相对简单,部分编译过程中出现问题可能是由于用的是root用户,现在 winddows10带wrl-ubuntu虚拟机很棒的,我用的是Ubuntu, 默认是没有提供root用户, 如果切换成普通用户下载并编译可能会更顺利一些。
获取openwrt源码
下载openwrt源码 ,注意要用gitee国内站,如用用的github国外站慢的开始怀疑人生。编译时常会出问题,希望一切胜利 , Good luck
$ git clone
https://gitee.com/mirrors/openwrt.git -b <分支版本>
当下载好openwrt源码后,进入openwrt文件夹
$ cd openwrt/
查看openwrt文件夹内容
$ ls
列出文件夹的内容如下
BSDmakefile config Config.in feeds.conf.default include LICENSE Makefile package README rules.mk scripts target toolchain tools
对于上述出现的文件,首先第一步要看的内容就是 README
$ cat README
This is the buildsystem for the OpenWrt Linux distribution.
To build your own firmware you need a Linux, BSD or MacOSX system (casesensitive filesystem required). Cygwin is unsupported because of the lackof a case sensitive file system.
You need gcc, binutils, bzip2, flex, python3.5+, perl, make, find, grep, diff,unzip, gawk, getopt, subversion, libz-dev and libc headers installed.
1. Run "./scripts/feeds update -a" to obtain all the latest package definitionsdefined in feeds.conf / feeds.conf.default
2. Run "./scripts/feeds install -a" to install symlinks for all obtainedpackages into package/feeds/
3. Run "make menuconfig" to select your preferred configuration for thetoolchain, target system & firmware packages.
4. Run "make" to build your firmware. This will download all sources, buildthe cross-compile toolchain and then cross-compile the Linux kernel & allchosen applications for your target system.
Sunshine! Your OpenWrt Community
http://www.openwrt.org
"README" 34L, 1299C 1,1 All
Openwrt开发环境搭建
阅读README内容,openwrt开发环境安装依赖工具链以及库:gcc, binutils, bzip2, flex, python3.5+, perl, make, find, grep, diff,unzip, gawk, getopt, subversion, libz-dev 和 libc
安装库以及工具链(依我的经验多加了一些)
sudo apt-get update
sudo apt-get install git g++ make libncurses5-dev subversion libssl-dev gawk libxml-parser-perl unzip wget python xz-utils vim zlibc zlib1g zlib1g-dev build-essential ccache gettext xsltproc flex patch asciidoc binutils bzip2 bison autoconf sharutils ncurses-term
如果是 64 位操作系统,需要多操作如下步骤:(注意libc6:i386 libncurses5:i386 libstdc++6:i386 中间要加冒号)
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
编译openwrt源码
阅读README,有步骤1.2.3.4.共四步。这四步就是openwrt源码的编译步骤。
如下
1、更新源码包
$ ./scripts/feeds update -a
3、编译配置
$ make menuconfig
可能会出错
Build dependency: Please install the GNU C++ Compiler (g++). //安装 gcc g++ 如果要编译ARM平台 需要arm-linux-gcc
Build dependency: Please install ncurses. (Missing libncurses.so or ncurses.h) //安装ncurese
Build dependency: Please install zlib. (Missing libz.so or zlib.h) //安装zlib
Build dependency: Please install GNU awk. www.2cto.com //
sudo apt-get install gawk 注意名称
Build dependency: Please install flex. //安装flex
Build dependency: Please install patch. //安装pathc
Build dependency: Please install git (git-core). //安装git
Build dependency: Please install the subversion client. //安装subversion client
环境检测通过的话,运行到这步的时候会出现openwrt的配置界面
各种参数即可通过这里设置。
将Target Profile 设置为 可支持硬件板子
Target Profile
1. Multiple devices (TARGET_MULTI_PROFILE) //多种硬件
2. Broadcom SoC, BCM43xx WiFi (b43, brcmfmac, default) (TARGET_bcm53xx_generic_Generic) //博通的Soc
3. ASUS RT-AC56U (TARGET_bcm53xx_generic_DEVICE_asus_rt-ac56u) //华硕主板
4. ASUS RT-AC68U (TARGET_bcm53xx_generic_DEVICE_asus_rt-ac68u)
5. ASUS RT-AC87U (TARGET_bcm53xx_generic_DEVICE_asus_rt-ac87u)
6. ASUS RT-N18U (TARGET_bcm53xx_generic_DEVICE_asus_rt-n18u)
7. Buffalo WXR-1900DHP (TARGET_bcm53xx_generic_DEVICE_buffalo_wxr-1900dhp) //我不认识这个了
8. Buffalo WZR-600DHP2 (TARGET_bcm53xx_generic_DEVICE_buffalo_wzr-600dhp2)
9. Buffalo WZR-900DHP (TARGET_bcm53xx_generic_DEVICE_buffalo_wzr-900dhp)
10. Buffalo WZR-1750DHP (TARGET_bcm53xx_generic_DEVICE_buffalo_wzr-1750dhp)
11. D-Link DIR-885L (TARGET_bcm53xx_generic_DEVICE_dlink_dir-885l) //D-Link DIR-885L路由器
12. Linksys EA6300 v1 (TARGET_bcm53xx_generic_DEVICE_linksys_ea6300-v1) //以下的都不识
13. Linksys EA6500 v2 (TARGET_bcm53xx_generic_DEVICE_linksys_ea6500-v2)
14. Linksys EA9200 v1 (TARGET_bcm53xx_generic_DEVICE_linksys_ea9200)
15. Linksys EA9500 (TARGET_bcm53xx_generic_DEVICE_linksys_ea9500)
16. Luxul ABR-4500 (TARGET_bcm53xx_generic_DEVICE_luxul_abr-4500)
17. Luxul XAP-1610 (TARGET_bcm53xx_generic_DEVICE_luxul_xap-1610)
18. Luxul XBR-4500 (TARGET_bcm53xx_generic_DEVICE_luxul_xbr-4500)
19. Luxul XWR-3150 (TARGET_bcm53xx_generic_DEVICE_luxul_xwr-3150)
20. Meraki MR32 (TARGET_bcm53xx_generic_DEVICE_meraki_mr32)
21. NETGEAR R6250 (TARGET_bcm53xx_generic_DEVICE_netgear_r6250)
22. NETGEAR R6300 v2 (TARGET_bcm53xx_generic_DEVICE_netgear_r6300-v2)
23. NETGEAR R7000 (TARGET_bcm53xx_generic_DEVICE_netgear_r7000)
24. NETGEAR R7900 (TARGET_bcm53xx_generic_DEVICE_netgear_r7900)
25. NETGEAR R8000 (TARGET_bcm53xx_generic_DEVICE_netgear_r8000)
26. NETGEAR R8500 (TARGET_bcm53xx_generic_DEVICE_netgear_r8500)
27. SmartRG SR400ac (TARGET_bcm53xx_generic_DEVICE_smartrg_sr400ac)
28. PHICOMM K3 (TARGET_bcm53xx_generic_DEVICE_phicomm_k3) //小米 PHICOMM K3路由器
29. Tenda AC9 (TARGET_bcm53xx_generic_DEVICE_tenda_ac9) //腾达 AC9路由器
30. TP-Link Archer C5 v2 (TARGET_bcm53xx_generic_DEVICE_tplink_archer-c5-v2) //TP-Link Archer C5 路由器
31. TP-Link Archer C9 v1 (TARGET_bcm53xx_generic_DEVICE_tplink_archer-c9-v1) //TP-Link Archer C9 路由器
市场上路由基本上用OpenWrt做的。
我的开发板是MT7628的选择
MediaTek Ralink MIPS(MTK MIPS)
Subtarget(MT76x8 base boards)
选择Package the OpenWrt-base Toolchain是为了有搭建交叉编译环境方便,不是必选的。
Target System (MediaTek Ralink MIPS) --->
Subtarget (MT76x8 based boards) --->
Target Profile (Jotale JS76x8 16M)
LuCI --->
1. Collections --->
<*> luci................... LuCI interface with Uhttpd as Webserver (default)
此外,勾选LuCI(网页形式的控制台)还是非常必要的。要勾选(前面出现*号):
最后Save,退出。
以上是基本的固件编译,如果需要其他功能,要再勾选或添加。
4、最后 make 编译
$ make -j10
编码出错了,
package/utils/busybox/Makefile' has a dependency on 'libpam', which does not exist
不写了,解决问题后,下回写吧
(编译出错是正常的,后面会相关总结,每次编译出错,我都会记录下来)
编译好了,找个设备试试吧!