Skip to content

Latest commit

 

History

History

kos

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Protobuf usage example

This solution is an example of using the previously built protobuf with KasperskyOS. The example demonstrates sending a protobuf message from one program to another.

The protobuf libraries can be built and used as either static or dynamic libraries, but not both simultaneously. In this solution a dynamically compiled version of the previously built protobuf libraries is used. As a result, attempting to force static linking using the initialize_platform(FORCE_STATIC) command will trigger a linkage error. For additional details regarding this command, please refer to the platform library.

Table of contents

Solution overview

List of programs

  • Producer—Program that reads the address book file on the SD card and converts it into a protobuf message, which it then sends to the Consumer program
  • Consumer—Program that prints the message received from the Producer
  • VfsSdCardFs—Program that supports the SD card file system
  • BlobContainer—Program that loads dynamic libraries used by other programs into shared memory
  • SDCard—SD card driver
  • EntropyEntity—Random number generator
  • BSP—Driver for configuring pin multiplexing parameters (pinmux)

Initialization description

Statically created IPC channels
  • example.Consumerkl.bc.BlobContainer
  • example.Producerkl.VfsSdCardFs
  • example.Producerexample.Consumer
  • example.Producerkl.bc.BlobContainer
  • kl.VfsSdCardFskl.drivers.SDCard
  • kl.VfsSdCardFskl.EntropyEntity
  • kl.VfsSdCardFskl.bc.BlobContainer
  • kl.bc.BlobContainerkl.VfsSdCardFs
  • kl.drivers.SDCardkl.drivers.BSP
  • kl.drivers.SDCardkl.bc.BlobContainer
  • kl.EntropyEntitykl.bc.BlobContainer
  • kl.drivers.BSPkl.bc.BlobContainer

The ./einit/src/init.yaml.in template is used to automatically generate 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 part of the security.psl file using CMake tools. The security.psl file contains 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 the Raspberry Pi hardware platform, make sure you meet all the System requirements listed in the KasperskyOS Community Edition Developer's Guide.
  2. Make sure that the environment variable CMAKE_FIND_ROOT_PATH specifies the installation path of the protoc compiler.

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, go to the <root_directory>/kos directory (where root_directory is the root directory with the project's source files) and execute the build-example.sh script. Syntax for using the build-example.sh script:

$ SDK_PREFIX=/opt/KasperskyOS-Community-Edition-<version> ./build-example.sh <platform> [--help],

where:

  • version—Variable that specifies the latest version number of the KasperskyOS Community Edition SDK.
  • SDK_PREFIX—Environment variable that specifies the path to the installed version of the KasperskyOS Community Edition SDK. The value of this environment variable must be set.
  • platform—Variable that can take one of the following values: qemu for QEMU or rpi for Raspberry Pi 4 B. Default value: qemu.
  • -h, --help—Parameter that displays help text when used.

QEMU

Running build-example.sh creates a KasperskyOS-based solution image that includes the example. The kos-qemu-image solution image is located in the <root_directory>/build/example_kos/einit directory, where root_directory is the root directory with the project's source files. The build-example.sh script both builds the example on QEMU and runs it.

Raspberry Pi 4 B

Running build-example.sh creates a KasperskyOS-based solution image that includes the example and a bootable SD card image for Raspberry Pi 4 B. The kos-image solution image is located in the <root_directory>/build/example_kos/einit directory, where root_directory is the root directory with the project's source files. The rpi4kos.img bootable SD card image is located in the <root_directory>/build/example_kos 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/example_kos/rpi4kos.img of=/dev/sd[X] conv=fsync,

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

  2. Connect the bootable SD card to the Raspberry Pi 4 B.

  3. Supply power to the Raspberry Pi 4 B and wait for the example to run.

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

  1. Prepare Raspberry Pi 4 B and a bootable SD card to run the example by following the instructions in the KasperskyOS Community Edition Online Help.
  2. Run the example by following the instructions in the KasperskyOS Community Edition Online Help

⬆ Back to Top

CMake input files

./consumer/CMakeLists.txt—CMake commands for building the Consumer program.

./producer/CMakeLists.txt—CMake commands for building the Producer program.

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

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

Usage

After running the example, the address book content and the results of any actions performed should be displayed in the standard output. For example:

...

[example.Consumer] Started
[example.Producer] Started
[example.Consumer] Person ID:  0
[example.Consumer]   Name: White Rabbit
[example.Consumer]   E-mail address:  [email protected]
[example.Consumer]   Mobile phone #: 8-801-587-5002
[example.Consumer]   Updated:  2024-04-21T21:38:32Z
[example.Consumer] Person ID:  1
[example.Consumer]   Name:  Santa Claus
[example.Consumer]   E-mail address:  [email protected]
[example.Consumer]   Home phone #: 8-123-456-7890
[example.Consumer]   Updated:  2024-04-21T21:38:32Z
[example.Consumer] Person ID:  2
[example.Consumer]   Name: Boogie Man
[example.Consumer]   E-mail address:  [email protected]
[example.Consumer]   Work phone #: 8-800-123-4567
[example.Consumer]   Mobile phone #: 8-001-987-5432
[example.Consumer]   Updated:  2024-04-21T21:38:32Z

Licensing

This project is licensed under the terms of the 3-Clause BSD License. See LICENSE for more information.

⬆ Back to Top

© 2024 AO Kaspersky Lab