2012年2月3日 星期五

tomato 編譯詳解

看這個帖子這前,請確認一下您能自己搞定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/tool​​s/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+xy 保存退出, 以便每次啟動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-mixvpn
  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/tomatovpn
  43.   origin/vpngui
  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 -VPN - (BT plus VPN) 
a Big - (Ext plus NOCAT plus NFS plus BT gui) 
n Mega - (Big + BT Client minus NOCAT) 
e VPN - (standard plus VPN, extra utilities and NTFS support) 
b Big-VPN - (Big plus VPN) 
o Mega-VPN - (Mega plus VPN 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 VPN (no usb) - (VPN with no USB support) 
w SD-VPN (no usb) - (VPN 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-VPN 
r2a MIPS Release 2 Big 
r2n MIPS Release 2 Mega 
r2e MIPS Release 2 VPN 
r2b MIPS Release 2 Big-VPN 
r2o MIPS Release 2 Mega-VPN 
r2z MIPS Release 2 AIO (for routers +8MB flash) 
r2v MIPS Release 2 VPN (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-VPN 
n60a Linksys E-series build Big 
n60n Linksys E-series build Mega 
n60e Linksys E-series build VPN 
n60b Linksys E-series build Big-VPN 
n60o Linksys E-series build Mega-VPN 
n60s Linksys E-series build Std with IPv6 
n60v Linksys E-series build VPN 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生成配置文件,再回頭繼續編譯,不用替換源碼了。



link from:http://www.right.com.cn/forum/thread-53623-1-1.html

What is Port Triggering?

If you have not read my explanation of port forwarding do so now. You can find it here.
Port triggering is pretty simple once you know what port forwarding is. Port Triggering is port forwarding with an on/off switch for the ports that have been forwarded. This on/off switch is turned on or off by data flowing out of a trigger port.
TriggerPacket.jpg


Let's say that there is a port triggering rule configured in the router. This port triggering rule says when data flows out on port 50 forward port 80. In the picture above you see data flowing from a computer to the internet on port 50.
TriggerForward.jpg


The router see's the traffic coming out of the router on port 50, and evaluates it's triggering rules. The router then forwards port 80 to the computer that sent out the data on port 50. It's important to realize that port 80 can only be forwarded to one computer at a time. If two computers were trying to send data out on port 50, there would be a conflict. What happened after that really depends upon which router you are running. One thing is for sure, port 80 would not be forwarded to both computers.
TriggerNoOut.jpg


The picture above shows that the data has quit being sent out of port 50. Programs do not send data if there is nothing to be sent, so data being sent out of port 50 is not guaranteed. The router keeps port 80 forwarded for a certain amount of time. How much time really depends upon the router.
TriggerNoForward.jpg


Once the router is done waiting, it quits forwarding port 80 to the computer that sent data out on port 50. This makes a port triggering configuration a tricky thing. The software that requires ports to be forwarded must first send data out of a port at a somewhat constant rate. If the software has a port that is constantly sending data out, then port triggering is possible. The length of time that the router keeps those ports open still needs to be taken into account. If the router times out between the gaps of outgoing data, the port forwarding connection will be severed. That is why so few programs support port triggering. What happens when you are trying to download a very large file? Well the software you have setup port triggering for may not keep sending data out of the trigger port. If it doesn't your router closes the incoming ports, and your download is interrupted.
Port Triggering is a little more secure than port forwarding, because the incoming ports are not open all the time. They are only open when a program is actively using the trigger port. Another thing to note, is that most port triggering setups do not require you to enter an internal ip address to forward the incoming ports to. This means that any computer on the network can use your port triggering setup. If two computers try to use the port triggering setup at the same time you will run into problems.

How to use simple speedtest in RaspberryPi CLI

  pi@ChunchaiRPI2:/tmp $  wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py --2023-06-26 10:4...