开发

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 05:30, 15 May 2010 (edit)
Leangjia (Talk | contribs)
(Changing DD-WRT改变DD-WRT)
← Previous diff
Revision as of 04:43, 21 May 2010 (edit) (undo)
Leangjia (Talk | contribs)

Next diff →
Line 1: Line 1:
{{Languages|Development}} {{Languages|Development}}
-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.+大多数时候,你并不真的需要从源码来重新编译DD-WRT,以满足您所期望的功能。现在,固件修改工具包让这一进程已变得相当容易。 [http://www.bitsum.com/firmware_mod_kit.htm 固件修改工具包.] 该套件能够使用户无需从源码重新编译固件而修改固件镜像文件的功能变化。它通过其组成部分基于文件系统的支持,提取到固件的squashfs-LZMA的,(其他文件系统可以用)。然后用户可以以提取的文件系统进行修改,然后重新生成固件镜像。
-Features include:特征:+其特点(特征)包括:
-* add initialization scripts添加初始化脚本+* 添加初始化脚本
-* install new packages (remember, packages pre-installed are compressed much better)安装新功能包+* 安装新功能包
-* extend web UI扩展web用户界面+* 扩展web用户界面
-* remove un-needed packages移除不需要的功能包+* 移除不需要的功能包
* mix-and-match packages from various DD-WRT variants * 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.+警告:在2006年8月4日前在eBay上销售的预刷了DD-WRT固件的路由器已受品牌保护。
=要求= =要求=
-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:+我竭尽全力降低本套件的使用门槛,以确保任何人均可方便使用本套件。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固件需要满足下列基础要求(相信每位都容易满足这样的要求的了):
-# A compatible platform. The following are specifically supported (or specifically unsupported):一个兼容平台,支持(或不支持)以下:+# 一个兼容的平台。下面是具体的支持(或不支持):
-## LINUX+## LINUX平台
-## OS X +## OS X 平台
-## CYGWIN **alpha stage testing (!! built firmwares may not boot !!)**+## CYGWIN(注:linux操作系统的一种)平台 **alpha阶段测试(!! 内置固件可能无法启动!!)**
-# GNU C (gcc)+# GNU C (gcc库)
-# GNU C++ (g++)+# GNU C++ (g++)
-# Standard C runtime library development+# 标准C运行时库的开发
-# Standard C++ runtime library development+# 标准C++运行时库的开发
# GNU make # GNU make
-# TAR and GZIP (optional, used by ipkg_install.sh)+# tar和gzip(可选,由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.+
对于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
Line 52: Line 50:
|} |}
-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>
Line 65: Line 63:
</pre> </pre>
-; firmware.bin : the firmware image you want to extract, i.e. DD-WRT.v23_MICRO_GENERIC.BIN. +; firmware.bin :你想提取的固件的镜像文件, 如, DD-WRT.v23_MICRO_GENERIC.BIN.
-; 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!+; working_directory :你要使用的工作目录。这将被胜于保存中间文件和提取系统文件。请注意,在工作目录中的文件可能被删除!
- +
-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>+不要紧,您提供的固件镜像文件,如,为一WRT54G或华硕WL-500G。这些镜像文件通常都是相同的,只是在头格式有所不同。在重建过程中,将会创建各种型号的镜像。
 +一种提取日志创建为'' extract.log ''<br>
dsf dsf
Line 78: Line 75:
</pre> </pre>
-==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. *** 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 95: Line 92:
</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脚本。
-==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 106: Line 102:
</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==+==[~matrix]在Debian下编译DD-WRT V24==
-=== Initializing Workspace ===+=== 初始化工作区===
-=== Fill the Workspace with Sources ===+=== 导入源码===
-=== Customization ===+===定制===
-=== Building Sources ===+=== 编译源码===
-=== Testing ===+=== 测试 ===
-==Building DD-WRT from Source 从源文件开始编译DD-WRT==+==从源文件开始编译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. +根据DD-WRT的源码来编译重建DD-WRT是件相当有难度的事情,在这里肯定不是第一次尝试这个工作。你会看到很多奇怪的错误,许多混乱的脚本安装。这,论坛中也没人能作出通过运行程序这种安装充分。在论坛的新闻区远远高于这些新来港,但也很混乱,混淆了。
-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.+Brainslayer没有时间做的一切。直到有一天,是DD - WRT的将建立一个没有任何额外的步骤,我已经写了一些脚本,将成立一个对DD - WRT的建设环境。较新的版本可能打破这些脚本的兼容性的DD - WRT的。如果发生这种情况,我不更新它们,''''花时间来更新它们'''如果'''你肯定你的修改是适当的。
 +===需求===
 +你需要一台Linux机器来编译DD-WRT。它应该工作于安装好了基础开发工具包的机器上。
-===Requirements===+最低资格(TODO:在有人请完成此列表 - /在openwrt先决条件最需要):
-To build DD-WRT, you need a Linux machine. It should work on any reasonably modern machine with basic development tools installed.+
- +
-Pre-requisites (todo: someone please finish this list -- most/all of the openwrt pre-requisites are required):+
* Automake v1.9.4 * Automake v1.9.4
Line 156: Line 149:
* 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 172: Line 165:
</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 187: Line 180:
</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 204: Line 197:
<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 229: Line 222:
</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===+===说明===
-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 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>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 417: Line 409:
</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>
Line 434: Line 425:
</pre> </pre>
-Change micro Busybox configuration:+更改少许Busybox配置:
-Busybox配置少许更改:+
<pre> <pre>
cd DD-WRT/src/router/busybox cd DD-WRT/src/router/busybox
Line 443: Line 433:
</pre> </pre>
-Change micro kernel configuration:+ 
内核少许更改 内核少许更改
<pre> <pre>
Line 452: Line 442:
</pre> </pre>
-[[Category:Categories/zh cn]]+[[Category:Categories/zh cn中国大陆]]
-[[分类:分类/中国大陆]]+

Revision as of 04:43, 21 May 2010

大多数时候,你并不真的需要从源码来重新编译DD-WRT,以满足您所期望的功能。现在,固件修改工具包让这一进程已变得相当容易。 固件修改工具包. 该套件能够使用户无需从源码重新编译固件而修改固件镜像文件的功能变化。它通过其组成部分基于文件系统的支持,提取到固件的squashfs-LZMA的,(其他文件系统可以用)。然后用户可以以提取的文件系统进行修改,然后重新生成固件镜像。

其特点(特征)包括:

  • 添加初始化脚本
  • 安装新功能包
  • 扩展web用户界面
  • 移除不需要的功能包
  • mix-and-match packages from various DD-WRT variants

警告:在2006年8月4日前在eBay上销售的预刷了DD-WRT固件的路由器已受品牌保护。

Contents

要求

我竭尽全力降低本套件的使用门槛,以确保任何人均可方便使用本套件。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++编译器并使其能正常使用。

兼容性

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

Firmware Notes
DD-WRT
OpenWrt probably not at the moment - should require older mksquashfs if using White Russian
FreeWrt untested
Sveasoft Alchemy/Talismen untested
HyperWrt untested

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

用法说明

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

解压固件 (extract_firmware.sh)

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

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

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

Example:

$ ./extract_firmware.sh  dd-wrt.v24-11218_NEWD_mega  ./mega/

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

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

  • rootfs/
      • This is where the file system is. Make modifications here.
  • 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脚本。

重新编译固件 (build_firmware.sh)

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

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

编译日志创建为build.log。

在Fedora 9下编译DD-WRT V24

获取源代码

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

定制

编译

检查

[~matrix]在Debian下编译DD-WRT V24

初始化工作区

导入源码

定制

编译源码

测试

从源文件开始编译DD-WRT

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

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

需求

你需要一台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

组织架构

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 ~]$

获取源码

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

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]$

下载区

另一种方式来获得源是从[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.

说明

你需要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 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.

注意: 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

This second script needs to be run as 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!

更改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