编译NETGEARwndr4300v2原厂代码小记

来源:互联网 发布:c语言 base64 encode 编辑:程序博客网 时间:2024/04/28 11:58

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解决,

这三个错误不能重现了,第二次直接编译通过了










原创粉丝点击