編譯NETGEARwndr4300v2原廠代碼小記

1。下載源碼,百度得,https://kb.netgear.com/2649/NETGEAR-Open-Source-Code-for-Programmers-GPL,ctrl+f搜索wndr4300v2,下載的是1.0.0.32版本。

2。編譯環境用的是CENTOS 7 x64 minimal,不需要圖形界面。硬件環境是win10 x64+virtualbox。vbox裝了增強工具,把win10的一個盤符直接掛在了home/user目錄下,會自動掛載。

初始編譯工具是可能編譯完成openwrt cc的,編譯石像鬼1.9.2也能成功。

根據內核版本2.6.31看出使用的是openwrt aa,查看openwrt 在github的代碼文件include/kernel-version.mk ,aa換了多個內核版本從2.6.30.10到3.3.8大版本都換了多個,bb是3.10.49,cc是3.18.45

3。按照源碼包裏的說明操作:

===============================
 WNDR4300v2 Build Instructions
===============================
Note:(注:這裏說明了編譯環境,和我的不同,所以坑很多)
* This package has been built successfully on Ubuntu 10.04.3 (Server) with gcc 4.1.3.
* Compiling this package on platforms other than Ubuntu 10.04.3 may have unexpected results.
 Build code
============
1. uncompress source code file WNDR4300v2-V1.0.0.32_gpl_src.zip.
unzip WNDR4300v2-V1.0.0.32_gpl_src.zip
bzip2 -d WNDR4300v2-V1.0.0.32_gpl_src.tar.gz.bz2
tar -zxf WNDR4300v2-V1.0.0.32_gpl_src.tar.gz

bzip2 -d toolchain.tar.gz.bz2
tar -zxf toolchain.tar.gz -C WNDR4300v2-V1.0.0.32_gpl_src
2. run following commands to build toolchain and firmware.

1) build toochain only.
cd WNDR4300v2-V1.0.0.32_gpl_src
cp configs/defconfig-wndr4300v2 .config
GIT_HOME=`pwd`/git_home make prepare V=99

2) build toolchain and firmware, if toolchain has built and no update, these commands
   will only build firmware and not re-build toolchain.
cd WNDR4300v2-V1.0.0.32_gpl_src
cp configs/defconfig-wndr4300v2 .config
GIT_HOME=`pwd`/git_home make V=99

3. the final image is "bin/WNDR4300v2-V1.0.0.32.img".

User may upgrade to this image using the WNDR4300v2 GUI "Router Upgrade" page.


4。根據說明開始,編譯工具鏈GIT_HOME=`pwd`/git_home make prepare V=99就出錯了。

剛開始就報錯了

make: *** lxdialog: No such file or directory.  Stop.
make[3]: *** [lxdialog/lxdialog] Error 2
make[2]: *** [scripts/config/mconf] Error 2
make[2]: Leaving directory `/root/wndr43000v2/WNDR4300v2-V1.0.0.32_gpl_src'
make[1]: *** [.config] Error 2
make: *** [prepare] Error 2


看不出來錯誤點,加上-j1參數用單線程編譯,GIT_HOME=`pwd`/git_home make prepare V=99 -j1

make[2]: *** No rule to make target `.config',

沒複製.config文件呢~~~~  cp configs/defconfig-wndr4300v2 .config

另外make menuconfig走不能,沒有相關生成規則~~~


繼續,又出錯了:

checking the version of /usr/bin/patch... patch
configure: error:
quilt requires at least version 2.4 of GNU patch. You can download a
current version of patch from ftp.gnu.org, or if you already have GNU patch
then you can supply its path with the '--with-patch=' option.

查看patch有沒有,

[root@localhost WNDR4300v2-V1.0.0.32_gpl_src]# patch -v
GNU patch 2.7.1
Copyright (C) 2003, 2009-2012 Free Software Foundation, Inc.
Copyright (C) 1988 Larry Wall

有呢,趕緊問度娘,原來是quilt的configure文件有bug,如下

# Sun's patch, and others, do not work because GNU patch options are used.
{ echo "$as_me:$LINENO: checking the version of $PATCH" >&5
echo $ECHO_N "checking the version of $PATCH... $ECHO_C" >&6; }
if $PATCH --version 2> /dev/null | grep GNU >/dev/null; then
  set -- `$PATCH --version 2> /dev/null`
  patch_version=$2 #此處獲取到的是patch_version=patch,把此行換成test $2 == "patch" && patch_version=$3 || patch_version=$2
  { echo "$as_me:$LINENO: result: $patch_version" >&5
echo "${ECHO_T}$patch_version" >&6; }
  saved_IFS=$IFS; IFS='.'
  set -- $patch_version
  IFS=$saved_IFS
  set -- `echo $1 | $TR -cd 0-9` `echo $2 | $TR -cd 0-9`
  if test 0$1 -lt 2 || test 0$1 -eq 2 -a 0$2 -lt 4 ; then
    patch_version=
  fi
else #不是1.x.x就到了這裏
  { echo "$as_me:$LINENO: result: no GNU patch" >&5
echo "${ECHO_T}no GNU patch" >&6; }
fi
if test -z "$patch_version" ; then #不是1.2.4到這裏
  { { echo "$as_me:$LINENO: error:
$PACKAGE_NAME requires at least version 2.4 of GNU patch. You can download a
current version of patch from ftp.gnu.org, or if you already have GNU patch
then you can supply its path with the '--with-patch=' option.
" >&5
echo "$as_me: error:
$PACKAGE_NAME requires at least version 2.4 of GNU patch. You can download a
current version of patch from ftp.gnu.org, or if you already have GNU patch
then you can supply its path with the '--with-patch=' option.
" >&2;}
   { (exit 1); exit 1; }; }
fi


5。繼續,編譯系統GIT_HOME=`pwd`/git_home make V=99 -j1

錯誤:

make[4]: Entering directory `/root/wndr43000v2/WNDR4300v2-V1.0.0.32_gpl_src/build_dir/target-mips_uClibc-0.9.30.1/dnibusybox-1.4.2'
Makefile:400: *** mixed implicit and normal rules.  Stop.

問度娘,說要改文件:

vi dnibusybox-1.4.2/Makefile

         修改前:416行 config %config: scripts_basic outputmakefile FORCE

         修改後:416 行 %config: scripts_basic outputmakefile FORCE
        
         修改前:1449 行 / %/: prepare scripts FORCE

         修改後:1449 行 %/: prepare scripts FORCE


還有兩個錯誤,一個是關於binutils,

把.config文件修改CONFIG_BINUTILS_VERSION_2_19_1=y修改爲2_20_1

還有遇到automake版本高,需要編譯安裝1.11版本,

另外@itemx must follow @item這個錯誤,安裝texinfo解決,

這三個錯誤不能重現了,第二次直接編譯通過了










發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章