Running examples on Raspberry Pi 4 B

Connecting a computer and Raspberry Pi 4 B

To see the output of the examples on the computer:

  1. Connect the pins of the FT232 USB-UART converter to the corresponding GPIO pins of the Raspberry Pi 4 B (see the figure below).

    RPI_USB

    Diagram for connecting the USB-UART converter and Raspberry Pi 4 B

  2. Connect the computer's USB port to the USB-UART converter.
  3. Install PuTTY or a similar program for reading data from a COM port. Configure the settings as follows: bps = 115200, data bits = 8, stop bits = 1, parity = none, flow control = none.

To allow a computer and Raspberry Pi 4 B to interact through Ethernet:

  1. Connect the network cards of the computer and Raspberry Pi 4 B to a switch or to each other.
  2. Configure the computer's network card so that its IP address is in the same subnet as the IP address of the Raspberry Pi 4 B network card (the settings of the Raspberry Pi 4 B network card are defined in the dhcpcd.conf file, which is found at the path <example name>/resources/...).

Preparing a bootable SD card for Raspberry Pi 4 B

A bootable SD card for Raspberry Pi 4 B can be prepared automatically or manually.

To automatically prepare the bootable SD card, connect the SD card to the computer and run the following commands:

# The following command creates an image file for the bootable

# drive (*.img).

$ sudo /opt/KasperskyOS-Community-Edition-<version>/examples/rpi4_prepare_fs_image.sh

# In the following command, path_to_img is the path to the image file

# of the bootable drive (this path is displayed upon completion

# of the previous command), [X] is the final character

# in the name of the SD card block device.

$ sudo dd bs=4M if=path_to_img of=/dev/sd[X] conv=fsync

To manually prepare the bootable SD card:

  1. Build the U-Boot bootloader for ARMv7, which will automatically run the example. To do this, run the following commands:

    $ sudo apt install gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf git bison flex

    $ git clone https://github.com/u-boot/u-boot.git u-boot-armv7

    $ cd u-boot-armv7 && git checkout tags/v2020.10

    $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- rpi_4_32b_defconfig

    # In the menu that appears when you run the following command, enable

    # the 'Enable a default value for bootcmd' option. In the 'bootcmd value' field, enter

    # fatload mmc 0 ${loadaddr} kos-image; bootelf ${loadaddr}.

    # Then exit the menu after saving the settings.

    $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

    $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- u-boot.bin

  2. Format the SD card. To do this, connect the SD card to the computer and run the following commands:

    $ wget https://downloads.raspberrypi.org/raspbian_lite_latest

    $ unzip raspbian_lite_latest

    # In the following command, [X] is the last symbol in the name of the block device

    # for the SD card.

    $ sudo dd bs=4M if=$(ls *raspbian*lite.img) of=/dev/sd[X] conv=fsync

  3. Copy the U-Boot bootloader to the SD card by running the following commands:

    # In the following commands, the path ~/mnt/fat32 is just an example. You

    # can use a different path.

    $ mkdir -p ~/mnt/fat32

    # In the following command, [X] is the last alphabetic character in the name of the block

    # device for the partition on the formatted SD card.

    $ sudo mount /dev/sd[X]1 ~/mnt/fat32/

    $ sudo cp u-boot.bin ~/mnt/fat32/u-boot.bin

  4. Copy the configuration file for the U-Boot bootloader to the SD card. To do so, go to the directory /opt/KasperskyOS-Community-Edition-<version>/examples and run the following commands:

    $ sudo cp config.txt ~/mnt/fat32/config.txt

    $ sync

    $ sudo umount ~/mnt/fat32

Running an example on a Raspberry Pi 4 B

To run an example on a Raspberry Pi 4 B:

  1. Go to the directory with the example and build the example.
  2. Copy the KasperskyOS-based solution image to the bootable SD card. To do this, connect the bootable SD card to the computer and run the following commands:

    # In the following command, [X] is the last alphabetic character in the name of the block

    # device for the partition on the bootable SD card.

    # In the following commands, the path ~/mnt/fat32 is just an example. You

    # can use a different path.

    $ sudo mount /dev/sd[X]1 ~/mnt/fat32/

    $ sudo cp build/einit/kos-image ~/mnt/fat32/kos-image

    $ sync

    $ sudo umount ~/mnt/fat32

  3. Connect the bootable SD card to the Raspberry Pi 4 B.
  4. Supply power to the Raspberry Pi 4 B and wait for the example to run.

    The output displayed on the computer indicates that the example started.

Page top