找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 43691|回复: 8

自己从源码编译dd-wrt

[复制链接]
发表于 2006-12-22 16:55:03 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
从源码构建DD-WRT不很困难,但是比编译openwrt要难一点。


一、安装系统和依赖的软件包
需要一个linux系统和相关的编译工具,我严重向大家推荐debian和ubuntu,因为它们比较方便。
编译需要的软件包如下:
Automake v1.9.4
GNU Make v?
GCC/G++ v4
ncurses
binutils
tar
bzip2
gzip
g++
patch
flex
bison
make
gettext
unzip
libz-dev
libc headers


安装以上的软件包用以命令:
  1.    sudo apt-get install gcc g++ binutils patch bzip2 flex bison make gettext unzip  zlib1g-dev libc6
复制代码
二、获取DD-WRT的源码

DD-WRT的源码文件结构如下:

src/            source
  router/       packages
  linux/        kernel
opt/            make/control


通过以下命令获取DD-WRT的最新源码:
  1. svn co svn://svn.dd-wrt.com/DD-WRT .
复制代码
这个命令会下载DD-WRT的全部源码到当前目录中,因为它的源码比较大,可能有2G左右,而且到国外的速度比较慢,所以可能需要一天才能下载完。

你需要下载 3.4.6 和4.1.0 版本的mipsl uclibc 工具链,可以从以下地址下载到:
http://www.dd-wrt.com/dd-wrtv2/d ... .debian.sp1.tar.bz2
把文件下载完后,解压到/homte/db90h目录中。

三、编译DD-WRT

要编译DD-WRT你只需要简单的做以下步骤:

0. 执行 ready_ddwrt.sh 和 ready_ddwrt_root.sh (这个脚本在后面).
1. 添加 4.1.0 toolchains 执行文件目录到环境变量中。
   PATH=$PATH:/home/db90h/toolchains/4.1.0-uclibc/bin
2. 进入DD-WRT/opt 目录运行 ./install.sh。或者执行不同的./install_×××,以编译出不同的固件版本.


以下两个在编译前需要执行的脚本文件:

重要提醒:这两个脚本都依赖于你系统中dd-wrt的下载目录和gcc toolchain的解压目录。所以你在运行前都要修改两个脚本中的内容以适合本机的情况,否则不能起到预期的作用。

  1. #!/bin/sh
  2. #
  3. # title: ready_ddwrt.sh
  4. # version: 1.14
  5. # author: Jeremy Collake <jeremy@bitsum.com>
  6. #
  7. # This silly script will prepare a build environment
  8. # for DD-WRT. You must also run ready_ddwrt_root.sh.
  9. #
  10. # RL 11/01/2006: Added line to compile tools/webcomp.c and write4.c
  11. #
  12. MINPARAMS=1
  13. if [ $# -lt "$MINPARAMS" ]
  14.         then
  15.         echo usage:
  16.         echo    ready_ddwrt.sh [ddwrt_base_path]
  17.         echo
  18.         echo i.e.:
  19.         echo    ready_ddwrt.sh /home/db90h/DD-WRT
  20.         echo
  21.         exit 1
  22. fi  

  23. ME=`whoami`
  24. DDROOT=$1

  25. echo I am $ME
  26. echo DD-WRT is at $DDROOT

  27. echo ................................................................
  28. echo creating some symlinks
  29. echo ................................................................
  30. rm $DDROOT/src/linux/brcm/linux.v23/include/asm
  31. ln -s $DDROOT/src/linux/brcm/linux.v23/include/asm-mips $DDROOT/src/linux/brcm/linux.v23/include/asm
  32. # for CFE building
  33. ln -s $DDROOT/src/linux/brcm/linux.v23 $DDROOT/src/linux/linux
  34. echo done

  35. echo ................................................................
  36. echo adjusting some attributes
  37. echo ................................................................
  38. chmod +x $DDROOT/src/router/iptables/extensions/.dccp-test
  39. chmod +x $DDROOT/src/router/iptables/extensions/.layer7-test
  40. echo done

  41. #echo ................................................................
  42. #echo fixing alconf's
  43. #echo ................................................................
  44. #cd src/router/pptpd
  45. #aclocal
  46. #cd ../../..

  47. echo ................................................................
  48. echo "re-building some tools"
  49. echo ................................................................
  50. cd $DDROOT

  51. # make bb_mkdep
  52. cd src/router/busybox/scripts
  53. rm bb_mkdep
  54. make bb_mkdep
  55. cd ../../../..

  56. # make jsformat
  57. cd src/router/tools
  58. rm jsformat
  59. make jsformat
  60. cd ../../..

  61. # make mksquashfs-lzma
  62. cd src/squashfs-tools/
  63. rm mksquashfs-lzma
  64. make
  65. cp mksquashfs-lzma ../linux/brcm/linux.v23/scripts/squashfs
  66. cd ../..

  67. # make strip
  68. cd tools
  69. rm ./strip
  70. gcc strip.c -o ./strip
  71. cd ..

  72. # make write3
  73. cd tools
  74. rm ./write3
  75. gcc write3.c -o ./write3
  76. cd ..

  77. # make write4
  78. cd tools
  79. rm ./write4
  80. gcc write4.c -o ./write4
  81. cd ..

  82. # make webcomp
  83. cd tools
  84. rm ./webcomp
  85. gcc -o webcomp -DUEMF -DWEBS -DLINUX webcomp.c
  86. cd ..
复制代码
第二脚本要以root权限运行。
  1. #!/bin/sh
  2. #
  3. # title: ready_ddwrt_root.sh
  4. # version: 1.1
  5. # author: Jeremy Collake <jeremy@bitsum.com> aka db90h
  6. #
  7. # This silly script will prepare a build environment
  8. # for DD-WRT. You must also run ready_ddwrt.sh.
  9. #
  10. MINPARAMS=2
  11. if [ $# -lt "$MINPARAMS" ]
  12.         then
  13.         echo
  14.         echo This script needs root access.
  15.         echo
  16.         echo usage:
  17.         echo    ready_ddwrt_root.sh [ddwrt_base_path] [3.4.6_toolchain_base_path]
  18.         echo
  19.         echo i.e.:
  20.         echo    ready_ddwrt_root.sh /home/db90h/DD-WRT /home/db90h/3.4.6-ucliblc-0.9.28
  21.         echo
  22.         exit 1
  23. fi  

  24. ME=`whoami`
  25. DDROOT=$1
  26. TCHAIN=$2

  27. echo I am $ME
  28. echo DD-WRT is at $DDROOT
  29. echo mipsl-uclibc-x toolchain is at $TCHAIN

  30. echo ................................................................
  31. echo creating some symlinks
  32. echo ................................................................
  33. # duh, this will already be here
  34. mkdir -p /opt
  35. rm /opt/3.3.6
  36. ln -s $TCHAIN /opt/3.3.6
  37. rm /GruppenLW
  38. ln -s $DDROOT/image /GruppenLW
复制代码
echo All done!



四、更改DD-WRT

进入 /src/router 目录,你会看到 .config* 文件. 使用 'make menuconfig' 编辑配置文件. 可以进入 /src/router/busybox 目录选择要编译的busybox选项。

Change micro configuration: WARNING: Before and after doing this you need to copy and restore the "Internal Options" section of the .config files. These options don't seem to be in #the Config template.


cd DD-WRT/src/router
cp .config .config_micro
make menuconfig
cp .config_micro .config
Change micro Busybox configuration:

cd DD-WRT/src/router/busybox
cp .config .config_micro
make menuconfig
cp .config_micro .config
Change micro kernel configuration:

cd DD-WRT/src/router/busybox
cp .config .config_micro
make menuconfig
cp .config_micro .config



原文链接:http://www.dd-wrt.com/wiki/index.php/Development
routeros
发表于 2006-12-22 23:26:04 | 显示全部楼层
等广告的美刀到了 我也败个玩玩 呵呵!
routeros
回复

使用道具 举报

发表于 2007-4-25 11:18:53 | 显示全部楼层
哈哈!
不错!!
routeros
回复

使用道具 举报

发表于 2008-2-19 20:59:33 | 显示全部楼层

执行ready_ddwrt.sh出错,请看一下是什么固原

root@wedo-desktop:~# sh /media/disk-1/DD-WRT/ready_ddwrt.sh /media/disk-1/DD-WRT
I am root
DD-WRT is at /media/disk-1/DD-WRT
................................................................
creating some symlinks
................................................................
done
................................................................
adjusting some attributes
................................................................
chmod: cannot access `/media/disk-1/DD-WRT/src/router/iptables/extensions/.dccp-test': No such file or directory
chmod: cannot access `/media/disk-1/DD-WRT/src/router/iptables/extensions/.layer7-test': No such file or directory
done
................................................................
re-building some tools
................................................................
rm: cannot remove `bb_mkdep': No such file or directory
make: *** No rule to make target `bb_mkdep'.  Stop.
cc     jsformat.c   -o jsformat
jsformat.c: In function ‘filter’:
jsformat.c:11: warning: incompatible implicit declaration of built-in function ‘malloc’
rm: cannot remove `mksquashfs-lzma': No such file or directory
make -C ./lzma/C/7zip/Compress/LZMA_Lib
make[1]: Entering directory `/media/disk-1/DD-WRT/src/squashfs-tools/lzma/C/7zip/Compress/LZMA_Lib'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/media/disk-1/DD-WRT/src/squashfs-tools/lzma/C/7zip/Compress/LZMA_Lib'
g++ mksquashfs.o read_fs.o sort.o -L./lzma/C/7zip/Compress/LZMA_Lib -llzma -o mksquashfs-lzma
make: g++: Command not found
make: *** [mksquashfs-lzma] Error 127
cp: cannot stat `mksquashfs-lzma': No such file or directory
strip.c: In function ‘main’:
strip.c:14: warning: incompatible implicit declaration of built-in function ‘memset’
strip.c:24: warning: incompatible implicit declaration of built-in function ‘strstr’
strip.c:30: warning: incompatible implicit declaration of built-in function ‘strlen’
strip.c:79: warning: incompatible implicit declaration of built-in function ‘memcpy’
strip.c:87: warning: incompatible implicit declaration of built-in function ‘strlen’
write4.c: In function ‘filter’:
write4.c:65: warning: incompatible implicit declaration of built-in function ‘strlen’
write4.c:80: warning: incompatible implicit declaration of built-in function ‘memcpy’
webcomp.c: In function ‘compile’:
webcomp.c:142: warning: comparison of distinct pointer types lacks a cast

其实那些提示没的文件或目录的(如红色标出的)源码里本来就没有的呢

[ 本帖最后由 WeDone 于 2008-2-19 23:21 编辑 ]
routeros
回复

使用道具 举报

发表于 2009-5-21 09:24:40 | 显示全部楼层
DDROOT/src/linux/brcm/linux.v23/include/asm

ln -s $DDROOT/src/linux/brcm/linux.v23/include/asm-mips $DDROOT/src/linux/brcm/linux.v23/include/asm

# for CFE building

ln -s $DDROOT/src/linux/brcm/linux.v23 $DDROOT/src/linux/linux

echo done



echo ................................................................

echo adjusting some attributes

echo ................................................................

chmod +x $DDROOT/src/router/iptables/extensions/
routeros
回复

使用道具 举报

发表于 2009-11-18 01:24:45 | 显示全部楼层
LINUX啊,看到晕
routeros
回复

使用道具 举报

发表于 2010-6-4 18:59:56 | 显示全部楼层
好多步骤,mark,马上就用得上了。
routeros
回复

使用道具 举报

发表于 2011-1-22 00:19:07 | 显示全部楼层
好多步骤,mark,马上就用得上了
routeros
回复

使用道具 举报

发表于 2012-5-29 22:25:10 | 显示全部楼层
非常感谢~~~~~~~~~~~
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-12-22 01:04 , Processed in 0.087474 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表