Installing AWS IoT Greengrass - FreeWaveTechnologies/ZumIQ GitHub Wiki

Installing AWS IoT GreenGrass on a ZumLink or ZumIQ, running IQ2

IMPORTANT NOTE: This version is superseded by Installing AWS IoT Greengrass newer version.

Introduction

This procedure has been tested on a Z9-PE, Z9-P2, and ZIQ-PE2. I assume it will work on any ZumLink or ZumIQ device.

The ZumLink or ZumIQ must be running IQ2 (kernel 4.14 or newer) and the associated developer environment.

Sources

This was the primary source: https://docs.aws.amazon.com/greengrass/latest/developerguide/gg-gs.html

This one was useful for the Preliminaries section: https://docs.aws.amazon.com/greengrass/latest/developerguide/setup-filter.other.html

Preliminaries

  1. Login as devuser. Add user ggc_user and group ggc_group.
sudo adduser --system ggc_user
sudo addgroup --system ggc_group
  1. Add protection for hard links and symbolic links.
sudo sysctl -w fs.protected_hardlinks=1
sudo sysctl -w fs.protected-symlinks=1
# To check:
sudo sysctl -a 2> /dev/null | grep fs
# or:
sudo cat /proc/sys/fs/protected_*
  1. If you're testing GG's suitability on the ZumLink, then do these steps:
cd /ptp
mkdir greengrass-dependency-checker-GGCv1.10.x
cd greengrass-dependency-checker-GGCv1.10.x
wget https://github.com/aws-samples/aws-greengrass-samples/raw/master/greengrass-dependency-checker-GGCv1.10.x.zip
unzip greengrass-dependency-checker-GGCv1.10.x.zip
cd greengrass-dependency-checker-GGCv1.10.x
sudo ./check_ggc_dependencies | more
  1. The suitability tester will point out the following issues:
  • Python 3.7 (optional) is needed to execute Python 3.7 lambdas on GG core. By the time you read this, Python 3.7 may be installed, and this message may not show up anymore.
  • node.js 8.10 (optional) is needed to execute NodeJS lambdas on GG core. Node.js is easily installed if you need it.
  • Java 8 (optional) is needed to execute Java lambdas on GG core. Java makes heavy use of both flash and RAM memories. If you must install Java, FreeWave recommends one of the lighter-weight Java alternatives, such as Zulu from Azul Systems, instead of Oracle Java.
  • No hardlink or symlink protection. This is remedied by using the sysctl commands in the previous steps.

Configure AWS Greengrass on AWS IoT

(These instructions are copied from https://docs.aws.amazon.com/greengrass/latest/developerguide/gg-config.html)

  1. Sign in to the AWS Management Console at https://console.aws.amazon.com.
  2. Click IoT Core to open the AWS IoT console.
  3. Click Greengrass in the left margin.
  4. Choose Create a Group, then choose Use easy creation.
  5. Use a meaningful group name, like 'zum_devices'. It will give you a default name for the AWS IoT GG core, like 'zum_devices_Core'. Choose Next.
  6. On the next page, Run a scripted easy Group creation, just click Create Group and Core.
  7. On the Connect your Core device page, click BOTH:
  • Download these resources as a tar.gz (AND write down the filename!)
  • Choose a root CA (AND write down the filename!)
  • DO NOT CLICK Choose your platform.
  1. Click Finish at the bottom of the page. This takes you to the Configuration page for your GG group.

Download and install GG Core on the Zumlink

  1. On your PC, download the Raspbian for Armv7l package from https://docs.aws.amazon.com/greengrass/latest/developerguide/what-is-gg.html#gg-core-download-tab .

  2. On your PC, copy the GG core package from step 1, and the hashhashhash-setup.tar.gz file to the ZumLink. The easiest way to do this is to open a Linux-like terminal window on the PC and use the scp utility.

# cd to the directory containing the GG core package.
scp greengrass-linux-armv7l-<version>.tar.gz devuser@<zumlinks_ip_address>:/ptp/.
# cd to the directory containing the setup.tar.gz file.
scp <hash>-setup.tar.gz devuser@<zumlinks_ip_address>:/ptp/.
scp AmazonRootCA1.pem devuser@<zumlinks_ip_address>:/ptp/.
  1. On the ZumLink, uncompress the files:
cd /ptp
sudo tar -xzvf greengrass-linux-armv7l-<version>.tar.gz
sudo tar -xzvf <hash>-setup.tar.gz -C greengrass
sudo mv AmazonRootCA1.pem certs/root.ca.pem
cd certs
sudo cp * ../greengrass/certs/.
  1. Edit the config.json file. This step may not be needed for long. system.d is coming to ZumIQ very soon.
cd /ptp/greengrass/config
vi config.json
# Go to line 12, and make it look like this: "useSystemd": "no"
# Search for '_HERE' and update all of the fields, per the website below
# Save and exit

The best documentation for config.json is at: https://docs.aws.amazon.com/greengrass/latest/developerguide/gg-core.html

Now you're ready to run AWS IoT Greengrass

First, there may be a conflict between Greengrass and another application on port 8000. Before running Greengrass, you must find out which process is using port 8000 and kill the process.

sudo netstat -tupln | grep 8000
# At the end of the line will be a PID and a program name,
# like 624/python3.5
kill -9 <the_PID_for_example_624>

Now run Greengrass.

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

You can verify that Greengrass is running by executing the command:

ps -ef | grep greengrass
⚠️ **GitHub.com Fallback** ⚠️