Fast Data: Rise of the Java Embedded Technology-Enabled Machines

| May 28, 2013
Because we need fast access to big data, the Rise of the Machines is finally happening. And, they're Java Embedded Technology-Enabled machines.

See:

Fast Data: Rise of the Machines

Here's a quote:

 There are many technologies that 
 support fast data. Baer lists his 
 fast data ingredients: in-memory 
 data grids and  (more...)

Oracle PartnerCast: Oracle Java Embedded Updates

| May 16, 2013
Here's a recent video of Geoff Morton, our Group Vice President of Worldwide Java Sales, interviewing Henrik Stahl, our Senior Director of Product Management at Oracle, asking about Java Embedded Updates.

See:

Oracle Java Embedded Updates

I like the intro music. Very catchy. And, learn all about Java Embedded on (more...)

Intel Atom vs ARM, CPU battle for Java Embedded devices

| May 8, 2013
Whether its an embedded device with an ARM CPU chip or one of the new fancy-schmancy Intel Atom super-power-efficient, crazy-high-performance Silvermont CPU chips coming out for embedded and mobile devices, programming using Java Embedded technology will be the way to go on either.

See:

Crazy-Delicious Silvermont Atom

Here's a quote:

  (more...)

BeagleBone Black: Great Raspberry Pi competitor and runs Java SE Embedded

| Apr 26, 2013
Step right up! For only $45, you can get an awesome BeagleBone Black Linux/ARM, Sitara AM335x 1GHz ARM Cortex-A8 processor, 512MB DDR3 RAM, and 2GB of eMMC memory. Wow! Now, that's giving the RPi a run for it's money! And... it can run Java SE Embedded. That's the coolest part...

(more...)

Last chance! A few good embedded submissions needed for JavaOne

| Apr 11, 2013
Roger Brinkley is making a plea for a few good embedded abstracts for the JavaOne 2013 call for papers which is still open until Fri. 12Apr2013.

See:

A Few Good Talks

Here's a quote:

 The JavaOne 2013 Call for Papers closes 
 April 12, but [Roger Brinkley is] still 
 looking for  (more...)

RPi with an Oscilloscope and Java Embedded: Ready for Benchmarking (Part 7)

| Apr 4, 2013
Meh. I'm only getting 22KHz (see photo) with this last approach using java.io.FileWriter on the GPIO file handle. That's much slower than the Pi4J Java to JNI library from Savage Home Automation. And, no where close to the 5MHz using C native.

It might be better to continue (more...)

RPi with an Oscilloscope and Java Embedded: Ready for Benchmarking (Part 6)

| Mar 28, 2013
Well, the best laid plans of Raspberry Pi, Java Embedded and all that. There's some type of device access issue on the Raspberry Pi when trying to NIO memory map /dev/mem. So, I'm going to have take some time to debug that.

Instead let's go back to what we know works. Using pure Java Embedded API's we can use the file handle to get to the GPIO pins for access. So, let's roll back and start there again and incrementally move toward trying to match what we should be able to do with NIO.

Here's the code that we will roll back to. You can try this at home to see what type of speed you can get on your oscilloscope. I'll report what I have also.

/*
 * Example Code
 */

/*
 * Java Embedded Raspberry Pi Servo app
 */
package jerpitest;

import java.io.FileWriter;
import java.io.File;

/**
 *
 * @author hinkmond
 */
public class GPIOMaxRate {
    
    static final String GPIO_OUT = "out";
    static final String GPIO_ON = "1";
    static final String GPIO_OFF = "0";
    
    static String[] GpioChannels =  { "24" };

    /**
     * @param args the command line arguments
     */
    @SuppressWarnings("UseSpecificCatch")
    public static void main(String[] args) {
        FileWriter[] commandChannels;
        
        try {
            
            /*** Init GPIO port for output ***/
            
            // Open file handles to GPIO port unexport and export controls
            FileWriter unexportFile = 
                    new FileWriter("/sys/class/gpio/unexport");
            FileWriter exportFile = 
                    new FileWriter("/sys/class/gpio/export");

            // Loop through all ports if more than 1
            for (String gpioChannel : GpioChannels) {
                System.out.println(gpioChannel);
    
                // Reset the port, if needed
                File exportFileCheck = 
				new File("/sys/class/gpio/gpio"+gpioChannel);
                if (exportFileCheck.exists()) {
                    unexportFile.write(gpioChannel);
                    unexportFile.flush();
                }
            
                // Set the port for use
                exportFile.write(gpioChannel);   
                exportFile.flush();

                // Open file handle to port input/output control
                FileWriter directionFile =
                    new FileWriter("/sys/class/gpio/gpio" + gpioChannel + 
                        "/direction");
            
                // Set port for output
                directionFile.write(GPIO_OUT);
                directionFile.flush();
            }
            
            /*** Send fastest on/off to GPIO port ***/
            
            // Set up a GPIO port as a command channel
            FileWriter commandChannel = new 
			FileWriter("/sys/class/gpio/gpio" +
              	GpioChannels[0] + "/value");
            
            // Loop forever with fastest on/off to GPIO pin
            while (true) {
                    commandChannel.write(GPIO_ON);
                    commandChannel.flush();               

                    commandChannel.write(GPIO_OFF);
                    commandChannel.flush();        
                }
            }
            
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
}

This should be still pretty fast and good enough for most applications. But, we are still searching for the theoretically maximum frequency we can achieve using pure Java Embedded.

RPi with an Oscilloscope and Java Embedded: Ready for Benchmarking (Part 5)

| Mar 21, 2013
One way to convert the C language GPIO access of /dev/mem is to use a Java NIO memory mapped buffer to open the Raspberry Pi memory as a device (with a Linux file descriptor), then get the file channel, then map it into the Java NIO accessible memory.

This is essentially the same process that Gordon Drogon is using in his WiringPi.c file. Instead of Java NIO, he is using the C and the Linux mmap() function to a file descriptor pointing to /dev/mem. So, our Java translation of that same functionality would look something like this.

/*
 * Example Code
 */

import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

//...

  RandomAccessFile fileHandle = new 
    RandomAccessFile("/dev/mem", "rw");

  FileChannel fileChannel = fileHandle.getChannel();

  MappedByteBuffer gpioMem = fileChannel.map(
    FileChannel.MapMode.READ_WRITE, BCM2708_PERI_BASE + 0x200000, 
    PAGE_SIZE);

So, we have our Java code. Let's take a look if this works on the Raspberry Pi with our Java Embedded stack...

RPi with an Oscilloscope and Java Embedded: Ready for Benchmarking (Part 4)

| Mar 18, 2013
The next step in making Java Embedded just as fast as C native for Raspberry Pi GPIO pulse-wave modulation (PWM) is to match what C native does in the fastest programming case.

And, this means the place to look is in Gordon Drogon's canonical C native Wiring Pi library for the Arduino-compatible RPi GPIO. It's the best C code implementation currently out there, and it's what Pi4J uses underneath it's Java implementation.

See: WiringPi C Native Library

What we see when we carefully read the wiringPi.c file is that Gordon is using C native memory mapping of "/dev/mem" to access the GPIO portion of the RPi memory map for the quickest access possible. That's awesome! That's a very simple way to get at the GPIO pins with high performance for both reading and writing. So, of course we can do the same in Java (without JNI) using an NIO memory mapped file/device for that same high performance (in theory). Cool!

Here's the code we will consider...

/*
 * Example C Native Code: From wiringPi.c 
 * See: 
 * https://github.com/WiringPi/WiringPi/blob/master/wiringPi/wiringPi.c
 */
#define BCM2708_PERI_BASE 0x20000000
//...
#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000)

#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)

//...

// Open the master /dev/memory device

  if ((fd = open ("/dev/mem", O_RDWR | O_SYNC) ) < 0)
  {
    fprintf (stderr, "wiringPiSetup: Unable to open /dev/mem: %s\n", 
      strerror (errno)) ;
    return -1 ;
  }

// GPIO:

// Allocate 2 pages - 1 ...

  if ((gpioMem = malloc (BLOCK_SIZE + (PAGE_SIZE-1))) == NULL)
  {
    fprintf (stderr, "wiringPiSetup: malloc failed: %s\n", 
      strerror (errno)) ;
    return -1 ;
  }

// ... presumably to make sure we can round it up to a whole page size

  if (((uint32_t)gpioMem % PAGE_SIZE) != 0)
    gpioMem += PAGE_SIZE - ((uint32_t)gpioMem % PAGE_SIZE) ;

  gpio = (uint32_t *)mmap((caddr_t)gpioMem, BLOCK_SIZE, 
    PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, fd, 
    GPIO_BASE) ;

Next, this needs to be translated from C to Java. We do this using NIO (New I/O) in Java SE Embedded. Note that NIO is not available in Java ME Embedded. Java SE Embedded has the full set of Java SE API's (including NIO) which is the crucial part of this exercise in order to get the same performance as C native.

More in the next blog post...

Open Now Until April 12: JavaOne 2013 San Francisco Call for Papers

| Mar 14, 2013
Yes! The JavaOne 2013 Conference (San Francisco) Call for Papers is now open! Submit your cool and interesting ideas for talks at this Web page:

See:

JavaOne 2013 Call for Papers

Here's a quote:

 The Call for Proposals is open. Have 
 something interesting to present to 
 the world’s largest gathering of 
 Oracle technologists and business 
 leaders? Making breakthrough 
 innovations with Java or MySQL? We 
 want to hear from you...
Let's see how many talks we can get this year on Java Embedded and the Raspberry Pi. Let me know if there are other Java Embedded areas that you'd like to (more...)

Open Now Until April 12: JavaOne 2013 San Francisco Call for Papers

| Mar 14, 2013
Yes! The JavaOne 2013 Conference (San Francisco) Call for Papers is now open! Submit your cool and interesting ideas for talks at this Web page:

See:

JavaOne 2013 Call for Papers

Here's a quote:

 The Call for Proposals is open. Have 
 something interesting to present to 
 the world’s largest gathering of 
 Oracle technologists and business 
 leaders? Making breakthrough 
 innovations with Java or MySQL? We 
 want to hear from you...
Let's see how many talks we can get this year on Java Embedded and the Raspberry Pi. Let me know if there are other Java Embedded areas that you'd like to (more...)

RPi with an Oscilloscope and Java Embedded: Ready for Benchmarking (Part 3)

| Mar 12, 2013
The first step in our investigation is to reproduce what Robert Savage saw in his benchmarking. See: Java GPIO Benchmarking

In his study, Robert Savage measured the Pi4J library on Oracle Java JDK 8 Preview for Linux/ARM yielding about 153 kHz on the Raspberry Pi GPIO output. So, following the scientific method, we should be able to reproduce the experiment.

And, with the following Java Embedded app on my RPi running with Oracle JDK 8 Preview for Linux/ARM and using my HP logic analyzer/oscilloscope I'm seeing about the same: 166 kHz. Click on the above photo to zoom in and (more...)

RPi with an Oscilloscope and Java Embedded: Ready for Benchmarking (Part 2)

| Mar 8, 2013
You now have your PicoScope or your extravagant logic analyzer with oscilloscope, and you're ready to hook it up to your Raspberry Pi to measure your Java app. It's pretty straight-forward.

Attach your scope probe (refer to your documentation for your specific oscilloscope), then find an open GPIO pin that you'll use. I'm going to use GPIO24 which is Pin #18 on the header (see diagram below).

The easiest way to do this is to take a male/female jumper wire (See: link) and connect the female end to Pin #18 (GPIO24) and the male end to the probe hook (more...)

RPi with an Oscilloscope and Java Embedded: Ready for Benchmarking (Part 1)

| Mar 7, 2013

So, the oscilloscope that Gary C. and Vlad D. found for our Java Embedded on Raspberry Pi analysis (see top photo) is actually a fancy-schmancy HP 16700A logic analyzer with an HP 16534A oscilloscope module -- which in plain English means it cost SavaJe beaucoup bucks to buy (4 G's back in 2001). And, I'm guessing that as a typical RPi hobbyist, you're not going to want to drop $4k on your project just to measure the frequency of a Java Embedded generated PWM wave. Am I right?

Thought so. Well, if you are interested in using an oscilloscope to (more...)

RPi with a Oscilloscope and Java Embedded: Ready for Benchmarking

| Mar 4, 2013
Houston, we have an oscilloscope!

Yes, through hard work and determination, well... actually through the luck of the donation of an old leftover logic analyzer with an oscilloscope module from the former SavaJe acquisition via Sun Microsystems, Inc. then now here at Oracle, we now have a scope here in the office connected to our Raspberry Pi running Java Embedded technology! Woo-hoo!

I want to thank Gary A. and Vlad D. in their help tracking down this awesome (er, uh... a bit old) piece of electronic equipment. In a back storage closet somewhere in the darkest reaches of our Burlington, (more...)