Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / IoT

Start Amazon Web Services Greengrass Core on the UP Squared Development Board

0.00/5 (No votes)
26 Apr 2018CPOL5 min read 5.7K  
This guide shows the steps to start Amazon Web Services (AWS) Greengrass core on Ubuntu using the UP Squared development board.

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

Introduction

This guide shows the steps to start Amazon Web Services (AWS) Greengrass* core on Ubuntu* using the UP Squared* development board.

About the UP Squared* Board

Characterized by low power consumption and high performance - which is ideal for the Internet of Things (IoT) - the UP Squared platform is the fastest x86 maker board based on the Apollo Lake platform from Intel. It contains both the Intel Celeron® processor Dual Core N3350 and Intel® Pentium® brand Quad Core N4200 processor.

AWS Greengrass*

AWS Greengrass is software that extends AWS cloud capabilities to local devices, allowing them to collect and analyze data on the local devices. This reduces latency between the devices and data processing layer, and reduces storage and bandwidth costs involved with sending data to the cloud. The user can create AWS Lambda functions to enable Greengrass to keep data in sync, filter data for further analysis, and communicate with other devices securely.

Operating System Compatibility

The UP Squared board can run Ubilinux*, Ubuntu*, Windows® 10 IoT Core, Windows® 10, Yocto Project*, and Android* Marshmallow operating systems. For more information on UP Squared, visit this website.

Hardware Components

The hardware components used in this project are listed below:

Create AWS Greengrass* Group

An AWS Greengrass group is a collection of settings for AWS Greengrass core devices, and the devices that communicate with them. Let’s start by logging into the Amazon Web Services (AWS)* Management Console, opening AWS IoT console, choosing a region from the top right corner of the navigation bar, then selecting Greengrass.

On the Welcome to AWS Greengrass screen, choose Get Started.

Image 1

Figure 1: AWS IoT Console

On the Set up your Greengrass group page, select Use easy creation to create an AWS Greengrass group.

Image 2

Figure 2: Setting up AWS Greengrass Group

Choose a name for your Greengrass Group, then click Next.

Image 3

Figure 3: Setting up AWS Greengrass Group: Name the Group

Use the default name for the AWS Greengrass core, then select Next.

Image 4

Figure 4: Setting up AWS Greengrass Group: Name the Greengrass Core

Select Create group and Core on the Run a scripted easy Group creation page.

Image 5

Figure 5: Setting up AWS Greengrass Group: Create Group and Core

You should see following page while the AWS Greengrass Group is being created.

Image 6

Figure 6: Setting up AWS Greengrass Group: Creating Group and Core

When you see a certificate and public and private keys, you have successfully created the new Greengrass group. Click on Download these resources as a tar.gz to download the certificate and private key for later use. Select x86_64 for CPU architecture and then click on the Download Greengrass to start the Greengrass download.

Image 7

Figure 7: Setting up AWS Greengrass Group: Certificate and Private Key

Select Finish.

Image 8

Figure 8: Setting up AWS Greengrass Group: Successfully

Development Boards

Before you begin, make sure that the Ubuntu* operating is installed on The UP Squared board. To ensure that the Ubuntu operating system is up to date and dependent Ubuntu packages are installed, open a command prompt (terminal) and type the following:

sudo apt-get update

Image 9

Install sqlite3 package by entering the following command in the terminal:

sudo apt-get install sqlite3

Image 10

Create the Greengrass user and group account:

sudo adduser --system gcc_user
sudo addgroup --system gcc_group

Image 11

Untar the Greengrass Core software that was downloaded in the "Figure 7: Setting up AWS Greengrass Group: Certificate and Private Key" step earlier.

Image 12

Download the cmake package by entering the following command in the terminal:

wget https://cmake.org/files/v3.8/cmake-3.8.0.tar.gz

Image 13

Execute the following commands:

tar -xzvf cmake-3.8.0.tar.gz
cd cmake-3.8.0
./configure
make
sudo make install

Image 14

Image 15

Image 16

Image 17

Use the following commands to install OpenSSL:

wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz
tar -xzvf openssl-1.0.2k.tar.gz
cd openssl-1.0.2k
./config --prefix=/usr
make
sudo make install
sudo ln –sf /usr/local/ssl/bin/openssl ‘which openssl’
openssl version -v

Image 18

Image 19

Image 20

Image 21

Image 22

Image 23

Enable Hardlinks and Softlinks Protection

Activate the hardlinks and softlinks protection to improve security on the device. Add the following two lines to /etc/sysctl.d/10-link-restrictions.conf.

fs.protected hardlinks = 1
fs.protected symlinks = 1

Reboot the UP Squared board and validate the system variables by running:

sudo sysctl -a | grep fs.protected

Image 24

Install Greengrass Certificate and Key

Copy the certificate and private keys files created in the "Figure 7: Setting up AWS Greengrass Group: Certificate and Private Key" above to the UP Squared board as follow:

  • cloud.pem.crt: 4f7a73faa9-cert.pem.crt created above
  • cloud.pem.key: 4f7a73faa9-private.pem.key created above
  • root-ca-cert.pem: wget https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem -O root-ca-cert.pem

Image 25

The ~/greengrass/certs should look like this:

Image 26

Edit config.json

Open a command prompt (terminal) and navigate to ~/greengrass/config folder. Edit config.json as follows to configure the Greengrass Core:

{
    "coreThing": {
        "caPath": "root-ca-cert.pem",
        "certPath": "cloud.pem.crt",
        "keyPath": "cloud.pem.key",
        "thingArn": "arn:aws:iot:us-east-1:xxxxxxxxxxxx:thing/MyGreengrass1stGroup_Core",
        "iotHost": "yyyyyyyyyyyy.iot.us-east-1.amazonaws.com",
        "ggHost": "greengrass.iot.us-east-1.amazonaws.com",
	"keepAlive": 600
    },
    "runtime": {
        "cgroup": {
            "useSystemd": "yes"
        }
    },
    "system": {
        "shadowSyncTimeout": 120
    }
}

Note: The default value of shadowSyncTimeout is 1.

  • •thingArn: Navigate to AWS IoT console, choose Manage on the left, and then select MyGreengrass1stGroup under Thing.

Image 27

ThingARN should look like this:

Image 28

  • iotHost: Navigate to AWS IoT console, the Endpoint is located under Settings on the bottom left corner of the AWS IoT console.

Image 29

Start AWS Greengrass* Core

Open a command prompt (terminal) and navigate to ~/greengrass/config folder

cd ~/greengrass/ggc/core
sudo ./greengrassd start

When you see the message "Greengrass successfully started", you will know the Greengrass core has been created successfully.

Image 30

To confirm that the Greengrass core process is running, run the following command:

ps aux | grep greengrass

Image 31

Summary

We have described how to start the Greengrass core on the UP Squared board. From here, there are several projects you can try to explore the potential of the UP Squared board. For example, you can create a Greengrass deployment, add a group of devices that can communicate with the local IoT endpoint, enable Lambda functions to filter data for further analysis, and more.

References

Amazon Kinesis* Service API Reference:
http://docs.aws.amazon.com/greengrass/latest/developerguide/what-is-gg.html
http://docs.aws.amazon.com/greengrass/latest/developerguide/gg-config.html

Up Squared:
http://www.up-board.org/upsquared

Amazon:
https://aws.amazon.com/kinesis/streams/getting-started

IoT References:
https://software.intel.com/en-us/iot/hardware/devkit

About the Author

Nancy Le is a software engineer at Intel Corporation in the Software and Services Group, working on the Intel Atom® processor and IoT scale enabling projects.

*Other names and brands may be claimed as the property of others.

More on UP Squared

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)