KasperskyOS Community Edition 1.0

Preparing the solution's boot image

To automate the process of preparing the solution's boot image, you need to configure a build system. You can base this system on the build system implemented in the examples.

This section describes various methods for configuring a build system to prepare a solution's boot image.

In this section

Using a Makefile template from the contents of KasperskyOS Community Edition

Using CMake from the contents of KasperskyOS Community Edition

Using your own build system

Page top
[Topic build_automation_tools]

Using a Makefile template from the contents of KasperskyOS Community Edition

To simplify the process of preparing the solution's boot image using the make build system, you can use the build.mk template from KasperskyOS Community Edition. The template file is located at the following path:

/opt/KasperskyOS-Community-Edition-<version>/common/build.mk

To prepare a make build system using the build.mk template, do the following in the Makefile build script:

  1. Specify the value of the targets variable. In the variable value, list all applications included in the solution, separating them with a space. You are not required to specify the Einit or kl.core.Core applications because they are processed separately.
  2. For each application specified in the targets variable, specify the values for the following variables:
    • <application-name>-objects – list of object files of the application. You must list all object files.

      The names of object files are taken from the names of the entity source files according to the following rules:

      • *.c → *.o
      • *.idl → *.idl.o
      • *.cdl → *.cdl.o
      • *.edl → *.edl.o
    • <application-name>-ldflags – list of flags passed to the linker. If the entity uses the virtual file system, you must pass the flags specified in the LIBVFS_REMOTE variable.
    • <application-name>-base – application load address in hexadecimal. If this variable is not specified, the address is assigned automatically. Use this variable for debugging the application.

    This same address is passed to the debugger using the following command, which can be added to the .gdbinit file:

    add-symbol-file <application-name> <application-load-address>

  3. If the ROMFS partition must contain additional files, define the value for the ROMFS-FILES variable. In the variable value, list the files while separating them with blank spaces. If you are using the virtual file system, you must pass the file specified in the VFS_ENTITY variable.
  4. Add a statement for importing the build.mk template using the following command:

    include /opt/KasperskyOS-Community-Edition-<version>/common/build.mk

The build.mk template file has the following build targets:

  • sim (default target) – start the solution's boot image using the QEMU emulator.

    When started, the QEMU emulator may capture the mouse and will indicate this in the title bar of the emulator window.

  • Kos-image – build the solution's boot image to be started on the target hardware platform.
  • gdbsim – start the solution's boot image with the capability for debugging. After QEMU emulation is started, it awaits the start of the debugger. For this, call the gdb target in a different command line.

    Make sure that TCP/IP port 1234 is open by using the netstat -anput command, for example.

    Port 1234 is monitored by the gdbserver program, which is used for remote debugging of applications and is part of the QEMU emulator.

    When using the gdb debugger, you must use hardware breakpoints (hbreak). The QEMU emulator used in the examples is started with the -enable-kvm key, which makes it impossible to use regular breakpoints.

  • gdb – start the debugger. After starting the debugger for applications that require debugging, run the following commands:

    add-symbol-file <application-name> <application-load-address>

    target remote localhost:1234

Example

This example uses the make build system. In addition to the actions executed in the build.mk template, in the build script you must specify the Hello application and the list of object files of this application. The load address is specified for solution debugging purposes.

Makefile

# List of applications for the build.

targets = hello

# List of object files of the Hello application

hello-objects = hello.o hello.edl.o

# Load address of the Hello entity (in hex)

hello-base = 800000

# Include template with general build rules.

include ../common/build.mk

To start the make build system, run the make hello command.

To run the hello example while in the folder /opt/KasperskyOS-Community-Edition-<version>/examples/hello, run the make command.

Page top
[Topic using_makefiles]

Using CMake from the contents of KasperskyOS Community Edition

The CMake build automation system supports cross compilation of applications. To perform cross compilation using CMake, specify the path to a file with the build system extension (toolchain.cmake).

To cross compile an application for KasperskyOS, define the value of the variable: DCMAKE_TOOLCHAIN_FILE=/opt/KasperskyOS-Community-Edition-<version>/toolchain/share/toolchain.cmake

KasperskyOS Community Edition includes the platform library containing a set of ready-to-use scripts for the CMake system.

To prepare an application for debugging:

  1. In the CMakeLists.txt file, define the LINK_FLAGS parameter value for the application that you want to debug as follows:

    set_target_properties (<application-name> PROPERTIES LINK_FLAGS "-Ttext <text-section-address>")

    The script automatically creates .gdbinit files. The set of commands for the GDB debugger are contained within .gdbinit files. This set of commands determines which address the GDB debugger will use to load entities for debugging.

  2. Build the application.
Page top
[Topic using_cmake]

Using your own build system

You can use other build systems or implement your own build system to prepare the solution's boot image.

To prepare the solution's boot image, the build system must include the following actions:

  1. Generate code of the transport methods and types used to create, send, receive and process IPC messages between entities that are included in the solution.

    Use the NK compiler for this purpose. In command arguments, relay the path to the files containing EDL-, CDL- and IDL descriptions of entities, components and interfaces.

  2. Build all entities included in the solution.

    To do so, use the cross compilers that are included in KasperskyOS Community Edition.

  3. Build an Einit initializing entity.

    Use the einit tool to generate the code of the Einit entity. In the command arguments, pass the path to the init description file (init.yaml by default).

    Then the Einit entity must be built using the C compiler that is provided in KasperskyOS Community Edition.

  4. Build the kernel module with Kaspersky Security System.

    To do so, use the makekss script. In the command arguments, relay the path to the security configuration file (security.psl by default).

  5. Create an image of the solution.

    To do so, use the makeimg script. In the command arguments, pass the executable ELF files of entities, the kernel module with Kaspersky Security System, the KasperskyOS kernel image, and any additional files.

Page top
[Topic using_custom_build_tools]