2007年4月23日星期一

做事情要讲究方法论,做群众工作也不例外

先看图:



呵呵,没啥说的了吧。

2007年4月19日星期四

Setting up cross-compiling environment for A1200

Introduction
介绍
It is not difficult to set up development environment for A1200 mobile phone in Fedora Core 6 Linux.

I will show you how to do it step by step.
在Fedora Core 6版本的Linux系统下面设置一套用于A1200手机的开发环境是不难的。

我会一步步地告诉你该怎么做。
1. Download or make crosstool-gcc-3.3.2-gli
bc-2.3.2-arm-linux-devel-0.42-1.*.rpm
1. 下载或自行编译生成 crosstool-gcc-3.3.2-gli bc-2.3.2-arm-linux-devel-0.42-1*.rpm
If your Linux is running on a 64 bit x86 system, you may download crosstool-gcc-3.3.2-glibc-2.3.2-arm-lin ux-devel-0.42-1.x86_64.rpm from here. This RPM is made by codeminders.

Or if your Linux is running on a 32 bit x86 system, you may download crosstool-gcc-3.3.2-glibc-2.3.2-arm-lin ux-devel-0.42-1.i386.rpm from here or here or here. This RPM is made by me based on SRPM provided by codeminders.

Or if you want to compile and make this package by yourself, you may do the following:
  1. Install gcc 3.2.3. (gcc 3.2 is used to make crosstool-gcc-3.3.2. Although you can not find gcc 3.2 in Fedora Core 6 software package list, but you can get it from Fedora Core 5 software download site and manually install it.)
  1. Download compat-gc c-32-3.2.3-56.fc5.i386.rpm from official Fedora Core 5 Download site.
  2. As root user,
  3. run rpm -vih compat-gcc-32-3.2.3*.rpm
  1. Download crosstool-gcc-3.3.2-gli bc-2.3.2-0.42-1.src.rpm from here.
  2. As root user,
  3. Run rpm -vih crosstool*.src.rpm
  4. Run cd /usr/src/redhat/SPECS
  5. Run rpmbuild -bb crosstool*.spec

Then, you can find the package in /usr/src/redhat/RPMS/ directory.

如果你的Linux运行在64位的x86系统上,你可以从这里下载crosstool-gcc-3.3.2-glibc-2.3.2-arm-lin ux-devel-0.42-1.x86_64.rpm。这个RPM是codeminders制作的。

或者如果你的Linux运行在32位的x86系统上,你可以从这里这里这里下载crosstool-gcc-3.3.2-glibc-2.3.2-arm-lin ux-devel-0.42-1.i386.rpm。这个RPM是我根据codeminders提供的SRPM制作的。

或者如果你想要自己编译并生成这个安装包,你可以这样做:
  1. 安装gcc 3.2.3. (编译crosstool-gcc-3.3.2本身需要用到gcc 3.2。 虽然在Fedora Core 6的软件包里是找不到gcc 3.2,但是我们可以从Fedora Core 5的软件包下载网站上找到它,并且可以手工进行安装。)
    1. Fedora Core 5的官方网站下载compat-gc c-32-3.2.3-56.fc5.i386.rpm
    2. 以超级用户的身份,
    3. 执行rpm -vih compat-gcc-32-3.2.3*.rpm
  2. 这里下载crosstool-gcc-3.3.2-gli bc-2.3.2-0.42-1.src.rpm
  3. 以超级用户的身份,
  4. 执行 rpm -vih crosstool*.src.rpm
  5. 执行 cd /usr/src/redhat/SPECS
  6. 执行 rpmbuild -bb crosstool*.spec
于是,你就可以在/usr/src/redhat/RPMS/目录下找到编译生成的安装包了.
2. Install cross-compiler
2. 安装交叉编译器
  1. As root user,
  2. Run rpm -vih crosstool*devel*.rpm
  3. Create crosstool.sh in /etc/profile.d directory
  1. Run chmod a+x /etc/profile.d/crosstool.sh
  2. Run /etc/profile.d/crosstool.sh

Content of crosstool.sh should be:
  1. 以超级用户的身份,
  2. 执行 rpm -vih crosstool*devel*.rpm
  3. /etc/profile.d目录下创建crosstool.sh文件
  1. 执行chmod a+x /etc/profile.d/crosstool.sh
  2. 执行/etc/profile.d/crosstool.sh

把这些作为crosstool.sh文件的内容:

if ! echo ${PATH} | /bin/grep -q /usr/crosstool/gcc-3.3.2-glibc-2.3.2/arm-linux/bin ; then
PATH=/usr/crosstool/gcc-3.3.2-glibc-2.3.2/arm-linux/bin:${PATH}
fi


3. Install librarys and header files
3. 安装库文件和头文件
  1. Download dev-ezx-0.2.0.tgz from here. This is the unofficial SDK reverse-engineered by Sam Revitch.
  2. Extract it to any place (for example, /usr/local) you like .
  3. Copy the full contents (including sub-directories) of /usr/lib from your phone to dev-ezx-0.2.0/lib.
  4. Change to directory dev-ezx-0.2.0/moc.
  5. Run make
  6. Download ezx-sdk.tar.gz from here or here. This is the official SDK leaked from Motorola.
  7. Extract doc directory to dev-ezx-0.2.0/
  8. Extract all files inside include directory to dev-ezx-0.2.0/include/ezx directory, if files with the same name already exist, replace them.
  9. Modify ezxres.h to change "QPixmap getIcon(char const*);" to "QPixmap getIcon(char const*, bool);".
  10. Rename directory dev-ezx-0.2.0 to ezx-sdk or any other name you like.

  1. 这里下载dev-ezx-0.2.0.tgz。这是Sam Revitch 通过逆向工程的办法自己做的非官方SDK。
  2. 把它展开到任意的目录(例如,/usr/local)下。
  3. 拷贝你手机上/usr/lib目录下的所有内容(含子目录)到dev-ezx-0.2.0/lib
  4. 进入dev-ezx-0.2.0/moc目录。
  5. 执行make
  6. 这里或这里下载ezx-sdk.tar.gz。这是泄露出来的摩托罗拉公司的官方SDK。
  7. 展开其中的doc目录到dev-ezx-0.2.0/
  8. include目录中的所有文件展开到dev-ezx-0.2.0/include/ezx目录,如遇有同名文件,覆盖之。
  9. 修改ezxres.h文件,将“QPixmap getIcon(char const*);”改为“QPixmap getIcon(char const*, bool);
  10. 将目录dev-ezx-0.2.0改名为ezx-sdk或其它任何你喜欢的名字。
4. Build helloworld to verify your development environment
4. 编译helloworld以验证你的开发环境
To verify your development environment, you can try to compile the helloworld sample application.
  1. Change to directory helloworld.
  2. Modify Makefile
    • Change LIBS from "-lezxappbase-xscale-r -lqte-mt-xscale-r -lezxjpeg-xscale-r -lezxnotification-xscale-r" to "-lezxappbase -lqte-mt -lezxjpeg -lezxpm -lipp-jp -lipp-miscGen -lezxappsdk -lezxopenwindow"
  3. Download test2.rar from here . This is a sample provided by yan0.
  4. Extract (you may need to run rpm -ivh http://rpm.livna.org/livna-rele ase-6.rpm and yum install unrar first if unrar not installed yet) test2.cpp and rename it to helloworld.cpp
  5. Run make clean
  6. Run make
  7. Run make dist

为了验证你的开发环境,你可以尝试编译helloworld程序。
  1. 进入helloworld目录。
  2. 修改Makefile文件。
    • LIBS由“-lezxappbase-xscale-r -lqte-mt-xscale-r -lezxjpeg-xscale-r -lezxnotification-xscale-r”修改为“-lezxappbase -lqte-mt -lezxjpeg -lezxpm -lipp-jp -lipp-miscGen -lezxappsdk -lezxopenwindow
  3. 这里下载test2.rar。这是yan0写的样例程序。
  4. 展开(如果你没有unrar那么你需要先执行rpm -ivh http://rpm.livna.org/livna-rele ase-6.rpmyum install unrar以安装unrar)其中的test2.cpp文件并改名为helloworld.cpp
  5. 执行 make clean
  6. 执行 make
  7. 执行 make dist

5. Run helloworld from inside your phone
5. 在你的手机上运行helloworld
By default USBLAN driver should be already include in Linux kernel.

To connect to your phone, you may follow these steps:
  1. Run ifconfig -a and check if "usb0" is there.
  2. If "usb0" is there, run this command to configure IP address: ifconfig usb0 192.168.1.1 netmask 255.255.255.248 up
  3. Then you can access your phone through IP address 192.168.1.2
  4. If you want to run any application on your phone when you are telneting to it, you need to run this command on your phone first: ". /home/native/.profile"

缺省情况下,USBLAN的驱动已经包含在Linux的kernel中了。

为了连接到你的手机,可以这样做:
  1. 执行ifconfig -a然后检查是不是能看到“usb0”。
  2. 如果能看到“usb0”,执行这个命令来设置IP地址:ifconfig usb0 192.168.1.1 netmask 255.255.255.248 up
  3. 然后你就可以通过192.168.1.2这个地址来访问你的手机了。
  4. 如果想直接telnet进手机后从命令行执行程序,你需要先在手机上执行:“. /home/native/.profile”。
6. Use helloworld as template, develop your own application
6. 把helloworld作为模板,开发你自己的应用
Start your own adventure!
开始你自己的探索之路吧!

2007年4月12日星期四

Fixing MotoVision on A1200

Introduction 介绍

Motovision is an application that can run on some Motorola mobile phones, such as A780, but failed to run on A1200. However, it is not too difficult to fix this issue. I fixed it by writing a TCL script acting as a middle-man between linux-side part and windows-side part of MotoVision. This is a quick and dirty fix, as a temporary solution.

MotoVision可以运行在摩托罗拉的一些手机上,比如A780,但是在A1200上却不行。解决这个问题不是很困难。我写了一个TCL脚本来插在MotoVision的linux端程序和Windows端程序之间,从而给出了一个临时的解决方案。
1. Downloading 1. 下载

You need to download the following:

  • MotoVision, which could be downloaded from various sources.
  • USBLAN driver. I recommend latest official version which could be downloaded from here after register and login.
  • Modified MVDS.exe. You can do it yourself, just replace "169.254.142.2" with "127.000.000.1" in any editor with binary editing mode, then save it as MVDS_a1200.exe. I prepared an already modified one which can be downloaded from here.
  • TCL environment, which will be used to run the TCL script. You may download it from here or other places.
  • The TCL script (mv_a1200.tcl) I wrote could be downloaded from here.

需要下载这些东西:

  • MotoVision本身可以从很多地方下载到。
  • USBLAN的驱动程序可以从很多地方下载到。建议使用Motorola的最新官方版本,下载地址在摩托罗拉网站上,需要注册并登录。
  • 修改后的MVDS.exe。你可以自己修改,用支持二进制格式的编辑器把其中的"169.254.142.2"替换成"127.000.000.1"就行了,改好之后可以改名为MVDS_a1200.exe。我准备了一个已经修改好的,可以从这里下载。
  • 用来执行TCL脚本的TCL运行环境。可以从这里 或者其它地方下载到。
  • 我写的TCL脚本mv_a1200.tcl可以从这里下载。
2. Install 2. 安装

Installation is easy, but there are a few things you may be careful:

  • It is better to install latest official version of USBLAN driver, rather than install other versions descripted in MotoVision installation steps.
  • I recommend installing inetd on you mobile phone, installation steps could be found in my previous blogs. So you can telnet into the phone and terminate motovision process whenever needed, by issueing ps -e and kill commands.
  • mv_a1200.tcl could be saved in any place after downloading. You may use any text editor to open this file and modify these two variable settings: phoneIpAddress and frameInterval. The former is the IP address of your A1200. The latter is an interval in mille-seconds, greater value makes the refreshing of video slower, and at the same time consums less CPU cycle.

安装是很简单的。有几点值得注意:

  • 安装最新官方版本的USBLAN驱动比安装很多MotoVision安装说明中讲的其它版本更好。
  • 建议根据我之前的博客文章在手机上安装inetd。从而可以在需要的时候telnet进手机来用ps -ekill终止掉不需要的motovision进程。
  • 下载的mv_a1200.tcl可以保存在任意地址,可以用文本编辑器打开来修改其中的两个参数:phoneIpAddressframeInterval。前者是手机的IP地址,后者是以毫秒为单位的间隔时间,值越大则画面更新越慢,同时对机器CPU的占用也越小。
3. Usage 3. 使用

To start, follow these steps:

  1. Connect your phone to your computer, make sure that you can ping to your phone.
  2. Run motovision on your phone.
  3. Open a command prompt window, and run: tclsh mv_a1200.tcl. tclsh.exe is located in the bin directory of your TCL installation.
  4. Double click to run MVDS_a1200.exe.
  5. Minimize MVDS_a1200.exe window.

To pause, follow these steps:

  1. Switch to the command prompt window running mv_a1200.tcl, press Ctrl-C.
  2. If the program does not respond to Ctrl-C, open task manager and end the task named tclsh.

You don't need to terminate MVDS_a1200.exe.

To resume, follow these steps:

  1. Switch to the command prompt window running mv_a1200.tcl, run tclsh mv_a1200.tcl again.

You don't need to restart MVDS_a1200.exe or motovision.

To terminate motovision process running in your phone, follow these steps:

  1. Telnet into your phone.
  2. run ps -e and find out the PID of motovision process
  3. run kill <PID>. Replace the <PID> here with the real PID of motovision process.

按这个步骤启动:

  1. 把手机连接到电脑,确保能ping通手机。
  2. 在手机上启动motovision。
  3. 在电脑上打开一个命令行窗口,执行:tclsh mv_a1200.tcltclsh.exe在你安装好的TCL环境的bin目录下。
  4. 双击执行MVDS_a1200.exe
  5. 最小化MVDS_a1200.exe的窗口。

按这个步骤暂停:

  1. 在运行mv_a1200.tcl的窗口中,按Ctrl-C。
  2. 如果按Ctrl-C没反应,打开任务管理窗口,终止掉名为tclsh的进程。

不需要终止MVDS_a1200.exe

按这个步骤继续:

  1. 在运行mv_a1200.tcl的窗口中,再次执行tclsh mv_a1200.tcl

不需要重新启动MVDS_a1200.exe或者motovision

按这个步骤可以终止手机中的motovision进程:

  1. Telnet进你的手机
  2. 运行ps -e找出motovision进程的PID号码
  3. 运行kill <PID>。这里的<PID>motovision的实际PID号码代替。
4. Known Issues 4. 已知问题
  • 1/3 of the video area is black.
  • Consumes a lot of CPU.
  • Video refreshing is slow.
  • mv_a1200.tcl will report error messages if motovision or MVDS_a1200.exe terminated unexpectedly, or if network disconnected.
  • 大约1/3的视频区域是全黑的。
  • 占用CPU比较多,毕竟是TCL脚本语言写的。
  • 画面刷新慢,毕竟是TCL脚本语言写的。
  • motovisionMVDS_a1200.exe意外停止时,或者当网络中断时,mv_a1200.tcl会报错。
5. Your feedback and help are welcome 5. 欢迎反馈和帮助
  • Welcome your feedback.
  • Welcome your modification to mv_a1200.tcl to make it better.
  • Welcome your help to provide or modify or re-write the source code of MotoVision itslef. I don't have the source code, and I don't have compiling environment (yet). But I believe that the solution I described here is just a temporary one.
  • 欢迎反馈。
  • 欢迎修改mv_a1200.tcl让它更好用。
  • 欢迎提供、修改、重写MotoVision的源代码。我自己没有源代码,(目前)也没有编译环境。但是我相信,我提供的这个方案只是临时的。

2007年4月10日星期二

批评而不是发泄

有一次坐地铁,不远处传来一位中年妇女的声音,“你自己没脑子的啊?”,“人家叫你做什么你就做什么啊?”,“叫你跳到地铁下面去你跳不跳的啦?”。 乍一听我还以为是有人在吵架,比如谁占了谁座位,要么就是谁的脚被踩了。扭头一看,却发现原来是一位母亲在教训自己的小孩。仔细听了听,似乎是因为小孩听了同学的话做了件什么事情结果遭到了老师的批评。

不仅仅是小孩子做错了事情,很多时候我们都需要对他人提出批评,至少是表达抱怨。批评固然是应该的,但是如果都像那位母亲一样以斥责的口吻来展开一场口水讨伐,效果肯定不好。

关键在于,我们要分清楚批评与发泄的区别。批评是为了别人好,是为了解决问题,是有明确的目的的。发泄则是为了出自己胸中一口恶气,获得口头之愉快,让对方灰头土脸无地自容。像地铁里那位母亲,本来她应该对自己的小孩进行批评教育,引导小孩按正确的方法去做事情。可实际上呢,她只不过是在发泄自己对小孩“不争气”的不满,发泄起来固然痛快,小孩也不可能有什么反驳,只能任由母亲酣畅淋漓地斥责,可是这能达到最好的效果吗?当然不能。所以,这位母亲是自私的,为了自己的痛快,不顾对孩子的正确教育方法。

在日常生活中,类似的场景也很多。比如,朋友们一起去饭店吃饭,结果由于服务不规范、卫生不好、饭菜质量有问题、等待时间太长等等原因,往往需要向饭店提出抱怨、批评、投诉。在这种情况下,特别要掌握好分寸。因为我们的目的是吃顿好饭,营造朋友之间融洽的聚会气氛,如果一味地把发泄自身不满放在首位,固然可以出气,但是考虑一下你身边的朋友们吧,他们大老远跑了来可不是为了观看你如何有理有据地训斥一个乡下来的服务生。所以,出现纠纷时一定要明确自己的目的,抓住要矛盾,尽快找到一个解决办法才是重要的。何况万一碰到一个油嘴滑舌之人,争来争去只会越争怨气越大,连发泄的目的都达不到。

所以,我们要用批评作为手段,达到合理的目的,而不要贪图发泄的痛快。特别是在教育小孩的时候,做出生气的样子是需要的,但是借教育的名义发泄自己的脾气是不好的。有一个很简单的办法来检验自己是不是在借机发泄,那就是看看自己说的话里面“反问句”和“陈述句”的比例。对小孩子应该尽量用“陈述句”,少用“反问句”。心平气和的批评教育应该是以“陈述句”为主。