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.

See:

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);
           System.out.println
             ("Successfully updated the status to: " + 
               status.getText());
        } catch (Exception e) {
           e.printStackTrace();
        }
    }
}

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/\
164b0fe2b3b56081c7510df93bc1440aebe45f7e/boot/\
arm496_start.elf

sudo mv /boot/start.elf /boot/orig-start.elf
sudo mv arm496_start.elf /boot/start.elf
sudo reboot
free
             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:
  http://downloads.sourceforge.net/project/win32diskimager/Archive/win32diskimager-v0.7-binary.zip

2. Download the RPi Debian Wheezy image from here:
  http://files.velocix.com/c1410/images/debian/7/2012-08-08-wheezy-armel/2012-08-08-wheezy-armel.zip

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:
  http://www.oracle.com/technetwork/java/embedded/downloads/javase/index.html
  NOTE: First click accept, then choose the first bundle in the list:
    ARMv6/7 Linux - Headless EABI, VFP, SoftFP ABI, Little Endian -
    ejre-7u6-fcs-b24-linux-arm-vfp-client_headless-10_aug_2012.tar.gz

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.

About

Hinkmond Wong's blog on making Machine to Machine (M2M) and the Incredible Internet of Things (IoT) smarter with Java Embedded Technologies

Search

Categories
Archives
« October 2012 »
SunMonTueWedThuFriSat
 
1
2
3
4
5
6
7
9
11
13
14
16
17
19
20
21
22
24
27
28
29
31
   
       
Today