Skip to content

Latest commit

 

History

History
246 lines (180 loc) · 12 KB

File metadata and controls

246 lines (180 loc) · 12 KB

Example of using the PackageManager component API

The KasperskyOS Community Edition SDK is delivered with three tools: cas-inspect, cas-pm, and cas-pack.

The cas-inspect tool (toolchain/bin/cas-inspect executable file) lets you get information about the contents of a KPA package. The KPA package consists of a KPA package manifest and KPA package components. The KPA package component may be an executable file, dynamic library, text data containing parameters, or any other data required for the program to work. For more information, see the KPA package topic in the KasperskyOS Community Edition Online Help.

The cas-pm utility (toolchain/bin/cas-pm executable file) installs KPA packages into a KasperskyOS-based solution image.

The cas-pack utility (toolchain/bin/cas-pack executable file) packs program source files into the KPA package.

For more information about these tools, see the Tools for managing KPA packages topic in the KasperskyOS Community Edition Online Help.

This example demonstrates how to use these tools from packing sources files of the program into the KPA package to install the KPA package into the KasperskyOS-based solution image. The installed program is also started with the ExecutionManager component.

For additional details on KasperskyOS, including its limitations and known issues, please refer to the KasperskyOS Community Edition Online Help.

Table of contents

Solution overview

List of programs

  • Application—Program that reads the contents of a text resource file and outputs its contents to standard error output
  • Launcher—Program that starts the Application program installed from the KPA package
  • ExecMgrEntity—Program that provides an interface for creating, starting, and stopping processes
  • BlobContainer—Program that loads dynamic libraries used by other programs into shared memory
  • DCM—Program for dynamic creation of IPC channels
  • NameServer—Program that provides an interface for dynamically creating IPC channels
  • EntropyEntity—Random number generator
  • VfsSdCardFs—Program that supports the SD card file system
  • SDCard—SD card driver
  • BSP—Driver for configuring pin multiplexing parameters (pinmux)

Initialization description

Statically created IPC channels
  • launcher.Launcherkl.core.NameServer
  • launcher.Launcherkl.bc.BlobContainer
  • launcher.Launcherexecution_manager.ExecMgrEntity
  • kl.bc.BlobContainerkl.VfsSdCardFs
  • execution_manager.ExecMgrEntitykl.bc.BlobContainer
  • execution_manager.ExecMgrEntitykl.core.DCM
  • kl.core.DCMkl.bc.BlobContainer
  • kl.core.NameServerkl.bc.BlobContainer
  • kl.VfsSdCardFskl.drivers.SDCard
  • kl.VfsSdCardFskl.EntropyEntity
  • kl.VfsSdCardFskl.bc.BlobContainer
  • kl.drivers.SDCardkl.bc.BlobContainer
  • kl.drivers.SDCardkl.drivers.BSP
  • kl.EntropyEntitykl.bc.BlobContainer
  • kl.drivers.BSPkl.bc.BlobContainer

The ./einit/src/init.yaml.in template is used to automatically generate a part of the solution initialization description file init.yaml. For more information about the init.yaml.in template file, see the KasperskyOS Community Edition Online Help.

Security policy description

The ./einit/src/security.psl.in template is used to automatically generate a part of the security.psl file using CMake tools. The security.psl file contains a part of a solution security policy description. For more information about the security.psl file, see Describing a security policy for a KasperskyOS-based solution.

⬆ Back to Top

Getting started

Prerequisites

  1. To install KasperskyOS Community Edition SDK and run examples on QEMU or on a hardware platform, make sure you meet all the System requirements, which are listed in the KasperskyOS Community Edition Developer's Guide.
  2. Install KasperskyOS Community Edition SDK. You can download the latest version of the KasperskyOS Community Edition for free from os.kaspersky.com. The minimum required version of KasperskyOS Community Edition SDK is 1.3. For more information, see System requirements.
  3. Copy source files to your project directory.

Building and running the example

The example is built using the CMake build system, which is provided in the KasperskyOS Community Edition SDK.

To build the example, run the ./cross-build.sh script. There are environment variables that affect the build of the example:

  • SDK_PREFIX specifies the path to the installed version of the KasperskyOS Community Edition SDK. If the -s option is not specified when the cross-build.sh script has been run, it is necessary to set the value of the SDK_PREFIX environment variable.
  • TARGET specifies the target platform. (Currently only the aarch64-kos platform is supported.)

Syntax for using the cross-build.sh script:

$ ./cross-build.sh [-h] [-l] [-t TARGETS] [-s PATH] [-b PATH],

where:

  • -h, --help

    Help text.

  • -l, --list

    List of all CMake targets which are available for building.

  • -t, --target TARGETS

    List of CMake targets that you want to build. Enclose the entire list of targets in quotation marks and separate the individual targets within the quotation marks with a space character. If not specified, the default target sim will be built.

  • -s, --sdk-path PATH

    Path to the installed version of the KasperskyOS Community Edition SDK. The path must be set using either the value of the SDK_PREFIX environment variable or the -s option. The value specified in the -s option takes precedence over the value of the SDK_PREFIX environment variable.

  • -b, --build PATH

    Path to the generated CMake build directory. If not specified, the default path ./build will be used.

For example, review the following command:

$ SDK_PREFIX=/opt/KasperskyOS-Community-Edition-<version> ./cross-build.sh

The command builds the example and runs the KasperskyOS-based solution image on QEMU. The solution image is based on the SDK found in the /opt/KasperskyOS-Community-Edition-<version> path, where version is the latest version number of the KasperskyOS Community Edition SDK.

QEMU

Running cross-build.sh (with the --target parameter set to sim) creates a KasperskyOS-based solution image that includes the example. The kos-qemu-image solution image is located in the ./<build_path>/einit directory, where build_path is the path to the generated CMake build directory.

The cross-build.sh script both builds the example on QEMU and runs it.

Hardware

Running cross-build.sh (with the --target parameter set to kos-image or sd-image) creates a KasperskyOS-based solution image that includes the example and a bootable SD card image for Raspberry Pi 4 B or Radxa ROCK 3A. The kos-image solution image is located in the ./<build_path>/einit directory. The hdd.img bootable SD card image is located in the ./<build_path> directory.

  1. To copy the bootable SD card image to the SD card, connect the SD card to the computer and run the following command:

$ sudo dd bs=64k if=build/hdd.img of=/dev/sd[X] conv=fsync,

where [X] is the final character in the name of the SD card block device.

  1. Connect the bootable SD card to the Raspberry Pi 4 B or Radxa ROCK 3A.
  2. Supply power to the Raspberry Pi 4 B or Radxa ROCK 3A and wait for the example to run.

You can also use an alternative option to prepare and run the example:

  1. Prepare the required hardware platform and bootable SD card for it by following the instructions:
  2. Run the example as described in the KasperskyOS Community Edition Online Help

CMake input files

When you develop a KasperskyOS-based solution, use the recommended structure of project directories to simplify usage of CMake scripts.

The CMakeLists.txt files use standard CMake syntax and scripts from the platform, nk, install, and image SDK libraries.

./application/CMakeLists.txt—CMake commands for building the Application program.

./einit/CMakeLists.txt—CMake commands for building the Einit program and the solution image.

./execution_manager/CMakeLists.txt—CMake commands for building the ExecMgrEntity program.

./kpa_package/CMakeLists.txt—CMake commands for packing the Application program source files into the KPA package, getting information about the contents of the KPA package, and installs this package into a KasperskyOS-based solution image.

./launcher/CMakeLists.txt—CMake commands for building the Launcher program, that starts the Application program with the ExecutionManager component.

./CMakeLists.txt—CMake commands for building the solution.

⬆ Back to Top

Usage

Build and run the example. After running the example, the following actions will be executed:

  1. KasperskyOS kernel runs the Einit initialization process.
  2. Einit initializes static IPC channels and runs all processes except the Application program.
  3. Launcher program starts the Application program.
  4. The Application program reads the contents of a text resource file and outputs its contents to standard error output
  5. On successful completion of work, programs print messages to standard output. The expected output is contained in the ./expected_output.txt file.

Trademarks

Registered trademarks and endpoint marks are the property of their respective owners.

Raspberry Pi is a trademark of the Raspberry Pi Foundation.

⬆ Back to Top

© 2025 AO Kaspersky Lab