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
Launcher – application that starts the Toybox program.Terminal – system program that facilitates interaction between the UART serial port and the virtual file system (Vfs program) for implementing standard input/output streams.ExecMgrEntity – system program that manages the life cycle of processes via IPC mechanisms.BlobContainer – system program that is designed to load binary data into memory and is used by the Execution Manager program to start processes.Dmesg – system program that is used to read diagnostic messages from the KasperskyOS kernel buffer, process them, and organize their storage and output. It is used in a solution when running the dmesg command.Ping – system program that is used to diagnose network availability, send ICMP requests, and check connections with other nodes on the network. It is used in a solution when running the ping command.EntropyEntity – system program that implements random number generation.Dhcpcd – system program that implements a DHCP client, which gets network interface parameters from an external DHCP server in the background and passes them to a virtual file system.Ntpd – system program that implements an NTP client that receives time parameters from external NTP servers in the background and forwards them to the KasperskyOS kernel.Vfs – system program that implements a virtual file system that includes both the network stack and file systems. In the application, it configures the terminal settings, processes the command line arguments and environment variables, then checks the initialization of the VFS backend and starts the main processing loop for file operations.DCM – system program that lets you dynamically create IPC channels.SDCard – SD card driver.DNetSrv – network card driver.UART is a driver for working with a universal asynchronous receiver-transmitter.When you build an example for the target hardware platform, platform-specific drivers are automatically included in the solution:
BSP is a hardware platform support package (Board Support Package). Provides cross-platform configuration of peripherals for the Radxa ROCK 3A and Raspberry Pi 4 B.PCIE – PCIE bus driver for the Radxa ROCK 3A and Raspberry Pi 4 B.GPIO – GPIO support driver for the Radxa ROCK 3A and Raspberry Pi 4 B.PinCtrl – low-level pin multiplexing (pinmux) configuration driver for the Radxa ROCK 3A.USB – driver for controlling all types of USB devices for the Radxa ROCK 3A and Raspberry Pi 4 B.Bcm2711MboxArmToVc – driver for working with the VideoCore (VC6) coprocessor via mailbox technology for Raspberry Pi 4 B.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:
/romfs/Toybox executable file from which the process will be started by using the ExecutionManager component.DcmConnect() function. (The DCM system program is used to connect to the ExecutionManager process.)IExecutionManager interface instance obtained at step 2.StartEntityInfo structure, which contains the parameters for starting the process:Toyboxtoybox.ToyboxVFS_NETWORK_BACKEND=client:toybox.Vfs and VFS_FILESYSTEM_BACKEND=client:toybox.Vfs/romfs/Toybox executable file by using the StartEntity() function of the IApplicationController interface.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