Skip to content

MicroEJ/AbstractionLayer-Zephyr

Repository files navigation

SDK ARCH

Generic Abstraction Layer for Zephyr VEE Ports

Overview

This project contains a complete Abstraction Layer implementation to run the VEE on a Zephyr system.

It consists of a Zephyr application project, with its own set of configurations (prj.conf, Kconfig, CMakeLists.txt).

Supported Features

This Abstraction Layer is compliant with Architecture 8.x and the following Packs:

Pack Name Version
DEVICE 1.2.0
EVENT 2.2.0
FS 6.0.4
MICROAI 2.2.0
NET 11.1.0

Architecture

The Multi-Sandbox Application download implementation is based on Best Fit Allocator backend in RAM, so without reboot persistence. Features are allocated in a fixed-size dedicated buffer.

Device Pack

The Device UID is based on the Zephyr Hardware Information API.

FS Pack

The following features of the file system are not available:

  • Setting the last modified date
  • Getting the last modified date
  • Synchronized I/O file integrity completion (FS_O_SYNC not supported by Zephyr)

MicroAI Pack

MicroAI implementation is based on TensorFlow Lite for Microcontrollers.

Usage

This project has two configuration steps.

First, you add this Abstraction Layer into a Zephyr VEE Port project.

Then you customize the features for your VEE Port requirements.

How to Use this Abstraction Layer in a Zephyr VEE Port

A typical Zephyr VEE Port can use this Abstraction Layer as its BSP to build and run the VEE.

See MicroEJ documentation about BSP connection.

The following folder structure can be used:

  • a VEE Port configuration project containing the board specific configurations (see details below)
  • a VEE Port Abstraction Layer (the current repository, fetched in bsp/vee)

It should look like this:

├── vee-port
    ├── bsp
        ├── boards
            ├── <my_board>.cmake
            ├── <my_board>.conf
            └── <my_board>.overlay
        ├── scripts
            ├── set_project_env.bat
            └── set_project_env.sh
    ├── build.gradle.kts
    ├── configuration.properties
    ...
├── bsp
    ├── zephyr-sources/
    ├── zephyr-modules/
    └── vee
        ├── CMakeLists.txt
        ├── Kconfig
        ├── prj.conf
        ├── build/
        ├── gradle/libs.versions.toml
        ├── inc/
        ├── lib/
        ├── port/
        ├── src/
        └── scripts/

BSP Connection

  • In this folder structure, we are using a full BSP connection: For example, in vee-port/configuration.properties:
bsp.microejapp.relative.dir=vee/lib
bsp.microejlib.relative.dir=vee/lib
bsp.microejinc.relative.dir=vee/inc
bsp.microejscript.relative.dir=vee/scripts
bsp.root.dir=${project.parent.dir}/bsp

Pack Version Dependencies

This Abstraction Layer is compatible with a set of MicroEJ packs.

The VEE Port project can use the file libs.versions.toml to set the proper pack dependencies in Gradle.

To do so, add in your VEE Port settings.gradle.kts file:

dependencyResolutionManagement {
    versionCatalogs {
        create("libsOverride") {
            from(files("./bsp/vee/gradle/libs.versions.toml"))
        }
    }
}

And in vee-port/build.gradle.kts:

    // Add the packs in the Gradle dependencies
    microejPack(libsOverride.pack.device)
    microejPack(libsOverride.pack.event)
    microejPack(libsOverride.pack.fs)
    microejPack(libsOverride.api.microai)
    microejPack(libsOverride.pack.net)

CMake Project Configuration

This Abstraction Layer does not come with a default configuration. It needs to be provided by the VEE Port project.

Three files are necessary, their contents are detailed in the following section VEE Port Configuration.

Here is a way to install them correctly on top of the Abstraction Layer:

// Add this code in vee-port/build.gradle.kts
tasks.register<Copy>("copyBspScripts") {
    from("bsp")
    into("../bsp/vee")
}

tasks.getByName("buildVeePort").dependsOn("copyBspScripts")
tasks.getByName("buildVeePortConfiguration").dependsOn("copyBspScripts")

This method makes sure that the files are copied before the compilation stage.

How to Customize the VEE Port

Now that we have seen how to connect this Abstraction Layer with a VEE Port, we will see how it can be configured.

VEE Port Configuration

This project relies on the Zephyr Configuration system. For detailed information, have a look at Zephyr's Application Development guide.

Board Configuration

At build time, the VEE Port configuration project will install the following files into the Zephyr Abstraction Layer project:

vee-port/bsp/
├── boards
│   ├── <board_name>.cmake
│   ├── <board_name>.conf
│   ├── <board_name>.overlay
└── scripts
    ├── set_project_env.bat
    └── set_project_env.sh

Note that Zephyr's BOARD qualifiers of the form // are normalized so that / is replaced with _ when used for filenames, for example: soc1/foo becomes soc1_foo when used in filenames.

Board selection

The board selection is done by setting an environment variable in the provided scripts : vee/scripts/set_project_env.bat/sh.

This allows quick switching between different boards for the same MicroEJ Application, without any modification in the building and flashing scripts.

If you wish to set the BOARD configuration via the west command line, it will have precedence on the environment variables, see Zephyr Application Development

Board-specific configuration

Once the BOARD is set, the Zephyr Abstraction Layer project will apply several board-specific configurations:

  • vee/boards/<board_name>.cmake

    • This is where you set all the CMake cache variables for your project, for example:
      • BOARD_FLASH_RUNNER and BOARD_DEBUG_RUNNER in case you want to change the default flashing tool (jlink, linkserver, OpenOCD).
      • EXTRA_CONF_FILE to customize Zephyr, see device tree overlays.
      • DTC_OVERLAY_FILE and EXTRA_DTC_OVERLAY_FILE to customize the boards device tree overlays.
  • vee/boards/<board_name>.conf

    • This Zephyr configuration file is used to set specific Kconfig options for your board. See Kconfig.
  • vee/boards/<board_name>.overlay

    • This Zephyr overlay is used to extend your board device tree.

How to Enable/Disable Each Module

The support of each MicroEJ pack is separated into different modules, which can all be disabled using Zephyr's Kconfig system.

Examples:

  • If your VEE Port doesn't need the FS Foundation Library, you can disable CONFIG_MICROEJ_FS.
  • CONFIG_MICROEJ_VALIDATION is only used to validate the core architecture and kernel implementation.

To disable a feature, add the following line in the vee-port/bsp/boards/<board_name>.conf file:

CONFIG_MICROEJ_FS=n

FS configurations

File System

To configure the File System, you can set the variable CONFIG_MICROEJ_FS_BACKEND_FATFS or CONFIG_MICROEJ_FS_BACKEND_FATFS in vee-port/bsp/boards/<board_name>.conf.

It will automatically select the relevant File System Kconfig options in Zephyr.

Mount point

To configure the filesystem location, you can set the variable CONFIG_MICROEJ_FS_MNT_POINT in vee-port/bsp/boards/<board_name>.conf to four values:

Here are some examples:

  • LITTLEFS: "/lfs"
  • FLASH: "/NAND:"
  • SDMMC: "/SD:"
  • RAM: "/RAM:"

If you use FatFS on RAM, you can modify the partition size in vee-port/bsp/boards/<board_name>.overlay.

Kernel configuration

The Kernel Zephyr Abstraction Layer allocates a buffer of CONFIG_MICROEJ_KF_KERNEL_WORKING_BUFFER_SIZE bytes in RAM. Features will be allocated in this dedicated buffer.

Requirements

This Abstraction Layer implementation requires the Zephyr SDK and Zephyr source.

MISRA Compliance

This Abstraction Layer has a list of components that are MISRA-compliant (MISRA C:2012) with some noted exception. Below is the list of folders that have been verified:

  • port/core

It has been verified with Cppcheck v2.13. Here is the list of deviations from MISRA standard:

Deviation Category Justification
Rule 17.7 Required Unused non-void returned type, the use of
returned values of debug traces is not necessary
Rule 21.6 Required The Standard Library input/output functions shall not be used

Dependencies

  • MicroEJ Architecture 8.x or higher.
  • Zephyr 4.1 or higher.

Source

N/A

Restrictions

None.


Markdown
Copyright 2025 MicroEJ Corp. All rights reserved.
Use of this source code is governed by a BSD-style license that can be found with this software.

About

MicroEJ Abstraction Layer implementation for Zephyr.

Resources

License

Stars

Watchers

Forks

Packages

No packages published