5.3. AWS Greengrass Cloud Connectivity

5.3.1. Overview

The AM62x can be used as an Edge Gateway or Edge Router to the cloud, whether private or public. AWS is one of the most popular cloud options available. AWS IoT Greengrass is an edge computing platform that can easily be added to the Processor SDK for the AM62x. This addition allows a AM62x based device to be added to AWS as an edge device.

../_images/greengrass-AM62xEdgeGatewayConcept.png

The above diagram shows a concept of an AM62x based device connecting a variety of wireless and wired sensors and control elements to AWS via Greengrass running on Linux provided by the Processor SDK. This short how-to covers how to add AWS Greengrass to the Processor SDK to start building a system like the one above. This guide focuses on getting the AM62x Starter Kit connected to AWS by adding the necessary components to Linux, running Linux on the AM62x Starter Kit, and connecting to AWS to run the provided getting started tutorials.

5.3.1.1. About AWS IoT Greengrass

To learn more about AWS IoT Greengrass, see how it works and what’s new.

5.3.2. Necessary Hardware

Here is a list of things needed to run this demo:

  • AM62 Starter Kit (SK-AM62) EVM with the necessary connections outlined in the Quick Start Guide to boot off of a SD Card. This includes a power supply and cable and a USB to serial connection for the Linux console.

  • SD card that can be overwritten and a way to write to it from a PC.

  • A host machine running Linux (preferably an Ubuntu LTS distribution, 18.04 or newer).

  • An ethernet connection for the EVM to connect to AWS.

5.3.3. System Setup

To set up the AM62x-SK, follow the Quick Start Guide to boot the Processor SDK from a SD Card on the AM62 Starter Kit (SK-AM62) EVM.

Make sure the EVM can connect to the internet using an Ethernet or Wireless connection. This connection is needed to talk to the AWS servers with Greengrass in the following steps. Please refer to Setup Network for more information on setting up these network connections on the EVM.

5.3.4. Use Yocto to Build the Corretto JVM

The Processor SDK is built from Yocto/Open Embedded and can easily be extended or modified. In order to run AWS IoT Greengrass, the SDK needs a Java Virtual Machine (JVM). Since AWS recommends Corretto, Yocto can be used to add Corretto to the SDK in order to run Greengrass.

The instructions for building the SDK with Yocto are documented here. Follow the instructions up to Section 1.2.2.2 Build Steps. Instead of the provided bitbake instruction that builds the entire SDK or filesystem, use the below intruction:

  • Execute the build instruction, bitbake, like below to only build the Corretto package (ipk) instead of the entire SDK. This command saves quite a bit of time since the entire SDK is not needed at this point:

    MACHINE=am62xx-evm bitbake corretto-11-bin
    

    This step will take a few minutes to complete as it will download and build Corretto and all of its dependencies.

    The built packages will be in arago-tmp-external-arm-glibc/deploy/ipk/aarch64.


  • Copy the necessary packages listed below to the target device by either copying them to the SD card using a SD card writer, or using the network with something like a SCP command.

    • corretto-11-bin_11.0.15.9.1-r0.0_aarch64.ipk


  • On the target, install the package with the below command:

    opkg install corretto-11-bin_11.0.15.9.1-r0.0_aarch64.ipk
    

  • Verify the installation is successful:

    java --version
    

    If java is installed and working, output with the version should be displayed.

5.3.5. Setup AWS IoT Greengrass

These steps will set up an AWS account to interact with and manage the IoT Greengrass target.

5.3.5.1. Setup your AWS account and Permissions

Refer to the instructions at Set up your AWS Account. Follow the steps outlined in these sections to create your account and a user and get started:

Pay special attention to the notes included in these pages.

5.3.5.2. Create Resources in AWS IoT

Refer to the instructions at Create AWS IoT Resources. Follow the steps outlined in these sections to provision resources for your device:

Pay special attention to the notes included in these pages.

5.3.5.3. Install the AWS Command Line Interface (CLI)

To install the AWS CLI on your host machine, refer to the instructions at Installing the AWS CLI v2. Installing the CLI is needed to complete the instructions in this guide.

Once you have installed AWS CLI, configure it as per the instructions in this online guide. Set the appropriate values for Access key ID, Secret access key, and AWS Region. You can set Output format to “json” if you prefer.

Note

The credentials used by the AWS CLI are stored in plaintext files and are not encrypted. It is strongly recommended that you configure file system permissions on the $HOME/.aws folder and its child folders and files to restrict access to only authorized users. Use roles with temporary credentials wherever possible to reduce the opportunity for damage if the credentials are compromised. Use long-term credentials only to request and refresh short-term role credentials.

5.3.5.4. Install AWS IoT Greengrass

To install AWS IoT Greengrass on the target device, refer to the instructions at Install the AWS IoT Greengrass Core software. This installation will leverage the Coretto JVM added to the SDK earlier.

5.3.5.5. Create a Hello World Component

In Greengrass v2, components can be created on the edge device and uploaded to the cloud, or vice versa.

5.3.5.5.1. Create the component on your edge device

Follow the instructions online under the section To create a Hello World component to create, deploy, test, update and manage a simple component on your device.

5.3.5.5.2. Upload the Hello World component

Follow the instructions online at Upload your component to upload your component to the cloud, where it can be deployed to other devices as needed.

5.3.5.6. Troubleshooting

For guidance on troubleshooting the starter kit, refer to the documentation.

Refer to the instructions at Troubleshooting Greengrass for information on:

  • How to View AWS IoT Greengrass Core software logs

  • How to View component logs

  • AWS IoT Greengrass Core software issues

  • AWS IoT Greengrass cloud issues

  • Core device deployment issues

  • Core device component issues

You can also refer to Logging and Monitoring to learn how to log API calls, gather system health telemetry data, and check core device status.