找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 48176|回复: 61

tomato 编译详解

 火.. [复制链接]
本帖最后由 sady 于 2011-10-7 19:11 编辑

看这个帖子这前, 请确认一下您能自己搞定ubuntu或debian的安装, 不管是vm下安装,或实体机安装均可以, 如果您不知道如何安装它们并使之正常运行, 请移步linux社区或论坛学习或放弃..  本帖假设您已安装好ubuntu 并可以正常运行和上网.

一. 先打开 linux终端,在终端命令行下执行,安装编译所需的组件

  1. sudo apt-get install build-essential linux-headers-$(uname -r)
  2. sudo apt-get install libncurses5 libncurses5-dev m4 bison flex libstdc++6-4.4-dev g++-4.4 g++ libtool sqlite
  3. sudo apt-get install gcc g++ binutils patch bzip2 flex bison make gettext unzip zlib1g-dev
  4. sudo apt-get install libc6 libncurses5-dev  automake automake1.7 automake1.9
  5. sudo apt-get install git-core
  6. sudo apt-get install gitk
复制代码
以上每复制一行,然后在终执行一次, 如果都可以顺利完成,请看下一步

二. 获取tomato源代码
  1. cd ~
  2. sudo -s
  3. mkdir tomato_git
  4. cd tomato_git
  5. git clone git://repo.or.cz/tomato.git
复制代码
稍等10~30分钟(取决于网速),完成后,先备份好源码以便在编译时改乱了,能恢复原始状态,需不要重复痛苦的重新下载源码
  1. tar zcvf tomato_git.tar.gz ./tomato  
复制代码
完成后,将在当前目录下生成tomato_git.tar.gz 备份包, 以备不时之需.

如果源码有更新, 那么不需要重新下载源码,只需执行下列命令,可增量同步更新
  1. git pull
复制代码
三. 建立交叉编译变量环境
  1. sudo ln -s ~/tomato_git/tomato/tools/brcm /opt/brcm
复制代码
  1. nano /root/.profile
  2. 在最后一行处加入
  3. if [ -d "/opt/brcm" ] ; then
  4.     PATH=/opt/brcm/hndtools-mipsel-uclibc/bin:/opt/brcm/hndtools-mipsel-linux/bin:$PATH
  5. fi
  6. 按ctrl+x y 保存退出, 以便每次启动linux时能找到编译器.
复制代码
四. 查看并获取当前tomato 分支源码

这部分源码并不包含在前面的源码包中, 需要另外下载,

1.查看当前源码分支

  1. cd ~/tomato_git/tomato
  2. git branch -r
  3. 例:
  4. debian:~/tomato_git/tomato# git branch -r
  5.   origin/Clientmon
  6.   origin/HEAD -> origin/tomato
  7.   origin/IPT-X
  8.   origin/QOS-DEV
  9.   origin/QOS-Limiter
  10.   origin/Static-ARP
  11.   origin/Teaman-BWM
  12.   origin/Teaman-IPTraffic
  13.   origin/Teaman-ND
  14.   origin/Teaman-ND-SDHC
  15.   origin/Teaman-RT
  16.   origin/Toastman-IPT-ND
  17.   origin/Toastman-ND
  18.   origin/Toastman-RT
  19.   origin/Toastman-RT-N
  20.   origin/Toastman-VLAN
  21.   origin/Toastman-VLAN-ND
  22.   origin/Toastman-VLAN-RT
  23.   origin/Toastman-VLAN-RT-N
  24.   origin/Tomato-RAF
  25.   origin/Transmission
  26.   origin/VLAN-GUI
  27.   origin/VLAN-MultiSSID
  28.   origin/minidlna
  29.   origin/multilanguage
  30.   origin/nfs_server
  31.   origin/ntfs-3g
  32.   origin/p910nd
  33.   origin/tomato
  34.   origin/tomato-K26-WL
  35.   origin/tomato-ND-USBmod
  36.   origin/tomato-ND-usbmod-mixvirtual**
  37.   origin/tomato-RT
  38.   origin/tomato-RT-N
  39.   origin/tomato-miniupnpd
  40.   origin/tomato-sdhc-ND-vlan
  41.   origin/tomato-shibby
  42.   origin/tomatovirtual**
  43.   origin/virtual**gui
  44.   origin/vsftpd
  45. debian:~/tomato_git/tomato#
复制代码
2. 获取分支源码

吐司超人版:
  1. git checkout origin/Toastman-RT
  2. git checkout -b origin/Toastman-RT
复制代码
Shibby mod版
  1. git checkout origin/tomato-shibby
  2. git checkout -b origin/tomato-shibby
复制代码
但是要注意,您一次只能获取一种分支源码,不能同时下载, 如果已经下载了吐司超人版源码.. 后来又想编译Shibby源码,那么需要将整个tomato目录删掉,重新解压源码备份,再获取shibby源码,这样获得的源码才干净.
  1. sudo rm -rf ~/tomato_git/tomato
  2. tar zxvf ~/tomato_git/tomato.tar.gz .
复制代码
四. 开始编译.
如果需要自己配置核心, 添加对更多硬件的支持. 那么
  1. R1版:
  2. cd ~/tomato_git/tomato/release/src/linux/linux
  3. 或R2版:
  4. cd ~/tomato_git/tomato/release/src-rt/linux-2.6

  5. sudo make menuconfig

复制代码
根据情况自行选择内核参数, 没有经验不建议更改,很容易导致核心挂掉(省略5000字)

开始编译.
  1. R1版:
  2. cd ~/tomato_git/tomato/release/src
  3. 或R2版:
  4. cd ~/tomato_git/tomato/release/src-rt
复制代码
查看有那些参数可选.不同的分支版本,编译参数是不同的.具体查看
  1. make help
复制代码
例:
debian:~/tomato_git/tomato/release/src-rt# make help
m            Ext - (standard plus extra utilities and NTFS support)
c            BTgui - (Ext plus BT gui)
r            BT - (Ext plus BT Client)
t            BT-virtual** - (BT plus virtual**)
a            Big - (Ext plus NOCAT plus NFS plus BT gui)
n            Mega - (Big + BT Client minus NOCAT)
e            virtual** - (standard plus virtual**, extra utilities and NTFS support)
b            Big-virtual** - (Big plus virtual**)
o            Mega-virtual** - (Mega plus virtual** plus NOCAT minus NFS)
i            MiniIPv6 - (IPv6 with no USB support minus CIFS and RIPv1/2)
s            Std - (no USB support)
f            Mini - (no USB support minus CIFS and RIPv1/2)
v            virtual** (no usb) - (virtual** with no USB support)
w            SD-virtual** (no usb) - (virtual** with SD-MOD and no USB support)
r2m          MIPS Release 2 Ext
r2c          MIPS Release 2 BTgui
r2r          MIPS Release 2 BT
r2t          MIPS Release 2 BT-virtual**
r2a          MIPS Release 2 Big
r2n          MIPS Release 2 Mega
r2e          MIPS Release 2 virtual**
r2b          MIPS Release 2 Big-virtual**
r2o          MIPS Release 2 Mega-virtual**
r2z          MIPS Release 2 AIO (for routers +8MB flash)
r2v          MIPS Release 2 virtual** (no usb)
r2s          MIPS Release 2 Std
r2i          MIPS Release 2 MiniIPv6 (for 4MB flash)
r2f          MIPS Release 2 Mini (for netgear)
n60m         Linksys E-series build Ext
n60c         Linksys E-series build BTGui
n60r         Linksys E-series build BT
n60t         Linksys E-series build BT-virtual**
n60a         Linksys E-series build Big
n60n         Linksys E-series build Mega
n60e         Linksys E-series build virtual**
n60b         Linksys E-series build Big-virtual**
n60o         Linksys E-series build Mega-virtual**
n60s         Linksys E-series build Std with IPv6
n60v         Linksys E-series build virtual** with IPv6


开始编译
  1. sudo make V1=Shibby V2=-20111007 r2r
复制代码
说明: 其中V1=分支名称 ,V2=版本号, 两个可以自定义,也可以都不要,您自己决定. 它会出现在固件的about 页面中的版本中. r2r是表示编译的是r2版本带内置bt的功能.

可以休息了, 大约1小时到2小时,取决您的电脑速度.
中间如果有出错,请根据出错提示信息纠错解决(需要一定经验和知识)
编译完成. 在当前的image目录下可查到,将它复制出来.然后刷机,测试..

五. 重新编译
  1. 同一版本
  2. make clean

  3. 改动较大版本
  4. make distclean

复制代码
清整掉以后,再用本节方法重新make.

六. 其他
如果您决定编译shibby源码最新版. 因为最新版的transmission需要libevent-2.0.10 以上组件, 请替换掉源码中的libevent旧版本,再进行编译.否则会出错
  1. rm -rf ~/tomato_git/tomato/release/src/router/libevent/
  2. wget http://www.monkey.org/~provos/libevent-2.0.10-stable.tar.gz

  3. tar xzvf libevent-2.0.10-stable.tar.gz -C ~/tomato_git/tomato/release/src/router/libevent/
复制代码
补充参考网站:
tomatousb官网编译教程(此教程没有说明如何获取tomato分支代码)
http://tomatousb.org/tut:how-to- ... ato-for-total-noobs

数位天堂tomato讨论区,认真看,受益非浅.
http://digiland.tw/viewforum.php?id=42

补充内容 (2012-1-31 23:49):
TT核心配置方面,make menuconfig 后会生成.config 文件,此配置文件在编译TT过程中会被删除,需要处理一下:
mv config_base config_base_bak
cp .config config_base


补充内容 (2012-1-31 23:50):
还有就是默认情况下编译shibby 下transmission会到libevent时会出错,处理方法是在 src/router/libevent 下运行一下./Configure 生成配置文件,再回头继续编译,不用替换源码了。

评分

参与人数 12恩山币 +18 收起 理由
wsz*** + 1 终于知道怎么汉化UI了
laom*** + 5 感谢分享
lei*** + 1 一看就是觉得高端、大气、上档次!
jzm*** + 1 膜拜大师
qzhan*** + 1 泥马,真给力,我要顶!
BIZ*** + 1 GOOD!
fch*** + 1 赞一个,你是我的呕像!
西门*** + 1 很久没有人这么热心了!
春暖*** + 1 坚决和楼主站在一起
徐*** + 1 很好的编译教程
phant*** + 3 good
小*** + 1 支持楼主

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
10-30分钟能下载完源码,想必楼主的网速很不错

点评

www.xinvren.com/book/1/1623/ 惊悚乐园  发表于 2014-9-30 19:36
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

终于看到tomato的编译教程了,感谢楼主。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

收到

感觉开头装的组件稍有点乱
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
2# fugcon


我的网速是10M, 当时下载没有注意时间. 这是个估算值

打包后的源码大小为728M ..

顺便给大家提供一些有用的资料. 给喜欢研究的路友.

http://digiland.tw/viewtopic.php?id=372
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

谢谢楼主的教程,今晚下载完源码了,编译前有几点疑问:编译Tomato可不可以像编译Openwrt那样,只选择编译某型号路由用的固件呢,例如想编译适合中兴h618b用的;tomato的分支较多,那一个分支是中文界面的?希望楼主能解答一下。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
本帖最后由 sady 于 2011-10-8 09:19 编辑

不可以,tomato编译没有指定路由型号的选项, 如果针对特定的路由编译个性化的固件,先要了解此路由的硬件如cpu型号,网卡型号等,然后改核心配置文件与之相对应,再编译.

目前只有Shibby分支提供多语言切换功能,包含中文, 此功能为Shibby特有,内置一个类似于sed s/英文/中文/g 类的脚本替换程序.
不过普通的版本也可以汉化,将src/router/www下文件下载到电脑上, 然后手动翻译,再拷回去重新编译,就是中文界面了, 这不是技术活, 纯体力活,因为文件很多考验你的耐力. 也可以用现成的其他中文版中文页面文件,把它们拷出来,再对比替换. 这样可以大大降低工作量.
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

编译出错了,是按照教程的步骤一步一步来做的,下面是出错的截图,麻烦楼主看看问题出在那。

本帖子中包含更多资源

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

×
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
编译出错是再正常不过的事情, 不出错才是比较少见的

你的问题好像是出在找不到编译器. 可能是未指明路径.

试试先执行.

sudo ln -s ~/tomato_git/tomato/tools/brcm /opt/brcm
PATH=/opt/brcm/hndtools-mipsel-uclibc/bin:/opt/brcm/hndtools-mipsel-linux/binPATH

然后再重新make.
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

还是同样的错,先后用Ubuntu11.4和ylmf3.0来编译,都出现同样的问题,估计是在设置交叉编译变量环境这个步骤没设置对,等等上传个截图麻烦楼主帮忙看看。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

强人,好帖,一定要支持
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

帮顶了!!!!!!!!!!!!!!!!!!!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

版主还不快射精,真hold住了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

感谢楼主,看了楼主的教程也看了数位天堂上的编译教程,折腾编译N次,终于编译出来了。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

环境变量和交叉编译链就已经难倒一大批人了,何况很多源码本身存在问题
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

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

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-29 18:30

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

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