Wednesday, May 25, 2011

Running Java on Embedded Linux

[1] Libffi Official Link
[2] http://www.linuxquestions.org/questions/linux-kernel-70/locale-support-in-linux-kernel-811248/
[3] http://java.sun.com/developer/technicalArticles/JavaTechandLinux/RedHat/ ---NPTL from RedHat
[4] http://en.wikipedia.org/wiki/NPTL#cite_note-0 ---NPTL
[5] http://en.wikipedia.org/wiki/LinuxThreads ---NPTL replace LinuxThreads
[6] http://dev.maxtrack.com.br/index.php/Td60_notes#Set_Locale --- locale issue
[7] http://sourceware.org/ml/libffi-discuss/2009/msg00004.html --- mail list for using libffi for power pc.
[8] http://www.linuxquestions.org/questions/linux-general-1/locale-cannot-set-lc_all-to-default-locale-no-such-file-or-directory-218622/ --- check locale
[9] http://www.busybox.net/ --- busy box home page
[10] http://groups.google.com/group/netusg20/tree/browse_frm/month/2010-01/2d17cfad90f32150?rnum=31&lnk=ol --- localedef crash (same as locale-gen crash)
[11] http://www.linuxquestions.org/questions/linux-newbie-8/detect-glibc-version-based-on-libpthread-so-627968/ --- check Glibc version
[12] http://ubuntuforums.org/showthread.php?t=829866 ---- java class library loading error.
[13] http://www.coderanch.com/t/110728/Linux-UNIX/find-vma-failed-warning ---VM Stack warning.
[14] http://www.velocityreviews.com/forums/t149023-cant-detect-initial-thread-stack-location.html --- JVM Stack warning.
[15] Embedded JRE Download from Oracle --- EJRE
[16] http://www.linux-mtd.infradead.org/faq/jffs2.html#L_bbhandle ---- jffs2 file system CRC error on node



RUN REST SERVER ON LINUX USING JAVA
------------------------------------
[root@10 HandMade]# java -jar Make.jar &
[1] 384
[root@10 HandMade]# Jan 3, 1970 1:52:04 AM org.restlet.engine.http.connector.HttpServerHelper start
INFO: Starting the internal HTTP server on port 8182

From Browser:
http://10.10.20.89:8182/powergridiq/datapac
[root@10 HandMade]# ps -A --sort -rss -o comm,pmem |head -n 11
COMMAND %MEM
java 57.7
sh 5.5
ps 3.0
init 0.9
head 0.8
kthreadd 0.0
ksoftirqd/0 0.0
events/0 0.0
khelper 0.0
async/mgr 0.0
[root@10 HandMade]# cat /proc/meminfo
MemTotal: 28952 kB
MemFree: 1424 kB
Buffers: 0 kB
Cached: 11684 kB
SwapCached: 0 kB
Active: 13344 kB
Inactive: 12100 kB
Active(anon): 6732 kB
Inactive(anon): 7028 kB
Active(file): 6612 kB
Inactive(file): 5072 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 13792 kB
Mapped: 4444 kB
Shmem: 0 kB
Slab: 1100 kB
SReclaimable: 256 kB
SUnreclaim: 844 kB
KernelStack: 264 kB
PageTables: 116 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 14476 kB
Committed_AS: 31352 kB
VmallocTotal: 745472 kB
VmallocUsed: 428 kB
VmallocChunk: 744912 kB





Access REST server from browser
http://10.10.20.89:8182/powergridiq/datapac



WORKAROUND FOR CLASS LIBRARY LOADING ERROR
----------------------------------------------
Here's a workaround. It's for making the package install and configure properly, not for actually running java in the chrooted environment.

1. Install sun-java6-bin. It fails to configure.
2. Find out where libjli.so is. Do "locate libjli.so". In my case it was here:

/opt/jdk1.7.0/jre/lib/i386/jli/libjli.so

3. Set the LD_LIBRARY_PATH variable so that the package can configure properly. Enter the following command (using your location of libjli.so):

LD_LIBRARY_PATH=/opt/jdk1.7.0/jre/lib/i386/jli dpkg --configure -a

Hopefully it's now installed and configured correctly.


TRY RUNNING JAVA PROGRAM AFTER LOCALE IS SET CORRECTLY
-----------------------------------------------------
[root@10 HandMade]# java -jar Make.jar
Java HotSpot(TM) Client VM warning: Can't detect initial thread stack location - find_vma failed
Jan 1, 1970 12:44:27 AM org.restlet.engine.http.connector.HttpServerHelper start
INFO: Starting the internal HTTP server on port 8182



Calling C function from Java. [1]
-----------------------------------


CHECK GLIBC VERSION [11]
-------------------
[root@GsnCommsModule lib]# cat /lib/libpthread.so.0 |grep GLIBC
GLIBC_2.4
GLIBC_PRIVATE
pthread_cond_timedwait@@GLIBC_2.4
__libc_dlopen_mode@@GLIBC_PRIVATE
tfind@@GLIBC_2.4
pthread_attr_getaffinity_np@@GLIBC_2.4
__fsetlocking@@GLIBC_2.4



SOLVE LOCALE ISSUE TO GET EMBEDDED JAVA RUN IN EMBEDDED LINUX [2]
-----------------------------------------------------------------
From [8]
[root@GsnCommsModule /]# locale
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
[root@GsnCommsModule /]# locale -a
C
POSIX
[root@GsnCommsModule /]#

AFTER USING CODESOURCERY arm-2010q1 COMPILER
----------------------------------------------
arm-2010q1 is using newer version GCC (GCC4.41)
So all locale and language suit are generated in LTIB
Extra folders are removed so that only support wanted languages and font coding.

[root@LIQ-GateWay /]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
[root@LIQ-GateWay /]# locale -a
C
en_GB
en_GB.utf8
en_US
en_US.utf8
POSIX

[root@LIQ-GateWay /]# locale -m
UTF-8

No comments: