Tuesday Oct 30, 2012

RPi and Java Embedded GPIO: It all begins with hardware

So, you want to connect low-level peripherals (like blinky-blinky LEDs) to your Raspberry Pi and use Java Embedded technology to program it, do you? You sick foolish masochist. No, just kidding! That's awesome!

You've come to the right place. I'll step you though it.

And, as with many embedded projects, it all begins with hardware. So, the first thing to do is to get acquainted with the GPIO header on your RPi board. A "header" just means a thingy with a bunch of pins sticking up from it where you can connect wires. See the the red box outline in the photo.

Now, there are many ways to connect to that header outlined by the red box in the photo (which the RPi folks call the P1 header). One way is to use a breakout kit like the one at Adafruit. But, we'll just use jumper wires in this example.

So, to connect jumper wires to the header you need a map of where to connect which wire. That's why you need to study the pinout in the photo. That's your map for connecting wires.

But, as with many things in life, it's not all that simple. RPi folks have made things a little tricky. There are two revisions of the P1 header pinout. One for older boards (RPi boards made before Sep 2012), which is called Revision 1. And, one for those fancy 512MB boards that were shipped after Sep 2012, which is called Revision 2. So, first make sure which board you have: either you have the Model A or B with 128MB or 256MB built before Sep 2012 and you need to look at the pinout for Rev. 1, or you have the Model B with 512MB and need to look at Rev. 2.

That's all you need for now.

More to come...

Friday Oct 26, 2012

Rockin' out with @jerpi_bilbo blinking his LEDs via Java Embedded RPi GPIO

I've got Java Embedded talking to the RPi GPIO now. It's controlling a bank of yellow LEDs. So, jerpi_bilbo is blinking away to AC/DC in this video clip.

Hope you like it.


Video of jerpi_bilbo blinking LEDs

I'll post the Java source code to do this on the RPi in a separate blog entry.

Thursday Oct 25, 2012

Named my RPi 512MB @jerpi_bilbo

To keep our multiple Raspberry Pi boards apart from each other, I've now named my RPi Model B w/512MB: "jerpi_bilbo", which stands for Java Embedded Raspberry Pi - Bilbo (named after the Hobbit from the J.R.R. Tolkien stories).

I also, set up a Twitter account for him. You can follow him at: @jerpi_bilbo

He's self-tweeting, manual prompted so far (using Java Embedded 7.0 and twitter4j Java library). Works great! I'm setting him up to be automated self-tweeting soon, so watch for that...

Here's a pointer to the open source twitter4j Java library: download here Just unzip and extract out the twitter4j-core-2.2.6.jar and put it on your Java Embedded classpath.

Here's how @jerpi_bilbo uses it to Tweet with his Java Embedded runtime:

import twitter4j.*;
import java.io.*

public final class Tweet {

    public static void main(String[] args) {
        String statusStr = null;
        if ((args.length > 0) && (args[0] != null)) {
          statusStr = args[0];
        } else {
          statusStr = new String("Hello World!");

        // Create new instance of the Twitter class
        Twitter twitter = new TwitterFactory().getInstance();
        try {
           Status status = twitter.updateStatus(statusStr);
             ("Successfully updated the status to: " + 
        } catch (Exception e) {

That's all you need. Java Embedded rocks the RPi! And, @jerpi_bilbo is alive...

Tuesday Oct 23, 2012

Oh snap! My RPi was upgraded to 512MB! Woo-hoo!

I ordered a Raspberry Pi Model B (256MB) over 4 months ago on backorder. When it finally came I saw it was upgraded to the new half a gig model! Woot!

But, all was not perfect. Gary C. told me the shipped configuration of the new RPi models didn't have the right firmware for 512MB, and I had to upgrade the start.elf in the /boot directory to recognize all of the 512MB RAM. I did a "free" command, and sure enough saw only 240MB. Sadness. But, Gary gave me a copy of his start.elf which worked after some trial and error.

For anyone ordering the new RPi Model B w/512MB, here are the steps to get you going with full 512MB RAM:

sudo apt-get update --fix-missing
sudo apt-get upgrade --fix-missing
# NOTE: This step takes at least a couple hours on a 
#   fast network

wget https://raw.github.com/raspberrypi/firmware/\

sudo mv /boot/start.elf /boot/orig-start.elf
sudo mv arm496_start.elf /boot/start.elf
sudo reboot
             total       used       free     shared    buffers     cached
Mem:        497768     210596     287172          0      16892     169624
-/+ buffers/cache:      24080     473688
Swap:       102396          0     102396

So of course this means... (drumroll) there is now 498MB available for the Java Embedded heap!

java -Xmx400m -version
java version "1.7.0_06"
Java(TM) SE Embedded Runtime Environment (build 1.7.0_06-b24, headless)
Java HotSpot(TM) Embedded Client VM (build 23.2-b09, mixed mode)
Yeah, baby!

Thursday Oct 18, 2012

Quickie Guide Getting Java Embedded Running on Raspberry Pi

***UPDATE 22Dec2012*** New Quickie Guide for JDK 8 for ARM & Hard-Float support: click here

Gary C. and I did a Bay Area Java User Group presentation of how to get Java Embedded running on a RPi. See: here. Also, see the technical article here. But, if you want the Quickie Guide on how to get Java up and running on the RPi (buy one here), then follow these steps (which I'm doing right now as we speak, since I got my RPi in the mail on Monday. Woo-hoo!!!).

So, follow along at home as I do the same steps here on my board...

1. Download the Win32DiskImager if you are on Windows, or if your are on a Linux PC skip this download and use dd instead:

2. Download the RPi Debian Wheezy image from here:

3. Insert a blank SD Card (NOTE: Only use a SD Card from this list) into your Windows, Mac, or Linux PC.

4. Use either Win32DiskImager or Linux dd to burn the unzipped image from #2 to the SD Card.
(NOTE: After burning the SD Card, it will say the size is 55MB. That's supposed to be that way and is OK, since the SD Card was imaged to have a swap area on it)

5. Insert the SD Card into your RPi. Connect an Ethernet cable to your RPi to your network. Connect the RPi Power Adapter. (NOTE: Make sure to use your RPi Power Adapter and do not use the USB port of a computer, since only the RPi Power Adapter will have enough current to drive your RPi and the SD Card)

6. The RPi will boot onto your network. Find its IP address using Windows Wireshark or Linux:
  sudo tcpdump -vv -ieth0 port 67 and port 68

7. ssh to your RPi:
  ssh <ip_addr_rpi> -l pi
  <Password: "raspberry">

8. Download Java SE Embedded:
  NOTE: First click accept, then choose the first bundle in the list:
    ARMv6/7 Linux - Headless EABI, VFP, SoftFP ABI, Little Endian -

9. scp the bundle from #8 to your RPi:
   scp <ejre-bundle> pi@<ip_addr_rpi>:/home/pi

10. Untar the bundle from #9 and rename (move) the ejre1.7.0_06 directory to /usr/local/java
   cd /home/pi
   tar zxvf ejre-7u6-fcs-b24-linux-arm-vfp-client_headless-10_aug_2012.tar.gz
   sudo mv ejre1.7.0_06 /usr/local/java
   export PATH=$PATH:/usr/local/java/bin
   java -version
     java version "1.7.0_06"
     Java(TM) SE Embedded Runtime Environment (build 1.7.0_06-b24, headless)
     Java HotSpot(TM) Embedded Client VM (build 23.2-b09, mixed mode)

That's it! You are ready to roll with Java Embedded on your RPi.

Monday Oct 15, 2012

Unboxing Raspbery Pi for Java Embedded Prototyping

My new Raspberry Pi is here! My new Raspberry Pi is here! Finally. Darn, it sure took long enough being out of stock for so long. You can see here (left) some shots of the unboxing of my Raspberry Pi.


Unboxing Raspberry Pi

Next up: load it with Java Embedded...

Friday Oct 12, 2012

Oracle moves to Java technology to embedded middleware

Here's another article pointing out our move to Java Embedded Middleware with our launch of Oracle Java Embedded Suite 7.0


Oracle moves to Java embedded middleware

Here's a quote:

 At the JavaOne Embedded conference, a 
 wafer thin embedded device that was 
 smaller than a Ritz cracker was loaded 
 up with the Java Embedded Suite.
I like that: "a wafer thin embedded device". Just one thin wafer. Reminds me of the scene from Monty Python's, The Meaning of Life. "Better?"

Wednesday Oct 10, 2012

JavaOne 2012 demo of Java SE Embedded on Raspberry Pi

Here's the Inquirer's article about our Java SE Embedded demos at JavaOne 2012 this year. Simon Ritter had a fun presentation showing the cool demo on the Raspberry Pi at his talk.


Demo Java SE Embedded on Raspberry Pi

Here's a quote:

 Oracle demonstrated Java SE for 
 embedded devices running on the 
 Raspberry Pi bare bones computer 
 at the Java One show on Wednesday, 
 with the aim of encouraging 
 developers to try it out for 
 themselves to create reference 
 libraries for the target school 
 children audience.
I had the presentation after Simon and saw the size crowd he had. They were laughing and clapping at the demo and having a good ol' time. Good to see the interest in Java SE Embedded, even if it is for a "toy" device like the Raspberry Pi. ;-)

Monday Oct 08, 2012

JavaOne 2012 session slides: "Dev Berkeley DB & DB Mobile Server for Java Embedded Tech"

The latest JavaOne 2012 slides are available on the Web. Here's the presentation that Eric Jensen and I did on "Developing Berkeley DB & DB Mobile Server for Java Embedded Technology". Enjoy!

You don't have a PDF plugin for this browser. It's OK, you can click here to download the PDF file.


Click here for the slides in a new window

It was fun to present this talk at JavaOne 2012 with Eric. We had some good questions from the audience. Let me know in the Comments if you have any further questions. I'll pass all the good questions to Eric and keep the bad questions for myself. ;-)


Hinkmond Wong's blog on making the Internet of Things (IoT) smarter with Java Technology and Artificial Intelligence (AI)


« October 2012 »