Thursday, May 29, 2014

The indispensable man

Was reading some "5 ways to make you indispensable" bull crap and came across this poem. Keeping.

The Indispensable Man

(by Saxon White Kessinger)

Sometime when you're feeling important;
Sometime when your ego's in bloom;
Sometime when you take it for granted,
You're the best qualified in the room:
Sometime when you feel that your going,
Would leave an unfillable hole,
Just follow these simple instructions,
And see how they humble your soul.  

Take a bucket and fill it with water,
Put your hand in it up to the wrist,
Pull it out and the hole that's remaining,
Is a measure of how much you'll be missed.
You can splash all you wish when you enter,
You may stir up the water galore,
But stop, and you'll find that in no time,
It looks quite the same as before.  

The moral of this quaint example,
Is to do just the best that you can,
Be proud of yourself but remember,
There's no indispensable man.

Discover GS105E with Netgear Prosafe tool

Windows only.
To use Netgear Prosafe to discover netgear switch:

  • Turn off Internet Sharing Control (ICS) service
  • Turn on network discover - Not 100% sure if this is needed, but done anyway.
Proceed to configure the mirroring function under System/Monitoring/Mirroring.

Wednesday, May 28, 2014

Embedded JVM - JamVM on MIPS

Documenting some work done to run JVM on a embedded product.

I found this worth noting down due to lack of information (or rather, largely scatter information in forum, blogsphere etc) around this topic. What can be found on internet are usually deployment on the ARMs. The main reference (with detail steps that's also applicable for MIPS) was: Running OpenMUC on ARM systems

This project dealt with:
  • Processor: MIPS 24Kc 
  • JVM: JamVM 1.5.4
  • Classpath 0.98 (Could have been 0.99)
Here are the adapted steps, assuming the cross-compile tools are built and setup beforehand.

  1. zlib

Download zlib 1.2.8 from http://www.zlib.net/
Build:
CHOST=mips-example-linux-gnu ./configure
Before make, edit the Makefile to add -fPIC to the SFLAGS that's used to build the static lib. Otherwise will encounter error when building JamVM.
vim Makefile
    SFLAGS=-O3  -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN
make
Install the lib and headers to the toolchains directory:
sudo cp libz.a [toolchains_path]/lib
sudo cp zlib.h [toolchains_path]/include
sudo cp zconf.h [toolchains_path]/include
Edit

  1. JamVM

Download from http://jamvm.sourceforge.net/
Edit the configure to support mips-*-linux compiler:
vim configure   
   mips-*-linux*) host_cpu=mips host_os=linux ;;
Configure and build:
./configure --host=mips-example-linux-gnu --with-classpath-install-dir=/usr/local --prefix=/usr/local --enable-shared --enable-int-threading --enable-int-direct --enable-int-caching --enable-int-prefetch --enable-runtime-reloc-checks --enable-tls --enable-dependency-tracking
make
I think the -install-dir and -prefix is whatever will be like at the target system. Here I just follow convention.
This is what will be printed when running "jamvm -version" on target later on.
Boot Library Path: /usr/local/lib/classpath
Boot Class Path: /usr/local/share/jamvm/classes.zip:/usr/local/share/classpath/glibj.zip
Strip down the binary (I think this step can be skipped if the target build will strip it when making the rootfs):
cd src
mips-example-linux-gnu-strip jamvm
Deploy to target at:
  • src/jamvm -> /usr/sbin/jamvm
  • lib/classes.zip -> /usr/local/share/jamvm/
Edit

  1. Classpath

JamVM 1.5.4 requires GNU classpath.
Download 0.98 at http://www.gnu.org/software/classpath/
Configure and build:
./configure --host=mips-example-linux-gnu --without-x --disable-gtk-peer --disable-plugin --disable-dssi --enable-jni --disable-gconf-peer --enable-default-preferences-peer=memory --enable-default-toolkit --disable-examples --disable-tools --disable-Werror --disable-alsa
make
The resulted lib/glibj.zip is ~9MB.
This can be reduced further. Unzip the glibj.zip, remove "unneeded" (for now) class and zip back.
Depends on the apps to run, some cannot be removed. 
For example, these classes can be removed:
- gnu/CORBA
- gnu/java/awt
- gnu/javax/imageio
- gnu/javax/sound
- gnu/javax/swing
- java/sql/
- javax/imageio
- javax/sound
- javax/sql
- javax/swing
Zip the reduced classpath. This is reduced to about 6.5MB.
zip glibj.zip -r *
Deploy to target:
  • lib/glibj.zip -> /usr/local/share/classpath/glibj.zip
All the native libraries must also be deployed on target:
find ./native/ -name "*.so" -exec cp {} ${ROOT_PATH}/usr/local/lib/classpath \;
After completed the above step, should be able to just run the java apps by:
jamvm -jar hello.jar