首先来说下编译的最大感受:一定要早上编译啊,这个截图是下午的。早上的速度很快的。
-
搭建编译环境。编译建议在Linux下进行。我的系统是Linux mint 17,执行以下命令,编译环境:
sudo apt-get update
sudo apt-get install git-core build-essential gcc g++ binutils patch bzip2 flex bison make autoconf gettext texinfo unzip sharutils subversion libncurses5-dev ncurses-term zlib1g-dev gawk asciidoc libz-dev libssl-dev
-
获取openwrt源码。在当前用户主目录下执行
git clone git://git.openwrt.org/openwrt.git
等待代码下载。结束后,目录下会出现openwrt文件夹。
-
配置软件源。进入openwrt目录,执行
./scripts/feeds update -a
./scripts/feeds install -a
-
检查编译环境是否完整:
make defconfig
make prereq
根据提示信息安装需要的。如果提示类似
“tmp/.config-package.in:22022:warning: multi-line strings not supported”
的信息,打开 openwrt/tmp/.config-package.in,定位到对应行,添上丢掉的一个引号就可以了。
-
编译选项:
执行 make menuconfig,根据情况,选择 Target System 和 Sub。如意云一代和极壹S的 Target System 均为 Ralink RT288x/RT3xxx 。对于Subtarget ,前者为 MT7620n based boards ,后者为 MT7620a based boards。
其他选项根据个人喜好选择。一般来说要选中LuCI界面,选中中文语言包等等。
-
开始编译:
执行 make -j2 V=s 进行编译。-j后面的数字是电脑物理CPU数量加一。V=s可以显示出编译的详细信息。首次编译大概需要几个小时的时间。
-
错误排查:
编译失败,一般有两种情况:
1.代码下载链接失效。首次编译时,编译程序会实时从网上下载一些软件包的代码。如果下载链接失效,编译就会失败。这时需要根据软件包的名称,从网上自行下载,然后放在 openwrt/dl/ 目录下,执行 make -j2 V=s 继续编译即可。
2.软件包自身有问题。这时重新执行 make menuconfig ,取消对应软件包选中即可。这种情况比较少见,目前已知的有 tor 等。
编译成功,但没有生成固件。这种情况一般是因为选中的过多,导致固件大小超过16MB。重新执行 make menuconfig,去掉一些软件包,重新执行编译即可。
-
得到固件。在排除了所有错误后,现在终于得到了固件。对于如意云RY-1,固件在 openwrt/bin/ramips 目录下,形如
openwrt-ramips-mt7620n-rt-n14u-squashfs-sysupgrade.bin
openwrt-ramips-mt7620n-wrtnode-squashfs-sysupgrade.bin
openwrt-ramips-mt7620n-mlw221-squashfs-sysupgrade.bin
openwrt-ramips-mt7620n-wr8305rt-squashfs-sysupgrade.bin
等等。
错误汇总:
错误1:
- root@i-Ubuntu:~/OpenWrt/openwrt# ./scripts/feeds update -a
- Updating feed 'packages' from '' ...
- Already up-to-date.
- Create index file './feeds/packages.index'
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- xargs: grep: terminated by signal 13
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- Updating feed 'luci' '' ...
- Already up-to-date.
- Create index file './feeds/luci.index'
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- Updating feed 'routing' from '' ...
- Already up-to-date.
- Create index file './feeds/routing.index'
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: 21: function asort never defined
- Updating feed 'telephony' '' ...
- Already up-to-date.
- Create index file './feeds/telephony.index'
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- Updating feed 'management' from '' ...
- Already up-to-date.
- Create index file './feeds/management.index'
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- Updating feed 's' '' ...
- Already up-to-date.
- Create index file './feeds/s.index'
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: line 21: function asort never defined
- awk: include/scan.awk: 21: function asort never defined
解决办法:
- sudo apt-get install gawk
安装完gawk之后正常。