Difference between revisions of "MISC-TN-005: Running AWS Greengrass Core on SBCSPG"

From DAVE Developer's Wiki
Jump to: navigation, search
(Setting up the edge device)
Line 97: Line 97:
  
 
==Configuring AWS Greengrass Core on cloud side==
 
==Configuring AWS Greengrass Core on cloud side==
 +
 +
It looks like the kernel uses 'systemd' as the init process. Be sure to set the
 +
'useSystemd' field in the file 'config.json' to 'yes' when configuring Greengrass core.
 +
  
 
==Deploying the test Lambda function to the edge device==
 
==Deploying the test Lambda function to the edge device==

Revision as of 13:14, 6 August 2019

Info Box
SBCSPG-1.jpg Applies to SBCSPG
Warning-icon.png This technical note was validated against specific versions of hardware and software. It may not work with other versions. Warning-icon.png


History[edit | edit source]

Version Date Notes
1.0.0 August 2019 First public release

Introduction[edit | edit source]

In these days, we are witnessing the cloud war. Almost every week, the top three cloud providers⁠—Amazon, Microsoft, and Google⁠—add new services and new functionalities.

Technically speaking, it is hard to determine which platform is the best. Although basic services are similar, each platoform has different peculiarities that make it more or less suitable for a specific application.

In principle, DAVE Embedded Systems' products are designed to be cloud-agnostic in order to let the users the freedom to choose the cloud platform they think best fits their needs.

This Technical Note, for instance, shows how to interface the SBCSPG Industrial IoT gateway to Amazon Web Services (AWS). Specifically, this document shows how to configure and run the AWS Greengrass Core (GGC) on the device. According to AWS website, AWS IoT Greengrass is

software that lets you run local compute, messaging, data caching, sync, and ML inference capabilities on connected devices in a secure way. With AWS IoT Greengrass, connected devices can run AWS Lambda functions, execute predictions based on machine learning models, keep device data in sync, and communicate with other devices securely – even when not connected to the Internet.

AWS IoT Greengrass seamlessly extends AWS to devices so they can act locally on the data they generate, while still using the cloud for management, analytics, and durable storage. With AWS IoT Greengrass, you can use familiar languages and programming models to create your device software in the cloud, and then deploy it to your devices. AWS IoT Greengrass can be programmed to filter device data and only transmit necessary information back to the cloud.

In other words, GGC allows you to implement edge computing functionalities easily and quickly by deploying them on the edge device through the AWS platform.


Cloud and Edge computing in a typical IIoT scenario (image source: [1])


It is worth remembering that edge computing means a distributed computing paradigm which brings computation and data storage closer to the location where it is needed, to improve response times and save bandwidth, according to Wikipedia. Within the processing power limits of the edge device, moving such computations to the edge is an effective way to optimize costs. When the Internet connection is intermittent or poor, it can be even mandatory to meet system's requirements.

Please note that this Technical Note is not a step-by-step guide to set up the edge device and the cloud platform. AWS documentation is rich and detailed in this regard. Rather, this document aims to underline some specific SBCSPG-related steps required to run GGC on this device successfully. The procedure is based on the [https://docs.aws.amazon.com/greengrass/latest/developerguide/gg-gs.html Getting Started with AWS IoT Greengrass guide.

The test was performed with:

  • Linux kernel 4.1.15-rialto-1.1.3
  • Debian Stretch distribution (for more details, please see this Technical Note)
  • AWS IoT Greengrass Core 1.9.2.

Setting up the edge device[edit | edit source]

The first thing to do was to rebuild the Linux kernel after adding the missing options⁠—if any⁠—required by GGC, which are detailed here.

Once the device was up and running with the fresh Linux kernel, to enable IP routing to the Internet, the default gateway was setup like this:

root@sbcspg:~# route add default gw 192.168.0.254 eth0

/etc/resolv.conf was edited to add a typical DNS entry:

root@sbcspg:~# cat /etc/resolv.conf
nameserver 8.8.8.8

Then, the root file system had to be configured according to the requirements described here.

AWS documentation was a little bit confusing about the Node.JS and Java requirements. Both were installed, just in case. With regard to Java, OpenJDK 1.8.0 was installed.

The following guides were useful to install some of the required packages:

To setup cgroups, this script was used.

Finally, a couple of file system setting had to be tuned, too. They are hardlink and softlink protections. For more details about these settings, please refer to the following links:

Finally, the recommended certificate was installed

sudo wget -O root.ca.pem https://www.amazontrust.com/repository/AmazonRootCA1.pem

To verify that the device is setup properly, it is recommended to use the dependency checker script provided by AWS itself. The following image shows the output of the checker executed on SBCSPG after completing the configuration.


Output of the GGC dependencies checker


As shown, only one check is highlighted, which refers to the kernel version. To run GGC 1.9.2, it is recommended a 4.4 kernel version or later. Although checker's report didn't warn about the use of containers, we verified that GGC couldn't work on top of SBCSPG's 4.1.15 Linux kernel. Because a newer kernel was not available for SBCSPG at the time of this writing, to work around this issue, the default Lamba functions containerization was disabled.

In order to make the checker happy, two symbolic links were created as well:

lrwxrwxrwx 1 root root  4 Jul 30 16:50 /usr/bin/java8 -> java
lrwxrwxrwx 1 root root  6 Jul 30 16:52 /usr/bin/nodejs8.10 -> nodejs

Configuring AWS Greengrass Core on cloud side[edit | edit source]

It looks like the kernel uses 'systemd' as the init process. Be sure to set the 'useSystemd' field in the file 'config.json' to 'yes' when configuring Greengrass core.


Deploying the test Lambda function to the edge device[edit | edit source]

Testing the connection[edit | edit source]

TBD