The Eclipse Edje project, initiated by MicroEJ, defines a standard high-level Java API for accessing hardware features delivered by 32-bit microcontrollers for using serial links, general purpose inputs/outputs, or digital/analog converters. MCUs are small, low-cost, low-power processors designed to run software in resource-constrained environments: low memory (typically KB), flash (typically MB) and frequency (typically MHz). MCUs are provided by silicon vendors along with evaluation kits and are typically the ideal vectors for large scale deployments of low-power and cost-effective IoT, embedded or wearable devices. Edje aims at unifying and easing the programming of apps for MCUs with the largely adopted Java language.
2. Edje focuses on the following aspects
EDJE API FOCUS
Controller
Communication
Interfaces
Serial Port
CAN
Digital and
Analog I/O
GPIO
Peripheral
Management
LCD
USB Devices
Analog Input
3. Laurent Lagosanto
Senior Architect at MicroEJ®
18 years of “Java in the Small” activities
laurent.lagosanto@microej.com
ABOUT THE PRESENTER
The information contained herein is not warranted to be error-free.
MicroEJ® and all relative logos are trademarks or registered trademarks of IS2T S.A. in France and other Countries.
Java™ is Sun Microsystems’ trademark for a technology for developing application software and deploying it in cross-platform, networked
environments. When it is used in this site without adding the “™” symbol, it includes implementations of the technology by companies other
than Sun. Java™, all Java-based marks and all related logos are trademarks or registered trademarks of Sun Microsystems Inc, in the United
States and other Countries.
Other trademarks are proprietary of their respective owners.
4. Independent Software Vendor, global player in the embedded IoT industry
• http://www.microej.com/about
• Software tool & runtime licenses
• Professional services, training & consulting
KEY FINANCIALS
• $5M Series B funding end 2011 – $20M R&D total investment
Offices in France, Germany, USA
Expertise in embedded, virtualization, software engineering & process
Partnerships with key IoT, silicon, embedded SW and HW (EMS) vendors
ABOUT MICROEJ
13. Performance matters
Almost no boot time, instantly-on
Power efficiency, last for months, years
Size matters
Cost-effectiveness is key : footprint
Size of the package
Versatility matters
Plethora of protocols (to hardware, and to cloud services)
Shorten time to market by reducing development time
IOT : WHAT MATTERS FOR EDGE DEVICES ?
14. AN EXEMPLE OF FOOTPRINT REDUCTION
James Bauer James Bauer
Reply
Call me later
Alex
Jackson
Hi there! I’ll
be late, sorry.
RTOS (Linux) + Java platform RTOS (Any/None) + Java platform
Power 410 mAh – batteries recharge every day Batteries recharge every two or three weeks
Processor
Qualcomm Snapdragon 400 MSM8226,
ARM based Quadcore 1.2 GHz
ARM Cortex-M4 based MCU, 100 MHz
RAM (data) 256 MB Less than 0.5 MB
FLASH
(Code + Resources)
2,000 MB 2 MB
Boot Time 35,000 ms 50 ms
63% Bill of Materials savings
87% power consumption savings
15. ROM (KB)
Standard mode
ROM (KB)
Tiny mode**
RAM (KB)
Application Total: 36.1
36.1
Total: 27.2
27.2
See below (52.0)
Resources
Images uncompressed
Fonts
Strings
Total: 836.9
803.0
16.7
17.2
Total: 836.9
803.0
16.7
17.2
MicroEJ Platform
EDC
MicroUI, MWT, Motion
Total: 198.0
24.1
172.9
Total: 143.0
19.2
123.8
52.0 (application heap, stacks)
MicroEJ Sandbox
MicroEJ software core (VM)
MicroEJ RAM optimizer (GC)
Total: 29.1
15.2
13.9
Total: 29.1
15.2
13.9
BSP
RTOS
Driver & Low Level API
UI drivers
Total: 108.4
13.4
54.5
40.5
Total: 108.4
13.4
54.5
40.5
1.5
522 (2x frame buffers WQVGA) + 1
Total without Resources
Total with Resources
371 KB
1.2 MB
307 KB
1.1 MB
606.5 KB
606.5 KB
TYPICAL REAL APPLICATION FOOTPRINT (KB)
WASHING MACHINE ON ARM CORTEX-M4 / GCC
**Tiny mode available when MicroEJ application code is below 256KB of flash
16. A Hardware Abstraction Java API for the embedded systems
• Peripheral management
• Controller Communication Interfaces (Serial connection, CAN, SPI, I²C)
• Digital and Analog I/O (GPIO, ADC, DAC)
Scope
• Target resource-constrained devices (MCU & low-cost MPUs)
• Provide ready-to-use software packages for target hardware
• Define a modular and easy to port framework
Project Status
• Eclipse IoT project
• Proposal approved, entered Incubation phase
• Initial code drop end of July
EDJE PROJECT
18. JavaSE
List of minimum Java API
The minimum execution environment provided by an Edje-compatible device
Intersection between Java SE, Java SE Embedded, MicroEJ and Android
EDJE DEVICE CONFIGURATION (EDC)
JavaSE
Embedded
Android
MicroEJ OS
EDC
19. List of minimum Java API
The minimum execution environment provided by an Edje-compatible device
Intersection between Java SE, Java SE Embedded, MicroEJ and Android
EDJE DEVICE CONFIGURATION (EDC)
Edje Device Configuration
Edje API
Edje Application
Library
Execution
Environment
Application
Framework
Other
APIs
Other
APIs
Other
APIs
20. Only core packages are included:
java.lang (string, numbers, threads…)
java.lang.annotation (may not be runtime)
java.lang.ref (weak refs)
java.lang.reflect (only the annotation part)
java.io (no files)
java.security (permissions)
java.util (subset of collections)
EDJE DEVICE CONFIGURATION (EDC)
21. These features are NOT included:
• Network APIs
• Storage APIs
• Communication APIs
• Graphics & User Interface
Some may be added as Edje libraries, some don’t.
Some may require native implementations, some don’t and can be downloaded.
EDJE DEVICE CONFIGURATION (EDC)
23. Edje focuses on the following aspects
EDJE API FOCUS
Controller
Communication
Interfaces
Serial Port
CAN
Digital and
Analog I/O
GPIO
Peripheral
Management
LCD
USB Devices
Analog Input
24. Lists the peripherals of a platform
• MCU peripherals (UART, timer, USB controller, …)
• Board peripherals (screen, GPIO ports, button, LED, sensors, …)
• External peripherals (USB devices, bluetooth devices, …)
Peripheral plug/unplug notification system (event listeners)
Two use cases:
• Static peripherals:
• Attached to the board or the MCU, they never appear nor disappear
• applications can adapt to the target configuration
• Dynamic peripherals
• they can be unplugged from the device
• applications can react to these events (e.g. an application can register a Z-wave plug
“peripheral driver” because a USB serial port just appeared)
EDJE API: PERIPHERAL MANAGEMENT
27. EDJE API: PERIPHERAL MANAGEMENT SAMPLES
// static use case:
Iterator<Peripheral> peripherals = PeripheralManager.list();
while(peripherals.hasNext()) {
Peripheral p = peripherals.next();
System.out.println("Edje periph : " + p.getName());
}
// dynamic use case:
PeripheralManager.addRegistrationListener(new RegistrationListener<MyDevice>()
{
public void peripheralRegistered(RegistrationEvent<MyDevice> event) {
event.getPeripheral().myDeviceMethod(…);
}
public void peripheralUnregistered(RegistrationEvent<MyDevice> event){
}
}, MyDevice.class);
28. Some peripherals can establish a connection to external devices
• Serial Connection (UART)
• Serial Peripheral Interface (SPI)
• Inter-Integrated Circuit (I²C)
• Controller Area Network (CAN)
Such peripherals implement the Connectable interface:
interface Connectable {
Connection openConnection(String args) throws IOException;
}
EDJE API: COMMUNICATION INTERFACES
List<CommPort> serialPorts = PeripheralManager.list(CommPort.class);
for(CommPort serialPort : serialPorts){
// a connection is auto-closeable:
try {Connection cnx = serialPort.openConnection("baudrate=115200;bitsperchar=8") {
…
}
}
29. interface CommPort extends Peripheral, Connectable {
}
interface CommConnection extends StreamConnection {
int getBaudrate();
int setBaudrate(int baudrate);
}
interface BitsInput {
int getLength();
int readBits(boolean signExtends)
int readBits(int[] data, boolean signExtends)
…
}
interface BitsOutput {
…
}
EDJE API : COMM PORTS
30. Manage I/O pins connected to the MCU, configuring them with different
mode/options:
Digital In/Out: General Purpose Input/Output (GPIO)
• (input configurable in floating, pull-up or pull-down modes)
LED, Buzzer, Button
Analog In: Analog to Digital Converter (ADC)
• Potentiometer, Temperature Sensor, Light Sensor
Analog Out: Digital to Analog Converter (DAC)
• Speaker, Light Dimmer
Pulse Width Modulation: (PWM)
• Motor
EDJE API : DIGITAL AND ANALOG I/O
31. • A pin is identified by the port name and an ID
• Port name can be
• MCU specific
EDJE API : DIGITAL AND ANALOG I/O
PortAPortB
32. • A pin is identified by the port name and an ID
• Port name can be
• Board specific
EDJE API : DIGITAL AND ANALOG I/O
J1
J2
J3
J4
33. • A pin is identified by the port name and an ID
• Port name can be
• Standard / application dependent
EDJE API : DIGITAL AND ANALOG I/O
Digital Arduino
Analog Arduino
34. interface GPIOPort extends Peripheral {
enum Mode {
DIGITAL_INPUT, DIGITAL_INPUT_PULLUP,
DIGITAL_INPUT_PULLDOWN, DIGITAL_OUTPUT,
ANALOG_INPUT, ANALOG_OUTPUT
}
void setMode(int pin, Mode mode);
boolean getDigitalValue(int pin);
void setDigitalValue(int pin, boolean value);
int getAnalogValue(int pin);
void setAnalogValue(int pin, int value);
int getAnalogMinValue(int pin);
int getAnalogMaxValue(int pin);
}
EDJE API : DIGITAL AND ANALOG I/O
35. STM32F746G-DISCO
Cortex-M7 200 MHz
RAM: 8 MB
Flash: 16 MB
EDJE API : DIGITAL AND ANALOG I/O SAMPLES
Eth
Audio
USB-micro
USB-micro
USB-mini
(STLink)
SD
Digital
Arduino
Analog
Arduino
36. STM32F746G-DISCO
Cortex-M7 200 MHz
RAM: 8 MB
Flash: 16 MB
YWROBOT
(Easy Module Shield v1)
EDJE API : DIGITAL AND ANALOG I/O SAMPLES
Eth
Audio
USB-micro
USB-micro
USB-mini
(STLink)
SD
Digital
Arduino
Analog
Arduino
38. // Let’s blink a led
GPIOPort gpio = PeripheralManager.find(GPIOPort.class,
"ARDUINO_DIGITAL");
gpio.setMode(12, Mode.DIGITAL_OUTPUT);
boolean toggle = true;
while(true) {
gpio.setDigitalValue(12, toggle); // that’s D12
toggle = !toggle;
sleep(500);
}
EDJE API: DIGITAL AND ANALOG I/O SAMPLES
39. // Let’s read a potentiometer
GPIOPort gpio = PeripheralManager.find(GPIOPort.class,
"ARDUINO_ANALOG");
gpio.setMode(0, Mode.ANALOG_INPUT);
int value = 0;
while(true) {
int value = gpio.getAnalogValue(0); // that’s A0
System.out.println("potentiometer value = " + value);
sleep(500);
}
EDJE API: DIGITAL AND ANALOG I/O SAMPLES
43. Initial code drop (July 21st)
• Submitted after Legal review
• In develop branch, not master
• Draft API
Scope:
• Peripheral Management
• Connection API
• No actual peripheral APIs (no GPIO, no CommPort, …)
WHAT IS AVAILABLE
44. Updated / New API
• Core API changes (generics, permissions)
• CommPort API
• GPIO API
More tests
Samples
Reference implementation on MicroEJ OS
AVAILABLE FOR ECLIPSECON EUROPE 2016
45. Features
• Peripheral Management
• UART, USB CDC, GPIO, DAC, ADC
Hardware
• STM32F746G-DISCO
• Cortex-M7 @ 200 MHz
• RAM: 8 MB
• Flash: 16 MB
Platform
• MicroEJ OS
• FreeRTOS
• STM32Cube
REFERENCE IMPLEMENTATION: ON MICROEJ
46. Features
• Peripheral Management
• UART, USB CDC, GPIO, DAC, ADC
PC Simulation
• Java® SE
• Hardware In the Loop Simulation (HIL)
REFERENCE IMPLEMENTATION: ON MICROEJ
Execution
Flow
Ethernet
or Serial
50. Features
• Peripheral Management
• UART, USB CDC, GPIO, DAC, ADC
Hardware
• Raspberry-Pi 2
• Quad-Cortex-A7 @ 900 MHz
• RAM: 1 GB RAM
Platform
• Kura
• OpenJDK
• Linux
OTHER REFERENCE IMPLEMENTATION: JAVA SE ?
51. THANK YOU
FOR YOUR ATTENTION!
https://projects.eclipse.org/projects/iot.edje
Editor's Notes
To illustrate these differences, here is an example of a MCU based device and an example of a MPU based device.
The STM32F4 Discovery board embeds an ARM Cortex-M4 microcontroller. It runs at 168 MHz with some kilobytes of RAM and one mega byte of flash.
The Raspberry Pi 2 is more powerful, it is equipped with a quad-core ARM Cortex-A7. It has 1 gigabytes of RAM and the code is stored on an SD card with a capacity of several gigabytes.
This figure illustrates where Edje is used. It is embedded in the devices that collect data from sensors and drive actuators. These devices can communicate with the cloud directly or through a gateway.
Edje is really at the edge of the IoT.
First of all, before defining the Edje API we need to specify a Java execution environment that is available on all the Edje compatible devices.
Edje must rely only on this execution environment. This means the Edje API must compile on a platform that provides only the classes defined in this configuration.
This execution environment is called “Edje Device Configuration”. It is the intersection between Java SE Embedded, MicroEJ and Android.
First of all, before defining the Edje API we need to specify a Java execution environment that is available on all the Edje compatible devices.
Edje must rely only on this execution environment. This means the Edje API must compile on a platform that provides only the classes defined in this configuration.
This execution environment is called “Edje Device Configuration”. It is the intersection between Java SE Embedded, MicroEJ and Android.
First of all, before defining the Edje API we need to specify a Java execution environment that is available on all the Edje compatible devices.
Edje must rely only on this execution environment. This means the Edje API must compile on a platform that provides only the classes defined in this configuration.
This execution environment is called “Edje Device Configuration”. It is the intersection between Java SE Embedded, MicroEJ and Android.
First of all, before defining the Edje API we need to specify a Java execution environment that is available on all the Edje compatible devices.
Edje must rely only on this execution environment. This means the Edje API must compile on a platform that provides only the classes defined in this configuration.
This execution environment is called “Edje Device Configuration”. It is the intersection between Java SE Embedded, MicroEJ and Android.
The peripheral management service is in charge of listing the peripherals available on a device.
There are several kinds of peripherals depending on their location on the device:
MCU peripherals are internal peripherals located inside the micro controller chip (for example an UART used to established a serial connection).
The board peripherals are soldered on the device and are known by the platform
The external peripherals are dynamically created and destroyed when a peripheral is plugged or unplugged from the device.
The peripheral manager includes a plug/unplug notification system. You can define a listener that will be notified when a specific type of peripheral is connected or disconnected.
The topology of the peripherals on the device is accessible. You can get the children and parent of a peripheral.
Some peripherals can be used to establish a connection to an external device or peripheral.
Here are typical controller communication systems : UART, SPI, I²C, CAN
These peripherals implement the Connectable interface that defines the openConnection method. The connection configuration is described by a String.
Here is a simple example with Serial ports.
First line retrieved the list of the serial port available on the device.
The serialPort interface extends the connectable interface.
Then for each serialport we can open a connection. These connections may be used to open input or output streams.
The digital and analog I/O service manages the micro-controller pins.
The API is inspired from Arduino C API.
Depending on the MCU the pins can be configured in different ways.
It can be a GPIO, then you can set or get the digital value of the pin (0 or 1). A GPIO can drive a LED, a buzzer, a button. For example, setting a pin to 1 can turn on a LED.
A pin can be an Analog to digital converter. The pin is configured as an analog input. For example with a temperature sensor, you can get an integer value that represents the temperature.
With a Digital to Analog converter you are able to drive a speaker or a light dimmer.
A PWM is a more sophisticated analog output that can be used to control a motor.
A micro-controller based implementation will also be provided.
It will run on an STM32F7 discovery board designed by ST Microelectronics.
The microcontroller is an ARM Cortex-M7.
The java platform will be MicroEJ OS ported over FreeRTOS. The board support package used is STM32Cube.
A micro-controller based implementation will also be provided.
It will run on an STM32F7 discovery board designed by ST Microelectronics.
The microcontroller is an ARM Cortex-M7.
The java platform will be MicroEJ OS ported over FreeRTOS. The board support package used is STM32Cube.
A PC simulation will also be provided.
It will integrate an hardware in the loop solution.
With this kind of architecture, the peripheral accesses are delegated to a real device that communicates with the PC using a serial or ethernet connection.
This is useful for prototyping.
The reference implementations will provide the same features:
A peripheral manager
UART, USB CDC, GPIO, DAC and ADC
A raspberry pi implementation will be provided. It will run over Kura, the OpenJDK and linux.