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.
- 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.
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:
- Log on to the PLC as
- 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
- 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-armv7lin your favourite editor (e.g. nano or vi).
- Change the base image (on the first line) from
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.
- Open the file
- Build the docker imageThe
README.mdfile 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
$ 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.
- Install AWS configuration and certificates on the AXC F 2152Download the AWS
certsdirectories 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 email@example.com:~/aws-greengrass-docker-1.10.0 $ scp -r certs firstname.lastname@example.org:~/aws-greengrass-docker-1.10.0(note that the IP address in the above commands must match the IP address of your PLC)
- 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
- 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
If you get the error “Unable to find java or java8 executables” when deploying the group configuration, then disable Stream Manager.
Please ask any questions related to this article in the PLCnext Community Forum, under the category “Container @ PLCnext (Docker, Moby, balena)”
Thank you to Jan Christoph Müller and Marcel Luhmann for their help with the procedure described in this article.
Leave a Reply
You must be logged in to post a comment.