uart_toybox example

This example demonstrates how to work with the Toybox component in a KasperskyOS-based solution.

Example directory in the SDK

The code of the example and build scripts are available at the following path:

/opt/KasperskyOS-Community-Edition-<platform>-<version>/examples/uart_toybox

List of programs

When you build an example for the target hardware platform, platform-specific drivers are automatically included in the solution:

Initialization description

The solution initialization description file named init.yaml is generated during the solution build process based on the ./einit/src/init.yaml.in template. Macros in @INIT_*@‌ ‌format contained in the template are automatically expanded in the resulting init.yaml file. For more details, refer to init.yaml.in template.

Security policy description

The security.psl file contains a description of a security policy for a KasperskyOS-based solution and is located in the ./einit/src directory. The declarations in the PSL file are provided with comments that explain the purpose of these declarations.

The solution security policy description in this example allows any interaction between different processes and between processes and the kernel. This policy can be used only as a stub during the early stages of a solution development so that the security module does not interfere with interactions. It would be unacceptable to apply such a policy in a real-world KasperskyOS-based solution.

Resources

The ./resources/xdl/exec_app/ExecApp.edl file is the EDL description for the class of processes that are started when the exec command of the Toybox component is executed.

The ./resources/xdl/toybox directory contains the Vfs.edl and Launcher.edl files, which are the EDL descriptions of the Vfs and Launcher programs, respectively.

The ./resources/hdd/etc directory contains the configuration files for the Vfs and Dhcpcd programs: hosts and dhcpcd.conf, respectively.

The ./resources/hdd/var/db/dhcpcd directory is used by the Dhcpcd program to store network connection data.

Operating scenario

The Launcher program performs the following actions:

  1. Sets the name of the /romfs/Toybox executable file from which the process will be started by using the ExecutionManager component.
  2. Gets the pointer to an instance of the IExecutionManager interface of the ExecutionManager component by using the DcmConnect() function. (The DCM system program is used to connect to the ExecutionManager process.)
  3. Gets access to the IApplicationController interface of the ExecutionManager component by using the pointer to the IExecutionManager interface instance obtained at step 2.
  4. Checks the availability of the network.
  5. Sets the following values in the StartEntityInfo structure, which contains the parameters for starting the process:
    • Process name: Toybox
    • Process class: toybox.Toybox
    • Environment variables that will be passed to the process at startup: VFS_NETWORK_BACKEND=client:toybox.Vfs and VFS_FILESYSTEM_BACKEND=client:toybox.Vfs
  6. Starts the process from the /romfs/Toybox executable file by using the StartEntity() function of the IApplicationController interface.
  7. Uses an event mask to track events associated with a running process by using the SubscribeToObject(), GetEvent(), and UnsubscribeFromEvent() methods of the notifications endpoint. If a tracked event occurs, such as the termination, error, or stoppage of the Toybox process, this process is restarted.

After running the Launcher program, the terminal will go into interactive mode, as indicated by the display of the standard command line prompt $. In this mode, the commands described in the Terminal component become available.

Building and running the example

The CMake system, which is included with KasperskyOS Community Edition, is used to build and run the example.

For the example to work correctly on Radxa ROCK 3A, apply the DTBO overlay rk3568-uart2-m0 to the hardware configuration description binary file rk3568-rock-3a.dtb according to the instructions on applying overlays provided in the Building drivers for the Radxa ROCK 3A hardware platform section.

See Building and running examples section.

Page top