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

From eLinux.org
< R-Car‎ | Boards/Yocto-Gen3‎ | Azure IoT Edge
Revision as of 19:59, 17 January 2022 by Tkomagata (talk | contribs) (Tkomagata moved page R-Car/Azure IoT Hub/v5.5.0-draft to R-Car/Boards/Yocto-Gen3/Azure IoT Edge/v5.5.0: This page is related information to R-Car/Yocto-Gen3.)
Jump to: navigation, search


This page describes how to build the images to connect to the Azure IoT Hub on the R-Car, and receive telemetry messages from IoT Edge Device.


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) v2.0 OK
CCPF + R-Car Starter Kit Premier(H3) v2.0 OK
R-Car Starter Kit Pro(M3) v1.0 OK
R-Car Starter Kit Pro(M3) v3.0 OK
CCPF + R-Car Starter Kit Pro(M3) v1.0 OK
CCPF + R-Car Starter Kit Pro(M3) v3.0 OK

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".
    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.)
  4. Add the Azure module
    Add the Simulated Temperature Sensor module with reference to Deploy a module.


  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
  2. Set up initial git configuration
    $ git config --global user.email "you@example.com"
    $ git config --global user.name "Your Name"
  3. Create the following script(build.sh) for building
    BOARD_LIST=("h3ulcb" "m3ulcb" "h3ulcb-ccpf-sk" "m3ulcb-ccpf-sk")
    # Commit ID
    Usage () {
        echo "Usage: $0 \${TARGET_BOARD_NAME}"
        echo "BOARD_NAME list: "
        for i in ${BOARD_LIST[@]}; do echo "  - $i"; done
    # Check Param.
    if ! `IFS=$'\n'; echo "${BOARD_LIST[*]}" | grep -qx "${TARGET_BOARD}"`; then
    mkdir -p ${WORK}
    cd ${WORK}
    # Clone basic Yocto layers in parallel
    git clone git://git.yoctoproject.org/poky &
    git clone git://git.openembedded.org/meta-openembedded &
    git clone git://github.com/renesas-rcar/meta-renesas &
    git clone git://git.yoctoproject.org/meta-virtualization &
    git clone git://github.com/tkomagata/meta-docker &
    git clone git://github.com/meta-rust/meta-rust &
    git clone git://github.com/tkomagata/meta-iotedge &
    if [ "${TARGET_BOARD}" = "h3ulcb-ccpf-sk" ] || [ "${TARGET_BOARD}" = "m3ulcb-ccpf-sk" ]; then
        git clone git://github.com/renesas-rcar/meta-renesas-ccpf &
    # Wait for all clone operations
    # Switch to proper branches/commits
    cd ${WORK}/poky
    git checkout -b tmp ${POKY_COMMIT}
    cd ${WORK}/meta-openembedded
    git checkout -b tmp ${META_OE_COMMIT}
    cd ${WORK}/meta-renesas
    git checkout -b tmp ${META_RENESAS_COMMIT}
    cd ${WORK}/meta-virtualization
    git checkout -b tmp ${META_VIRTUALIZATION_COMMIT}
    cd ${WORK}/meta-docker
    git checkout -b tmp ${META_DOCKER_COMMIT}
    cd ${WORK}/meta-rust
    git checkout -b tmp ${META_RUST_COMMIT}
    cd ${WORK}/meta-iotedge
    git checkout -b tmp ${META_IOTEDGE_COMMIT}
    if [ "${TARGET_BOARD}" = "h3ulcb-ccpf-sk" ] || [ "${TARGET_BOARD}" = "m3ulcb-ccpf-sk" ]; then
        cd ${WORK}/meta-renesas-ccpf
        git checkout -b tmp ${META_RENESAS_CCPF_COMMIT}
    cd ${WORK}
    source poky/oe-init-build-env ${WORK}/build
    bitbake core-image-minimal
  4. Build
    $ chmod a+x build.sh
    $ ./build.sh <target_board_name>
    target_board_name is specified for each board according to the following table:

    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.
  5. Check the built images
    The built images are stored in the following:
  6. 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

      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

  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".
    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.