本人是隻菜鳥,沒有接觸過OpenWrt,只是平時都是在Linux下作開發。習慣了Linux的開發環境。linux
本人的操做系統是CentOS 6.4(很久都沒有換過了)。本人按照網上牛人們的指點也開始下載編譯OpenWRT。git
以下爲網上的資料:github
sudo apt-get update (更新)
安裝編譯須要的組件:
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install binutils
sudo apt-get install patch
sudo apt-get install bzip2
sudo apt-get install flex
sudo apt-get install bison
sudo apt-get install make
sudo apt-get install autoconf
sudo apt-get install gettext
sudo apt-get install texinfo
sudo apt-get install unzip
sudo apt-get install sharutils
sudo apt-get install subversion
sudo apt-get install libncurses5-dev
sudo apt-get install ncurses-term
sudo apt-get install zlib1g-dev
sudo apt-get install gawk
sudo apt-get install asciidoc
sudo apt-get install libz-devshell
編譯環境搭建完成
mkdir openwrt 建立一個openwrt文件夾
cd openwrt 進入openwrt文件夾
svn co svn://svn.openwrt.org/openwrt/branches/backfire 下載官網的源碼
./scripts/feeds update -a 更新軟件包
./scripts/feeds install -a 安裝軟件包
make menuconfig 進入定製界面(裏面能夠選擇芯片的型號,集成的組件等等,根據實際狀況選擇)
defconfig
make V=99 (開始編譯)
剩下的就是等待了,第一次編譯須要的時間相對比較長,這個跟你的電腦配置和網速有關。svn
因爲原做者是用的Ubuntu做爲開發環境,因此在安裝上面的那些依賴工具包時都是用 apt-get 來安排的,在CentOS裏採用 yum。其實都同樣,只要知道依賴哪些包就好了。工具
本人checkout 的OpenWRT源碼庫路徑爲 : svn://svn.openwrt.org/openwrt/trunkflex
其它的都按上面的步驟作。網站
以下是我遇到的幾個問題:
ui
報:es5
$ ./scripts/feeds update -a Updating feed 'packages' from 'https://github.com/openwrt/packages.git' ... Cloning into './feeds/packages'... fatal: Unable to find remote helper for 'https' failed.
多是git倉庫路徑不對,將https替換成git就能夠了。
用 grep 命令搜
$ grep 'https://github.com' feeds/* -R feeds/packages.tmp/location:https://github.com/openwrt/packages.git
那就把這個地方改一下囉。
再試一下。結果仍是老樣子,我想了一下,這個 feeds/packages.tmp/location 極可能是臨時文。改它不會有效果的。
好像 feeds.conf.default 文件裏也找到了。
$ grep 'https://github.com' feeds.conf.default -R src-git packages https://github.com/openwrt/packages.git src-git luci https://github.com/openwrt/luci.git src-git routing https://github.com/openwrt-routing/packages.git src-git telephony https://github.com/openwrt/telephony.git src-git management https://github.com/openwrt-management/packages.git src-git targets https://github.com/openwrt/targets.git
將裏面全部https替換成git。
再試一下,OK了。
後記:其實還有更根本的解決方法,詳見後期的博文《git 錯誤:Unable to find remote helper for 'https'》
我在第一次編譯OpenWRT時,出現以下錯誤提示:
gconvert.c:66:2: error: #error GNU libiconv not in use but included iconv.h is from libiconv
我在網上找解決方案,結果一致地都是說,從新 ./configure 一下:
./configure --enable-iconv=no --with-libiconv=gnu make
可問題的關鍵是:OpenWRT的trunk路徑下沒見有個 configure 呀!
後來,通過仔細推敲,發現是在編glib時沒經過。
$ find -name "gconvert.c" ./build_dir/host/pkg-config-0.28/glib/glib/gconvert.c
那我就直接進到 ./build_dir/host/pkg-config-0.28/glib/ 路徑下,發現該路徑下有 configure 文件。
那我說直接在該路徑下編譯 glib
$ cd build_dir/host/pkg-config-0.28/glib/ ./configure --enable-iconv=no --with-libiconv=gnu make
這樣,glib 就順利經過了編譯。
再回到 OpenWRT的trunk路徑下,繼續 make.
報錯:
mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/dl echo "Checking out files from the git repository..."; mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl && cd /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl && rm -rf libubox-2015-03-22 && [ \! -d libubox-2015-03-22 ] && git clone http://git.openwrt.org/project/libubox.git libubox-2015-03-22 --recursive && (cd libubox-2015-03-22 && git checkout b8d9b382e39823850331edc2a92379173daf1be3 && git submodule update) && echo "Packing checkout..." && rm -rf libubox-2015-03-22/.git && tar czf /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl/libubox-2015-03-22-b8d9b382e39823850331edc2a92379173daf1be3.tar.gz libubox-2015-03-22 && mv /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl/libubox-2015-03-22-b8d9b382e39823850331edc2a92379173daf1be3.tar.gz /home/hevake_lcj/Workspace/OpenWRT/trunk/dl/ && rm -rf libubox-2015-03-22; Checking out files from the git repository... Cloning into 'libubox-2015-03-22'... fatal: Unable to find remote helper for 'http' make[3]: *** [/home/hevake_lcj/Workspace/OpenWRT/trunk/dl/libubox-2015-03-22-b8d9b382e39823850331edc2a92379173daf1be3.tar.gz] Error 128
從第二行看出,是用git clone工程:
git clone http://git.openwrt.org/project/libubox.git
整個第三行是將clone下來的源碼打包tar.gz包。
因而,我訪問了一下:http://git.openwrt.org/project/libubox 果真出現 404頁面。看來還真沒有?
我再訪問了一下:http://git.openwrt.org/ 結果,發現列表裏有這個工程:
進入連接 project/libubox.git:
我本身親自 git clone 一下。
$ cd dl $ mkdir tmp $ cd tmp $ git clone http://git.openwrt.org/project/libubox.git libubox Cloning into 'libubox'... fatal: Unable to find remote helper for 'http'
我在網上找了「fatal: Unable to find remote helper for 'http'」的解決方法。得知將 "http:" 換成 「git:」 便可。
因而,我再次 git clone
$ git clone git://git.openwrt.org/project/libubox.git
結果成功clone了。
而後,手動完成編譯命令過程:
mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl cd /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl rm -rf libubox-2015-03-22 git clone git://git.openwrt.org/project/libubox.git libubox-2015-03-22 echo "Packing checkout..." rm -rf libubox-2015-03-22/.git tar czf libubox-2015-03-22-b8d9b382e39823850331edc2a92379173daf1be3.tar.gz libubox-2015-03-22 mv libubox-2015-03-22-b8d9b382e39823850331edc2a92379173daf1be3.tar.gz ../../dl/ rm -rf libubox-2015-03-22;
而後,回到OpenWRT的trunk路徑下繼續 make.
編譯報錯:
make[3]: Entering directory `/home/hevake_lcj/Workspace/OpenWRT/trunk/package/network/config/netifd' mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/dl echo "Checking out files from the git repository..."; mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl \ && cd /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl \ && rm -rf netifd-2015-03-31 \ && [ \! -d netifd-2015-03-31 ] \ && git clone http://git.openwrt.org/project/netifd.git netifd-2015-03-31 --recursive \ && (cd netifd-2015-03-31 \ && git checkout 3a0f953722698eab6f3f623a1d6ec5a1b7102b77 \ && git submodule update) && echo "Packing checkout..." \ && rm -rf netifd-2015-03-31/.git \ && tar czf /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl/netifd-2015-03-31-3a0f953722698eab6f3f623a1d6ec5a1b7102b77.tar.gz netifd-2015-03-31 \ && mv /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl/netifd-2015-03-31-3a0f953722698eab6f3f623a1d6ec5a1b7102b77.tar.gz /home/hevake_lcj/Workspace/OpenWRT/trunk/dl/ \ && rm -rf netifd-2015-03-31;
找到 package/network/config/netifd/Makefile,打開
將第8行的「http:」替換成"git:",而後再回到OpenWRT目錄再make.
注:後來我還會反覆遇到這個問題。火了!一條命令所有換掉!
$ grep -E "http:.*\.git" `find -name Makefile | xargs` | \ awk -F: '!/.svn/{print $1}' | uniq | xargs \ sed -i 's/http\(:.*\.git\)/git\1/g'
在trunk目錄下,找出Makefile中有"http:xxxxx.git"的文件,並將全部的"http:xxxxx.git"替換成"git:xxxxx.git"
$ grep -E "https:.*\.git" `find -name Makefile | xargs` | \ awk -F: '!/.svn/{print $1}' | uniq | xargs \ sed -i 's/https\(:.*\)\.git/git\1\.git/g'
把 https 也替換成 git
Checking out files from the git repository... Cloning into 'opkg-9c97d5ecd795709c8584e972bfdf3aee3a5b846d'... fatal: Could not read from remote repository.
這時往上看一下,看make到哪兒了
make[3]: Entering directory `/home/hevake_lcj/Workspace/OpenWRT/trunk/package/system/opkg'
原來是 opkg 在 git clone 時多是路徑的問題,失敗了。
我嘗試打開 opkg 路徑下的 Makefile,將
PKG_SOURCE_URL:=http://git.yoctoproject.org/git/opkg
改爲:
PKG_SOURCE_URL:=git://git.yoctoproject.org/git/opkg
結果仍是沒有生效。
我手動搜opkg,找到官網: http://git.yoctoproject.org/cgit/cgit.cgi/opkg/ 打開,看到網頁最下面有:
因而,我改 trunk/package/system/opkg/Makefile 文件,把 PKG_SOURCE_URL改爲:
PKG_SOURCE_URL:=git://git.yoctoproject.org/opkg
繼續 make,經過了!
fatal: Unable to look up git.kernel.org (port 9418) (Temporary failure in name resolution)
我到 git.kernel.org 網站找到了 linux-firmware 的倉庫 https://git.kernel.org/cgit/linux/kernel/git/balbi/linux-firmware.git/
看到最下面的 git 路徑說明:
這與 Makefile 裏指定的不統一。因而將Makefile裏的git路徑改過來
再 make
我如今都總結出經驗來了。
凡是git clone失敗的,若是是http頭的問題,將http替換成git再試。
若是仍是不行,就要檢查一下git的路徑是否是對的。簡單的方法就是到 git 路徑的根節點上去找出源碼倉庫,並獲得其真實有效的git路徑。
並將Makefile中的改過來就OK了。
make[3]: Entering directory `/home/hevake_lcj/Workspace/OpenWRT/trunk/package/kernel/mac80211' mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/dl echo "Checking out files from the git repository..."; mkdir -p /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl \ && cd /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl \ && rm -rf linux-firmware-f404336ba808cbd57547196e13367079a23b822c \ && [ \! -d linux-firmware-f404336ba808cbd57547196e13367079a23b822c ] \ && git clone git://git.kernel.org/pub/scm/linux/kernel/git/balbi/linux-firmware.git linux-firmware-f404336ba808cbd57547196e13367079a23b822c --recursive \ && (cd linux-firmware-f404336ba808cbd57547196e13367079a23b822c \ && git checkout f404336ba808cbd57547196e13367079a23b822c \ && git submodule update) \ && echo "Packing checkout..." \ && rm -rf linux-firmware-f404336ba808cbd57547196e13367079a23b822c/.git \ && tar cjf /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl/linux-firmware-2015-03-20-f404336ba808cbd57547196e13367079a23b822c.tar.bz2 linux-firmware-f404336ba808cbd57547196e13367079a23b822c \ && mv /home/hevake_lcj/Workspace/OpenWRT/trunk/tmp/dl/linux-firmware-2015-03-20-f404336ba808cbd57547196e13367079a23b822c.tar.bz2 /home/hevake_lcj/Workspace/OpenWRT/trunk/dl/ \ && rm -rf linux-firmware-f404336ba808cbd57547196e13367079a23b822c; Checking out files from the git repository... Cloning into 'linux-firmware-f404336ba808cbd57547196e13367079a23b822c'... remote: Counting objects: 2344, done. remote: Compressing objects: 100% (1164/1164), done. remote: Total 2344 (delta 1182), reused 2272 (delta 1145) Receiving objects: 100% (2344/2344), 42.07 MiB | 26 KiB/s, done. Resolving deltas: 100% (1182/1182), done. fatal: reference is not a tree: f404336ba808cbd57547196e13367079a23b822c make[3]: *** [/home/hevake_lcj/Workspace/OpenWRT/trunk/dl/linux-firmware-2015-03-20-f404336ba808cbd57547196e13367079a23b822c.tar.bz2] Error 128 make[3]: Leaving directory `/home/hevake_lcj/Workspace/OpenWRT/trunk/package/kernel/mac80211'
fatal: reference is not a tree: f404....22c,意思好像是說git工程裏沒有 f404...22c 這麼版本。那麼我得檢查一下這個版本號對不對。
在trunk/tmp/dl路徑下下載的linux-firmware尚未刪掉,咱們進入該目錄。並用git log查看一下提交日誌,獲得:
commit b8ac7c7e27dcd13fa3c843aaf62457e9c57ea4db Author: Rasesh Mody <rmody@brocade.com> Date: Tue Sep 10 16:10:54 2013 -0700 linux-firmware: Add Brocade FC/FCOE Adapter firmware files This patch adds firmware files for Brocade HBA and CNA drivers(BFA and BNA). Signed-off-by: Rasesh Mody <rmody@brocade.com> Signed-off-by: Ben Hutchings <ben@decadent.org.uk> commit 8ff6cc3a5e1d9452ae8fb993532afc1f3ab3a71f Merge: 1461bed e7c85b2 Author: Ben Hutchings <ben@decadent.org.uk> Date: Mon Sep 30 04:50:51 2013 +0100 Merge branch 'moxa' of https://github.com/lunn/linux-firmware commit 1461bed1300097efeba59c82ffa30c90cc7e3ae5 Author: Alex Deucher <alexander.deucher@amd.com> Date: Mon Aug 26 10:45:33 2013 -0400 radeon: add ucode for KAVERI GPUs Add new ucode files and update the WHENCE entry. Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Ben Hutchings <ben@decadent.org.uk> commit 66f87a226160b545ac02f3844ea601cbe10a5da2 Author: Alex Deucher <alexander.deucher@amd.com> Date: Mon Aug 26 10:42:44 2013 -0400 radeon: add smc ucode for BONAIRE
在這裏面,沒有搜到 f404336ba808cbd57547196e13367079a23b822c 這個版本號
那,我就將其改爲最新的版本號吧 b8ac7c7e27dcd13fa3c843aaf62457e9c57ea4db,希望沒有問題。
同時,將 trunk/tmp/dl/下的原下載目錄更名(避免反覆下載)、
$ cd tmp/dl $ mv linux-firmware-f404336ba808cbd57547196e13367079a23b822c/ linux-firmware-b8ac7c7e27dcd13fa3c843aaf62457e9c57ea4db
好!咱們再 make 一下。