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.
First create a new Kernel Application.
A new project is generated into the workspace:
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:
To configure a VEE Port with SDK 6, see Select a VEE Port.
To configure a VEE Port with SDK 5, see Select a VEE Port.
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.
In the Package Explorer, right-click on the project and select Build Module. The build of the Executable and Virtual Device may take several minutes. Once the build has succeeded, the folder myfirmware > target~ > artifacts contains the firmware output artifacts (see Input and Output Artifacts) :
mymodule.out
: The Executable to be programmed on device.mymodule.kpk
: The Kernel package to be imported in a MicroEJ Forge instance.mymodule.vde
: The Virtual Device to be imported in the SDK.mymodule-workingEnv.zip
: This file contains all files produced by the build phase (intermediate, debug and report files).
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:
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")
}
A Kernel API or a Runtime Environment module is added as a dependency with the configuration
kernelapi->default
.
<dependency org="com.microej.kernelapi" name="edc" rev="1.2.0" conf="kernelapi->default"/>
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
Your device may come with pre-installed applications, also known as applications that are already available when the Kernel starts. These applications are installed during the manufacturing process, such as in ROM alongside the Kernel executable.
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")
}
with the configuration systemapp-vd->application
<dependency org="com.mycompany" name="myapp" rev="0.1.0" conf="systemapp-vd->application"/>
The provided Application is installed in the Virtual Device only, refer to the Application Linking page to install Applications on the Kernel.
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]"/>
Configuration Mapping |
Dependency Kind |
Usage |
---|---|---|
|
Add-On Library ( |
Embedded in the Virtual Device only, not in the Executable |
|
Add-On Library ( |
Embedded in both the Executable and the Virtual Device |
|
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) |
|
Runtime Environment ( |
|
|
Application ( |
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