Renesas
RZ/V AI

3.00

The best solution for
starting your AI applications.

Provided by Renesas Electronics Corporation

To keep you updated,
Watch our GitHub repository
Watch



This project is maintained by renesas-rz

Hosted on GitHub Pages — Theme by orderedlist

How to build RZ/V2H AI SDK Source Code



This page explains how to build Linux with RZ/V2H AI SDK Source Code.
Supported version: RZ/V2H AI SDK v3.00

Introduction

AI SDK is a quick and easy AI Application development environment.
It is specifically made for RZ/V2H Evaluation Board Kit with fixed Linux components.
(For more information, please refer to Getting Started and AI SDK.)

To modify Linux component, you need to build AI SDK from source code.
AI SDK Source Code can generate the same Linux environment as AI SDK.

AI Application and AI SDK software

This page explains how to build AI SDK Source Code.
After you have completed this page, you would be able to change the source code and customize Linux environment (i.e., memory map, additional OSS etc...).
To customize the Linux environment, please refer to RZ/V2H BSP Manual Set.

Requirement
  1. Users have launched RZ/V2H Evaluation Board Kit according to Getting Started, which means they can run AI Application on the board.
  2. To build Yocto Linux, the below equipment should be prepared.
    Equipment Details
    Linux PC Approximately 120GB free space is necessary.
    OS Ubuntu 20.04 LTS
    64bit OS must be used.

Now you are ready to build your Linux development environment.
Let's get started!!


Step 1: Obtain RZ/V2H AI SDK Source Code

Download the RZ/V2H AI SDK Source Code from the link below.

Download Link

AI SDK Source Code (RTK0EF0180F*_linux-src.zip) contains following files:
File name Description
README.txt README file.
rzv2h_ai-sdk_yocto_recipe_v*.tar.gz Yocto recipe.
Yocto recipes are text files that contains necessary information to build Yocto Linux.


Step 2: Extract RZ/V2H AI SDK Source Code


This step explains how to extract RZ/V2H AI SDK Source Code zip file.

  1. On your Linux PC, check you have already registered the environment variable WORK with the below command.
    printenv WORK

  2. Make the working directory on your Linux PC.
    mkdir -p ${WORK}/src_setup
  3. Move to the working directory.
    cd ${WORK}/src_setup
  4. Extract RZ/V2H AI SDK Sorce Code zip file.
    unzip <Path to the file>/RTK0EF0180F*_linux-src.zip -d ${WORK}/src_setup
  5. Check the working directory to confirm the package contents.
    ls -1 ${WORK}/src_setup
    • If the above command prints followings, the package is extracted correctly.
      README.txt
      rzv2h_ai-sdk_yocto_recipe_v3.00.tar.gz


Step 3: Build RZ/V2H AI SDK Source Code

This step explains how to build Linux environment with RZ/V2H AI SDK Source Code

  1. To install necessary sofware, run the following commands on your Linux PC.
    sudo apt-get update
    sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
    build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
    xz-utils debianutils iputils-ping libsdl1.2-dev xterm p7zip-full libyaml-dev \
    libssl-dev 
  2. Run the following commands and set the user name and email address before starting the build procedure.
    It is needed to avoid errors when using git command to apply patches.
    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"
  3. Register the working directory path to an environment variable.
    export YOCTO_WORK=${WORK}/src_setup/yocto
    mkdir -p ${YOCTO_WORK}
  4. Extract Yocto recipe package.
    cd ${YOCTO_WORK}
    tar zxvf ${WORK}/src_setup/rzv2h_ai-sdk_yocto_recipe_v*.tar.gz
  5. Apply patch files to fix link error.
    1. Obtain the patch file from the link below.
      Patch file link Description
      0001-recipes-debian-buster-glibc-Update-version-from-2.28.patch patch file for fixing glibc link error
      0001-rz-common-recipes-debian-buster-glibc-update-to-v2.28-10+deb10u4.patch patch file for fixing glibc link error
      61835_update_url_gst_common.patch patch file for fixing codec library link error
    2. Copy and apply the patch file.
      cp <Path to the file>/0001-recipes-debian-buster-glibc-Update-version-from-2.28.patch ${YOCTO_WORK}
      cd ${YOCTO_WORK}/meta-renesas
      patch -p1 < ../0001-recipes-debian-buster-glibc-Update-version-from-2.28.patch
      
      cp <Path to the file>/0001-rz-common-recipes-debian-buster-glibc-update-to-v2.28-10+deb10u4.patch ${YOCTO_WORK}
      cd ${YOCTO_WORK}/meta-renesas
      patch -p1 < ../0001-rz-common-recipes-debian-buster-glibc-update-to-v2.28-10+deb10u4.patch
      
      cp <Path to the file>/61835_update_url_gst_common.patch ${YOCTO_WORK}
      patch -d ${YOCTO_WORK}/meta-rz-features/meta-rz-codecs -p1 < ${YOCTO_WORK}/61835_update_url_gst_common.patch
      
  6. Get e-CAM22_CURZH camera driver (MIPI) from e-con Systems.
    The e-CAM22_CURZH camera driver (MIPI) used in AI SDK is not included in the RZ/V2H AI SDK Source Code. The required driver needs to be obtained through the following procedure.
    1. To build the e-CAM22_CURZH camera driver (MIPI) for RZ/V2H Evaluation Board Kit, contact e-con Systems at this link to obtain the patch file below.
      File name Description
      e-CAM22_CURZ*.patch e-CAM22_CURZH camera driver (MIPI) Yocto patch file for RZ/V2H
    2. Copy and apply the patch file.
      cp <Path to the file>/e-CAM22_CURZ*.patch ${YOCTO_WORK}
      cd ${YOCTO_WORK}
      patch -p1 -i e-CAM22_CURZ*.patch
  7. Check the working directory to confirm Yocto recipes content.
    ls -1 ${YOCTO_WORK}
    • If the above command prints followings, Yocto recipes are extracted correctly.
      0001-recipes-debian-buster-glibc-Update-version-from-2.28.patch
      0001-rz-common-recipes-debian-buster-glibc-update-to-v2.28-10+deb10u4.patch
      0001-tesseract.patch
      61835_update_url_gst_common.patch
      e-CAM22_CURZ*.patch
      meta-econsys
      meta-gplv2
      meta-openembedded
      meta-renesas
      meta-rz-features
      meta-virtualization
      poky
    Note 1 Evaluation version of Graphics Library has restriction on their running time.
    If you would like to use unrestricted version of Graphics Library, please refer to Appendix 1: Build Graphics Library for Unrestricted Version.
    Note 2 Video Codec Library supports only H.264 Enc in AI SDK v3.00.
    If you would like to use H.264 Dec and H.265 Enc/Dec function, please refer to Appendix 3: Prepare Video Codec Library for H.264 Enc/Dec and H.265 Enc/Dec function.
  8. Initialize a build using the oe-init-build-env script in Poky and set environment variable TEMPLATECONF to the below path.
    cd ${YOCTO_WORK}
    TEMPLATECONF=${PWD}/meta-renesas/meta-rzv2h/docs/template/conf/ source poky/oe-init-build-env
    Note The default size of the microSD card image created in this guide is approximately 4 GB.
    If you would like to change the microSD card image size, please refer to Appendix 2: Change the size of the microSD card image in WIC format.
  9. Run the following commands to add necessary layers for AI application to ${YOCTO_WORK}/build/conf/bblayers.conf (configration file for layers).
    bitbake-layers add-layer ../meta-rz-features/meta-rz-graphics
    bitbake-layers add-layer ../meta-rz-features/meta-rz-drpai
    bitbake-layers add-layer ../meta-rz-features/meta-rz-opencva
    bitbake-layers add-layer ../meta-rz-features/meta-rz-codecs
    bitbake-layers add-layer ../meta-econsys
  10. Apply a patch file to add Tesseract Open Source OCR Engine for AI applications.
    patch -p1 < ../0001-tesseract.patch
  11. Run the following command below to builde Linux kernel files.
    (It takes a few hours to finish building depending on the user's host PC performance)
    MACHINE=rzv2h-evk-ver1 bitbake core-image-weston
    All necessary files listed below will be generated by the build command and they will be located in ${YOCTO_WORK}/build/tmp/deploy/images/rzv2h-evk-ver1 directory.
    File name Description
    core-image-weston-rzv2h-evk-ver1.wic.bmap
    core-image-weston-rzv2h-evk-ver1.wic.gz
    WIC format SD card image
  12. Run the following command to build cross compiler installer.
    MACHINE=rzv2h-evk-ver1 bitbake core-image-weston -c populate_sdk
    A necessary file listed below will be generated by the build command and the cross compiler installer will be located in ${YOCTO_WORK}/build/tmp/deploy/sdk/poky-glibc-x86_64-core-image-weston-aarch64-rzv2h-evk-ver1-toolchain-*.sh.
    File name Description
    poky-glibc-x86_64-core-image-weston-aarch64-rzv2h-evk-ver1-toolchain-*.sh Cross compiler installer
    Note If some errors occurred during the build, please clean the directory and rebuild it after a period of time according to the below commands.
    cd ${YOCTO_WORK}/build
    MACHINE=rzv2h-evk-ver1 bitbake core-image-weston -c cleanall
    And run the build command again.
    • For Linux kernel files
      MACHINE=rzv2h-evk-ver1 bitbake core-image-weston
    • For cross compiler installer
      MACHINE=rzv2h-evk-ver1 bitbake core-image-weston -c populate_sdk


This is the end of how to build AI SDK Source Code.

You have prepared following files, which is same as the one provided in Step 3: Obtain RZ/V2H AI SDK in Getting Started, and you can run AI Applications according to Getting Started.

Path File name Description
${YOCTO_WORK}/build/tmp/deploy/images/rzv2h-evk-ver1 core-image-weston-rzv2h-evk-ver1.wic.bmap
core-image-weston-rzv2h-evk-ver1.wic.gz
WIC format SD card image
${YOCTO_WORK}/build/tmp/deploy/sdk poky-glibc-x86_64-core-image-weston-aarch64-rzv2h-evk-ver1-toolchain-*.sh Cross compiler installer
Note 1 For more Yocto Project information, please refer the link below:
https://docs.yoctoproject.org/3.1.26/brief-yoctoprojectqs/brief-yoctoprojectqs.html
Note 2 When customizing Linux development environment, following information may help.
Note 3 To add more functionality to AI SDK, please refer to following URL.


If you have any questions about AI SDK Source Code,
please add new issues to AI SDK GitHub issues.

Go to GitHub issues



Appendix 1: Prepare Graphics Library for Unrestricted Version

This section explains how to prepare Graphics Library for unrestricted version, intead of evaluation version.

Note Following instruction assumes that you have completed Step 3-6 in How to build RZ/V2H AI SDK Source Code.
  1. Download zip files from the link below.
    Note It may take much time to obtain Graphics Library for unrestricted version due to necessary examinations on your business purpose.

    Download Link

  2. After you downloaded the zip files, please move the zip files to "${WORK}/src_setup" on your Linux PC.

  3. Check that zip files are moved to appropriate location.
    cd ${WORK}/src_setup
    ls -1 
    • If the above command prints followings, the package is extracted correctly.
      README.txt
      RTK0EF0*ZJ-v*_rzv_*.zip
      rzv2h_ai-sdk_yocto_recipe_v3.00.tar.gz
      yocto
  4. Run the below command to delete evaluation version.
    rm -rf ${YOCTO_WORK}/meta-rz-features/meta-rz-graphics
  5. Run the below command to extract the unristricted version.
    unzip RTK0EF0045Z14001ZJ*.zip
    tar zxvf RTK0EF0045Z14001ZJ*/meta-rz-features_graphics_*.tar.gz -C ${YOCTO_WORK}

After this procedure, please proceed to Step 3-7 in How to build RZ/V2H AI SDK Source Code to start building Linux kernel files.

Appendix 2: Change the size of the microSD card image in WIC format

This section explains how to change the microSD card image size by changing the build settings of the WIC file.

Note Following instruction assumes that you have completed Step 3-7 in How to build RZ/V2H AI SDK Source Code.
  1. Open ${YOCTO_WORK}/build/conf/local.conf file in a text editor.
  2. Find the following text in the file and edit the highlighted value to define the disk space of the image in Kbytes.
    ...
    # Support WIC images with default wks from WKS_DEFAULT_FILE
    # Reupdate WKS_DEFAULT_FILE if want to support another wks file.
    WKS_SUPPORT ?= "1"
    WKS_DEFAULT_FILE_rzv2h-dev = "rz-image-bootpart-mmc.wks"
    WKS_DEFAULT_FILE_rzv2h-evk-alpha = "rz-image-bootpart-esd_rzv2h.wks"
    WKS_DEFAULT_FILE_rzv2h-evk-ver1 = "rz-image-bootpart-esd_rzv2h.wks"
    # Defines additional free disk space created in the image in Kbytes.
    IMAGE_ROOTFS_EXTRA_SPACE = "1048576"
    ...
    
    The table below shows examples of setting values written in local.conf file.
    Note If you have customized Linux, the disk image size may differ from the table.
    SD card image size
    (Gbytes)
    Setting values in the "local.conf" file
    (Kbytes)
    4 1048576 (default)
    8 4194304

After this procedure, please proceed to Step 3-8 in How to build RZ/V2H AI SDK Source Code to build the Linux kernel files.

Appendix 3: Prepare Video Codec Library for H.264 Enc/Dec and H.265 Enc/Dec function

This section explains how to prepare Video Codec Library for H.264 Enc/Dec and H.265 Enc/Dec function.

Note Following instruction assumes that you have completed Step 3-6 in How to build RZ/V2H AI SDK Source Code.
  1. Download zip file from the link below.

    Download Link

  2. After you downloaded the zip file, please move the zip file to "${WORK}/src_setup" on your Linux PC.

  3. Check that zip file are moved to appropriate location.
    cd ${WORK}/src_setup
    ls -1 
    • If the above command prints followings, the package is extracted correctly.
      README.txt
      RTK0EF0192Z00001ZJ.zip
      rzv2h_ai-sdk_yocto_recipe_v3.00.tar.gz
      yocto
  4. Run the below command to delete current Video Codec Library and OpenCVA directories.
    rm -rf ${YOCTO_WORK}/meta-rz-features/meta-rz-codecs
    rm -rf ${YOCTO_WORK}/meta-rz-features/meta-rz-opencva
  5. Run the below command to extract the Video Codec Library for H.264 Enc/Dec and H.265 Enc/Dec function.
    unzip RTK0EF0192Z00001ZJ.zip
    tar xvf RTK0EF0192Z00001ZJ/meta-rz-features.tar.gz -C ${YOCTO_WORK}
  6. Run the below command to apply a patch file to add Video Codec Library.
    cd ${YOCTO_WORK}
    patch -p1 -d meta-renesas < ${WORK}/src_setup/RTK0EF0192Z00001ZJ/0001-rzv2h-conf-r9a09g057-Add-hwcodec-to-MACHINE_FEATURE.patch

After this procedure, please proceed to Step 3-7 in How to build RZ/V2H AI SDK Source Code to start building Linux kernel files.

Note Examples of running the Video Codecs Library is shown below.
  • H.264 Encode
    Input from a USB camera, encode in H.264, and output to an MP4 file (H264_MP4_file.mp4).
    gst-launch-1.0 v4l2src num-buffers=100 device=/dev/video0 ! videoconvert ! video/x-raw, format=NV12 ! omxh264enc control-rate=2 target-bitrate=10485760 interval_intraframes=14 periodicty-idr=2 ! video/x-h264, profile=\(string\)high, level=\(string\)4 ! h264parse ! video/x-h264, stream-format=avc, alignment=au ! qtmux ! filesink location=H264_MP4_file.mp4
  • H.264 Decode
    Decode and display the above MP4 file (H264_MP4_file.mp4).
    gst-launch-1.0 filesrc location=H264_MP4_file.mp4 ! qtdemux ! h264parse ! omxh264dec ! waylandsink
  • H.265 Encode
    Input from a USB camera, encode in H.265, and output to an MP4 file (H265_MP4_file.mp4).
    gst-launch-1.0 v4l2src num-buffers=100 device=/dev/video0 ! videoconvert ! video/x-raw, format=NV12 ! omxh265enc control-rate=2 target-bitrate=10485760 interval_intraframes=14 ! video/x-h265, profile=\(string\)main, level=\(string\)5 ! h265parse ! qtmux ! filesink location=H265_MP4_file.mp4
  • H.265 Decode
    Decode and display the above MP4 file (H265_MP4_file.mp4).
    gst-launch-1.0 filesrc location=H265_MP4_file.mp4 ! qtdemux ! h265parse ! omxh265dec ! waylandsink