数码网络嵌入的必要provides integrated support for different AWS IoT components:

  • AWS Greengrass core. A recipe installs this software and allows you to configure the required parameters to build firmware ready for your core.

  • AWS IoT device SDK for embedded C. Several recipes build the libraries and some examples to help you test AWS IoT.

With Digi Embedded Yocto, you can:

Build an AWS IoT image

数码网络嵌入的必要offers a recipe to build an AWS dedicated image calleddey-image-aws. This image is based on core-image and includes:

  • Greengrass core. This software is configured to be launch at startup if the system is properly configured (such as certificate files and core software configuration).

  • AWS IoT examples. You can generate your own certificates and set the build system to include them in your image.

You can add more packages to this image editing your project’sconf/local.conffile.

To build the AWS IoT image:

1. Prepare Greengrass core requirements

Thegreengrassrecipe in Digi Embedded Yocto installs the required software and configures the system to create a final image ready to run the Greengrass core software:

  1. You must download the Greengrass core software and specify where Digi Embedded Yocto can find it in your PC.

  2. Optionally, before building, you cancreate the required certificatesandconfigure the required parametersin your project’sconf/local.conffile. Digi Embedded Yocto generates a completely functional image to program in your device so it performs as a Greengrass core just after booting.

You can provide the certificates and configure the Greengrass core software later at runtime.

Download the Greengrass core software

Download the AWS Greengrass core distributable:

  1. Go to theAWS IoT console.

  2. SelectSoftwarefrom the navigation pane.

  3. In theAWS Greengrass Core Softwaresection, clickConfigure download.

  4. SelectARMv8 (AArch64)from the combo list and clickDownload.

  5. Edit yourconf/local.confto specify where the tarball you have just downloaded is located in your file system:

    GG_TARBALL_LOCAL_PATH="/path/to/greengrass/core/tarball"

Generate the certificates for the Greengrass core software

The device running the Greengrass core software needs certificates to properly establish the connection with AWS IoT. You can generate these certificates beforehand so Digi Embedded Yocto adds them directly to the build image.

数码网络嵌入的必要provides tools to help you with the creation of certificates. The scriptdey-aws-tool.shfacilitates the certificates generation. It also registers the Greengrass core Thing in your AWS account if a name is provided:

Run thedey-aws-tool.shscript inmeta-digilayer to generate the certificates.

$/sources/meta-digi/scripts/dey-aws-tool.sh --create-certs  --thing-name 
  • is the absolute path where the tool will generate the certificates.

  • is the name of the core thing. The tool will register it in your AWS account if it is not already registered.

    Thedey-aws-tool.shtool requires theAWS Command Line Interface (CLI)to be installed and properly configured with your account credentials.

For example, for the output directory/home/user/my-certsand a Thing namemy-core, the output will be similar to the following:

$dey-aws-tool.sh --create-certs /home/user/my-certs --thing-name my-core [INFO] Downloading AWS root CA certificate. [INFO] Creating Greengrass Core CA certificate and key. [INFO] Creating verification certificate. [INFO] Creating Greengrass Core device certificate. [INFO] Registering Greengrass Core Thing. For Greengrass enabled images, add the following configuration to your project: AWS_IOT_CERTS_DIR = "/home/user/my-certs" AWS_GGCORE_IOT_HOST = "ABCDEFG1234567.iot.us-west-2.amazonaws.com" AWS_GGCORE_THING_ARN = "arn:aws:iot:us-west-2:ABCDEFG1234567:thing/my-core" Please verify variables' value is correct.

The certificates are generated inside the provided directory:

$ls - l /home/user/my-certs/总40 -rw-rw-r——1 user user 1758 jun 20 2014 aws-root-ca.pem -rw-rw-r-- 1 user user 1070 jun 29 14:36 gg-core.csr -rw-rw-r-- 1 user user 1675 jun 29 14:36 gg-core.key -rw-rw-r-- 1 user user 1330 jun 29 14:36 gg-core.pem -rw-rw-r-- 1 user user 1679 jun 29 14:36 root-ca.key -rw-rw-r-- 1 user user 1444 jun 29 14:36 root-ca.pem -rw-rw-r-- 1 user user 17 jun 29 14:36 root-ca.srl -rw-rw-r-- 1 user user 1123 jun 29 14:36 root-ca-verif.csr -rw-rw-r-- 1 user user 1675 jun 29 14:36 root-ca-verif.key -rw-rw-r-- 1 user user 1383 jun 29 14:36 root-ca-verif.pem
The certificates generated by the dey-aws-tool.sh script must be registered and attached to the thing representing your core in your account. For more information about AWS certificates, see theofficial AWS IoT documentation.

Configure the required Greengrass core parameters

You need to associate your physical device running AWS Greengrass core software with the AWS IoT thing you created for it when running thedey-aws-tool.shscript.

To do that, the Greengrass recipe includes some variables you can configure for your project. Edit your project’sconf/local.conffile and set the following parameters:

  • AWS_GGCORE_IOT_HOST: MQTT host or endpoint, similar to "ABCDEFG1234567.iot.us-west-2.amazonaws.com". You can get it from theSettingsmenu on the navigation bar of the AWS IoT Console.

  • AWS_GGCORE_THING_ARN: The Greengrass core thing ARN, a unique identifier assigned in the cloud to your AWS Greengrass core device.

  • AWS_IOT_CERTS_DIR:绝对路径的证书s directory in your PC.

The value of these required parameters are provided by the output of thedey-aws-tool.sh. In the example above:

AWS_IOT_CERTS_DIR="/home/user/my-certs"AWS_GGCORE_IOT_HOST="ABCDEFG1234567.iot.us-west-2.amazonaws.com"AWS_GGCORE_THING_ARN="arn:aws:iot:us-west-2:ABCDEFG1234567:thing/my-core"
If you changed the name of the certificates or used another method to generate them, set the value for the following variables in your project’sconf/local.conffile:
## Verisign root CA server certificate used to authenticate the AWS IoT server.## https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem#AWS_GGCORE_ROOT_CA ?="aws-root-ca.pem"# Greengrass core device certificateAWS_GGCORE_CERTIFICATE ?="gg-core.pem"# Greengrass core device private keyAWS_GGCORE_PRIVATE_KEY ?="gg-core.key"

2. Prepare AWS IoT example requirements

数码网络嵌入的必要provides an IoT AWS device C SDK demo to monitor the CPU temperature and load and remotely switch a device LED on and off.

Theawsiotsdk-demo_git.bbrecipe in Digi Embedded Yocto installs the demo application and allows you to create a pre-configured image ready to connect to the AWS IoT platform.

Use theAWS IoT demo applicationcode and the recipe as a reference to create your own AWS IoT applications.

Generate the certificates for the AWS IoT example

Before connecting to AWS IoT, you must generate the required X.509 certificates. Follow the steps in theAWS IoT documentation.

Configure the required AWS IoT parameters

Edit your project’sconf/local.conffile and set the following parameters:

  • AWS_IOT_MQTT_HOST: MQTT host or endpoint, similar toABCDEFG1234567.iot.us-west-2.amazonaws.com. You can obtain it from the Settings menu on the navigation bar of the AWS IoT Console.

  • AWS_IOT_MY_THING_NAME: Thing name that represents your device in your AWS IoT account.

  • AWS_IOT_CERTS_DIR:绝对路径的证书s directory in your PC. It is the same variable used atConfigure the required Greengrass core parameters.

    You can also configure the names of the certificate files:

For more information about AWS certificates, see theofficial AWS documentation.

3. Build your firmware

Once all these parameters are configured, you canbuild-a-software-update-packageto upgrade your device firmware.

$bitbake dey-image-aws-swu

This generates the update package calleddey-image-aws-swu--.swuunder/tmp/deploy/images/.

To install the update packagedey-image-aws-swu--.swuin your device, seeProgram firmware from Linux.

Add Greengrass to your image

If you already have a recipe to generate your own image, you can also integrate the Greengrass core without modifying it from your project configuration:

  1. Download Greengrass core software. SeeDownload the Greengrass core software.

  2. Add Greengrass core software package.

    To create an image with the Greengrass core, you must add thegreengrasspackage to your image.

    Edit your project’sconf/local.conffile and add this package to the list of packages to install:

    IMAGE_INSTALL_append=" greengrass"
    Note the required white space when appending a value to an array variable using the_appendoverride syntax.
  3. Generate the certificates for the Greengrass core software. SeeGenerate the certificates for the Greengrass core software.

  4. Configure the Greengrass core required parameters. SeeConfigure the required Greengrass core parameters.

  5. Build your firmware as usual.

Add an AWS IoT application to your image

You can build your applications to connect to AWS IoT platform using the AWS IoT support already included in Digi Embedded Yocto. Use theAWS IoT democode and its recipe as a reference to create your own AWS IoT applications and recipes. For more information on creating your AWS IoT application, seeAWS IoT device SDK for embedded C.

  1. Add your AWS IoT application package.

    Edit your project’sconf/local.conffile and add the package to the list of packages to install. For example, to add the AWS IoT demo:

    IMAGE_INSTALL_append=" awsiotsdk-demo"
    Note the required white space when appending a value to an array variable using the_appendoverride syntax.
  2. Generate the certificates for the AWS IoT application. SeeGenerate the certificates for the AWS IoT example.

  3. Configure the required AWS IoT parameters. SeeConfigure the required AWS IoT parameters.

  4. Build your firmware as usual.