开发

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 11:58, 8 May 2010 (edit)
Glenn (Talk | contribs)
(catchg)
← Previous diff
Current revision (02:03, 18 January 2011) (edit) (undo)
Leangjia (Talk | contribs)
(说明)
 
(44 intermediate revisions not shown.)
Line 1: Line 1:
-Most of the time you don't really need to re-build DD-WRT to make your desired changes. Now, this process has been made easy with the [http://www.bitsum.com/firmware_mod_kit.htm Firmware Modification Kit.] This kit gives the user the ability to make changes to a firmware image without recompiling the firmware sources. It works by extracting the firmware into its component parts, then extracting the squashfs-lzma based file system (other file systems can be supported with tweaks). The user can then make modifications to the extracted file system, then rebuild the firmware image.+{{Languages|Development}}
-Features include:特征:+----
-* add initialization scripts添加初始化脚本+ 
-* install new packages (remember, packages pre-installed are compressed much better)安装新功能包+大多数时候,你并不真的需要从源码来重新编译DD-WRT,以满足您所期望的功能。现在,固件修改工具包让这一进程已变得相当容易。 [http://www.bitsum.com/firmware_mod_kit.htm 固件修改工具包.] 该套件能够使用户无需从源码重新编译固件而修改固件镜像文件的功能变化。它通过其组成部分基于文件系统的支持,提取到固件的squashfs-LZMA的,(其他文件系统可以用)。然后用户可以以提取的文件系统进行修改,然后重新生成固件镜像。
-* extend web UI扩展web用户界面+【leangjia附 Toolchain下载:http://www.macsat.com/forum/index.php?topic=681.msg3699#msg3699 】
-* remove un-needed packages移除不需要的功能包+其特点(特征)包括:
-* mix-and-match packages from various DD-WRT variants+* 添加初始化脚本
-WARNING: Due to abuse by those re-branding DD-WRT and selling it, or pre-flashed routers with it on eBay, builds dated later than 08/04/2006 have some protections against re-branding the web UI.+* 安装新功能包
 +* 扩展web用户界面
 +* 移除不需要的功能包
 +* 来自不同的DD-WRT设备的混合与匹配。(注:固件修改工具包 的特征是可以用于DD-WRT的私生设备??)
 +警告:因为,晚于08/04/2006的版本,有对这个从网页升级的保护,你不要把刷新的设备拿去升级或者去销售(言外之意是:你用web无法升级。他没有明确的说 TFTP 是否可以。--TKS:TeTrAhEdRoN)
=要求= =要求=
-I've worked hard to make sure the requirements are low enough for anyone to use this kit. However, to reduce distribution costs and better represent the multi-platform capabilities of this kit, the binary tools in the kit do automatically build themselves the first time you run one of the scripts. Any machine set up to build anything C or C++ on the machine will probably be ready. The few requirements are all basic items that everyone has easy access to:+===需求===
 +你需要一台Linux机器来编译DD-WRT。它应该工作于安装好了基础开发工具包的机器上。
-# A compatible platform. The following are specifically supported (or specifically unsupported):一个兼容平台,支持(或不支持)以下:+最低资格(TODO:须安装下列库或软件以配置好编译环境):
-## LINUX+
-## OS X +
-## CYGWIN **alpha stage testing (!! built firmwares may not boot !!)**+
-# GNU C (gcc)+
-# GNU C++ (g++)+
-# Standard C runtime library development+
-# Standard C++ runtime library development+
-# GNU make+
-# TAR and GZIP (optional, used by ipkg_install.sh)+
-For OS X, installing the Mac OS X Developer Tools will supply the needed GNU C and C++ compilers and make utility.+* 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
 +* build-essentials
 + 
 +安装上述,命令如下:
 + 
 + sudo apt-get install gcc g++ binutils patch bzip2 flex bison make gettext unzip zlib1g-dev libc6
 + 
 +我竭尽全力降低本套件的使用门槛,以确保任何人均可方便使用本套件。However, to reduce distribution costs and better represent the multi-platform capabilities of this kit, the binary tools in the kit do automatically build themselves the first time you run one of the scripts. 每台机器准备好C或C++库,每台机器的编译固件的环境基础通过本套件来修改DD-WRT固件需要满足下列基础要求(相信每位都容易满足这样的要求的了):
 + 
 +# 一个兼容的平台。下面是具体的支持(或不支持):
 +## LINUX平台
 +## OS X 平台
 +## CYGWIN(注:linux操作系统的一种)平台 **alpha阶段测试(!! 内置固件可能无法启动!!)**
 +# GNU C (gcc库)
 +# GNU C++ (g++库)
 +# 标准C运行时库的开发版
 +# 标准C++运行时库的开发版
 +# GNU make
 +# tar和gzip(可选,由ipkg_install.sh使用)
对于OS X,请安装Mac OS X 开发工具,支持GNU C和 C++编译器并使其能正常使用。 对于OS X,请安装Mac OS X 开发工具,支持GNU C和 C++编译器并使其能正常使用。
=兼容性= =兼容性=
-Any cybertan style firmware image format that uses squashfs-lzma as a root file system should work fine. Firmwares that use regular squashfs or other file systems (i.e. cramfs) will work if the steps that extract the file system and rebuild the file system are tweaked. As is, it is compatible with the following:+固件使用正常的squashfs - LZMA的cybertan结构(linux架构的一种)的固件镜像文件格式。如果将工作的步骤提取文件系统和文件系统的重建小的改动,由于是使用squashfs或其他常规的(即cramfs)文件系统,故它与下面所列相兼容:
{| border=1 cellspacing=0 cellpadding=5 {| border=1 cellspacing=0 cellpadding=5
-| '''Firmware'''+| '''固件名'''
-| '''Notes'''+| '''注意'''
|- |-
| DD-WRT | DD-WRT
Line 41: Line 71:
|- |-
| FreeWrt | FreeWrt
-| untested+| 未测试
|- |-
| Sveasoft Alchemy/Talismen | Sveasoft Alchemy/Talismen
-| untested+| 未测试
|- |-
| HyperWrt | HyperWrt
-| untested+| 未测试
|- |-
|} |}
-I may extend default support to cramfs, regular squashfs, and older squashfs and squashfs-lzma versions if there is sufficient demand. Note that for firmwares that do have an easy to use build system and/or an image builder utility, i.e. OpenWrt, this kit is of less use.+如果有足够的需求,我可以将默认支持cramfs,常规的squashfs,和旧版本的squashfs和squashfs-LZMA的版本。 请注意,对于那些固件有易于使用的编译系统和/或镜像生成器实用程序,即OpenWrt,这个工具包是较少使用。
-=Instructions用法说明=+=用法说明=
-I've written two scripts that simplify the process considerably. Basically, it's a one-step process to extract the firmware, and a one-step process to rebuild the firmware. +我已经写了两个脚本,大大简化了程序。基本上,这是一个提取固件的过程中的步骤和一个重建固件的过程中的步骤。
-==Extracting the firmware 解压固件 (extract_firmware.sh)==+== 解压固件 (extract_firmware.sh)==
-Simply run extract_firmware.sh with the following parameters. You must run this tool from inside the directory it exists in.+只需运行下面的extract_firmware.sh。您必须运行此目录内存在的工具。
<pre> <pre>
$ ./extract_firmware.sh firmware.bin working_directory/ $ ./extract_firmware.sh firmware.bin working_directory/
</pre> </pre>
 +新手须知:上述命令解释:"./extract_firmware.sh"表示执行当前目录下的extract_firmware.sh。加"./",即当前目录,就不必设置path环境变量。
 +; firmware.bin :你想提取的固件的镜像文件, 如, DD-WRT.v23_MICRO_GENERIC.BIN.
 +; working_directory :你要使用的工作目录。这将被用于保存中间文件和提取系统文件。请注意,在工作目录中的文件可能被删除!
-; firmware.bin : the firmware image you want to extract, i.e. DD-WRT.v23_MICRO_GENERIC.BIN. +您提供的固件镜像文件,如,为一WRT54G或华硕WL-500G。这些镜像文件通常都是相同的,只是在头格式有所不同。在重建过程中,将会创建各种型号的镜像。
-; working_directory : the working directory you want to use. This is where the intermediate files and the extracted file system will be stored. Note that files in the working directory may be deleted!+提取的日志将创建为'' extract.log ''<br>
- +
-It doesn't matter which firmware image you supply, i.e. for a WRT54G or an ASUS WL-500G. These images are usually all the same and differ only in the header format. The rebuilding process will create images for the various models.+
- +
-An extraction log is created as ''extract.log''.<br>+
-dsf+
-'''Example:'''+'''举例:'''
<pre> <pre>
-$ ./extract_firmware.sh dd-wrt.v24-11218_NEWD_mega ./mega/+$ ./extract_firmware.sh dd-wrt.v24_mega_generic.bin ./mega/
</pre> </pre>
 +上述命令解释:执行当前目录下的extract_firmware.sh,将7.3MB的固件dd-wrt.v24_mega_generic.bin解到当前mega目录下。
-==Modifying the firmware 修改固件 (manual and/or ipkg_install.sh)==+==修改固件 (manual and/or ipkg_install.sh)==
-Modifying the firmware is simple. The file system is stored in the working directory you supplied to extract_firmware.sh. Here are the subfolders of this directory:+修改固件很简单。该文件系统是存储在您的工作目录提供给extract_firmware.sh。以下是该目录下的子文件夹:
* rootfs/ * rootfs/
-*** This is where the file system is. Make modifications here.+*** 这是该文件系统。在这里进行修改。
* image_parts/ * image_parts/
-*** This is where intermediate files are stored. If you need to replace the kernel (not at all recommended), you can do so by replacing vmlinuz here.+*** 这是中间文件的存储位置。如果您需要更换内核(不是建议更换),您可以通过更改这里的menu.lst。
-One merely changes, adds, or removes files in rootfs/ to make changes to the firmware's file system. After you're done making changes, rebuild the firmware.+一只是改变,增加,或删除的文件在rootfs /向该固件的文件系统的变化。之后你完成更改后,重建固件。
-Installing packages (.IPK)+安装软件包(.IPK)
-Packages are pre-built collections of files pertaining to a set of software. OpenWrt and DD-WRT both use packages, and most are cross-compatible. These packages are stored in a tar/gzip archive of a pre-defined structure that includes some control files. You can extract and copy the files manually, or use the ipkg_install.sh script included with this kit. For a list of some of the available packages (not all may work), see http://ftp.selfnet.de/pub/openwrt/backports/rc5/ .+软件包是有关一套软件文件预先建立的集合。OpenWrt和DD - WRT都使用软件包的形式,而且大多数是相互兼容的。这些软件包都存储在一个tar/gzip格式,其中包括一些控制文件的档案中。你可以手动提取和复制的这些文件或使用这个工具包的ipkg_install.sh脚本。此处列出部分软件包,这里不可能列出所有,详见http://ftp.selfnet.de/pub/openwrt/backports/rc5/
-Example use:+例如使用:
<pre> <pre>
Line 94: Line 124:
</pre> </pre>
-; some_package-1.2.5.ipkg : would be the filename of the package.+; some_package-1.2.5.ipkg : 指软件包的文件名。
-; working_directory : is the same working directory you supplied to the extract_firmware.sh script.+; working_directory :为您提供相同的工作目录到extract_firmware.sh脚本。
 +!注意:若软件包需进行相关配置,则,如何利用WEB来配置此软件包,需要各自想办法。翻译者尝试过,但水平有限。有经验的朋友请到路由站http://2cna.3322.org:88 或leangjia@vip.qq.com分享一下。万分感谢!
-==Re-building the firmware 重新编译固件 (build_firmware.sh) ==+==重新编译固件 (build_firmware.sh) ==
-Rebuilding the firmware is as easy as extracting it. Use the build_firmware.sh script to automate the process. You must run this tool from inside the directory it exists in.+重建固件和提取固件同样容易。 使用build_firmware.sh脚本来自动化进程。您必须运行此目录内的存在有的工具。例如使用:
-Example use:+
<pre> <pre>
Line 105: Line 135:
</pre> </pre>
-; output_directory : the path to which the created firmware images should be stored. If images already exist here, they will be over-written. Firmware images for various models will be emitted (these images are all the same but have different header patterns so they are accepted by the target models).+; output_directory :该路径应储存所创建的固件的镜像文件。如果镜像文件已经存在,则将覆盖。各种型号的排放量(这些镜像文件都是相同的,但有不同的格式头使他们的目标模式是由接受固件镜像文件)。
-; working_directory : the working directory supplied to extract_firmware.sh.+; working_directory : 提供给extract_firmware.sh的工作目录。
-A building log is created as build.log.+编译日志创建为build.log。
-==Building on Fedora 9 using DD-WRT V24 +==在Fedora 9下编译DD-WRT V24==
-在Fedora 9下编译DD-WRT V24==+===获取源代码===
-===Source Retrieval 获取源代码===+我是一名中国在校学生。因为我想从源代码中学习,因此我想得到一份源代码。
- I am a student from china.I want to get the souece , because i want to lenrn from it.+
-===Customization 定制===+===定制===
-===Build the source 编译===+===编译===
-===Checking 检查===+===检查===
-==Building on Debian Unstable using DD-WRT V24 - Work in progress [~matrix]在Debian下编译DD-WRT V24==+==在Debian下编译DD-WRT V24==
-=== Initializing Workspace ===+=== 初始化工作区===
-=== Fill the Workspace with Sources ===+=== 一、修改固件法:===
-=== Customization ===+
-=== Building Sources ===+
-=== Testing ===+
-==Building DD-WRT from Source 从源文件开始编译DD-WRT==+
-Building DD-WRT from source is difficult and according to the text here definitly not working on first try. You will see lots of strange errors and many confusing install-scripts. The forum is full of people who were not able to make this install-procedure running through. The infos in the forum is much newer than these here, but also very confusing and mixed up. +
-Brainslayer does not have the time to do everything. Until the day comes that DD-WRT will build without any extra steps, I've written some scripts that will set up a build environment for DD-WRT. Newer builds of DD-WRT may break compatibility with these scripts. If this happens and I don't update them, ''please'' take the time to update them '''if''' you are sure your changes are appropriate.+2010-05-25 17:09
 +Debian为最新版(lenny)DVD ISO镜像文件,跑在VM绿盟精简版,firmware工具套装,无论是SVN释出的,又或下载的软件包,都试过。
 +按网上教程(搜出来很多篇,但均是转贴同一源贴),进入src目录make,直接提示make 命令未找到,
-===Requirements===+1、安装make:apt-get install make<br>
-To build DD-WRT, you need a Linux machine. It should work on any reasonably modern machine with basic development tools installed.+2、编译firmware-mod-kit工具套装(终于可以make了),make,提示make:gcc:命令未找到<br>
 +3、接着apt-get install gcc,需下载15.4MB的gcc软件包;<br>
 +4、接着make,又提示g++ 命令未找到,apt-get install g++,需下载4804KB的g++软件包;<br>
 +5、接着make,出错提示,找不到zlib.h 没有这个文件或目录;<br>
 +6、搜zlib,找到其官网,下载zlib包,右键解压到(Debian居然可以右键解压到了耶,表扬一下);<br>
 +7、进入zlib的解压目录,打开终端,输入./configure,看到回显,再输入make,回显,再输入make install,成功!<br>
 +8、接着make,成功!小庆祝一下!但,好像有提示warning,先不管。<br>
 +9、执行【拆开固件】的命令<br>
 +sudo ~/firmware_mod_kit/extract_firmware.sh firmware.bin ~/working_directory/<br>
 +依然提示command not found。郁闷ing~<br>
 +<br>
 +10、等待神仙打救ing。。。。
-Pre-requisites (todo: someone please finish this list -- most/all of the openwrt pre-requisites are required):+=== 二、导入源码法:===
 +===定制===
 +=== 编译源码===
 +=== 测试 ===
 + 
 +==在Ubuntu下编译DD-WRT==
 +从源码中编译DD-WRT是奶挑战编译人员的技术水平的哦。如果你一点都不懂GUN/LINUX,那么请你跳过吧。若你真的非常渴望,请先“充电”,打好基础再来。
 +=== 初始化工作区===
 +首先,在你的电脑上安装好Ubuntu(最新版本即可)操作系统。
 +=== 导入源码===
 +然后利用SVN来获取源码,释出到DD-WRT 文件夹,命令如下(MS,http的超链接,大陆访问失效了.--leangjia于2010-06-23):
 +<pre>svn co http://svn.dd-wrt.com/DD-WRT ./DD-WRT </pre>或<pre>svn co svn://svn.dd-wrt.com/DD-WRT ./DD-WRT</pre>
 +'''重要'''
 + 
 +!SVN释出的DD-WRT源代码 内容:131,506项,大小1.3GB --leangjia注。
 + 
 +请注意,由于该库包含每个硬件平台的Linux内核版本的源的数繁多,所以需要要很长的时间来下载(大于2GB)。
 +DD-WRT的的源代码是结构化的,类似这样子:
 + 
 +<pre>
 +src/ source
 + router/ packages
 + linux/ kernel
 +opt/ make/control
 + 
 +</pre>
 + 
 +===定制===
 +根据所需功能来定制;
 +=== 编译源码===
 + 
 +=== 测试 ===
 + 
 +==从源文件开始编译DD-WRT==
 +根据DD-WRT的源码来编译重建DD-WRT是件相当有难度的事情,在这里肯定不是第一次尝试这个工作。你会看到很多奇怪的错误,许多混乱的脚本安装。这,论坛中也没人能作出通过运行程序这种安装充分。在论坛的新闻区远远高于这些新来港,但也很混乱,混淆了。
 + 
 +Brainslayer没有时间做的一切。直到有一天,是DD - WRT的将建立一个没有任何额外的步骤,我已经写了一些脚本,将成立一个对DD - WRT的建设环境。较新的版本可能打破这些脚本的兼容性的DD - WRT的。如果发生这种情况,我不更新它们,''请''花时间来更新它们'''如果'''你肯定你的修改是适当的。
 + 
 +===需求===
 +你需要一台Linux机器来编译DD-WRT。它应该工作于安装好了基础开发工具包的机器上。
 + 
 +最低资格(TODO:在有人请完成此列表 - 对/在openwrt先决条件最需要):
* Automake v1.9.4 * Automake v1.9.4
Line 154: Line 232:
* build-essentials * build-essentials
-To install/update most of them at once:+若首次,其中大部分要安装/更新:
sudo apt-get install gcc g++ binutils patch bzip2 flex bison make gettext unzip zlib1g-dev libc6 sudo apt-get install gcc g++ binutils patch bzip2 flex bison make gettext unzip zlib1g-dev libc6
-===Organization===+===组织架构===
'''WiP''' '''WiP'''
-DD-WRT's source is organized like so:+DD-WRT的的源代码是有组织的,象这样:
<pre> <pre>
Line 170: Line 248:
</pre> </pre>
-Following is another listing of source tree checked out by svn.+以下是另一种使用svn释出的源代码树。
<pre> <pre>
[root@ibm ~]$ find DD-WRT -maxdepth 1 -type d [root@ibm ~]$ find DD-WRT -maxdepth 1 -type d
Line 185: Line 263:
</pre> </pre>
-===Source Retrieval===+===获取源码===
-The first step is to retrieve the desired DD-WRT version. You can do this by either downloading from the DD-WRT downloads section, or by checking out using Subversion.+第一步是要获取所需的DD - WRT的版本。您可以通过下载或从DD - WRT的下载部分,或使用Subversion签出这一点。
===Subversion=== ===Subversion===
-First you'll need to get subversion, available at http://subversion.tigris.org/+首先,您需要得到subversion,可在http://subversion.tigris.org/
-For some Linux distributions, you should be able to get subversion using the package manager tool.+对于一些Linux发行版,你应该能够使用软件包管理工具得到 subversion
-After installing, you can get the latest source from DD-WRT by running the following command:+安装后,您可以通过从DD-WRT的最新源运行以下命令:
<pre>svn co http://svn.dd-wrt.com/DD-WRT .</pre> <pre>svn co http://svn.dd-wrt.com/DD-WRT .</pre>
Line 202: Line 280:
<pre>svn co svn://svn.dd-wrt.com/DD-WRT .</pre> <pre>svn co svn://svn.dd-wrt.com/DD-WRT .</pre>
-That will download the source into the current directory, you could change the directory by changing the "." at the end to the directory you would like the source in. Leaving out the "." will download everything to a "DD-WRT" sub-directory.+这将下载源码到当前的目录,您可以通过更改“目录”。在结束的目录,你想进来走出了“源”。将下载到的一切“DD-WRT的”子目录。
-'''Important'''+'''重要'''
-Please be aware that the repository contains the sources for several linux kernel versions for each hardware platform, so be prepared for a very long download (>20G ?). +请注意,由于该库包含每个硬件平台的Linux内核版本的源的数繁多,所以需要要很长的时间来下载(大于20G?)。
-To checkout everything except kernel's source code please have a look at [[ddwrt_selective_co.sh]].+提取除了内核的源代码的所有源代码,请查看[[ddwrt_selective_co.sh]]
-Do a simple check after svn checkout download.+请在svn下载释出源码后做一个简单的检查运作。
<pre> <pre>
[root@ibm DD-WRT]$ svn list [root@ibm DD-WRT]$ svn list
Line 227: Line 305:
</pre> </pre>
-===Download Section===+===下载区===
-Another way to get the source is to download it from the [http://www.dd-wrt.com/dd-wrtv3/dd-wrt/downloads.html Downloads Section]. +另一种方式来获得源是从[http://www.dd-wrt.com/dd-wrtv3/dd-wrt/downloads.html]下载它。
-Afterwards you need to extract it which is done simply by using a command like:+随后你需要通过使用类似下面的很简单的命令来提取它:
<pre>tar -jxvf nameoffile.tar.bz</pre> <pre>tar -jxvf nameoffile.tar.bz</pre>
--[[User:Jbrazio|jbrazio]] 13:07, 17 December 2008 (CET) The download section seems not to contain the source code for v24 and up. --[[User:Jbrazio|jbrazio]] 13:07, 17 December 2008 (CET) The download section seems not to contain the source code for v24 and up.
-===Instructions===+===说明===
 +2011-01-18补充一下:toolchain-x86_x64-mipsel-4.1.2.tar.bz2下载地址出现在:http://www.dd-wrt.com/dd-wrtv2/downloads/others/tornado/toolchains/toolchain-x86_x64-mipsel-4.1.2.tar.bz2
-You'll need the 3.4.6 and 4.1.0 mipsl uclibc toolchains. They are available at [[http://www.dd-wrt.com/dd-wrtv2/downloads/others/sourcecode/toolchains/toolchains.x86.debian.sp1.tar.bz2]] for x86 users. There is also a ppc version in the download section at [[http://www.dd-wrt.com/dd-wrtv2/downloads/others/sourcecode/toolchains/toolchains.darwin.ppc.sp1.tar.bz2]] The mips-uclibc 3.4.6 toolchain is used for building the kernel and the 4.1.0 mipsel-uclibc toolchain is used for building the user-mode packages. Unpack the toolchains wherever you desire, the scripts below will set up symlinks appropriately.+你需要mipsl的版本为3.4.6和4.1.0的uClibc。他们可在[[http://www.dd-wrt.com/dd-wrtv2/downloads/others/sourcecode/toolchains/toolchains.x86.debian.sp1.tar.bz2]]为x86用户。 也有部分在下载PPC版本的[[http://www.dd-wrt.com/dd-wrtv2/downloads/others/sourcecode/toolchains/toolchains.darwin.ppc.sp1.tar.bz2]]在MIPS - uClibc的开发工具链3.4.6用于建设的内核和4.1.0 mipsel - uClibc的开发工具链,是建设用户模式程序包使用。无论你是否想解压,下面的脚本都将设立适当的符号链接。
-To build DD-WRT you simply need to:+为了编译DD-WRT,你只需:
- 0. Run ready_ddwrt.sh and ready_ddwrt_root.sh (the scripts are below).+ 0. 运行ready_ddwrt.sh ready_ddwrt_root.sh (下面的脚本).
- 1. Add the 4.1.0 toolchains bin folder to your path environment variable. i.e. + 1. 添加4.1.0工具库到您的bin文件夹路径环境变量。即
''PATH=$PATH:/home/db90h/toolchains/4.1.0-uclibc/bin'' ''PATH=$PATH:/home/db90h/toolchains/4.1.0-uclibc/bin''
- 2. In DD-WRT/opt run ./install.sh. Running ./install_* to build a particular + 2. DD-WRT/opt 目录运行 ./install.sh. 运行 ./install_* 建立一个特定
- variant requires you rebuild shared code first.+ 你要求重建共享代码的第一个变量。
 +这两个脚本应保存到ready_ddwrt.sh和ready_ddwrt_root.sh。你可以下载他们[[http://www.bitsum.com/files/ready_ddwrt.tar.gz这里]]但是ready_ddwrt.sh缺少最后两节,建立write4和webcomp,所以你最好把刚才的脚本从这个网页复制一下。
-These two scripts should be saved to ready_ddwrt.sh and ready_ddwrt_root.sh. You can download them [[http://www.bitsum.com/files/ready_ddwrt.tar.gz here]] HOWEVER ready_ddwrt.sh is missing the last two sections to build write4 and webcomp, so you are probably best off just copying that script from this page.+<b>注意:</b> $DDROOT/src/linux/brcm可能不存在于你的文件结构(我没有这个想法),所以下面的脚本来解决作出新的子目录$DDROOT/src/linux/brcm ,然后将您的文件夹$DDROOT/src/linux/linux.v2*或简单地改变脚本如下$DDROOT/src/linux/brcm 。
-<b>NOTE:</b> $DDROOT/src/linux/brcm may not exist on your file structure (it didn't on mine) so to fix the scripts below make a new sub-directory $DDROOT/src/linux/brcm and then move your $DDROOT/src/linux/linux.v2* folders to $DDROOT/src/linux/brcm or simply change the script below.+<b>注意:</b> If you are having issues with the first ready_ddwrt.sh script building mksquashfs-lzma and it's giving you some error about "ld: skipping incompatible ./lzma/C/7zip/Compress/LZMA_Lib/liblzma.a when searching for -llzma", then this is likely the result of the CPU tuning done in the CFLAGS in the makefiles. I had to edit src/squashfs-tools/Makefile and src/squashfs-tools/lzma/C/7zip/Compress/LZMA_Lib/makefile removing the following optimizations:
- +
-<b>NOTE:</b> If you are having issues with the first ready_ddwrt.sh script building mksquashfs-lzma and it's giving you some error about "ld: skipping incompatible ./lzma/C/7zip/Compress/LZMA_Lib/liblzma.a when searching for -llzma", then this is likely the result of the CPU tuning done in the CFLAGS in the makefiles. I had to edit src/squashfs-tools/Makefile and src/squashfs-tools/lzma/C/7zip/Compress/LZMA_Lib/makefile removing the following optimizations: +
* -D_FILE_OFFSET_BITS=64 * -D_FILE_OFFSET_BITS=64
* -D_LARGEFILE_SOURCE * -D_LARGEFILE_SOURCE
Line 367: Line 445:
</pre> </pre>
-This second script needs to be run as root ...+这第二个脚本需要以root运行...
<pre> <pre>
Line 415: Line 493:
</pre> </pre>
-===Changing DD-WRT改变DD-WRT===+===更改DD-WRT===
-'''''Work in progress'''''+'''''工作进展'''''
-DD-WRT is easily reconfigured. In the /src/router folder you'll find .config* files for each type of distribution. Use 'make menuconfig' to edit the appropriate configuration files. The /src/router/busybox folder contains .config* files for its configuration. Just edit them in a similar way.+
-Change micro configuration:+DD - WRT的很容易重新配置。在/ src目录/文件夹中你会发现路由器。配置每分布类型*文件。使用'make menuconfig'后编辑相应的配置文件。在/ src目录/路由器/ busybox的文件夹包含。配置为它的配置*文件。只要以同样的方式编辑它们。
-''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.''+ 
 +配置少许更改:
 + 
 +"警告:在更改前及更改后,你需要从内部选项中恢复默认配置文件。这些选项似乎不在配置模板中。
<pre> <pre>
cd DD-WRT/src/router cd DD-WRT/src/router
Line 429: Line 509:
</pre> </pre>
-Change micro Busybox configuration:+更改少许Busybox配置:
<pre> <pre>
cd DD-WRT/src/router/busybox cd DD-WRT/src/router/busybox
Line 437: Line 517:
</pre> </pre>
-Change micro kernel configuration:+ 
 +内核少许更改
<pre> <pre>
cd DD-WRT/src/router/busybox cd DD-WRT/src/router/busybox
Line 445: Line 526:
</pre> </pre>
-[[Category:Categories/zh cn]]+[[Category:Categories/zh cn中国大陆]]

Current revision



大多数时候,你并不真的需要从源码来重新编译DD-WRT,以满足您所期望的功能。现在,固件修改工具包让这一进程已变得相当容易。 固件修改工具包. 该套件能够使用户无需从源码重新编译固件而修改固件镜像文件的功能变化。它通过其组成部分基于文件系统的支持,提取到固件的squashfs-LZMA的,(其他文件系统可以用)。然后用户可以以提取的文件系统进行修改,然后重新生成固件镜像。 【leangjia附 Toolchain下载:http://www.macsat.com/forum/index.php?topic=681.msg3699#msg3699 】 其特点(特征)包括:

  • 添加初始化脚本
  • 安装新功能包
  • 扩展web用户界面
  • 移除不需要的功能包
  • 来自不同的DD-WRT设备的混合与匹配。(注:固件修改工具包 的特征是可以用于DD-WRT的私生设备??)

警告:因为,晚于08/04/2006的版本,有对这个从网页升级的保护,你不要把刷新的设备拿去升级或者去销售(言外之意是:你用web无法升级。他没有明确的说 TFTP 是否可以。--TKS:TeTrAhEdRoN)

Contents

[edit] 要求

[edit] 需求

你需要一台Linux机器来编译DD-WRT。它应该工作于安装好了基础开发工具包的机器上。

最低资格(TODO:须安装下列库或软件以配置好编译环境):

  • 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
  • build-essentials

安装上述,命令如下:

   sudo apt-get install gcc g++ binutils patch bzip2 flex bison make gettext unzip  zlib1g-dev libc6

我竭尽全力降低本套件的使用门槛,以确保任何人均可方便使用本套件。However, to reduce distribution costs and better represent the multi-platform capabilities of this kit, the binary tools in the kit do automatically build themselves the first time you run one of the scripts. 每台机器准备好C或C++库,每台机器的编译固件的环境基础通过本套件来修改DD-WRT固件需要满足下列基础要求(相信每位都容易满足这样的要求的了):

  1. 一个兼容的平台。下面是具体的支持(或不支持):
    1. LINUX平台
    2. OS X 平台
    3. CYGWIN(注:linux操作系统的一种)平台 **alpha阶段测试(!! 内置固件可能无法启动!!)**
  2. GNU C (gcc库)
  3. GNU C++ (g++库)
  4. 标准C运行时库的开发版
  5. 标准C++运行时库的开发版
  6. GNU make
  7. tar和gzip(可选,由ipkg_install.sh使用)

对于OS X,请安装Mac OS X 开发工具,支持GNU C和 C++编译器并使其能正常使用。

[edit] 兼容性

固件使用正常的squashfs - LZMA的cybertan结构(linux架构的一种)的固件镜像文件格式。如果将工作的步骤提取文件系统和文件系统的重建小的改动,由于是使用squashfs或其他常规的(即cramfs)文件系统,故它与下面所列相兼容:

固件名 注意
DD-WRT
OpenWrt probably not at the moment - should require older mksquashfs if using White Russian
FreeWrt 未测试
Sveasoft Alchemy/Talismen 未测试
HyperWrt 未测试

如果有足够的需求,我可以将默认支持cramfs,常规的squashfs,和旧版本的squashfs和squashfs-LZMA的版本。 请注意,对于那些固件有易于使用的编译系统和/或镜像生成器实用程序,即OpenWrt,这个工具包是较少使用。

[edit] 用法说明

我已经写了两个脚本,大大简化了程序。基本上,这是一个提取固件的过程中的步骤和一个重建固件的过程中的步骤。

[edit] 解压固件 (extract_firmware.sh)

只需运行下面的extract_firmware.sh。您必须运行此目录内存在的工具。

$ ./extract_firmware.sh firmware.bin working_directory/

新手须知:上述命令解释:"./extract_firmware.sh"表示执行当前目录下的extract_firmware.sh。加"./",即当前目录,就不必设置path环境变量。

firmware.bin :你想提取的固件的镜像文件, 如, DD-WRT.v23_MICRO_GENERIC.BIN.
working_directory 
你要使用的工作目录。这将被用于保存中间文件和提取系统文件。请注意,在工作目录中的文件可能被删除!

您提供的固件镜像文件,如,为一WRT54G或华硕WL-500G。这些镜像文件通常都是相同的,只是在头格式有所不同。在重建过程中,将会创建各种型号的镜像。 提取的日志将创建为 extract.log

举例:

$ ./extract_firmware.sh  dd-wrt.v24_mega_generic.bin  ./mega/

上述命令解释:执行当前目录下的extract_firmware.sh,将7.3MB的固件dd-wrt.v24_mega_generic.bin解到当前mega目录下。

[edit] 修改固件 (manual and/or ipkg_install.sh)

修改固件很简单。该文件系统是存储在您的工作目录提供给extract_firmware.sh。以下是该目录下的子文件夹:

  • rootfs/
      • 这是该文件系统。在这里进行修改。
  • image_parts/
      • 这是中间文件的存储位置。如果您需要更换内核(不是建议更换),您可以通过更改这里的menu.lst。

一只是改变,增加,或删除的文件在rootfs /向该固件的文件系统的变化。之后你完成更改后,重建固件。 安装软件包(.IPK) 软件包是有关一套软件文件预先建立的集合。OpenWrt和DD - WRT都使用软件包的形式,而且大多数是相互兼容的。这些软件包都存储在一个tar/gzip格式,其中包括一些控制文件的档案中。你可以手动提取和复制的这些文件或使用这个工具包的ipkg_install.sh脚本。此处列出部分软件包,这里不可能列出所有,详见http://ftp.selfnet.de/pub/openwrt/backports/rc5/ 。 例如使用:

$ ./ipkg_install.sh some_package-1.2.5.ipk working_directory/
some_package-1.2.5.ipkg 
指软件包的文件名。
working_directory 
为您提供相同的工作目录到extract_firmware.sh脚本。

!注意:若软件包需进行相关配置,则,如何利用WEB来配置此软件包,需要各自想办法。翻译者尝试过,但水平有限。有经验的朋友请到路由站http://2cna.3322.org:88 或leangjia@vip.qq.com分享一下。万分感谢!

[edit] 重新编译固件 (build_firmware.sh)

重建固件和提取固件同样容易。 使用build_firmware.sh脚本来自动化进程。您必须运行此目录内的存在有的工具。例如使用:

$ ./build_firmware.sh output_directory/ working_directory/
output_directory 
该路径应储存所创建的固件的镜像文件。如果镜像文件已经存在,则将覆盖。各种型号的排放量(这些镜像文件都是相同的,但有不同的格式头使他们的目标模式是由接受固件镜像文件)。
working_directory 
提供给extract_firmware.sh的工作目录。

编译日志创建为build.log。

[edit] 在Fedora 9下编译DD-WRT V24

[edit] 获取源代码

我是一名中国在校学生。因为我想从源代码中学习,因此我想得到一份源代码。

[edit] 定制

[edit] 编译

[edit] 检查

[edit] 在Debian下编译DD-WRT V24

[edit] 初始化工作区

[edit] 一、修改固件法:

2010-05-25 17:09 Debian为最新版(lenny)DVD ISO镜像文件,跑在VM绿盟精简版,firmware工具套装,无论是SVN释出的,又或下载的软件包,都试过。

按网上教程(搜出来很多篇,但均是转贴同一源贴),进入src目录make,直接提示make 命令未找到,

1、安装make:apt-get install make
2、编译firmware-mod-kit工具套装(终于可以make了),make,提示make:gcc:命令未找到
3、接着apt-get install gcc,需下载15.4MB的gcc软件包;
4、接着make,又提示g++ 命令未找到,apt-get install g++,需下载4804KB的g++软件包;
5、接着make,出错提示,找不到zlib.h 没有这个文件或目录;
6、搜zlib,找到其官网,下载zlib包,右键解压到(Debian居然可以右键解压到了耶,表扬一下);
7、进入zlib的解压目录,打开终端,输入./configure,看到回显,再输入make,回显,再输入make install,成功!
8、接着make,成功!小庆祝一下!但,好像有提示warning,先不管。
9、执行【拆开固件】的命令
sudo ~/firmware_mod_kit/extract_firmware.sh firmware.bin ~/working_directory/
依然提示command not found。郁闷ing~

10、等待神仙打救ing。。。。

[edit] 二、导入源码法:

[edit] 定制

[edit] 编译源码

[edit] 测试

[edit] 在Ubuntu下编译DD-WRT

从源码中编译DD-WRT是奶挑战编译人员的技术水平的哦。如果你一点都不懂GUN/LINUX,那么请你跳过吧。若你真的非常渴望,请先“充电”,打好基础再来。

[edit] 初始化工作区

首先,在你的电脑上安装好Ubuntu(最新版本即可)操作系统。

[edit] 导入源码

然后利用SVN来获取源码,释出到DD-WRT 文件夹,命令如下(MS,http的超链接,大陆访问失效了.--leangjia于2010-06-23):

svn co http://svn.dd-wrt.com/DD-WRT ./DD-WRT 
svn co svn://svn.dd-wrt.com/DD-WRT ./DD-WRT

重要

!SVN释出的DD-WRT源代码 内容:131,506项,大小1.3GB --leangjia注。

请注意,由于该库包含每个硬件平台的Linux内核版本的源的数繁多,所以需要要很长的时间来下载(大于2GB)。 DD-WRT的的源代码是结构化的,类似这样子:

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

[edit] 定制

根据所需功能来定制;

[edit] 编译源码

[edit] 测试

[edit] 从源文件开始编译DD-WRT

根据DD-WRT的源码来编译重建DD-WRT是件相当有难度的事情,在这里肯定不是第一次尝试这个工作。你会看到很多奇怪的错误,许多混乱的脚本安装。这,论坛中也没人能作出通过运行程序这种安装充分。在论坛的新闻区远远高于这些新来港,但也很混乱,混淆了。

Brainslayer没有时间做的一切。直到有一天,是DD - WRT的将建立一个没有任何额外的步骤,我已经写了一些脚本,将成立一个对DD - WRT的建设环境。较新的版本可能打破这些脚本的兼容性的DD - WRT的。如果发生这种情况,我不更新它们,花时间来更新它们如果你肯定你的修改是适当的。

[edit] 需求

你需要一台Linux机器来编译DD-WRT。它应该工作于安装好了基础开发工具包的机器上。

最低资格(TODO:在有人请完成此列表 - 对/在openwrt先决条件最需要):

  • 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
  • build-essentials

若首次,其中大部分要安装/更新:

   sudo apt-get install gcc g++ binutils patch bzip2 flex bison make gettext unzip  zlib1g-dev libc6

[edit] 组织架构

WiP DD-WRT的的源代码是有组织的,象这样:

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

以下是另一种使用svn释出的源代码树。

[root@ibm ~]$ find  DD-WRT -maxdepth 1 -type d
DD-WRT
DD-WRT/redboot
DD-WRT/src
DD-WRT/opt
DD-WRT/tools
DD-WRT/image
DD-WRT/.svn
DD-WRT/.subversion
[root@ibm ~]$

[edit] 获取源码

第一步是要获取所需的DD - WRT的版本。您可以通过下载或从DD - WRT的下载部分,或使用Subversion签出这一点。

[edit] Subversion

首先,您需要得到subversion,可在http://subversion.tigris.org/ 对于一些Linux发行版,你应该能够使用软件包管理工具得到 subversion 。

安装后,您可以通过从DD-WRT的最新源运行以下命令:

svn co http://svn.dd-wrt.com/DD-WRT .

--jbrazio 13:05, 17 December 2008 (CET) HTTP method is not working currently.

or

svn co svn://svn.dd-wrt.com/DD-WRT .

这将下载源码到当前的目录,您可以通过更改“目录”。在结束的目录,你想进来走出了“源”。将下载到的一切“DD-WRT的”子目录。


重要

请注意,由于该库包含每个硬件平台的Linux内核版本的源的数繁多,所以需要要很长的时间来下载(大于20G?)。

提取除了内核的源代码的所有源代码,请查看ddwrt_selective_co.sh


请在svn下载释出源码后做一个简单的检查运作。

[root@ibm DD-WRT]$ svn list
.cvsignore
.project
Makefile
image/
opt/
redboot/
src/
tools/
[root@ibm DD-WRT]$

[edit] 下载区

另一种方式来获得源是从[1]下载它。 随后你需要通过使用类似下面的很简单的命令来提取它:

tar -jxvf nameoffile.tar.bz

--jbrazio 13:07, 17 December 2008 (CET) The download section seems not to contain the source code for v24 and up.

[edit] 说明

2011-01-18补充一下:toolchain-x86_x64-mipsel-4.1.2.tar.bz2下载地址出现在:http://www.dd-wrt.com/dd-wrtv2/downloads/others/tornado/toolchains/toolchain-x86_x64-mipsel-4.1.2.tar.bz2

你需要mipsl的版本为3.4.6和4.1.0的uClibc。他们可在[[2]]为x86用户。 也有部分在下载PPC版本的[[3]]在MIPS - uClibc的开发工具链3.4.6用于建设的内核和4.1.0 mipsel - uClibc的开发工具链,是建设用户模式程序包使用。无论你是否想解压,下面的脚本都将设立适当的符号链接。

为了编译DD-WRT,你只需:

 0. 运行ready_ddwrt.sh 和 ready_ddwrt_root.sh (下面的脚本).
 1. 添加4.1.0工具库到您的bin文件夹路径环境变量。即
   PATH=$PATH:/home/db90h/toolchains/4.1.0-uclibc/bin
 2. 到 DD-WRT/opt 目录运行 ./install.sh. 运行 ./install_* 建立一个特定
     你要求重建共享代码的第一个变量。

这两个脚本应保存到ready_ddwrt.sh和ready_ddwrt_root.sh。你可以下载他们[[4]]但是ready_ddwrt.sh缺少最后两节,建立write4和webcomp,所以你最好把刚才的脚本从这个网页复制一下。

注意: $DDROOT/src/linux/brcm可能不存在于你的文件结构(我没有这个想法),所以下面的脚本来解决作出新的子目录$DDROOT/src/linux/brcm ,然后将您的文件夹$DDROOT/src/linux/linux.v2*或简单地改变脚本如下$DDROOT/src/linux/brcm 。

注意: If you are having issues with the first ready_ddwrt.sh script building mksquashfs-lzma and it's giving you some error about "ld: skipping incompatible ./lzma/C/7zip/Compress/LZMA_Lib/liblzma.a when searching for -llzma", then this is likely the result of the CPU tuning done in the CFLAGS in the makefiles. I had to edit src/squashfs-tools/Makefile and src/squashfs-tools/lzma/C/7zip/Compress/LZMA_Lib/makefile removing the following optimizations:

  • -D_FILE_OFFSET_BITS=64
  • -D_LARGEFILE_SOURCE
  • -mtune=opteron
  • -march=opteron
  • -mfpmath=sse
  • -m3dnow
  • -msse2
  • -m64
  • -mmmx
  • -msse3

I kept the "-funroll-loops" and "-O3" optimizations since those should be non-CPU-specific. By all mean leave any optimizations that apply to your CPU. For a 64-bit CPU, leave -D_FILE_OFFSET_BITS=64, -D_LARGEFILE_SOURCE, and -m64. If you're curious as to what your cpu has, look at the flags listed in /proc/cpuinfo.

#!/bin/sh
#
# title: ready_ddwrt.sh
# version: 1.14
# author: Jeremy Collake <jeremy@bitsum.com>
#
# This silly script will prepare a build environment
# for DD-WRT. You must also run ready_ddwrt_root.sh.
#
# RL 11/01/2006: Added line to compile tools/webcomp.c and write4.c
#
MINPARAMS=1
if [ $# -lt "$MINPARAMS" ]
	then
	echo usage:
	echo    ready_ddwrt.sh [ddwrt_base_path]
	echo
	echo i.e.:
	echo    ready_ddwrt.sh /home/db90h/DD-WRT
	echo
	exit 1
fi  

ME=`whoami`
DDROOT=$1

echo I am $ME
echo DD-WRT is at $DDROOT

echo ................................................................
echo creating some symlinks
echo ................................................................
rm $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/.dccp-test
chmod +x $DDROOT/src/router/iptables/extensions/.layer7-test
echo done

#echo ................................................................
#echo fixing alconf's
#echo ................................................................
#cd src/router/pptpd
#aclocal
#cd ../../..

echo ................................................................
echo "re-building some tools"
echo ................................................................
cd $DDROOT

# make bb_mkdep
cd src/router/busybox/scripts 
rm bb_mkdep
make bb_mkdep 
cd ../../../.. 

# make jsformat
cd src/router/tools 
rm jsformat
make jsformat 
cd ../../..

# make mksquashfs-lzma
cd src/squashfs-tools/
rm mksquashfs-lzma
make 
cp mksquashfs-lzma ../linux/brcm/linux.v23/scripts/squashfs
cd ../..

# make strip
cd tools
rm ./strip
gcc strip.c -o ./strip
cd ..

# make write3
cd tools
rm ./write3
gcc write3.c -o ./write3
cd ..

# make write4
cd tools
rm ./write4
gcc write4.c -o ./write4
cd ..

# make webcomp
cd tools
rm ./webcomp
gcc -o webcomp -DUEMF -DWEBS -DLINUX webcomp.c
cd ..

echo done

这第二个脚本需要以root运行...

#!/bin/sh
#
# title: ready_ddwrt_root.sh
# version: 1.1
# author: Jeremy Collake <jeremy@bitsum.com> aka db90h
#
# This silly script will prepare a build environment
# for DD-WRT. You must also run ready_ddwrt.sh.
#
MINPARAMS=2
if [ $# -lt "$MINPARAMS" ]
	then
	echo 
	echo This script needs root access.
	echo
	echo usage:
	echo    ready_ddwrt_root.sh [ddwrt_base_path] [3.4.6_toolchain_base_path]
	echo
	echo i.e.:
	echo    ready_ddwrt_root.sh /home/db90h/DD-WRT /home/db90h/3.4.6-ucliblc-0.9.28
	echo
	exit 1
fi  

ME=`whoami`
DDROOT=$1
TCHAIN=$2

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

echo ................................................................
echo creating some symlinks
echo ................................................................
# duh, this will already be here
mkdir -p /opt
rm /opt/3.3.6
ln -s $TCHAIN /opt/3.3.6
rm /GruppenLW
ln -s $DDROOT/image /GruppenLW

echo All done!

[edit] 更改DD-WRT

工作进展

DD - WRT的很容易重新配置。在/ src目录/文件夹中你会发现路由器。配置每分布类型*文件。使用'make menuconfig'后编辑相应的配置文件。在/ src目录/路由器/ busybox的文件夹包含。配置为它的配置*文件。只要以同样的方式编辑它们。

配置少许更改:

"警告:在更改前及更改后,你需要从内部选项中恢复默认配置文件。这些选项似乎不在配置模板中。

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

更改少许Busybox配置:

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


内核少许更改

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