Re: Java for chumby!

Hi!

I've followed the instructions on http://wiki.chumby.com/mediawiki/index.php/Java to run a Java VM on my chumby...

I have the correct file/folder structure on the USB memory dongle.

1. When inserting the USB dongle in the chumby, nothing particular happens, is this correct?
2. If I want to run a Java application on the chumby, where do I put the class-files? In the root of the USB dongle?
3. How do start up a specific Java application on the USB dongle? What do I need to do to make it run?


BR
Ola

Re: Java for chumby!

chuttenh wrote:

Update: I got Qt (and jesperht's pictureflow) working just fine, as well as zlib, alsa, classpath, and jamvm.  The major problems before were prefixes and junk from GTK contaminating my build environment.  But I still get exactly the same error from jamvm/classpath regarding qtpeer (non-AWT Java appears to work).  Is there some reason the Qt peer shouldn't work with Qtopia?  Could something be running out of memory?  I'm grasping at straws here smile

Hi!

Has anyone got the AWT & Swing libraries (using GTK) working on the Chumby?
Is it possible to implement a Java application just painting something on the screen, without using AWT or Swing?

/Ola

Re: Java for chumby!

You can create your own librairies... (framebuffer /dev/fb). And I think, you can do it, only in Java.

Have fun

Re: Java for chumby!

I am interested too in AWT/Swing but it seems that a X server is required

anybody knows how GTK peer works ?

Java cannot access natively to /dev/fb, how to do it then ?

Is there any specific chumby class to access /dev/fb in the javavm package ?

-------------------------------------
Christian LEBAUDY  :  SW Engineer (JAVA/C/++ and more)
MSN : clebaudy AT hotmail DOT com
Agility and open source are the key to achieve SW projects in our modern world.

Re: Java for chumby!

If you want to access /dev/fb0 from a Java app, you might try using a MappedByteBuffer to open it essentially as a memory-mapped file, then write to it as a set of unsigned shorts.

Re: Java for chumby!

I've rebuilt the java hack for GCC 4.3.2/eabi (firmware 1.7).

I've also included Jikes, so it's now also possible to compile java programs on the chumby itself!  See the wiki as linked above.

Re: Java for chumby!

Chumbians, do you have a small example of loading a bitmap to /dev/fb0 with MappedByteBuffer and how long does that take to fill the entire screen of the Chumby?

Does chumbyflashplayer.x uses /dev/fb0 directly or does it uses nano-X or some other X stuff on the Chumby?

Gr,

Re: Java for chumby!

chumbyflashplayer.x opens both /dev/fb0 and /dev/fb1, and mmaps them.  There is no windowing system between the player and the frame buffer.

Sorry, I don't have any example code for MappedByteBuffer access to /dev/fb

Re: Java for chumby!

chumbyflashplayer.x performs an mmap() of /dev/fb0 directly.  So did, for example, Quake.

I would guess the process wouldn't take too very long.  The tricky part is converting a 32-bit r,g,b pair into a 16-bit representation.  I think you'll want to call putShort(320*y+x, ((r&0x1f)<<11) | ((g&0x3f)<<5) | (b&0x1f)) on it, but I'm not entirely certain if that's the correct order.  As an alternative to calling putShort(), if you can get an array of Shorts, that might be easiest.

I've not done much with Java, so I'm afraid I can't be more help than that right now.

Re: Java for chumby!

I tried to open /dev/fb0 as root but got an exception: non writable channel.

        long length = 320 * 240;
        MappedByteBuffer buf = new FileInputStream("/dev/fb0").getChannel().map(FileChannel.MapMode.READ_WRITE, 0, length);

java.nio.channels.NonWritableChannelException
   at gnu.java.nio.channels.FileChannelImpl.map(FileChannelImpl.java:305)
   at Hello.main(Hello.java:24)

That's very strange, the perms are ok:

chumby:/mnt/usb# ls -l /dev/fbdir/
crw-rw-rw-    1 root     root      29,   0 Dec 31  1969 0

Is that the correct way of opening a MappedByteBuffer for /dev/fb0?

Re: Java for chumby!

Not too savvy about this myself, however, shouldn't you be using FileOutputStream instead since you intend to write to the display, not read from it?

Re: Java for chumby!

The length would also be 320*240*2, since it's a 16bpp display, not an 8bpp display.

Re: Java for chumby!

Aaarrr... thanx to both of you!

        RandomAccessFile rf = new RandomAccessFile("/dev/fb0", "rw");
        FileChannel fc = rf.getChannel();
        MappedByteBuffer buf = fc.map(FileChannel.MapMode.READ_WRITE, 0, fc.size());

worked, no exceptions anymore.  The screen stays black when I try to putShort()s to it but I'm getting close now.... will post results when I get something showing up.

Re: Java for chumby!

Apparently FileChannel.size() always returns 0 for /dev/fb0, it doesn't seem possible to write anything to the buffer since its size is 0, and setting its size to anything else throws an exception.  Setting the length of the RandomAccessFile with setLength() doesn't help.

However, RandomAccessFile.write(byte[] entirescreen, 0, 320*240*2) seems to
be relatively fast.  seeking in /def/fb0 to write at some offset doesn't seem to work using seek().

Re: Java for chumby!

Hello,

Will The JVM at http://wiki.chumby.com/mediawiki/index.php/Java work on the Chumby One or has the
chipset changed?  Is it still possible to mount a USB stick at boot with a JVM on it?

Thanks

Re: Java for chumby!

The chumby One uses the exact same ABI as a Classic running 1.7 or later, so Java should work.  It also supports the same userhook / debugchumby script mechanism as a Classic, so if you have a USB stick that you use with a Classic chumby, you should be able to plug it in to a One and have it work without any modifications.

Re: Java for chumby!

I see quite a few people trying to write to /dev/fb from Java (in Linux forums), but failing because the file size is 0.

There's a project to run AWT and Swing directly on the framebuffer device. Once this works, this may be something of interest for the chumby:
https://fbtoolkit.dev.java.net/
http://openjdk.java.net/projects/fbtoolkit/

(this means implementing a complete AWT peer though, not sure whether any porting would need to be done to make this run on the chumby)

Re: Java for chumby!

Oracle's embedded ARM5 J2SE is discussed in this thread. http://forum.chumby.com/viewtopic.php?id=6011
It is a headless version with no display support.

44 (edited by phoenixflames 2011-08-17 16:48:06)

Re: Java for chumby!

Is it possible to run  .jar files, the ones used for cellphone applications and games? (J2ME) Or do I have to compile a different version myself?

Re: Java for chumby!

That is a good question ! Can someone give us an answer? Thanks in advance

Re: Java for chumby!

What I've built is a base version of Java - you would need to add whatever libraries to make it a full J2ME.

This is left as an "exercise for the reader".

Re: Java for chumby!

Duane wrote:

What I've built is a base version of Java - you would need to add whatever libraries to make it a full J2ME.

This is left as an "exercise for the reader".

Alright thanks, this could be a nice project to work on.