Makers Blog

How to turn an AXC F 2152 into an AWS Greengrass device

Martin PLCnext Team 19 February 2020 min. read
831 views 0 comments

Starting with firmware version 2020.0, AXC F 2152 devices are now “Docker Ready”. A guide showing how to install Balena Engine on an AXC F 2152 is available in Github.

This tutorial demonstrates how an OCI container can be used to easily turn an AXC F 2152 into an AWS IoT Greengrass device.

Prerequisites

  • Install Balena Engine on an AXC F 2152 by following the getting started guide.
  • You will need an Amazon Web Services (AWS) account in order to configure, deploy and test your IoT Greengrass device configuration.It is also highly recommended that the following steps be performing:
  • Work through the tutorial “Running AWS IoT Greengrass in a Docker Container” on a standard Linux distribution like Debian or Ubuntu.
  • Deploy and test a Lambda function to that IoT Greengrass “device”.This will help you to get familiar with the process of building, installing and using an AWS IoT Greengrass docker container. It will also prove that your Greengrass group configuration can be deployed successfully to a Greengrass device, before you start working with the AXC F 2152.

Procedure

Once you have successfully deployed and tested a Greengrass group configuration in a Debian-based docker container (for example), shut down that container and proceed with the following steps:

  1. Log on to the PLC as admin.
  2. Download and extract the AWS IoT Greengrass Core image source files to the PLC$ cd ~ $ wget https://d1onfpft10uf5o.cloudfront.net/greengrass-core/downloads/1.10.0/aws-greengrass-docker-1.10.0.tar.gz $ tar -xf aws-greengrass-docker-1.10.0.tar.gz $ rm aws-greengrass-docker-1.10.0.tar.gz $ cd aws-greengrass-docker-1.10.0
  3. Edit the DockerfileThe Greengrass image does not include python 3.7, which is needed for the Lambda function used in the AWS tutorial. So, change the base image from the standard alpine image, to an image that includes python 3.7:
    • Open the file Dockerfile.alpine-armv7l in your favourite editor (e.g. nano or vi).
    • Change the base image (on the first line) from arm32v7/alpine:3.9 to arm32v7/python:3.7-alpine
    If you want to include Java support in your image, add the following to the Dockerfile:RUN apk add openjdk8-jre && ln -s /usr/bin/java /usr/local/bin/java8If you choose not to install Java in your image, you must disable Stream Manager in your Greengrass Group configuration.
  4. Build the docker imageThe README.md file in the image source directory includes detailed instructions for building the image for Raspberry Pi. This procedure will also work for the AXC F 2152.In summary – from the aws-greengrass-docker-1.10.0 directory:$ su $ echo 1 > /proc/sys/fs/protected_hardlinks $ echo 1 > /proc/sys/fs/protected_symlinks $ balena-engine build -t "armv7l/aws-iot-greengrass:1.10.0" -f Dockerfile.alpine-armv7l ./ $ balena-engine imagesYou should see the image that you have just built.
  5. Install AWS configuration and certificates on the AXC F 2152Download the AWS config and certs directories to the PLC – the same ones that you used when following the tutorial on the AWS website. From your desktop Linux directory containing these directories, execute the following commands:$ scp -r config admin@192.168.1.10:~/aws-greengrass-docker-1.10.0 $ scp -r certs admin@192.168.1.10:~/aws-greengrass-docker-1.10.0(note that the IP address in the above commands must match the IP address of your PLC)
  6. Start the containerOn the PLC, as root user:$ balena-engine run --rm -it --name aws-iot-greengrass \ --entrypoint /greengrass-entrypoint.sh \ -v /opt/plcnext/aws-greengrass-docker-1.10.0/certs:/greengrass/certs \ -v /opt/plcnext/aws-greengrass-docker-1.10.0/config:/greengrass/config \ -p 8883:8883 \ armv7l/aws-iot-greengrass:1.10.0
  7. Deploy and test the Greengrass group configurationFrom your AWS account, deploy your Greengrass group configuration to the AXC F 2152.You should now see MQTT messages being sent from the AXC F 2152 to your AWS MQTT broker on the hello/world topic.

Troubleshooting

If you get the error “Unable to find java or java8 executables” when deploying the group configuration, then disable Stream Manager.

Questions?

Please ask any questions related to this article in the PLCnext Community Forum, under the category “Container @ PLCnext (Docker, Moby, balena)”

Acknowledgements

Thank you to Jan Christoph Müller and Marcel Luhmann for their help with the procedure described in this article.

Note:

The Makers Blog shows applications and user stories of community members that are not tested or reviewed by Phoenix Contact. Use them at your own risk.

Discussion

Please login/register to comment

Login/Register

Leave a Reply

Newsletter
Never miss a new article
Sign up for the newsletter
Never miss news about PLCnext Technology
Get interesting content via newsletter four times a year
Receive exclusive information before all other users