R-Car/Boards/Yocto-Gen3/Azure IoT Edge/v5.9.0

From eLinux.org
Jump to: navigation, search


Introduction

This page describes how to setup the Yocto environment to use the Azure IoT Edge with R-Car and run it.

This page contains information abot building and running Azure IoT Edge on Yocto environment on:

Topic

The new version of R-Car Starter Kit Premier is now on sale !!

  • Equipped with R-Car H3e-2G
    (En) https://www.renesas.com/jp/en/about/press-room/renesas-launches-r-car-gen3e-20-percent-higher-cpu-speed-automotive-infotainment-cockpit-and-digital
    (Zh) https://www.renesas.com/jp/zh/about/press-room/renesas-launches-r-car-gen3e-20-percent-higher-cpu-speed-automotive-infotainment-cockpit-and-digital
    (Jp) https://www.renesas.com/jp/ja/about/press-room/renesas-launches-r-car-gen3e-20-percent-higher-cpu-speed-automotive-infotainment-cockpit-and-digital
  • CPU performance is increased 20% by supporting up to 2GHz frequency over past products.
  • You can buy from here.

SW Release Information

Board name SW name Release date Note
R-Car Starter Kit ( Premier / Pro ) Yocto v5.9.0 (stable) [New!!] 2022/02/08
Kingfisher Infotainment Board Yocto v5.9.0 (stable) [New!!] 2022/02/14 To check for latest information, please refer to the meta-rcar/tree/v5.9.0.
Android 10 (stable) 2021/07/26 R-Car Starter Kit Premier(R-Car H3) + Kingfisher is supported.
R-Car Starter Kit Pro(RTP8J77961ASKB0SK0SA05A) + Kingfisher is also supported from 2021/11/25.
Android P (stable) 2020/09/29 R-Car Starter Kit Premier(R-Car H3) + Kingfisher is supported.
R-Car Starter Kit Pro(RTP8J77961ASKB0SK0SA05A) + Kingfisher is also supported from 2021/03/16.
CCPF-SK Board Yocto v5.9.0 (latest) [New!!] 2022/02/08 Prebuilt binary is available in Quick startup guide page. (Updated on 2022/03/18)


Software revisions

Software Revision
Yocto Project 3.1.11
aarch64-poky-linux-gcc (GCC) 9.3
Kernel Ver 5.10.41
Userland 64/32bit 64
U-Boot 2020.10
OP_TEE 3.13.0
IoT Edge 1.1.8

Environment

Host PC

OS Ubuntu 20.04 LTS (64bit)
Memory 8 GB or more
Storage At least 100 GB free

Boards confirmed to work

Board SoC Confirmed
R-Car Starter Kit Premier(H3) H3e-2G v3.0 OK
R-Car Starter Kit Premier(H3) H3 v3.0 (1rank DDR) OK
R-Car Starter Kit Premier(H3) H3 v3.0 (2rank DDR) NT
R-Car Starter Kit Premier(H3) H3 v2.0 with 4GB DDR OK
R-Car Starter Kit Pro M3 v3.0 OK
R-Car Starter Kit Pro M3 v1.0 OK
CCPF-SK + R-Car Starter Kit Premier(H3) H3e-2G v3.0 OK
CCPF-SK + R-Car Starter Kit Premier(H3) H3 v3.0 (1rank DDR) OK
CCPF-SK + R-Car Starter Kit Premier(H3) H3 v3.0 (2rank DDR) NT
CCPF-SK + R-Car Starter Kit Premier(H3) H3 v2.0 with 4GB DDR OK
CCPF-SK + R-Car Starter Kit Pro M3 v3.0 OK
CCPF-SK + R-Car Starter Kit Pro M3 v1.0 OK

18px <translate> Note:</translate> NT='Not Tested' but will work

See also:

Set up in the Azure

  1. Create an Azure account
    Create an Azure account with reference to https://azure.microsoft.com/en-us/free/.
  2. Create an Azure IoT Hub
    Create an Azure IoT Hub with reference to Create an IoT hub.
  3. Register an Azure Device
    Access https://portal.azure.com/ and select your IoT Hub.
    Select "IoT Edge" under "Device Management" from the side menu, and then click "+ Add IoT Edge Device".
    Azure-device-1.png
    Then, set an arbitrary name for "Device ID" and click "Save" without changing the other settings.
    And then, select "IoT Edge" under "Device Management" from the side menu, and click the device ID you created to check the "Primary Connection String".
    (The "Primary Connection String" is used in Receive telemetry messages.)
    Azure-device-3.png
  4. Add the Azure module
    Add the Simulated Temperature Sensor module with reference to Deploy a module.

Prepare the SW for R-Car

Getting Started using prebuilt binaries

  1. Download prebuilt binaries
  2. Setup SW

Building the BSP

Required packages

  1. Install the required packages
    $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
    build-essential chrpath socat cpio python3 python3-pip python3-pexpect \
    xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa \
    libsdl1.2-dev pylint3 xterm
    
    Refer to Yocto Project Quick Start for more information.
  2. Set up initial git configuration
    $ git config --global user.email "you@example.com"
    $ git config --global user.name "Your Name"
    

Building the BSP

  1. Create the following script(build.sh) for building
    #!/bin/bash
    
    BOARD_LIST=("h3ulcb" "m3ulcb" "h3ulcb-ccpf-sk" "m3ulcb-ccpf-sk")
    TARGET_BOARD=$1
    WORK=`pwd`/${TARGET_BOARD}-build
    
    repolist=( \
        "git://git.yoctoproject.org/poky;74b22db6879b388d700f61e08cb3f239cf940d18" \
        "git://git.openembedded.org/meta-openembedded;814eec96c2a29172da57a425a3609f8b6fcc6afe" \
        "https://github.com/renesas-rcar/meta-renesas;13fd24957b9acc29a235ee0c7f398fd867f38b47" \
        "https://github.com/renesas-rcar/meta-renesas-ccpf;09dd815616cce3a2bdcf8906c0d21403df8b93bd" \
        "https://github.com/yhamamachi/meta-rcar-dev-utils;remotes/origin/v5.9.0"
    )
    repolist_iotedge=( \
        "git://git.yoctoproject.org/meta-virtualization;c4f156fa93b37b2428e09ae22dbd7f5875606f4d" \
        "https://github.com/tkomagata/meta-docker;f8f83a7b15930b74b4af2ae5e7c4c55607fafa86" \
        "https://github.com/meta-rust/meta-rust;7ff669d8cedd83a2d3efb73073a63b0a7efffddc" \
        "https://github.com/tkomagata/meta-iotedge;e9f1e6373b3e2017aff2eeceebb3d267fd10f3a8" \
    )
    
    _usage () {
        echo "Usage: $0 \${BOARD_NAME} [release package option]"
        echo "BOARD_NAME list: "
        for i in ${BOARD_LIST[@]}; do echo "  - $i"; done
        echo "release package options:"
        echo "  -r: Create core-image-xxxxx-release"
        exit
    }
    
    repo_clone () {
        mkdir -p ${WORK}
        for repo in ${repolist[@]}; do
            URL=$(echo $repo | cut -d';' -f1)
            COMMIT=$(echo $repo | cut -d';' -f2)
            NAME=${URL##*/}
            if [[ ! -d "${WORK}/${NAME}" ]]; then
                git clone ${URL} ${WORK}/${NAME}
            fi
            cd ${WORK}/${NAME}; git checkout -B tmp ${COMMIT}
        done
    }
    
    check_target_board () {
        if ! `IFS=$'\n'; echo "${BOARD_LIST[*]}" | grep -qx "${TARGET_BOARD}"`; then
            _usage
        fi
    }
    
    set_build_type () {
        BUILD_TARGET=core-image-minimal
        BUILD_TYPE=bsp
        repolist=(${repolist[@]} ${repolist_iotedge[@]})
    }
    
    build_yocto () {
        cd ${WORK}
        BUILD_DIR=${WORK}/build_${TARGET_BOARD}_${BUILD_TYPE}${RELEASE}
        rm -rf ${BUILD_DIR}/conf
        TEMPLATECONF=${WORK}/meta-iotedge/conf/machine/${TARGET_BOARD}/${BUILD_TYPE}/ \
            source poky/oe-init-build-env ${BUILD_DIR}
        echo "DL_DIR = '${DL_DIR:-${WORK}/yocto_dl_dir}'" >> ${BUILD_DIR}/conf/local.conf
        echo "SSTATE_DIR = '${SSTATE_DIR:-${WORK}/yocto_sstate_dir}'" >> ${BUILD_DIR}/conf/local.conf
        echo "${LOCAL_CONF_APPEND}" >> ${BUILD_DIR}/conf/local.conf
        bitbake-layers add-layer ${WORK}/meta-rcar-dev-utils/meta-rcar-gen3
        if [[ "${RELEASE}" != "" ]]; then
            cp -f ${WORK}/meta-rcar-bsp-release/meta-rcar-gen3/docs/sample/site.conf.sample \
                ${BUILD_DIR}/conf/site.conf
            bitbake-layers add-layer ${WORK}/meta-rcar-bsp-release/meta-rcar-gen3
        fi
        bitbake ${BUILD_TARGET}${RELEASE}
    }
    
    build_32bit_rom_writer () {
        cd ${WORK}
        BUILD_32_DIR=${WORK}/build_32
        source poky/oe-init-build-env ${BUILD_32_DIR}
        cp -f ${BUILD_DIR}/conf/* -t ${BUILD_32_DIR}/conf/
        echo "MACHINE ??= 'qemuarm'" >> ${BUILD_32_DIR}/conf/local.conf
        echo "DEFAULTTUNE = 'armv7a'" >> ${BUILD_32_DIR}/conf/local.conf
        bitbake flash-writer renesas-bsp-rom-writer
        cp -rf ${BUILD_32_DIR}/tmp/deploy/images/qemuarm/renesas-bsp-rom-writer_32bit \
            -t ${BUILD_DIR}/tmp/deploy/release/binary/ipl/
    }
    
    ## main process ##
    RELEASE=""
    check_target_board $@
    set_build_type $@
    if [[ "$(echo $*' ' | grep ' -r ')" != "" ]]; then
        repolist+=("https://github.com/yhamamachi/meta-rcar-bsp-release;remotes/origin/v5.9.0")
        RELEASE=-release
    fi
    repo_clone
    build_yocto
    if [[ "$(echo $*' ' | grep ' -r ')" != "" ]]; then
        build_32bit_rom_writer
    fi
    
  2. Build
    $ chmod a+x build.sh
    $ ./build.sh <target_board_name> <release package option>
    Ex.)
        h3ulcb build:
            ./build.sh h3ulcb
        m3ulcb-ccpf-sk build for release:
            ./build.sh m3ulcb-ccpf-sk -r
    
    target_board_name is specified for each board according to the following table:
    R-car-sk-target-board-name.png

    Depending on the performance of the host PC, it may take several hours for the build to complete.
    When the build completes successfully, you will see the following output:
    NOTE: Tasks Summary: Attempted 4704 tasks of which 31 didn't need to be rerun and all succeeded.
    
  3. Check the built images
    The built images are stored in the following:
     <target_board_name>-build/build_<target_board_name>_bsp(-release)/tmp/deploy/images/<target_board_name>/
  4. Write the images to the SD card
    Write the images to the SD card with reference to Loading kernel and rootfs via eMMC/SD card.
    18px <translate> Note:</translate> Please replace "core-image-weston" with "core-image-minimal".

Receive telemetry messages

  1. Procedure on the target board
    1. Turn on the target board
      1. Insert the SD card into the target board, and connect the LAN cable to it.
      2. Use a microUSB cable to connect the target board, connect a power supply to it, and connect to serial console.
      3. Power on.
        Short-press SW8 "Power" to switch the board on.
        If the board is attached to the CCPF board, short-press SW4 "Power" instead of SW8.
    2. Configure U-Boot to boot from SD card
      Refer to Configure U-Boot to boot from SD card.
    3. Connect to your IoT Hub
      Configure to connect to your IoT Hub.
      1. Add a write permission to "/etc/iotedge/config.yaml".
        $ chmod +w /etc/iotedge/config.yaml
        
      2. Set the "Primary Connection String" to device_connection_string.
        $ vi /etc/iotedge/config.yaml
          device_connection_string: "<ADD DEVICE CONNECTION STRING HERE>" ← ★
        
        18px <translate> Note:</translate> See Register an Azure Device for the "Primary Connection String".
      3. Remove a write permission from "/etc/iotedge/config.yaml".
        $ chmod -w /etc/iotedge/config.yaml
        
      4. Restart the IoT Edge daemon.
        $ systemctl restart iotedge
        
      5. Check that the IoT Edge daemon is running.
        $ systemctl status iotedge --no-page
        
        Azure-status-no-page.png

      6. Check that the following modules are deployed and are running.
        18px <translate> Note:</translate> It may take several minutes for the deployment to complete.
        $ iotedge list
        
      Azure-list.png

  2. Procedure on the Azure IoT Explorer
    Check that it receives telemetry messages from the IoT Edge Device.
    1. Install the Azure IoT Explorer.
      Download the installer from https://github.com/Azure/azure-iot-explorer/releases/tag/v0.14.1.
      18px <translate> Note:</translate> Use v0.14.1 because v0.14.7(latest version) does not receive any telemetry messages.
    2. Launch the Azure IoT Explorer.
    3. Get the "Primary Connection String" for the iothubowner.
      Go the IoT Hub page on the Azure Portal, click your "IoT Hub", "Shared access policies" from the side menu, and then click "iothubowner". Next, copy the "Primary Connection string".
      Azure-iot-exp-1.png
    4. Register your IoT Hub to the IoT Explorer
      Select the "IoT hubs" from the side menu of the Azure IoT Explorer, and click "+ Add connection".
      Paste the "Primary Connection string" you copied into the "Connection string" text box, finally click the "Save".
    5. Receive telemetry messages
      Select the "Telemetry" from the side menu, and click "Start".
      When a message is received, the following log is displayed.
      Azure-iot-exp-3.png