Building drivers for the Radxa ROCK 3A hardware platform

Drivers for the Raspberry Pi 4 B hardware platform are delivered in binary format, so you don't need to build them and can proceed straight to building examples.

To study the principles of developing drivers for KasperskyOS, the SDK includes the source code of some drivers (but they are only included in the deb package for working with the Radxa Rock 3A hardware platform). The source code of the drivers for the Radxa Rock 3A hardware platform is located in the /opt/KasperskyOS-Community-Edition-<platform>-<version>/drivers directory.

When you build an example for the hardware platform, platform-specific drivers are automatically included in the solution. Before building and running examples that use drivers, you must build the drivers from the source code.

To conveniently work with the SDK, you are advised to build binaries for all of the drivers included in the SDK before beginning to work with the examples. To build all of the drivers included in the SDK, run the following commands:

# Before building the drivers, you must set the values of the environment variables required for using the SDK.

$ cd /opt/KasperskyOS-Community-Edition-<platform>-<version>

$ source ./common/set_env.sh

# You need to build the drivers in a directory in which you have write access.To do so, copy the directory containing the drivers to the home directory, for example.

$ cp -r ./drivers/ ~/drivers

$ cd ~/drivers

$ cmake -B build -D CMAKE_TOOLCHAIN_FILE="$KOSCEDIR/toolchain/share/toolchain-aarch64-kos.cmake" -DCMAKE_INSTALL_PREFIX="$KOSCEDIR/sysroot-aarch64-kos"

$ sudo env "PATH=$PATH" cmake --build build --target all

Detailed instructions for building each driver can be found in the README.md files in the directory of each driver.

Special features of Radxa ROCK 3A hardware platform drivers

The PinCtrl driver for KasperskyOS automatically selects the default mode in the hardware configuration description (Device Tree). After building the examples, you can configure some PinCtrl modes using the Device Tree Overlay binary files (DTBO) that are supplied with KasperskyOS Community Edition and are designed to change the original configuration. The requirement for using overlays is indicated in the description of each example.

Please note that conflicting overlays cannot be applied. Also, you cannot use multiple mX overlays for the same controller (for example, the pwm1-m0 and pwm1-m1 overlays are mutually exclusive).

The overlay compatibility table is provided in the file /opt/KasperskyOS-Community-Edition-<platform>-<version>/drivers/rk3568/pinctrl/README.md.

Details on the supplied overlays for each of the supplied drivers are provided in the README.md files for each driver.

Applying overlays

To apply DTBO overlays to a binary file containing a hardware configuration description (.dtb), run the following commands:

# Create a backup copy of the hardware configuration

$ cp rk3568-rock-3a.dtb rk3568-rock-3a.dtb.orig

# Merge the original configuration with the changes and save the result

$ fdtoverlay -i rk3568-rock-3a.dtb.orig -o rk3568-rock-3a.dtb <overlay1>.dtbo <overlay2>.dtbo

# Verify and optimize the resulting hardware configuration

$ dtc -R 4 -p 0x1000 -I dtb -O dtb -o rk3568-rock-3a.dtb rk3568-rock-3a.dtb

This will change the hardware configuration for all subsequent boots of the system.

You can also manually apply overlays in the U-Boot command line before loading the system image:

# Load the original hardware configuration into RAM

$ load mmc 1:1 ${fdt_addr_r} rk3568-rock-3a.dtb;

# Instruct U-Boot to use the configuration from memory

$ fdt addr ${fdt_addr_r};

# Load changes

$ load mmc 1:1 ${fdtoverlay_addr_r} overlay/<name>.dtbo;

# Apply configuration changes

$ fdt apply ${fdtoverlay_addr_r};

# Load kos-image, which is the image of the KasperskyOS-based solution

$ load mmc 1:1 ${loadaddr} kos-image;

# Start the KasperskyOS kernel with the changed hardware configuration.

# After running the booti command, the system will resume the standard boot process.

$ booti ${loadaddr} - ${fdt_addr_r};

Page top