Sunday, October 12, 2014

Arduino IDE 1.5.8 on Banana Pi

I use Arch Linux on Banana Pi. In my previous post, I used a workaround to compile Arduino code on an x86_64 platform and then copy the *.hex file to upload to Arduino from Banana Pi. While i7-4770 is very fast, it's also very power hungry. I dug a little bit and managed to get Arduino IDE 1.5.8 running on my Banana Pi.

If you want to install Arduino 1.0.5-1, Arch Assualt Repo has an almost working version. To make it work, you'll need to install java-rxtx, and replace /usr/share/arduino/lib/librxtxSerial.so with a symlink to /usr/lib/librxtxSerial.so , and also RXTXcomm.jar -> /usr/share/java/rxtx/RXTXcomm.jar

Now, this is how I got version 1.5.8 working (thanks to this post for a pointer):

Use the following PKGBULID (modified from its AUR for x86 and x86_64) to build and install a package:

# Maintainer: Lauri Hakko # Contributor: PyroPeter # Contributor: darkapex pkgname=arduino-beta epoch=1 pkgver=1.5.8 pkgrel=1 pkgdesc="Arduino SDK Beta release" arch=('armv7h') url="http://arduino.cc/en/Main/Software" options=(!strip) license=('GPL') depends=('avr-libc' 'libusb-compat' 'java-runtime') install="arduino.install" conflicts=('arduino' 'arduino-toolchain') provides=('arduino') source=("http://downloads.arduino.cc/arduino-${pkgver//_/-}-linux32.tgz" 'arduino' 'arduino.png' 'arduino.desktop') md5sums=('289b1e3ad64f29db3ed13b06880dce40' '5e385c8cba80ca1b4227b162e4cad5cd' '9e36d33891d5e68d38ec55d1494499a5' 'eebc4d6495864bea99ad057af801afb9') package() { cd "$srcdir/arduino-${pkgver//_/-}" # arduino excutable should accept arguments sed -i 's/^java .* processing.app.Base$/\0 "$*"/' arduino mkdir -p "$pkgdir"/usr/{bin,share/{doc,applications,pixmaps}} # copy the whole SDK to /usr/share/arduino/ cp -r . "$pkgdir/usr/share/arduino" # at least support the FHS a little bit: install -m755 "$srcdir/arduino" "$pkgdir/usr/bin/arduino" ln -s /usr/share/arduino/reference "$pkgdir/usr/share/doc/arduino" # desktop icon install -m644 "$srcdir/arduino.desktop" "$pkgdir/usr/share/applications/" install -m644 "$srcdir/arduino.png" "$pkgdir/usr/share/pixmaps/" }

This version won't run because /usr/share/arduino/hardware/tools/* are compiled for x86. We need those files compiled for Arm7. Let's remove /usr/share/arduino/hardware/tools now.

Download a pre-compiled version 1.5.4 by UDOO folks (big thanks for their efforts!). Go to their download page, click on Driver & Tools, and click on Arduino IDE for UDOO. Unpack the archive. We only need arduino/hardware/tools . Move it to /usr/share/arduino/hardware/tools

Since 1.5.8 above expects avr tools in /usr/share/arduino/hardware/tools/avr, and Arch installs it separately, so we need to make another two symlinks.

$ ln -s /usr/bin /usr/share/arduino/hardware/tools/avr/
$ ln -s /etc /usr/share/arduino/hardware/tools/avr/

There's one more file we need to replace: arduino/lib/libastylej.so . I just installed astyle from archlinuxarm.org and do a symlink libastylej.so -> /usr/lib/libastyle.so

That's it.

Friday, October 10, 2014

Control Arduino IDE 1.5.8 with command line

My workbench for Arduino development does not have enough space for a high power PC so I use lower power Arm devices (Raspberry Pi, Banana Pi, and Yun Shield) instead. However, Arduino IDE 1.5.x is not well supported yet (Raspbery Pi has a working version but not the other two, which I prefer. UPDATE: I figured it out.), and several Makefile solutions are still buggy against 1.5.x's libraries.

My temporary solution is to outsource the compiling to the more powerful machine (my i7-4770 running Arch 64 finishes compilation almost instantly, as opposed to 40 seconds on Raspberry Pi), and grab the compiled *.hex file back to these Arm devices to upload to Arduino via the USB serial connection.

As of October 4, 2014, Arduino IDE 1.5.8 has a buggy command line parameter passing, so I cannot compile the code remotely without doing a remote X session, and I want to avoid having to run an X server on these Arm devices (although Banana Pi actually runs X quite well). Therefore, I use the following hack to trigger the compiling via the command line.

$ DISPLAY=:0 xdotool search --name "Arduino 1.5.8" windowactivate --sync windowfocus mousemove --window %1 10 30 click 1

xdotool searches for a window whose title contains "Arduino 1.5.8", activates the virtual desktop it's on, focuses on the window, moves the mouse cursor to coordinates (10,30) relative to the application window (where the "Verify/Compile" button is) and then clickes on it to trigger the compilation.

For some reason sending ctrl+r doesn't work for me. If anyone knows why, I'd love to know.

$ # this doesn't work
$ DISPLAY=:0 xdotool search --name "Arduino 1.5.8" windowactivate --sync windowfocus key ctrl+r

Wednesday, September 11, 2013

Some trivia for search engines

For those who have the need to search for these answers. :)

The first ruler of England was "Egbert", King of Wessex.  (See World History, Historical Figures).

The "Mayflower" Compact was America's first written constitution.  (See U.S. History).

Francis Lightfoot Lee, one of the original signers of the Declaration of Independence, was a "farmer" by trade.  (See U.S. History, Signers of the Declaration).

James Monroe, 5th President of The United States, was the son of "Spence" Monroe and Eliza Jones.  (See Presidents' Biographies).

"glansnost" is another word for openness or candor.  (See Language, Foreign Words).

A "bug" is a mistake that occurs in a program within a computer.  (See Language, Computerese).

Sandy Koufax won the Cy Young Award "3" times.  (See Sports, Baseball).

"Mach" is a word used to describe supersonic speed.  (See Weights, Measures and Numbers, Breaking the Sound Barrier).

According to the National Film Registry, the film Casablanca was released in the year "1942".  (See Arts and Media - Movies, National Film Registry).

Cary Grant's original first name was "Archibald".  (See Noted Personalities, Original Names).

What famous boxer hails from the Bluegrass State?  "Muhammad Ali".  (See States of the Union, Kentucky).

Peggy Fleming won the Olympic gold medal in women's singles figure skating in "1968".  (See Sports, Winter Olympics).

More wheat and rice is grown in "China" than any other country in the world.  (See Agriculture).

William "Tyler" Page, Clerk of the U.S. House of Representatives, wrote "The American's Creed."  (See Great Seal, American's Creed).

Clint Eastwood was born in "San Francisco", California.  (See Noted Personalities, Entertainers).

In the year 1540, Spanish explorer Hernando Alarcon discovered the "Colorado" River.   (See World Exploration and Geography, Early Explorers of the Western Hemisphere).

"Batman" was the top grossing movie of 1989.  (See Arts and Media - Plays; Movies, All Time Top 50 American Movies, 1989).

Elzie C. Segar was the creator of the cartoon "Popeye".   (See Noted Personalities, Cartoonists)

Friday, November 30, 2012

Thinn Ooh Ooh (Darkening Sky) for Viola Ensemble 天黑黑 (中提琴合奏)

I was commissioned by Tim Deighton early this year to write this piece for his viola ensemble.

這是我今年初受中提琴家 Tim Deighton 委托的作品。


Monday, November 19, 2012

Segmentation of Bopomofo Symbols

A friend of mine is working on a project in which he needs to display Bopomofo (Chinese phonetic symbols used in Taiwan). He decided to display, in his program, each syllable as one unit that consists of vertically stacked phonetic symbol. To generate those well positioned symbols, he used MS Word to type all syllables he needs, captured the screenshot as images, and asked me to segment them. He gave me 26 files in total. Each files has several lines of something like this:

Monday, December 26, 2011

Homeless

This post is a translation of my other post in Chinese.  I wrote that to share my personal reaction toward a recent incident in Taiwan: the municipal administration used water jets to drive away homeless people in the park in a cold evening.

Please note that since this is a direct translation from the original Chinese post, the composition flow may not be as natural to English readers. Please bear with me and hear out what I have to say, if you are interested in reading this anyway.



When I moved from Southern California to Philadelphia for my graduate study in 1998, I was shocked to see so many homeless people. I witnessed a country in which the rich can personally own a hill, while the poor would seek food in the garbage can.  While some spend their afternoons watching seagulls with their beer on the beach, some others try to survive a cold night by staying close to the external vent of a building's heater.

街友

(English readers, you may be interested in my English translation of this post.)

記得1998年從美國西岸加州到美國東岸費城讀書時,第一次見到眾多的遊民,大為震憾。美國這個國家,有人富有到坐擁山頭,有人窮到得從垃圾筒翻出別人吃剩的便當出來填肚子;有人每天下午到海灘看沙鷗喝啤酒,有人每天晚上得縮在高樓旁的暖氣通風口取暖度冬夜。

那時候我很幸運,獎學金夠我過日子,也夠幫一兩位社區內的街友多買個便當。日子久了,和他們聊起來,才知道他們幫國家打仗受傷,戰後政府沒有好好照顧他們,他們寶貴的年輕時間都在戰場上耗掉了,退伍後年紀大要再回學校已是很困難。付擔不起房租,所以居無定所;想要好好老實找份工作,大部份的業主看到他們沒有個固定的住址,都不願意給他們機會。收容所的環境很不好,通風不良,傳染病問題嚴重,生了病很難好,再加上收容所的工作人員對待這些遊民的人態度極度不佳,讓他們寧可餐風露宿,也不願自尊被人踐踏。