2011年4月12日 星期二

Beagleboard Hibernation DEMO

I gave a talk in OSDC. But I did not provide _visible_ demo by that time.
Now, seeing is believing.
hibernation demo

The idea behind this technology is not something new. It's based on hibernation.
Special thanks for walkingice's help out on filming this, CATCAN's sponsor on LCD expansion board.

2011年3月29日 星期二

Alternative use of Openmoko debug board

If you have an openmoko debug board, don't throw it away as recycling.

By combining om-debugboard and MOSFET drivers, you can issue commands to power on/off your device. But why do so?

Sometimes, when a system such as android is in development, system library would be crashed from time to time. Even adbd is down. At this moment, what you can do is to reset the device through power on/off. But this usually requires manual operation. Think about another scenario, if you want to run CTS on android device, you of course prefer everything is automatic. You definitely need an approach to shutdown the power of your device or turn it on.

The keyword is openmoko debug board, relay leg and MOSEFT drivers.

Thanks my bro's help out and his lab from NTUST. The corresponding circuit is simple enough. I will make schematic later. Since my TODO list can't be added any more options recently. :(

The way to control the GPIO on debugboard is easy. libftdi provides many features on this. The easiest approach is to enable bitbang mode. I implemented a simple program to control GPIO(TDO pin) output.
You can download it here:


2010年12月1日 星期三

Make Beagleboard to Be Hibernated

Previously, there's a Japanese company called Ubiquitous. It achieves very impressive demo which makes machine's boot time as one second. Its primitive idea is based on hibernation. IMHO, this solution is not _generic_ enough. It means that, the porting for platform would take a lot of effort. So it might be better to use more generic solution to achieve hibernation.

However, Hiroshi did a good job on improving boot time for Meego platform.
He gave a talk on LinuxConf in Japan. After his experiments, the boot time could be reduced about 3 seconds at some certain points.


or you can build the slide locally:

git clone git://gitorious.org/improving-meego-boot-up-time/t2t.git

Fortunately, his target platform is N900 whose CPU core is also ARM cortex A8 (OMAP3430). So, Beagleboard should be worked on hibernation. After some modification, either SWSUSP or TuxOnIce can work on Beagleboard.

Here is the result:

root@beagleboard:~# echo disk >/sys/power/state
[ 97.613098] Initiating a hibernation cycle.
[ 97.617980] Failed to launch userspace program '/usr/local/sbin/tuxoniceui_text': Error -2
[ 97.626403] Launch userspace program failed.
[ 97.630767] Freezing processes & syncing filesystems.
[ 97.635864] Stopping fuse filesystems.
[ 97.639648] Freezing user space processes ... (elapsed 0.00 seconds) done.
[ 99.313568] Stopping normal filesystems.
[ 99.379211] Freezing remaining freezable tasks ... (elapsed 0.00 seconds) done.
[ 99.435852] Preparing Image. Try 1.
[ 99.440734] Restarting normal filesystems.
[ 99.466796] Stopping fuse filesystems.
[ 99.470611] Freezing user space processes ... (elapsed 0.00 seconds) done.
[ 99.532409] Stopping normal filesystems.
[ 99.590179] Freezing remaining freezable tasks ... (elapsed 0.00 seconds) done.
[ 99.651702] Starting to save the image..
[ 99.655670] Writing caches...
[ 100.171966] ...20%...40%...60%...80%
[ 102.023406] Doing atomic copy/restore.
[ 102.027221] Suspending console(s) (use no_console_suspend to debug)
[ 102.906646] nand_resume called for a chip which is not in suspended state
[ 102.939483] Post atomic.
[ 102.942047] Writing kernel & process data...
[ 103.593719] ...20%...40%...60%...80%
[ 104.767242] Power down.
[ 104.769897] System halted.

[ 14.434020] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 1
[ 14.443267] TuxOnIce 3.2-rc2 (http://tuxonice.net)
[ 14.449829] TuxOnIce: Image found.
[ 14.982788] Failed to launch userspace program '/usr/local/sbin/tuxoniceui_text': Error -2
[ 14.991149] Launch userspace program failed.
[ 14.995513] Stopping fuse filesystems.
[ 14.999328] Freezing user space processes ... (elapsed 0.00 seconds) done.
[ 15.006591] Stopping normal filesystems.
[ 15.010559] Freezing remaining freezable tasks ... (elapsed 0.00 seconds) done.
[ 15.032104] Reading kernel & process data...
[ 15.420349] ...20%...40%...60%...80%
[ 15.822692] Atomic restore.
[ 15.825622] Doing atomic copy/restore.
[ 15.829376] Suspending console(s) (use no_console_suspend to debug)
[ 16.302551] omapdss DISPC error: SYNC_LOST, disabling LCD
[ 16.849487] nand_resume called for a chip which is not in suspended state
[ 17.184478] Post atomic.
[ 17.187103] Reading caches...
[ 18.130859] ...20%...40%...60%...80%
[ 18.612609] Cleaning up...
[ 18.616302] Restarting all filesystems ...
[ 18.620452] Restarting tasks ... Restarting tasks ... done.
[ 18.679138] TuxOnIce debugging info:
[ 18.679138] - TuxOnIce core : 3.2-rc2
[ 18.679168] - Kernel Version :
[ 18.679168] - Compiler vers. : 4.4
[ 18.679168] - Attempt number : 3
[ 18.679168] - Parameters : 0 667648 0 0 0 0
[ 18.679199] - Overall expected compression percentage: 0.
[ 18.679199] - Compressor is 'lzo'.
[ 18.679199] Compressed 52920320 bytes into 16659760 (68 percent compression).
[ 18.679229] - Block I/O active.
[ 18.679229] Used 4110 pages from swap on /dev/......
[ 18.679229] - Max outstanding reads 404. Max writes 195.
[ 18.679229] Memory_needed: 1024 x (4096 + 200 + 72) = 4472832 bytes.
[ 18.679260] Free mem throttle point reached 0.
[ 18.679260] - Swap Allocator enabled.
[ 18.679260] Swap available for image: 34136 pages.
[ 18.679290] - File Allocator active.
[ 18.679290] Storage available for image: 0 pages.
[ 18.679290] - I/O speed: Write 12 MB/s, Read 22 MB/s.
[ 18.679290] - Extra pages : 0 used/2000.
[ 18.679321] - Result : Succeeded.

Obviously, the boot time has a lot of space to improve. But it a first step to hack hibernation. And thanks Hiroshi's suggestion to make this working. :)

2010年7月13日 星期二

Power is not enough

Eventually, I got damn-spare time to post something interesting.
Last update was posted in the last year. It's so obvious to see
how busy/lazy I was in the past half year.

Tick and I are managed to build a robot project based on Beagleboard. We plan to share this project and concepts behind this on the event of COSCUP.

Well, I can say so far, the most tough work is not writing software to control robot. Instead, it's all about hardware such as providing power to servos. The ultimate goal is to make everything on robot wireless such as communication and power supply. Of course high capacity battery becomes the only option. Initially, we tried Ni-MH battery bought from RC car store. Even battery is full, it can't drive all revolute joints (servos). So we need plan B. :(

Occasionally, I found lead acid battery might be the candidate. After go shopping in the Guang-Hua market, Its voltage and capacity and size are all satisfied with our requirement. Most of important, it could drive all servos, totally 18 servos. Here is snapshot of the battery and debut robot.

2009年12月30日 星期三

My blood has whisky

馬上要邁入"twenty ten"了, 回頭看看這一年
失去了不少, 也得到了很多
關於30歲這一年, 我一直在想, Peter Pan他30的時候會不會也跟我
一樣徬徨, 猶豫著結與不結的抉擇, 生氣著台北房子貴的離譜

就這樣吧, 跟著心走, 隨遇而安

可能是因為要跨年的關係, 加上晚上剛解完的issue
我決定要好好來慰勞一下自己, 所以我就跑去敗了三瓶whisky

為什麼是whisky? 很簡單, 我生下來就是whisky控

左上角的酒, 應該是我目前買的最貴的whisky, Ardbeg, 味道我之前有試過
帶有很濃的泥煤味, 但這種味道則是見人見智, 不是每個人都喜歡
我買的是"almost there"的年份

第二瓶, Highland Park, 老實說, 我沒喝過, 是老闆說值得試試的酒
而且是舊瓶裝, 聽說新瓶跟舊瓶的味道不一樣
那一種好? 我想你應該猜得到

最後一瓶就是我的最愛啦, 目前啦, 余市十五年, Nikka single malt
一想到跨年可以品嘗這些酒, 我身體都熱了起來

2009年12月10日 星期四

Motion Sensor Demo on Beagleboard

If you saw my previous post, it was mentioned my next step is to integrate this 3-axis accelerometer into Android. To prove my implementation could work flawlessly, I ask my colleague, Jeremy to record the following clip.

The demo application is called 3D Level.

The HAL implementation could be found here:

It's based on Michael's porting on Android for Openmoko GTA02.

2009年11月30日 星期一

Build 3-axis Accelerometer on Beagleboard from Scratch

First of all, I would like to thanks Jerry, who is the project manager from STMicroelectronic Taiwan branch. He sponsored 0xlab couple chips of LIS302DL, which is a 3-axis accelerometer device. And Neo (YOSUN's FAE) provides me a fixture for this device. So everything is ready for me to make it work on the Beagleboard.

- LIS302DL
You probably feel it is looked familiar. Yes, this chip is the same motion sensor as Openmoko Freerunner used. The only difference is that its interface would be adopted I2C instead of 3-wire SPI for Beagleboard.

- Power source for LIS302DL
If you probe the schematic of Beagleboard, the expansion header (J3) reserved DC 5v and VIO 1v8 respectively. You can leverage these as the power source for your own devices. Unfortunately, the range of Vdd for LIS302DL is located between 2v16 and 3v6. DC 5v is not fulfilled for this case. So tinker DC 5v is needed. Zerner diode can regulator the voltage as you want. In this case, one reistor and one zerner diode are required.

- TSX0102
It's very Beagleboard specific or you can say it's TI specific. If you want to add an external device on the Beagleboard, a voltage level translator might be necessity. Since most of current devices, the least signaling I/O would be around 2v6. But Beagleboard only provides 1v8 voltage as I/O signaling. The real reason behind this I don't know about it. Maybe for the power consumption issue. Or can I call it's a kind of "product placement"? :p

- Interrupt
Basically, all the I/O to the host controller, Beagleboard, are based on 1v8 signaling. The I2C communication is through TXS0102 to talk between host and device. But there is one more line for one-directional signaling, that is interrupt from LIS302DL to host. My former colleague, Dkay, suggested a simple approach to reslove this. A diode and two pull high resistors would be enough.

- Kernel driver
The corresponding kernel driver is put here:


Edit your kernel config with CONFIG_INPUT_ST_MOTION_SENSOR=y.

The following picture is the overall picture for this work. Although it's not pretty, but it works perfectly. With evtest utility, I can retrieve input events from LIS302DL device.

# ./evtest /dev/input/event1
Input driver version is 1.0.0
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "LIS302DL Motion Sensor"
Supported events:
Event type 0 (Sync)
Event type 3 (Absolute)
Event code 0 (X)
Value 3
Min 0
Max 0
Event code 1 (Y)
Value 245
Min 0
Max 0
Event code 2 (Z)
Value 56
Min 0
Max 0
Testing ... (interrupt to exit)
Event: time 12.269714, type 3 (Absolute), code 0 (X), value 4
Event: time 12.269989, type 3 (Absolute), code 1 (Y), value 245
Event: time 12.270233, type 3 (Absolute), code 2 (Z), value 55
Event: time 12.270233, -------------- Report Sync ------------
Event: time 12.273864, type 3 (Absolute), code 0 (X), value 3
Event: time 12.274200, type 3 (Absolute), code 2 (Z), value 56
Event: time 12.274200, -------------- Report Sync ------------
Event: time 12.284332, type 3 (Absolute), code 0 (X), value 4
Event: time 12.284545, type 3 (Absolute), code 1 (Y), value 244
Event: time 12.284698, -------------- Report Sync ------------
Event: time 12.294403, type 3 (Absolute), code 0 (X), value 3
Event: time 12.294799, type 3 (Absolute), code 2 (Z), value 55
Event: time 12.294799, -------------- Report Sync ------------
Event: time 12.304840, type 3 (Absolute), code 1 (Y), value 245
Event: time 12.305023, -------------- Report Sync ------------
Event: time 12.315063, type 3 (Absolute), code 1 (Y), value 244
Event: time 12.315277, type 3 (Absolute), code 2 (Z), value 56

So, what's the next? Making it integrated into Android would be a good idea.