Advertisement

Java technology for embedded systems

Embedded applications are moving to complex user interfaces that demand new tools

BY REGIS LATAWIEC

Executive Vice President of Business Development

IS2T

www.is2t.com

The nature of embedded systems is being changed with the advent of graphical, intelligent human-machine interfaces and the Internet of Things. Every imaginable system, from coffee makers and washing machines to health-monitoring and industrial control, are offering improved user experience by providing excellent human interfaces.
The challenge of this revolution is how to implement complex functionality that has historically required very fast processing speeds and massive amounts of memory into the resource-constrained microcontrollers of embedded applications. The C language, which is great for implementing the real-time command and control functions required by embedded systems, is very inadequate for designing these more complex applications.
One needs to consider what technology should be used for designing attractive products launched on time without sacrificing robustness and quality, and while maximizing return on software investments from the past. New Java technology implementations are the enabling technologies that meet those constraints.
C language is good for specifics tasks
The C language uses an imperative programming paradigm (procedural) that keeps data and processing separated. Like assembly language, C programmers can decide about data representation in memory since data are not strongly typed and can directly manipulate address pointers using arithmetic to access to data areas. This perfectly fits actual processor architectures whose hardware resources or peripherals can be accessed through data registers and buffers using address pointers.
Of course, having full control of data representation and addressing allows fast program execution — sometime almost as fast as assembly code when the compiler is excellent – but is weak regarding robustness and security, since code is raw executed without checks at runtime. Moreover, debugging is tedious: an error while dealing with a complex memory manipulation can easily lead to a system crash hard to debug at runtime.
Thus C fits programmer’s requirement when there is a need to control hardware from software and as long as memory management and interaction with other processing functions are limited. Applications like software drivers can provide a better abstraction of hardware peripherals or specific software libraries such as signal processing might take advantage of dedicated hardware mechanisms to optimize execution speed.
What Java can do that C/C++ can’t
Embedded software now often includes more complex application levels such as GUI or networked data collecting and processing. These are areas where the Java technology enables key benefits over C or C++.
Java is a general purpose programming technology based on statically typed object oriented (data and behavior are in a single entity). Java program source files are compiled into a well defined assembly code (bytecode) specified for a standardized processor that virtualizes the underlying execution architecture. This processor is called a Java Virtual Machine (virtual processor, JVM) and is usually implemented using software. The association of an object oriented programming language and of a virtual processor provides many key benefits.
Java language is easy to learn and to understand. It mainly borrows its syntax from C, but uses a single programming paradigm (OOP) that supports a dual paradigm (object oriented like Java and imperative like C), and is less confusing than C++. It also provides a clean and unified program organization while C/C++ spreads code across source file and header files. It is taught in many universities and more than 9 million of Java programmers are available across the world. Java language is a strongly typed language that avoids mistakes programmers tend to make while manipulating data, regardless of the underlying hardware processor architecture.
Virtual processor features and benefits
The virtual processor provides interesting features at runtime. Data memory management is automatic and controlled by the garbage collector (GC). The GC can be considered a memory optimizer that maximizes data memory availability during program execution. Data object allocations and releases are automatically managed without any programmer explicit action except invoking the creation of a new object when required. Thanks to the GC, additional parts of an application or new software libraries can easily be added without dealing with memory management strategy.
Runtime checks of memory allocation aid reliability ease testing requirements. Binary portability is another key feature. Multithreading is another important feature. Both the language and the virtual machine offer simple built-in mechanisms such as thread management and synchronization for mutual exclusive access of code blocks and reliable communication between threads.
Simulation
The Java technology is an opportunity to redefine the goal of simulation. Software simulation has always been a difficult task for embedded applications because it must embrace cycle true execution, functional behavior, and hardware in the loop testing. Since a Java platform is standardized by a well defined execution model and software APIs, it separates the execution platform (hardware, drivers and virtual processor) from the software application layers. The decoupling of the platform and the application design cycles allows designers to fully test and characterize the platform independently from the application and to focus simulation on the application itself.
 FAJH_IS2T_1_Feb2013

Fig. 1: Embedded & simulated Java platforms.
Using the Java virtual platform concept, it is easy and convenient to build an embedded platform that runs on a workstation with simulation capability. The simulated platform can include properties such as RTOS scheduling and can provide mock objects that extend to include capabilities not originally available from the workstation. This could include device front panels, sensors, actuators, and special communication protocols.
Such simulated platforms support a strong validation process because Java applications are executed by both the embedded and simulated platform using the same JAVA bytecode. Thus, the simulated platform becomes a powerful tool for debugging and testing the application from the highest level (functional test coverage) to the lowest one (binary test coverage).
Benefits for graphical user interfaces and internet of things
All above advantages over classic technologies are keys when designing software applications such as GUI and network oriented applications. They all heavily rely on object oriented concepts: GUI uses graphical objects such as shapes and widgets and network oriented devices define objects such as sensors and actuators. Such applications are highly dynamic and require intensive data memory allocation.
Simulation provides GUI with fast prototyping functionality that helps to verify end-user expectations within short design iterations before hardware is available.
C developers concerns about Java technology often deal with three topics: memory usage, execution speed, and legacy C code integration. Most embedded systems are based on an MCU with fairly small amount of on-chip flash. New Java technology implementations now offer low memory usage shown here below for typical platform example optimized for Cortex-M3/M4 based MCU. In this example, the Java platform provides a full implementation of the MicroUI and MWT graphical libraries for building complex GUI for color dot matrix displays.
FAJH_IS2T_2_Feb2013

Fig. 2: Java platform memory requirements.
Since we can consider Java libraries memory requirements to be equal to their C counterparts, the actual cost for the Java technology access is just 28 Kbytes (the Java virtual Machine runtime).
Execution speed is dictated by the Java Virtual Machine runtime performance, but also by the associated native (C) libraries. JAVA development platforms feature low complexity Java virtual machine runtimes and highly optimized libraries with average execution speed, compared to functionally identical C code, that is typically just about 20% slower.
Java integration with stable legacy native code (C/asm) has to be very simple to guarantee developers an easy and safe path.
The MicroEJ software development kit
One Java platform is the MicroEJ SDK. Built on the Eclipse IDE, it provides a complete software development environment for designing embedded Java applications. Developers can prototype, develop and test their Java applications with simulated Java platforms before programming them to embedded devices with the embedded Java platform runtime.
Two tasks are required to integrate a Java platform into an existing C-based system, 1) embed a Java Virtual Machine into the existing software architecture; 2) interface the hardware and the native (C/asm) business code to the Java libraries and application layers.
JVM and RTOS integration
The Java virtual machine is provided by MicroEJ as a library that can be linked with any ELF linker. ARM Keil SDK and GNU gcc are typical of native C development environments supported by the MicroEJ SDK. Adding more software features to an existing application often requires the addition of a simple RTOS (usually pre-emptive one) because the application needs to be responsive to many interactions (user interface or network events), even if background tasks are being processed.

Advertisement



Learn more about IS2T

Leave a Reply