Kernel Creation

Create a new Project

To create a new Kernel project:

Create a new Application following the steps described in SDK 6 User Guide - Create a Project depending on your IDE.

Configure a VEE Port

Before building the Kernel, you need to have a VEE Port with Multi-Sandbox capability. To enable the Multi-Sandbox capability in your VEE Port configuration, follow the instructions from the Multi-Sandbox section.

Once the VEE Port is available, configure the target VEE Port in your Kernel project:

Build the Executable and Virtual Device

The Multi-Sandbox Executable and the Virtual Device of the Kernel Application must be built to allow the development and execution of Sandboxed Applications.

  • The Executable can be built by executing the Gradle buildExecutable task:

    ./gradlew buildExecutable
    

The Executable is generated in the build/application/executable folder of the project. For more information about the build of the Executable depending on your IDE, refer to the Build an Executable page.

  • The Virtual Device can be built by executing the Gradle buildVirtualDevice task:

    ./gradlew buildVirtualDevice
    

The Virtual Device is generated in the build/virtualDevice folder of the project. For more information about the build of the Virtual Device depending on your IDE, refer to the Build a Virtual Device page.

Build the Executable in the Workspace

Note

The build of the Executable in the Workspace is available for SDK 5 only. Refer to the Build an Executable page to build the Executable with SDK 6.

It is possible to build the Executable using a MicroEJ Launch rather than the regular module build. This speeds-up the build time thanks to MicroEJ Module Manager workspace resolution and Eclipse incremental compilation.

  • Import the Kernel project and all Sandboxed Application projects in the same workspace,

  • Prepare a MicroEJ Application launch for the Kernel as a regular Standalone Application,

  • Prepare a MicroEJ Application launch for each Sandboxed Application using Build Dynamic Feature settings.

The following figure shows the overall build flow:

Kernel Build Flow using MicroEJ Launches

Kernel Build Flow using MicroEJ Launches

Expose APIs

A Kernel must define the set of classes, methods and static fields all applications are allowed to use.

Note

According to the Kernel and Features specification, no API is open by default to Sandboxed Applications.

This can be done either by declaring Kernel APIs or by defining a Runtime Environment.

The main difference is from the Application development point of view. In the first case, the Application project still declares standard module dependencies. This is the good starting point for quickly building a Kernel with Applications based on the MicroEJ modules as-is. In the second case, the Application project declares the runtime environment dependency. This is the preferred way in case you intend to build and maintain a dedicated Applications ecosystem.

A Kernel API or a Runtime Environment module must be added as dependency of the project:

  • A Kernel API module is added as a dependency with the configuration implementation.

dependencies {
   implementation("com.microej.kernelapi:edc:1.2.0")
   implementation("ej.api:edc:1.3.4")
}

Warning

Unlike SDK 5 (MMM), Kernel API dependencies are not transitively fetched with SDK 6. They must therefore be explicitly added.

  • A Runtime Environment module is added as a dependency with the configuration microejRuntimeEnvironment.

dependencies {
   microejRuntimeEnvironment("com.mycompany:myruntimeapi:1.0.0")
}

Implement a Security Policy

A complete section about how to setup a security policy is available in the Application security policy page.

Add Pre-installed Applications

On a device, when a Kernel starts, it will load all the installed applications from persistent memory (ROM) [1].

To mimic this behavior on a Virtual Device, add an Application as dependency of the Kernel project:

with the configuration microejApplication

dependencies {
    microejApplication("com.mycompany:myapp:0.1.0")
}

The provided Application is installed in the Virtual Device only, refer to the Application Linking page to install Applications on the target device.

Kernel Application Configuration with SDK 5

Note

This section concerns SDK 5 only. For more information about the configuration of a Kernel Application with SDK 6, refer to the Application section.

Module Configuration

The build-firmware-multiapp build type defines additional configurations, used to specify the different kind of firmware inputs (see Input and Output Artifacts) as dependencies.

The following table lists the different configuration mapping usage where a dependency line is declared:

<dependency org="..." name="..." rev="..." conf="[Configuration Mapping]"/>
Configurations Mapping for build-firmware-multiapp Build Type

Configuration Mapping

Dependency Kind

Usage

vdruntime->default

Add-On Library (JAR)

Embedded in the Virtual Device only, not in the Executable

default->default; vdruntime->default

Add-On Library (JAR)

Embedded in both the Executable and the Virtual Device

platform->default

VEE Port

VEE Port dependency used to build the Executable and the Virtual Device. There are other ways to select the VEE Port (see Select a VEE Port)

kernelapi->default

Runtime Environment (JAR)

See Runtime Environment

systemapp-vd->application

Application (WPK)

Included to the Virtual Device as pre-installed Application.

Example of minimal firmware dependencies.

The following example defines a Kernel that exposes all APIs of EDC library.

<dependencies>
    <dependency org="ej.api" name="edc" rev="1.2.0" conf="provided" />
    <!-- Runtime API (set of Kernel API files) -->
    <dependency org="com.microej.kernelapi" name="edc" rev="1.0.0" conf="kernelapi->default"/>
</dependencies>

Build Options

The Kernel Application module nature section describes all the options available for building a Kernel module.

Build only a Virtual Device with a pre-existing Kernel

Copy/Paste the .kpk file into the folder dropins