月度归档:2010年07月

项目马上要PK了,急啊!

最近比较折腾,huawei的项目马上要PK了,性能还未达标,公司内部已将其列为紧急状态,天天要更新数据报告。

这个项目是多频段GSM850/900/1800/1900+WCDMA850/900/1900/2100,主要难点在于阻抗适配,GSM1800频段对阻抗极为敏感,在容性区时TRP均能达标,放在感性区功率立马就降下来了。这还不是最令人郁闷的,更变态的不是提高功率而是如何降低TRP。功率高的话当然好,随之而来的是SAR测试超标,EU和US的标准不同,US标准更为严格,所以必须通过降低TRP把SAR降下来。

GSM900在容性区性能较好,但是调整低频会出现TRP达标而TIS最后信道不够的情况,目前尚未找到解决办法,眼看着PK日期一天天临近,实在是折磨啊 。

下午来了个Hengxin的项目,GSM900/1800+TD-SCDMA,客户急着赶时间给移动入库,所以明天必须将天线图纸发去深圳工厂线割,否则就误了客户的样品交期。时间紧迫,赶紧做无源治具调试,发现高频带宽窄,做1800单频还勉强合适。看下圆图,高频的mark点集中在第四象限,可以通过匹配电路调整。

匹配电路是两并两串,双L型,尝试在ANT端串电感,发现圆图位置基本上没变化。把靠近ANT端的匹配位置改为0欧直通,靠近PA端串4.7nH,对地的并位空置,看下S11图,高频带宽已经OK了,看下S21增益,辐射好强,哈哈搞定。

晚上安排测试SAR和无源,Hengxin项目明天应该可以发去线割了,呵呵

路由器安装squid实现透明代理

在vortex86上安装squid并设置为代理服务器,用起来感觉打开网页的速度有很大提升,突发奇想打算把squid装到路由器上做成透明代理,缓存代理80端口的访问。

belkin路由器,刷了Tomato Pandora 并设置好了optware环境,看了下optware的package里面包含了squid,直接ipkg就是了。

Tomato v1.27.0470 -R1 K26 USB Std
BusyBox v1.16.1 (2010-06-22 22:28:03 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

root@belkin7231-4:/tmp/home/root # ipkg install squid
Installing squid (2.6.23-1) to /opt/…
Downloading http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable/squid_2.6.23-1_mipsel.ipk

Configuring squid
create default cache and logs dir
FATAL: Could not determine fully qualified hostname.  Please set 'visible_hostname'

Squid Cache (Version 2.6.STABLE23): Terminated abnormally.
CPU Usage: 0.116 seconds = 0.059 user + 0.057 sys
Maximum Resident Size: 0 KB
Page faults with physical i/o: 0
Aborted

You should review the configuration file /opt/etc/squid/squid.conf,
make any necessary change, and complete the install by running –
/opt/etc/init.d/S80squid start

Successfully terminated.

安装完毕,直接/opt/etc/init.d/S80squid start,进程马上就挂掉了,估计是配置文件没搞好,研究下吧。

看下log文件里面的启动记录:

2010/07/20 18:31:43| Starting Squid Cache version 2.6.STABLE23 for mipsel-unknown-linux-gnu…
2010/07/20 18:31:43| Process ID 13579
2010/07/20 18:31:43| With 256 file descriptors available
2010/07/20 18:31:43| Using poll for the IO loop
2010/07/20 18:31:43| Performing DNS Tests…
2010/07/20 18:31:43| Successful DNS name lookup tests…
2010/07/20 18:31:43| DNS Socket created at 0.0.0.0, port 4543, FD 6
2010/07/20 18:31:43| Adding nameserver 210.22.70.225 from /etc/resolv.conf
2010/07/20 18:31:43| Adding nameserver 210.22.70.3 from /etc/resolv.conf
2010/07/20 18:31:43| Unlinkd pipe opened on FD 11
2010/07/20 18:31:43| Swap maxSize 102400 + 8192 KB, estimated 0 objects
2010/07/20 18:31:43| Target number of buckets: 425
2010/07/20 18:31:43| Using 8192 Store buckets
2010/07/20 18:31:43| Max Mem  size: 8192 KB
2010/07/20 18:31:43| Max Swap size: 102400 KB
2010/07/20 18:31:43| /opt/var/squid/cache/00: (2) No such file or directory
FATAL:  Failed to verify one of the swap directories, Check cache.log
 for details.  Run 'squid -z' to create swap directories
 if needed, or if running Squid for the first time.
Squid Cache (Version 2.6.STABLE23): Terminated abnormally.

哦,原来是没有初始化磁盘缓存文件夹,偶来初始化一下,然后在配置文件里指定下缓冲存取用户和组:

cache_effective_group nobody

初始化之后可以正常启动了,定义下服务器的地址和端口,transparent表示支持透明代理:http_port 192.168.2.1:8080 transparent

 设置下缓冲所使用的内存和磁盘缓存目录:
cache_mem 8 MB
cache_dir ufs /opt/var/squid/cache 40 16 256

定义防火墙规则:
http_access allow all

然后设置iptables防火墙规则:
iptables -t nat -A PREROUTING -i br0 -p tcp -s 192.168.2.0/24 –dport 80 -j REDIRECT –to-ports 8080

解释一下,ifconfig看下,由于之前在conf文件里定义了代理服务器的端口和地址,192.168.2.1:8080,,所以要把目标端口为80的访问重定向到192.168.2.1:8080,看了下192.168.2.1的网络接口是br0,所以itables规则应该写成上面的形式。

 /opt/etc/init.d/S80squid reload一下,发现已经生效了。

点击查看原图

使用效果如何,待我后续慢慢感受下,嘿嘿

cache_effective_group nobody
visible_hostname Tomato-Pandora
cache_mgr webmaster
cache_mem 15 MB
#cache_dir /opt/var/squid/cache null
cache_dir ufs /opt/var/squid/cache 40 16 256

http_access allow all
http_port 192.168.2.1:8080 transparent
cache_store_log none
cache_access_log none
#cache_log none
#iptables -t nat -A PREROUTING -i br0 -p tcp -s 192.168.2.0/24 –dport 80 -j REDIRECT –to-ports 8080

squid技巧整理

在Vortex86上面装了squid,做缓存代理服务器,试验下效果不错,顺便把一些技巧整理记下来,以后用的时候就不用放狗到处狂搜了!

1.squid 错误页面显示中文:
vi squid.conf
把# error_directory /usr/share/squid/errors/English
替换成下面内容
error_directory /usr/share/squid/errors/Simplify_Chinese

2.squid缓存错误页面的处理
Squid 默认将错误页面也缓存起来, 如果你先开启了一个不存在页面,然后你上传了页面, 由于被cahce住默认5分钟内都得到的是错误的页面,在squid中增加下面一行可以解决这个问题
negative_ttl 0 second  意思不缓存"连接失败"和"404 not Found"的页面.

优化Vortex86系统下的Debian5启动环境

Vortex86小主机性能比较弱,和台式机的CPU动辄双核四核CPU没法比,有必要精简下系统,去除不必要的组件。最大程度的压榨系统的性能是DIYer们孜孜不倦追求的境界。

看了一下,开机启动的服务有以下几个:

  • acpid
  • atd
  • cron
  • exim4
  • linux_logo
  • nfs-common
  • openbsd-inetd
  • rmnologin
  • rsyslog
  • samba
  • smartmontools
  • ssh
  • stop-bootlogd
  • webmin

1.先停掉exim4,然后禁止它开机自动启动。Exim4是Debian默认的邮件传输代理(MTA),下载机兼NAS不需要mail服务,这个东东完全可以去除。

2.已经设定了ssh登陆的logo界面,可以删除linuxlogo程序了。

3.我已经安装了samba,nfs-common就不需要了,禁止它开机启动。

4.关闭不需要的tty,编辑/etc/inittab,找到如下一段:
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

注释掉后面的四个,执行 init q 这个命令即可。q作为参数的含义:重新执行/etc/inittab中的命令

5.停掉并禁止开机启动rsyslog服务,性能为先,监控并记录日志就免了吧,有问题的话再开了看下。

暂时先这么搞,以后有想起来的再慢慢优化。

vortex86,Debian环境下编译安装mldonkey

安装了debian,发现源里面的mldoney是2.9版本的,有前车之鉴,知道这个版本修改download.ini文件后最容易出现无法启动的问题,直接安装新版3.0.1吧。

下载了mldonkey3.0.1的deb文件,dpkg安装下发现有一大堆的依赖关系,悲剧,还是本地编译吧。

先安装编译环境 apt-get install build-essential ,然后./configure一下发现还有包没安装。提示:   

  Checking system libraries.
———————————–
—– checking zlib (required)
checking for inflate in -lz… no
Zlib missing, did you install zlib and zlib-developer packages?
需要安装zlib和它的开发包,搜了一下,发现apt-get install zlib1g-dev即可解决。安装后再试一下,已经解决了!

———————————–
     Checking system libraries.
———————————–
—– checking zlib (required)
checking for inflate in -lz… no
Zlib missing, did you install zlib and zlib-developer packages?
debian-pristine:/mnt/gcc/mldonkey-3.0.1# cd
debian-pristine:~# screen
 – OpenFT                    disabled – currently not usable

Core features:
 – zlib (required)   enabled
 – threads           enabled
 – bzip2                     disabled
 – iconv             enabled
 – libmagic                  disabled
 – graphical stats           disabled

Compilers:
 – Ocaml version     3.11.1
 – gcc version       4.3.2
 – g++ version       4.3.2

Now execute 'make' to start compiling. Good luck!

To compile a static code execute:     make mlnet.static
To produce a release tarball execute: make release.mlnet.static
To clean the build directory execute: make maintainerclean

Compiling CryptoPP.cc can take several minutes, on slow machines up to half an hour.
 

OK,开始编译,CPU占用超高啊!

点击查看原图

啊哈,编译中又报错,忘了截图了,看出错提示貌似是跟ocaml有关,想了一下,类似问题之前遇到过,删除了mldonkey-3.0.1文件夹,重新解压mldonkey.tar文件,再configure,然后make就不会报错了。

debian-pristine:~# mlnet
2010/07/18 13:56:24 [cO] Starting MLDonkey 3.0.1 …
2010/07/18 13:56:24 [cO] Language ZH_CN, locale UTF-8, ulimit for open files 1024
2010/07/18 13:56:24 [cO] MLDonkey is working in /root/.mldonkey

2010/07/18 13:56:24 [cO] creating new MLDonkey base directory in /root/.mldonkey

2010/07/18 13:56:24 [cO] loaded language resource file
2010/07/18 13:56:24 [DNS] Resolving [debian-pristine] …
2010/07/18 13:56:24 [DNS] Resolving [www.mldonkey.org] …
2010/07/18 13:56:24 [cO] Logging in /root/.mldonkey/mlnet.log
2010/07/18 13:56:27 [dMain] Core started
 

哈哈,现在已经成功安装并运行MLDonkey 3.0.1啦!


 

用U盘给vortex86安装Debian

整了个vortex86的小玩具,配置为sis550单芯片/Pentium MMX 166/128MB SD内存(显卡动态分配8~32M)/SiS 550显卡/SiS 7019声卡/Realtek 8100网卡/3*USB1.1/1*LPT,采用5V3A的外接直流电源供电,尺寸13.6×11.8×6cm,刷了最新的BIOS之后主频为200Mhz。虽然性能差了点,但体积小又是X86架构,可以选择的系统也多,到手后找了个SATA2.5寸硬盘用转接卡转接为IDE44pin接上去,开始安装系统。

点击查看原图

点击查看原图

开机进BOIS发现可以支持USB-CDROM启动,把U盘量化为CDROM,插上去可以识别为USB光驱,但是启动失败,换了不同的ISO文件都是如此,看来这个方法行不通,必须得找USB光驱安装了。

放狗搜了一下,发现这个主机还可以从HDD模式启动,一不做二不休,把U盘量化为HDD模式,用ultraISO将iso镜像文件以hdd+模式写入,开机按F8选择hdd模式的U盘,顺利进入安装界面!

点击查看原图

可以接下来系统要检测CD-ROM设备,检测不到CD-ROM设备就自动拒绝往下安装了,悲剧啊!

正好手里还有个U盘,想了个办法,把另一个U盘加载同样的ISO文件量化为USB光驱的模式,瞒天过海希望能骗过固执的linux。

试验下,果然成功了!

点击查看原图

200Mhz的处理器,bogomips为400,性能和一般的NAS比起来还算不错,哈哈

processor : 0
vendor_id : SiS SiS SiS
cpu family : 5
model  : 0
model name : 05/00
stepping : 5
cpu MHz  : 200.010
fdiv_bug : no
hlt_bug  : no
f00f_bug : no
coma_bug : no
fpu  : yes
fpu_exception : yes
cpuid level : 1
wp  : yes
flags  : fpu tsc cx8 mmx
bogomips : 402.18
clflush size : 32
power management:

测试一下硬盘读取:

debian-pristine:~# hdparm -Tt /dev/hda3

/dev/hda3:
 Timing cached reads:    72 MB in  2.04 seconds =  35.31 MB/sec
 Timing buffered disk reads:   40 MB in  3.05 seconds =  13.11 MB/sec

几个常用的Debian更新源

deb http://ftp.debian.org/debian/

lenny main contrib non-free
deb-src http://ftp.debian.org/debian/

lenny main contrib non-free

deb http://ftp.tw.debian.org/debian/

lenny main contrib non-free
deb-src http://ftp.tw.debian.org/debian

lenny main contrib non-free

deb http://mirrors.163.com/debian/

lenny main contrib non-free
deb-src http://mirrors.163.com/debian

lenny main contrib non-free

deb http://mirrors.geekbone.org/debian/

lenny main contrib non-free
deb-src http://mirrors.geekbone.org/debian/

lenny main contrib non-free

deb http://ftp.us.debian.org/debian/

lenny main contrib non-free
deb-src http://ftp.us.debian.org/debian/

lenny main contrib non-free

deb http://mirror.dlut.edu.cn/debian/

lenny main contrib non-free
deb-src http://mirror.dlut.edu.cn/debian/

lenny main contrib non-free

deb http://debian.csie.ntu.edu.tw/debian/

lenny main contrib non-free
deb-src http://debian.csie.ntu.edu.tw/debian/

lenny main contrib non-free

deb http://mirrors.geekbone.org/debian/
lenny main
deb-src http://mirrors.geekbone.org/debian/
lenny main
 

Tomato固件下用iptables实现端口白名单功能

公司目前用的是TP-LINK家用无线路由,使用人数一多就频繁出现死机症状,每次都要去机房重启路由器,不胜其烦。

研究了一下传说中的企业级路由器,发现无外乎是IXP42X处理器加linux核心的固件,售价都在六七百元以上,功能多一些的路由器要价1K以上,本着为公司节约成本的考虑,偶打算用belkin路由器加第三方固件来实现比企业级路由器更为强悍更加灵活的功能。

基于linux的第三方开源固件大致有openwrt,ddwrt,tomato三大分支,openwrt功能过于强大过于专业,管理配置多有不便;ddwrt适合DIY玩家,tomato适合网吧及小型ISP用户,偶就选择tomato吧。

刷了Tomato Pandora
固件,ssh看下,发现内核已经更新为2.6.22了。由于要实现内网用户只能收发邮件,所以只能开放wan口的tcp53,25,110以及udp53端口。tomato的功能有限,通过路由器的web界面无法设置,只好ssh进去用iptables来做。

想到iptables里面INPUT定义为所有收到的并且目的地址为本机的报文都会经过这个链,而不管哪个接口进来的或者它往哪里去,就写了个规则出来:

iptables -I INPUT -j DROP
iptables -I INPUT -p tcp –dport 25 -j ACCEPT
iptables -I INPUT -p tcp –dport 110 -j ACCEPT
iptables -I INPUT -p tcp –dport 53 -j ACCEPT
iptables -I INPUT -p udp –dport 53 -j ACCEPT

试验一下居然把端口全都封杀了,甚至无法解析IP。

想了一下转发过滤不能在INPUT链上做,改在FORWARD上面来试试:

iptables -I FORWARD -j DROP
iptables -I FORWARD -p tcp –dport 25 -j ACCEPT
iptables -I FORWARD -p tcp –dport 110 -j ACCEPT
iptables -I FORWARD -p tcp –dport 53 -j ACCEPT
iptables -I FORWARD -p udp –dport 53 -j ACCEPT

还是不行,结果一样,所以端口全被封杀了。

得到论坛朋友指点,原来忘记了通信是双向的,应该用-o参数指定界面。嗯,指定wan口来写规则就可以达到目的。

看下路由器的网络接口:

root@belkin:/tmp/home/root# ifconfig
br0        Link encap:Ethernet  HWaddr 00:01:E3:0E:95:C4
           inet addr:192.168.2.1  Bcast:192.168.2.255  Mask:255.255.255.0
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:7684 errors:0 dropped:0 overruns:0 frame:0
           TX packets:7816 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:1337937 (1.2 MiB)  TX bytes:2623323 (2.5 MiB)

eth0       Link encap:Ethernet  HWaddr 00:01:E3:0E:95:C4
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:6007 errors:0 dropped:0 overruns:0 frame:0
           TX packets:6635 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:1612018 (1.5 MiB)  TX bytes:1377122 (1.3 MiB)
           Interrupt:5 Base address:0x2000

eth1       Link encap:Ethernet  HWaddr 00:01:E3:0E:95:C6
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:7699 errors:0 dropped:0 overruns:0 frame:383461
           TX packets:7976 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:1447927 (1.3 MiB)  TX bytes:2710136 (2.5 MiB)
           Interrupt:4 Base address:0x1000

lo         Link encap:Local Loopback
           inet addr:127.0.0.1  Mask:255.0.0.0
           UP LOOPBACK RUNNING MULTICAST  MTU:16436  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

vlan0      Link encap:Ethernet  HWaddr 00:01:E3:0E:95:C4
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:714 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:0 (0.0 B)  TX bytes:232670 (227.2 KiB)

vlan1      Link encap:Ethernet  HWaddr 00:01:E3:0E:95:C5
           inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:6007 errors:0 dropped:0 overruns:0 frame:0
           TX packets:5921 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:1503892 (1.4 MiB)  TX bytes:1144452 (1.0 MiB)


发现wan口对应的是vlan1,于是防火墙脚本应该这样写:

iptables -I FORWARD -o vlan1 -j DROP
iptables -I FORWARD -p udp –dport 53 -j ACCEPT
iptables -I FORWARD -p tcp –dport 53 -j ACCEPT
iptables -I FORWARD -p tcp –dport 25 -j ACCEPT
iptables -I FORWARD -p tcp –dport 110 -j ACCEPT

试验一下,成功!

Tomato Pandora firmware for Belkin 7231-4P

无意中发现Tomato Pandora已经支持belkin 7231-4P了,立马下载来试用一下尝尝鲜

看了一下,有3G版和VPN版两种,VPN版本不支持USB设备,并且精简了ssh,于是改刷3G版本,虽然偶不需要使用3G USB网卡,哈哈。

刷完看下界面,果然增加了许多东西,不错不错,不过偶最关注的还是USB和NAS。

点击查看原图

迫不及待插上U盘试下,很顺利地识别并挂载了!

点击查看原图

OK,偶来给路由器安装ipkg环境:

  1. 把U盘mount到jffs:mount /dev/sda1 /jffs
  2. 建立opt文件夹:mkdir /jffs/opt
  3. 将/jffs/opt挂载到/opt:mount -o bind /jffs/opt /opt
  4. 然后运行mkswap将刚刚建立的swapfile文件设置成swap文件:mkswap /jffs/Swapfile

然后就悲剧了,提示没有这个指令,估计作者把mkswap给精简掉了,偶先装optware环境吧。

比较懒,找了个自动安装脚本(http://pandoric.googlecode.com/svn/Pandora%20%e8%84%b1%e6%9c%ba%e8%bd%af%e4%bb%b6/optware-install.sh
),一键安装多快好省,哈哈

开始运行这个脚本:root@Belkin 7231-4P:/jffs# ./optware-install.sh
Checking system config …
Using 192.168.1.1 as default gateway.
Using the following nameserver(s):
nameserver 210.22.70.225
nameserver 210.22.70.3
Warning: local nameserver is different than gateway!
Check config or enter:
  sed -i s/192.168.*/192.168.1.1/ /tmp/resolv.conf
to correct this.

啊哈,居然提示我网关和DNS server的地址不一样!DNS难道非得和网关一样才能解析么?这叫什么逻辑哟!
打开这个脚本看下,删除了检测DNS的步骤,继续安装,成功!

嗯,很好很强大,这个脚本直接设置好了环境变量,直接ipkg安装就可以啦!安装busybox以便等下使用mkswap工具初始化swap

 root@Belkin 7231-4P:/jffs# ipkg install busybox
Installing busybox (1.10.3-1) to /opt/…
Downloading http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable/busybox_1.10.3-1_mipsel.ipk

Installing busybox-base (1.10.3-1) to /opt/…
Downloading http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable/busybox-base_1.10.3-1_mipsel.ipk

Installing busybox-links (1.10.3-1) to /opt/…
Downloading http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable/busybox-links_1.10.3-1_mipsel.ipk

Configuring busybox
Configuring busybox-base
Configuring busybox-links
update-alternatives: Linking //opt/bin/[ to /opt/bin/busybox
update-alternatives: Linking //opt/bin/[[ to /opt/bin/busybox
update-alternatives: Linking //opt/bin/arping to /opt/bin/busybox
update-alternatives: Linking //opt/bin/ash to /opt/bin/busybox
update-alternatives: Linking //opt/bin/awk to /opt/bin/busybox
update-alternatives: Linking //opt/bin/basename to /opt/bin/busybox
update-alternatives: Linking //opt/bin/bunzip2 to /opt/bin/busybox
update-alternatives: Linking //opt/bin/bzcat to /opt/bin/busybox
update-alternatives: Linking //opt/bin/bzip2 to /opt/bin/busybox
update-alternatives: Linking //opt/bin/cal to /opt/bin/busybox
update-alternatives: Linking //opt/bin/cat to /opt/bin/busybox
update-alternatives: Linking //opt/bin/chattr to /opt/bin/busybox
update-alternatives: Linking //opt/bin/chgrp to /opt/bin/busybox
update-alternatives: Linking //opt/bin/chmod to /opt/bin/busybox
update-alternatives: Linking //opt/bin/chown to /opt/bin/busybox
update-alternatives: Linking //opt/bin/chroot to /opt/bin/busybox
update-alternatives: Linking //opt/bin/chrt to /opt/bin/busybox
update-alternatives: Linking //opt/bin/chvt to /opt/bin/busybox
update-alternatives: Linking //opt/bin/cksum to /opt/bin/busybox
update-alternatives: Linking //opt/bin/clear to /opt/bin/busybox
update-alternatives: Linking //opt/bin/cmp to /opt/bin/busybox
update-alternatives: Linking //opt/bin/comm to /opt/bin/busybox
update-alternatives: Linking //opt/bin/cp to /opt/bin/busybox
update-alternatives: Linking //opt/bin/cpio to /opt/bin/busybox
update-alternatives: Linking //opt/bin/cut to /opt/bin/busybox
update-alternatives: Linking //opt/bin/date to /opt/bin/busybox
update-alternatives: Linking //opt/bin/dd to /opt/bin/busybox
update-alternatives: Linking //opt/bin/deallocvt to /opt/bin/busybox
update-alternatives: Linking //opt/bin/df to /opt/bin/busybox
update-alternatives: Linking //opt/bin/diff to /opt/bin/busybox
update-alternatives: Linking //opt/bin/dirname to /opt/bin/busybox
update-alternatives: Linking //opt/bin/dmesg to /opt/bin/busybox
update-alternatives: Linking //opt/bin/dos2unix to /opt/bin/busybox
update-alternatives: Linking //opt/bin/du to /opt/bin/busybox
update-alternatives: Linking //opt/bin/echo to /opt/bin/busybox
update-alternatives: Linking //opt/bin/ed to /opt/bin/busybox
update-alternatives: Linking //opt/bin/egrep to /opt/bin/busybox
update-alternatives: Linking //opt/bin/eject to /opt/bin/busybox
update-alternatives: Linking //opt/bin/env to /opt/bin/busybox
update-alternatives: Linking //opt/bin/ether-wake to /opt/bin/busybox
update-alternatives: Linking //opt/bin/expr to /opt/bin/busybox
update-alternatives: Linking //opt/bin/false to /opt/bin/busybox
update-alternatives: Linking //opt/bin/fgrep to /opt/bin/busybox
update-alternatives: Linking //opt/bin/find to /opt/bin/busybox
update-alternatives: Linking //opt/bin/free to /opt/bin/busybox
update-alternatives: Linking //opt/bin/grep to /opt/bin/busybox
update-alternatives: Linking //opt/bin/gunzip to /opt/bin/busybox
update-alternatives: Linking //opt/bin/gzip to /opt/bin/busybox
update-alternatives: Linking //opt/bin/head to /opt/bin/busybox
update-alternatives: Linking //opt/bin/hexdump to /opt/bin/busybox
update-alternatives: Linking //opt/bin/hostname to /opt/bin/busybox
update-alternatives: Linking //opt/bin/id to /opt/bin/busybox
update-alternatives: Linking //opt/bin/ifconfig to /opt/bin/busybox
update-alternatives: Linking //opt/bin/install to /opt/bin/busybox
update-alternatives: Linking //opt/bin/ip to /opt/bin/busybox
update-alternatives: Linking //opt/bin/ipcrm to /opt/bin/busybox
update-alternatives: Linking //opt/bin/ipcs to /opt/bin/busybox
update-alternatives: Linking //opt/bin/kill to /opt/bin/busybox
update-alternatives: Linking //opt/bin/killall to /opt/bin/busybox
update-alternatives: Linking //opt/bin/killall5 to /opt/bin/busybox
update-alternatives: Linking //opt/bin/less to /opt/bin/busybox
update-alternatives: Linking //opt/bin/ln to /opt/bin/busybox
update-alternatives: Linking //opt/bin/logger to /opt/bin/busybox
update-alternatives: Linking //opt/bin/logname to /opt/bin/busybox
update-alternatives: Linking //opt/bin/ls to /opt/bin/busybox
update-alternatives: Linking //opt/bin/lsattr to /opt/bin/busybox
update-alternatives: Linking //opt/bin/md5sum to /opt/bin/busybox
update-alternatives: Linking //opt/bin/mkdir to /opt/bin/busybox
update-alternatives: Linking //opt/bin/mkfifo to /opt/bin/busybox
update-alternatives: Linking //opt/bin/mknod to /opt/bin/busybox
update-alternatives: Linking //opt/bin/mount to /opt/bin/busybox
update-alternatives: Linking //opt/bin/mv to /opt/bin/busybox
update-alternatives: Linking //opt/bin/nc to /opt/bin/busybox
update-alternatives: Linking //opt/bin/netstat to /opt/bin/busybox
update-alternatives: Linking //opt/bin/nice to /opt/bin/busybox
update-alternatives: Linking //opt/bin/nmeter to /opt/bin/busybox
update-alternatives: Linking //opt/bin/nohup to /opt/bin/busybox
update-alternatives: Linking //opt/bin/od to /opt/bin/busybox
update-alternatives: Linking //opt/bin/openvt to /opt/bin/busybox
update-alternatives: Linking //opt/bin/patch to /opt/bin/busybox
update-alternatives: Linking //opt/bin/pidof to /opt/bin/busybox
update-alternatives: Linking //opt/bin/ping to /opt/bin/busybox
update-alternatives: Linking //opt/bin/ping6 to /opt/bin/busybox
update-alternatives: Linking //opt/bin/printf to /opt/bin/busybox
update-alternatives: Linking //opt/bin/ps to /opt/bin/busybox
update-alternatives: Linking //opt/bin/pwd to /opt/bin/busybox
update-alternatives: Linking //opt/bin/readlink to /opt/bin/busybox
update-alternatives: Linking //opt/bin/realpath to /opt/bin/busybox
update-alternatives: Linking //opt/bin/renice to /opt/bin/busybox
update-alternatives: Linking //opt/bin/reset to /opt/bin/busybox
update-alternatives: Linking //opt/bin/resize to /opt/bin/busybox
update-alternatives: Linking //opt/bin/rm to /opt/bin/busybox
update-alternatives: Linking //opt/bin/rmdir to /opt/bin/busybox
update-alternatives: Linking //opt/bin/script to /opt/bin/busybox
update-alternatives: Linking //opt/bin/sed to /opt/bin/busybox
update-alternatives: Linking //opt/bin/seq to /opt/bin/busybox
update-alternatives: Linking //opt/bin/sh to /opt/bin/busybox
update-alternatives: Linking //opt/bin/sha1sum to /opt/bin/busybox
update-alternatives: Linking //opt/bin/sleep to /opt/bin/busybox
update-alternatives: Linking //opt/bin/sort to /opt/bin/busybox
update-alternatives: Linking //opt/bin/stat to /opt/bin/busybox
update-alternatives: Linking //opt/bin/strings to /opt/bin/busybox
update-alternatives: Linking //opt/bin/stty to /opt/bin/busybox
update-alternatives: Linking //opt/bin/sync to /opt/bin/busybox
update-alternatives: Linking //opt/bin/tail to /opt/bin/busybox
update-alternatives: Linking //opt/bin/tar to /opt/bin/busybox
update-alternatives: Linking //opt/bin/tee to /opt/bin/busybox
update-alternatives: Linking //opt/bin/test to /opt/bin/busybox
update-alternatives: Linking //opt/bin/time to /opt/bin/busybox
update-alternatives: Linking //opt/bin/top to /opt/bin/busybox
update-alternatives: Linking //opt/bin/touch to /opt/bin/busybox
update-alternatives: Linking //opt/bin/tr to /opt/bin/busybox
update-alternatives: Linking //opt/bin/true to /opt/bin/busybox
update-alternatives: Linking //opt/bin/tty to /opt/bin/busybox
update-alternatives: Linking //opt/bin/umount to /opt/bin/busybox
update-alternatives: Linking //opt/bin/uname to /opt/bin/busybox
update-alternatives: Linking //opt/bin/uncompress to /opt/bin/busybox
update-alternatives: Linking //opt/bin/uniq to /opt/bin/busybox
update-alternatives: Linking //opt/bin/unix2dos to /opt/bin/busybox
update-alternatives: Linking //opt/bin/unzip to /opt/bin/busybox
update-alternatives: Linking //opt/bin/uptime to /opt/bin/busybox
update-alternatives: Linking //opt/bin/usleep to /opt/bin/busybox
update-alternatives: Linking //opt/bin/uudecode to /opt/bin/busybox
update-alternatives: Linking //opt/bin/uuencode to /opt/bin/busybox
update-alternatives: Linking //opt/bin/vi to /opt/bin/busybox
update-alternatives: Linking //opt/bin/watch to /opt/bin/busybox
update-alternatives: Linking //opt/bin/wc to /opt/bin/busybox
update-alternatives: Linking //opt/bin/which to /opt/bin/busybox
update-alternatives: Linking //opt/bin/who to /opt/bin/busybox
update-alternatives: Linking //opt/bin/whoami to /opt/bin/busybox
update-alternatives: Linking //opt/bin/xargs to /opt/bin/busybox
update-alternatives: Linking //opt/bin/yes to /opt/bin/busybox
update-alternatives: Linking //opt/bin/zcat to /opt/bin/busybox
update-alternatives: Linking //opt/libexec/syslogd to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/arp to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/fdisk to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/fsck to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/hdparm to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/httpd to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/hwclock to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/insmod to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/klogd to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/losetup to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/lsmod to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/mkswap to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/modprobe to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/pivot_root to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/rdate to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/rmmod to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/route to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/start-stop-daemon to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/swapoff to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/swapon to /opt/bin/busybox
update-alternatives: Linking //opt/sbin/sysctl to /opt/bin/busybox
Successfully terminated.
root@Belkin 7231-4P:/jffs# mkswap
BusyBox v1.10.3 (2010-05-21 00:45:35 UTC) multi-call binary

Usage: mkswap DEVICE

Prepare block device to be used as swap partition

root@Belkin 7231-4P:/jffs# mkswap /jffs/Swapfile
Setting up swapspace version 1, size = 67104768 bytes

root@Belkin 7231-4P:/jffs# swapon /jffs/Swapfile
root@Belkin 7231-4P:/jffs# free
              total         used         free       shared      buffers
  Mem:        62040        49472        12568            0         1892
 Swap:        64748            0        64748
Total:       126788        49472        77316

嗯,成功初始化swap并挂载它。

顺便把这些开机需要执行的指令丢到启动脚本里面去。

点击查看原图

 重启路由器,发现并没有自动挂载,大惑,dmesg看了下启动过程,发现系统启动到初始化USB storage设备大概需要6秒左右的时间,好吧,那就让它先sleep 10 ,这样应该就可以啦。

嗯,重启路由器之后自动按照脚本挂载USB设备到jffs并成功加载swap!

点击查看原图

 

贴一下偶的开机脚本和修改后的一键安装包。

sleep 10
mount /dev/sda1 /jffs
mount -o bind /jffs/opt /opt
sleep 3
swapon /jffs/Swapfile

ipkg环境的一键安装包:optware-install.rar

 

一时冲动,买了龙芯板子

一时冲动,在论坛里看见龙芯架构的路由板子开卖的消息,就拍下一块。

点击查看原图
点击查看原图

以下是卖家提供的信息:.
128M SDRAM, e-sata一个 sata板载一个(提供SATA电源支持), 16M
NOR flash
(TE28F128) , 4个10/100网口(IC PLUS),支持VLAN划分。 1个usb
1.1接口
。. 1个SD卡槽. cq8401 mips base 400Mhz 龙芯cpu , 1个mini-pci槽.一个reset按键。 TTL
排针的serial pin

软件提供
1:UBOOT源代码。
2:交叉编译环境
3:linux (openwrt
8.09 ported)
4:所有板上硬件的linux driver. 应用程序自己编译了(mipsel base)

拍下之后卖家告知SD读卡器是GPIO控制的,没有开发相关驱动,无法使用。USB又是1.1的,传输速度一定抓狂,手里没有SATA的硬盘,为此去买一个硬盘似乎很没必要,看了一下卖家发来的开发包,找不到config文件,郁闷。

在网上查了一下,debian官方没有提供针对龙芯的版本,民间倒是有人做出了debian包,估计解压到u盘然后chroot应该可以跑了,不知道需不需要打patch。还是算了吧,折腾点大众的东东比较合适,遇到问题也方便解决。

今天终于到货了,跟卖家协商一下,偶付了来回邮费把板子退回去了,以后买东西要查清楚再下手,再也不能被所谓的爱国芯之类的言论忽悠了。