Skip to content

Gradle plugin for building embedded Java applications on bare metal micros, like the Raspberry Pi

License

Notifications You must be signed in to change notification settings

chuckb/HaikuVMPlugin

Repository files navigation

HaikuVMPlugin Project

This is a Gradle plugin which aspires to simplify building and deploying Java applications on to bare metal micros, such as Arduino compatibles and the Raspberry Pis. It uses the HaikuVM project to generate a deployable virtual machine embedded with the target application's bytecode. It also couples a serial bootloader and boot image bundlng (in the Raspberry Pi case) to reduce embedded deployment friction.

This project is in active development and more hosts, boards, and documentation are planned for the future. The ./samples projects contain simple Java applications that demonstrate basic hello world LED blinking applications using delays, timers, and interrupts on the the Raspberry Pi Zero. They were tested out cross-compiling on a Mac host.

Prerequisites

  1. Java 1.8 or better
  2. Max OS/X or Windows 10 with WSL
  3. ARM cross compiler
  4. Pi Zero
  5. USB to TTL Serial Cable like this one from Adafruit

Running The Delayblink Sample

The delayblink Java project will blink the green ACT LED on the Rpi Zero.

  1. Clone this project.
  2. Change directory to samples/delayblink.
  3. ./gradlew buildPiImage
  4. cd build/firmware/pi
  5. Transfer the built pi boot image file to an empty micro SD card. Use sudo dd if=boot.img of=/dev/diskx bs=512. Use sudo diskutil list to find your SD card. Use sudo diskutil unmountDisk /dev/diskx to make the card available for dd writing.
  6. Plug card into Pi. Plug in USB serial adapter to workstation.
  7. Change directory back to samples/delayblink.
  8. ./gradlew deploy A console window should launch with host bootloader ready to transfer kernel to Rpi.
  9. Connect serial cable pins to Pi.
  10. Marvel at the blinking active LED on the Pi Zero board using bare metal Java code

RPi Serial Connection

Build A Standalone Project Using The Plugin

See Embedded Java Hello World On Raspberry Pi Zero. For Windows setup considerations, see Embedded Java For Raspberry Pi Zero Setup On Windows 10 Hosts

Attribution

This plugin is my own original work. My contribution was to add the missing bare-metal bootstrapping for boards like the Raspberry Pi and bundling/streamlining of the build/deploy operations into something familiar to Java developers, like Gradle tasks.

The plugin makes use of several projects and many educational sources: