編譯OpenWRT過程問題解決

yn6e 9年前發布 | 139K 次閱讀 OpenWRT Linux

本人是只菜鳥,沒有接觸過OpenWrt,只是平時都是在Linux下做開發。習慣了Linux的開發環境。

本人的操作系統是CentOS 6.4(好久都沒有換過了)。本人按照網上牛人們的指點也開始下載編譯OpenWRT。

如下為網上的資料:


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-dev

編譯環境搭建完成
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   (開始編譯)
剩下的就是等待了,第一次編譯需要的時間相對比較長,這個跟你的電腦配置和網速有關。



由于原作者是用的Ubuntu作為開發環境,所以在安裝上面的那些依賴工具包時都是用 apt-get 來安排的,在CentOS里采用 yum。其實都一樣,只要知道依賴哪些包就行了。

本人checkout 的OpenWRT源碼庫路徑為 : svn://svn.openwrt.org/openwrt/trunk

其它的都按上面的步驟做。


如下是我遇到的幾個問題:


./scripts/feeds update -a失敗

報:

$ ./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'


gconvert.c libiconv

我在第一次編譯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.


libubox安裝錯誤

報錯:

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/ 結果,發現列表里有這個工程:

編譯OpenWRT過程問題解決

進入鏈接 project/libubox.git:

編譯OpenWRT過程問題解決

我自己親自 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.


fatal: Unable to find remote helper for 'http'

編譯報錯:

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,打開

編譯OpenWRT過程問題解決

將第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


opkg下載失敗

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/ 打開,看到網頁最下面有:

編譯OpenWRT過程問題解決

于是,我改 trunk/package/system/opkg/Makefile 文件,把 PKG_SOURCE_URL改成:

PKG_SOURCE_URL:=git://git.yoctoproject.org/opkg

繼續 make,通過了!


linux-firmware clone失敗

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 路徑說明:

編譯OpenWRT過程問題解決

這與 Makefile 里指定的不統一。于是將Makefile里的git路徑改過來

編譯OpenWRT過程問題解決

再 make

我現在都總結出經驗來了。

凡是git clone失敗的,如果是http頭的問題,將http替換成git再試。

如果還是不行,就要檢查一下git的路徑是不是對的。簡單的方法就是到 git 路徑的根節點上去找出源碼倉庫,并得到其真實有效的git路徑。

并將Makefile中的改過來就OK了。


linux-firmware fatal: reference is not a tree 問題

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</pre>

在這里面,沒有搜到 f404336ba808cbd57547196e13367079a23b822c 這個版本號

那,我就將其改成最新的版本號吧 b8ac7c7e27dcd13fa3c843aaf62457e9c57ea4db,但愿沒有問題。

編譯OpenWRT過程問題解決

同時,將 trunk/tmp/dl/下的原下載目錄改名(避免反復下載)、

$ cd tmp/dl
$ mv linux-firmware-f404336ba808cbd57547196e13367079a23b822c/ linux-firmware-b8ac7c7e27dcd13fa3c843aaf62457e9c57ea4db

好!我們再 make 一下。

 本文由用戶 yn6e 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!