打印

编译移植phoneme feature mr3

[复制链接]
246|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
上一回合有说到打造自己的j2me和找到了phoneme这个开源项目。

经过这几天地下工作的努力终于是有所结果。(为什么说是地下呢?这可不好在此公开)



在linux下成功编译phoneme feature mr3的arm和x86平台,并可以成功在cldc_vm上运行Hello Java

arm平台在自己的sky2400和公司的marvell, storlink平台都测试通过

不过现在也只是完成了cldc这一层,虽然midp也成功编译,但是从makefile来看也只是omap730平台的

midp层是与自己的平台息息相关的东西,这个才是真正要做移植工作的地方

比如显示是用哪种接口,qt? directfb? 按键等等

下面先说说编译CLDC和MIDP吧,移植MIDP以后有机会再说



1,环境:

机器:x86 pc or vmware

系统: Debian GNU/Linux 4.0 r3 Etch



2,准备:

  1) 解包需要命令:unzip,如没有且可以上网可以:apt-get install unzip

  2) 如果编译MIDP需要库:libxp6, libxtst6,可以如此安装:apt-get install libxp6 libxtst6

     因为编译的是使用fb,这种比较简单依赖的库也最少,如果是qt或者directfb依赖的更多些

  3) 如果不编译MIDP可以使用jdk 5,否则一定要jdk 1.4。

     (本想直接使用jdk 5来处理的,可是研究了一小段时间还是不行)

     jdk 5和jdk 1.4可以只安装后者,或者两者都安装。

     

     安装jdk 5可以直接:apt-get install sun-java5-jdk

     

     jdk 1.4就没这么好办了,得到网上下载来安装,可参考如下步骤:

     wget http://mirrors.dotsrc.org/java-linux/JDK-1.4.2/i386/03/j2sdk-1.4.2-03-linux-i586.bin  ##下载安装包

     chmod +x j2sdk-1.4.2-03-linux-i586.bin ##加上可执行权限

     ./j2sdk-1.4.2-03-linux-i586.bin        ##进行安装

     mv j2sdk1.4.2 /opt                     ##移动/opt目录下



  4) 下载phoneme feature mr3

     wget http://download.java.net/mobileembedded/phoneme/feature/phoneme_feature-mr3-rel-src-b01-17_jul_2008.zip



3,编译脚本(又是脚本,懒人的好东西啊)

################## build-phoneme.sh file start ####################

#!/bin/sh



JAVACALL_PACKAGE=phoneme_feature-mr3-rel-src-b01-17_jul_2008.zip



### 这里视你安装的jdk版本和路径

export JDK_DIR=/opt/j2sdk1.4.2

#export JDK_DIR=/usr/lib/jvm/java-1.5.0-sun



### 记得这里要改的啊

export COMPONENTS_DIR=/home/fi9/j2me/phoneme_feature



if [ $1 = 'arm' ]; then

  ### arm

  export CPU=arm

  export TARGET_CPU=linux_arm

  export JAVACALL_PLATFORM=linux_arm_gcc

  export PCSL_PLATFORM=linux_arm_gcc

   

  ### 这里改为你的gcc前缀

  export GNU_TOOLS_PREFIX=arm-linux-

  ### 这里改为你的arm gcc存放的地方

  export GNU_TOOLS_DIR=/opt/EmbedSky/crosstools_3.4.1_softfloat/arm-linux/gcc-3.4.1-glibc-2.3.3

elif [ $1 = 'mips' ]; then

  ### mips !!!注,MIPS平台的还没编译通过, 因为PCSL和MDIP还没移植好,只是CLDC已有相关脚本

  export CPU=mips

  export TARGET_CPU=linux_mips

  export JAVACALL_PLATFORM=linux_mips_gcc

  export PCSL_PLATFORM=linux_mips_gcc

   

  ### 这里改为你的gcc前缀

  export GNU_TOOLS_PREFIX=mips_lexra_fp_be-

  ### 这里改为你的gcc存放的地方

  export GNU_TOOLS_DIR=/opt/hardhat/devkit/mips/lexra_fp_be

else



  ### x86

  export TARGET_CPU=linux_i386

  export JAVACALL_PLATFORM=linux_i386_gcc

  export PCSL_PLATFORM=linux_i386_gcc

  export GNU_TOOLS_DIR=/usr

fi



export AS=${GNU_TOOLS_PREFIX}as

export CC=${GNU_TOOLS_PREFIX}gcc

export CPP=${GNU_TOOLS_PREFIX}g++

export LD=${GNU_TOOLS_PREFIX}gcc

export AR=${GNU_TOOLS_PREFIX}ar

export ENABLE_PCSL=true

export ENABLE_ISOLATES=true



export COMPONENTS_DIR=`pwd`/phoneme_feature

export BUILD_OUTPUT_DIR=$COMPONENTS_DIR/build_output

export MIDP_OUTPUT_DIR=$COMPONENTS_DIR/midp

export PCSL_OUTPUT_DIR=$COMPONENTS_DIR/pcsl

export CLDC_OUTPUT_DIR=$COMPONENTS_DIR/cldc

export CLDC_DIST_DIR=$CLDC_OUTPUT_DIR/$TARGET_CPU/dist

export JVMWorkSpace=$COMPONENTS_DIR/cldc

export JVMBuildSpace=$COMPONENTS_DIR/cldc

export JAVACALL_DIR=$COMPONENTS_DIR/javacall

export PROJECT_JAVACALL_DIR=$COMPONENTS_DIR/javacall-com

export JAVACALL_OUTPUT_DIR=$COMPONENTS_DIR/javacall

export TOOLS_DIR=$COMPONENTS_DIR/tools

export TOOLS_OUTPUT_DIR=$COMPONENTS_DIR/tools



#####################################################################

## 修改phoneme_feature/midp/build/linux_fb_gcc/Options.gmk中相应的选项为true



##### JSRs

##### 详细可查看:http://jcp.org/en/jsr/detail?id=ID号

# (Extra) JSR75 Subsystem

# Description: PDA Optional Packages for the J2METM Platform

export JSR_75_DIR=$COMPONENTS_DIR/jsr75

export PROJECT_JSR_75_DIR=



# (Extra) Bluetooth Subsystem

# Description: JavaTM APIs for Bluetooth

export JSR_82_DIR=$COMPONENTS_DIR/jsr82

export PROJECT_JSR_82_DIR=



# (Extra) WMA 1.1 Subsystem

# Description: Wireless Messaging API

export JSR_120_DIR=$COMPONENTS_DIR/jsr120

export PROJECT_JSR_120_DIR=



# Multimedia Subsystem

# Description: Mobile Media API

export JSR_135_DIR=$COMPONENTS_DIR/jsr135



# (Extra) Web Services Subsystem

# Description: J2METM Web Services Specification

export JSR_172_DIR=$COMPONENTS_DIR/jsr172

export PROJECT_JSR_172_DIR=



# (Extra) SATSA Subsystem

# Description: Security and Trust Services API for J2METM

export JSR_177_DIR=$COMPONENTS_DIR/jsr177

export PROJECT_JSR_177_DIR=



# (Extra) Location Subsystem

# Description: Location API for J2METM

export JSR_179_DIR=$COMPONENTS_DIR/jsr179

export PROJECT_JSR_179_DIR=



# (Extra) SIP Subsystem

# Description: SIP API for J2METM

export JSR_180_DIR=$COMPONENTS_DIR/jsr180



# (Extra) M3G Subsystem

# Description: Mobile 3D Graphics API for J2METM

export JSR_184_DIR=$COMPONENTS_DIR/jsr184



# (Extra) WMA 2.0 Subsystem

# Description: Wireless Messaging API 2.0

export JSR_205_DIR=$COMPONENTS_DIR/jsr205

export PROJECT_JSR_205_DIR=



# (Extra) CHAPI Subsystem

# Description: Content Handler API

export JSR_211_DIR=$COMPONENTS_DIR/jsr211

export PROJECT_JSR_211_DIR=



# (Extra) Scalable Vector Graphics Subsystem

# Description: Scalable 2D Vector Graphics API for J2METM

export JSR_226_DIR=$COMPONENTS_DIR/jsr226

export PISCES_DIR=$COMPONENTS_DIR/pisces



# (Extra) Payment Subsystem

# Description: Payment API

export JSR_229_DIR=$COMPONENTS_DIR/jsr229

export PROJECT_JSR_229_DIR=



# (Extra) DataSync Subsystem

# Description: Data Sync API

export JSR_230_DIR=$COMPONENTS_DIR/jsr230



# (Extra) Advanced Multimedia Subsystem

# Description: Advanced Multimedia Supplements

export JSR_234_DIR=$COMPONENTS_DIR/jsr234



# (Extra) Mobile I18N Subsystem

# Description: Mobile Internationalization API

export JSR_238_DIR=$COMPONENTS_DIR/jsr238

export PROJECT_JSR_238_DIR=



# (Extra) OpenGL ES Subsystem

# Description: JavaTM Binding for the OpenGL ES API

export JSR_239_DIR=$COMPONENTS_DIR/jsr239

export PROJECT_JSR_239_DIR=



# (Extra) Mobile Sensor

# Description: Mobile Sensor API

export JSR_256_DIR=$COMPONENTS_DIR/jsr256

export PROJECT_JSR_256_DIR=



# (Extra) XML api for Java ME

# Description: JSR XML API for JavaTM ME

export JSR_280_DIR=$COMPONENTS_DIR/jsr280

export PROJECT_JSR_280_DIR=



# (Extra) Abstractions Subsystem

# Description: Abstractions for optional packages

export ABSTRACTIONS_DIR=$COMPONENTS_DIR/abstractions



##### DIRECTFB

export DIRECTFB_INSTALL_DIR=$COMPONENTS_DIR/../system/tmp



##### SSL

# Restricted Security

export USE_RESTRICTED_CRYPTO=true

export RESTRICTED_CRYPTO_DIR=$COMPONENTS_DIR/restricted_crypto



##### JPEG decoding for putpixel

# (Extra) JPEG lib

# Description: JPEG

export JPEG_DIR=$COMPONENTS_DIR/jpeg

#####################################################################





### 解包

if [ ! -d $COMPONENTS_DIR ]; then

  unzip -q $JAVACALL_PACKAGE



   ### patch

  sed -i -e "s/\/bin\/javac/\/bin\/javac -source 1\.4 -target 1\.4/" phoneme_feature/tools/makefiles/common_defs.gmk



  sed -i -e "s/\/bin\/javac\$(EXE)/\/bin\/javac\$(EXE) -source 1\.4 -target 1\.4/" phoneme_feature/pcsl/tools/sosProxy/GNUmakefile



  sed -i -e "s/\$(GNU_TOOLS_BINDIR)ar/\$(GNU_TOOLS_BINDIR)${GNU_TOOLS_PREFIX}ar/" phoneme_feature/pcsl/makefiles/share/gcc.gmk

  sed -i -e "s/\$(GNU_TOOLS_BINDIR)gcc/\$(GNU_TOOLS_BINDIR)${GNU_TOOLS_PREFIX}gcc/" phoneme_feature/pcsl/makefiles/share/gcc.gmk

  sed -i -e "s/\$(GNU_TOOLS_BINDIR)g++/\$(GNU_TOOLS_BINDIR)${GNU_TOOLS_PREFIX}g++/" phoneme_feature/pcsl/makefiles/share/gcc.gmk



  sed -i -e "s/NETWORK_MODULE = bsd\/qte/NETWORK_MODULE = bsd\/generic/" phoneme_feature/pcsl/makefiles/top.gmk

   sed -i -e "s/\$(GCC_PREFIX)ar/\$(GCC_PREFIX)${GNU_TOOLS_PREFIX}ar/" phoneme_feature/cldc/build/share/jvm.make

  sed -i -e "s/\$(GCC_PREFIX)as/\$(GCC_PREFIX)${GNU_TOOLS_PREFIX}as/" phoneme_feature/cldc/build/share/jvm.make

  sed -i -e "s/\$(GCC_PREFIX)gcc/\$(GCC_PREFIX)${GNU_TOOLS_PREFIX}gcc/" phoneme_feature/cldc/build/share/jvm.make

  sed -i -e "s/\$(GCC_PREFIX)g++/\$(GCC_PREFIX)${GNU_TOOLS_PREFIX}g++/" phoneme_feature/cldc/build/share/jvm.make

  sed -i -e "/gcc_arch = \$(host_arch)/iFORCE_GCC=g++" phoneme_feature/cldc/build/share/jvm.make



  sed -i -e "s/\/bin\/javac/\/bin\/javac -source 1\.4 -target 1\.4/" phoneme_feature/cldc/build/share/tools.make



  #sed -i -e "s/\/bin\/javac\$(EXE)/\/bin\/javac\$(EXE) -source 1\.4 -target 1\.4/" phoneme_feature/midp/build/common/makefiles/Defs.gmk

  sed -i -e "s/\/bin\/javac/\/bin\/javac -source 1\.4 -target 1\.4/" phoneme_feature/midp/build/common/makefiles/cdc_vm.gmk

  sed -i -e "s/\/bin\/javac\$(JVM_EXE_SUFFIX)/\/bin\/javac\$(JVM_EXE_SUFFIX) -source 1\.4 -target 1\.4/"  phoneme_feature/midp/build/share/libdefs.gmk

  sed -i -e "s/\$(GNU_TOOLS_BINDIR)ar/\$(GNU_TOOLS_BINDIR)${GNU_TOOLS_PREFIX}ar/" phoneme_feature/midp/build/common/makefiles/gcc.gmk

  sed -i -e "s/\$(GNU_TOOLS_BINDIR)gcc/\$(GNU_TOOLS_BINDIR)${GNU_TOOLS_PREFIX}gcc/" phoneme_feature/midp/build/common/makefiles/gcc.gmk

  sed -i -e "s/\$(GNU_TOOLS_BINDIR)g++/\$(GNU_TOOLS_BINDIR)${GNU_TOOLS_PREFIX}g++/" phoneme_feature/midp/build/common/makefiles/gcc.gmk

  sed -i -e "s/\$(GNU_TOOLS_BINDIR)ranlib/\$(GNU_TOOLS_BINDIR)${GNU_TOOLS_PREFIX}ranlib/" phoneme_feature/midp/build/common/makefiles/gcc.gmk

  sed -i -e "s/\$(GNU_TOOLS_BINDIR)as/\$(GNU_TOOLS_BINDIR)${GNU_TOOLS_PREFIX}as/" phoneme_feature/midp/build/common/makefiles/gcc.gmk

fi



### building PCSL

make -C $COMPONENTS_DIR/pcsl

if [ 0 -ne $? ]; then

  exit 1

fi



### building CLDC

## 编译OK后在目录 $COMPONENTS_DIR/midp/ 下生成相应的目录和程序、库

make -C $COMPONENTS_DIR/cldc/build/$TARGET_CPU product

if [ 0 -ne $? ]; then

  exit 1

fi



### building MIDP

## 在编译MIDP就去掉出面的注释

## 这里暂只使用fb,至于qt或者directfb有兴趣再研究

##

## 编译OK后在目录 $COMPONENTS_DIR/cldc/linux_arm/dist 下生成相应的程序和库

#make -C $COMPONENTS_DIR/midp/build/linux_fb_gcc

################## file end build-phoneme.sh ####################



4,patch和说明

  1) javac相关

     phoneme需要的是jdk 1.4,因此很多makefile(很多java源码也)写的时候没有考虑到现在都用jdk 5了

     也有少许几个makefile考虑到了兼容性的问题编译时使用了如:

     javac -source 1.4 -target 1.4

     以下是我修改以上这种情况的文件:

     a) phoneme_feature/tools/makefiles/common_defs.gmk  修改30行

     b) phoneme_feature/pcsl/tools/sosProxy/GNUmakefile  修改35行

     c) phoneme_feature/cldc/build/share/tools.make 修改28行

     d) phoneme_feature/midp/build/common/makefiles/cdc_vm.gmk  修改178行

     e) phoneme_feature/midp/build/share/libdefs.gmk  修改76行

     

     其中,phoneme_feature/midp/build/common/makefiles/Defs.gmk本来是修改168行的

     但是修改后倒是总也编译midp不通过,老是报以下的错误,而不修改就OK,暂时不明白为什么

    /home/fi9/j2me/phoneme_feature/midp/build/linux_fb_gcc/../../src/ams/ams_base_cldc/reference/classes/com/sun/midp/main/CldcMIDletLoader.java:70: cannot resolve symbol

    symbol  : method initCause (java.lang.ClassNotFoundException)

    location: class java.lang.NoClassDefFoundError

            if (!MIDlet.class.isAssignableFrom(midletClass)) {

                 ^

    Fatal Error: Unable to locate method initCause

    make[1]: *** [/home/fi9/j2me/phoneme_feature/midp/classes.zip] Error 1

    make[1]: Leaving directory `/home/fi9/j2me/phoneme_feature/midp/build/linux_fb_gcc'

    make: *** [build_classes] Error 2

    make: Leaving directory `/home/fi9/j2me/phoneme_feature/midp/build/linux_fb_gcc'

  2) gcc相关

     phoneme没有考虑到交叉编译时gcc之类是有个前缀的,像:arm-linux-

     因此,如果你的编译器是带前缀的必要修改以下文件:

     a) phoneme_feature/pcsl/makefiles/share/gcc.gmk 修改46~47行

     b) phoneme_feature/cldc/build/share/jvm.make 修改1482~1486行,并在1462行添加一行:FORCE_GCC=g++,如:

      ifeq ($(IsTarget), true)

      gcc_arch = $(arch)

      else

      gcc_arch = $(host_arch)

      FORCE_GCC=g++

      endif

     c) phoneme_feature/midp/build/common/makefiles/gcc.gmk 修改以下几行:91, 92, 95, 104, 107, 115

     如果出现类似以下的错误就是由于没做着b)这个修改:

     ... _MergedSrc001.cpp

     {standard input}: Assembler messages:

     {standard input}:6917: Error: bad instruction `int $03'

     {standard input}:7803: Error: bad instruction `int $03'

     {standard input}:7848: Error: bad instruction `int $03'

     {standard input}:8554: Error: bad instruction `int $03'

     {standard input}:8895: Error: bad instruction `int $03'

     {standard input}:8996: Error: bad instruction `int $03'

     {standard input}:9268: Error: bad instruction `int $03'

     make[1]: *** [_MergedSrc001.o] 错误 1

     make[1]: Leaving directory `/home/fi9/j2me/phoneme_feature/cldc/linux_arm/loopgen/app'

     make: *** [_loopgen] 错误 2

     make: Leaving directory `/home/fi9/j2me/phoneme_feature/cldc/build/linux_arm'

  3) 其它

     这里我只是修改了网络使用通用的BSD API实现而不是用QT库,以减少依赖性

     phoneme_feature/pcsl/makefiles/top.gmk 修改82行,bsd/qte改为bsd/generic

5,可能出现的问题

  1) 出现类似以下情况的一定是由于gcc的环境变量设置不对,参考上面4.2的gcc相关说明

    make[2]: Entering directory `/home/fi9/j2me/phoneme_feature/pcsl/print/stdout'

    /bin/sh: /opt/EmbedSky/crosstools_3.4.1_softfloat/arm-linux/gcc-3.4.1-glibc-2.3.3/bin/arm_920t_le-gcc: No such file or directory

    make[2]: *** [/home/fi9/j2me/phoneme_feature/build_output/pcsl/linux_arm/obj/pcsl_print.o] Error 127

    make[2]: Leaving directory `/home/fi9/j2me/phoneme_feature/pcsl/print/stdout'

    make[1]: *** [all] Error 2

    make[1]: Leaving directory `/home/fi9/j2me/phoneme_feature/pcsl/print'

    make: *** [all] Error 2

    make: Leaving directory `/home/fi9/j2me/phoneme_feature/pcsl'



6,测试。

   1)测试cldc。

     A) copy phoneme_feature/cldc/linux_arm/dist/bin/cldc_vm 到目标主机上

     B) 测试代码:

        /* filename: test.java */

public class test {

public static void main(String[] args) {

  System.out.println("Hello Java ME\n");

}

}

     C) 要开发机上编译

        javac test.java

     D) copy test.class 到目标机上

     E) 测试:cldc_vm test

   2)测试midp

     A) 分别copy phoneme_feature/midp目录下的appdb、bin和lib三目录到目标主机上

     B) 运行bin/arm目录下的./autotest



7,移植。

   1)屏幕宽高的设置。

     修改文件:

     phoneme_feature/midp/src/configuration/configuration_xml/linux_fb/constants.xml

     相关的HIGHT和WIDTH

   2)键盘鼠标等输入和输出。

     A)fb对就的文件:phoneme_feature/midp/src/highlevelui/fb_port/fb/native/fb_port.c

     修改initFrameBuffer和initKeyboard中设备的名称和初始化过程。

     B)directfb:phoneme_feature/midp/src/highlevelui/fb_port/directfb/native/directfb_port.c

     暂时还不清楚为什么getKeyboardFd和getMouseFd都是返回-1,

     可能就造成directfb下取不到输入,具体看:

     phoneme_feature/midp/src/events/mastermode_port/linux_fb/native/mastermode_check_signal.c中的函数checkForSocketPointerAndKeyboardSignal



要知下来的发展,请多多关注留意。

首次玩不太熟,有错望指出,也请牛人多指教。

email 4 me: hackthinking at gmail.com



writed by fi9 in shenzhen 2009-03-04



=================

修正了一些错误并修改了脚本以大家更好使用 2009-03-17



=================

1,添加以下一行,并加上出错的现象:

sed -i -e "/gcc_arch = \$(host_arch)/iFORCE_GCC=g++" phoneme_feature/cldc/build/share/jvm.make

2,修改BUG。把修改ar的向前移,不然会arm-linux-gcc的会再次被匹配上并被修改为:arm-linux-arm-linux-gcc。

modified by fi9 in cn.gd.sz 2009-04-07



==================

久不动,最近把directfb + gtk移植到s3c2440,今晚也成功把midp运行了起来,不过是基于fb,下来把其再移到directfb下,然后再完善完善。

添加以下:

1,添加测试的步骤。

modified by fi9 in cn.gd.sz 2009-06-09



==================

1,添加对扩展支持的设置,如:JSRs,DirectFB,JPEG等

2,添加移植的一些心得。

modified by fi9 in cn.gd.sz 2009-06-10

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

432

主题

439

帖子

0

粉丝