Connect Designs Quickly and Securely to the Cloud Using Amazon FreeRTOS

By Jacob Beningo

Contributed By Digi-Key's North American Editors

The traditional embedded systems developer typically works at the bare metal level on disconnected devices, but the IoT requires systems to connect to the Internet. This requires embedded system developers to learn how to connect their devices and use a higher level operating system, such as a real-time operating system (RTOS).

Rather than starting from scratch and learning every nuance required to securely connect an embedded system to the Internet, developers can use Amazon FreeRTOS. This will allow them to quickly and easily connect their devices to Amazon Web Services (AWS) in a secure manner that simplifies their development efforts. This article will discuss and demonstrate how to get started with Amazon FreeRTOS.

An introduction to Amazon FreeRTOS

Amazon FreeRTOS is an RTOS that, at its core, is the open source FreeRTOS kernel with additional components added to enable local and cloud connectivity, security, and over-the-air (OTA) updates. The FreeRTOS kernel is a well-known RTOS that has been around for more than a decade and provides useful features such as:

  • Priority-based task scheduling
  • Semaphores
  • Mutexes
  • Message queues

Also, FreeRTOS is freely available under the MIT software license.

What makes Amazon FreeRTOS unique and interesting to embedded software developers is that it adds connectivity libraries and security to FreeRTOS. It then pulls it all together into a single cohesive framework that allows developers to immediately connect their device to cloud services in a secure manner out of the box.

Selecting Amazon FreeRTOS hardware

The FreeRTOS kernel itself works on several dozen different microcontroller architectures. At the moment, Amazon FreeRTOS has been fully tested and integrated onto four different microcontroller vendor hardware platforms through the Amazon FreeRTOS Qualification Program. These are:

Image of NXP Semiconductors’ LPC54018 IoT Module

Figure 1: NXP Semiconductors’ LPC54018 IoT Module is based on an Arm® Cortex®-M4 180 MHz microcontroller with 128 Mbits of Macronix MX25L12835 Quad-SPI flash memory. A fully integrated Wi-Fi module to get a quick start with Amazon FreeRTOS. (Image source: NXP Semiconductors)

Each of these development kits has been fully tested with Amazon FreeRTOS, but developers may have a preferred silicon vendor. For example, it is worth noting that Amazon FreeRTOS also supports OTA, but that support is currently only provided in beta testing for the Texas Instruments CC3220SF-LaunchXL (Figure 2). This board is based on an Arm® Cortex®-M4 microcontroller and features an onboard temperature sensor, accelerometer, three LEDs, and a programmable user button. This module provides a fully integrated solution to get started with Amazon FreeRTOS.

In the future, the other boards will undoubtedly also be supported by OTA, but if this is a critical design feature right now, start with the Texas Instruments solution.

Image of Texas Instruments' CC3220SF-LaunchXL

Figure 2: Texas Instruments' CC3220SF-LaunchXL is a fully integrated solution to get started with Amazon FreeRTOS. It also supports the Amazon FreeRTOS OTA Beta demo example. (Image source: Texas Instruments)

Most of the development kits are single module kits that are single board solutions. The Microchip Curiosity development kit, however, requires developers to purchase additional modules such as Ethernet, a Wi-Fi module, and a USB-to-UART converter.

The board is based on a PIC32 microcontroller, but in order to get a fully functional board that can be used with Amazon FreeRTOS, a developer needs to purchase additional components. The best components to get in order to have a fully functional Amazon FreeRTOS example are the following MikroElektronika MIKROE expansion modules:

The completely assembled board will then appear as shown in Figure 3. A developer would be ready to run the example Amazon RTOS application.

Image of Microchip Technology’s PIC32MZEF Curiosity Development Kit

Figure 3: Microchip Technology’s PIC32MZEF Curiosity Development Kit offers a modular design that allows developers to customize the components that they need for their application on their development kit. The image as shown also includes the MIKROE Wi-Fi and MIKROE USB to UART daughter boards. (Image source: Microchip Technology)

Connecting Amazon FreeRTOS to the cloud

Getting Amazon FreeRTOS up and running on any of the development kits discussed in the last section is easy. Each development board has a demonstration that is ready to go with step-by-step instructions on how to run that demonstration. For example, the Microchip board has instructions located here.

First, locate the appropriate getting started guide for the development kit.

Next, set up the hardware. For most development kits the hardware is all-inclusive, but if the Microchip solution is selected, each of the module boards needs to be added to the Curiosity board, and an external programming tool such as an ICD4 needs to be connected.

Image of Microchip PIC32MZEF Curiosity Development Kit

Figure 4: The PIC32MZEF Curiosity Development Kit assembled and connected to an ICD4 programming tool. This setup uses a wired Ethernet connection to run the demonstration. (Image source: Amazon)

Once the hardware has been set up, the next step is to install the development environment in which to compile the Amazon FreeRTOS example. For example, developers using Microchip would download MPLAB X, along with the XC32 compiler.

In order to obtain access to the Amazon FreeRTOS examples, sign up for AWS and access their console. AWS does offer a 12-month free trial tier that allows developers to get access to AWS, Amazon FreeRTOS, and other features that would be useful for developing a connected device. Signing up for an account can be done here. Once the account is created, access the Amazon FreeRTOS page which will provide a list of software configurations for Amazon FreeRTOS. These configurations include source files for each development kit, as well as an Amazon FreeRTOS simulator. Download the predefined configuration that matches the development kit and import it into the development environment. For example, the corresponding Curiosity board would use the predefined “Connect to AWS IoT – Microchip configuration designed for the Curiosity PIC32MZEF.”

Image of Amazon FreeRTOS software configuration page

Figure 5: The Amazon FreeRTOS software configuration page has several predefined software configurations for different development kits and different applications. Use these predefined configurations to get a demonstration application connected to AWS and jump start development. (Image source: Amazon)

Once Amazon FreeRTOS has been downloaded, developers should return to their AWS console and click on the settings button. Under settings, they will discover that they have an IoT endpoint assigned to them such as:

<1234567890123>.iot.<us-east-1>.amazonaws.com.

This important number allows the IoT device to connect to AWS. A developer would then find aws_clientcredential.h in the example project and set the following properties:

  • clientcredentialMQTT_BROKER_ENDPOINT
  • clientcredentialIOT_THING_NAME
  • clientcredentialWIFI_SSID
  • clientcredentialWIFI_PASSWORD
  • clientcredentialWIFI_SECURITY

At this point, a developer only needs to configure their device key. In order to generate a key, go to the AWS console and select Secure -> Certificates. There is an option to create a quick certificate. Clicking this option will generate a certificate similar to the one shown in Figure 6. The private key and the certificate are needed to generate a keys file for the embedded device.

Image of creating a certificate and then a key

Figure 6: Creating a certificate and then a key requires developers to create their certificate from within AWS. The three files that will be created are a certificate, a public key and a private key. (Image source: Amazon)

The key generator is located in:

Copy<BASE_FOLDER>\demos\common\devmode_key_provisioning\CertificateConfigurationTool\CertificateConfigurator.htm

Loading the html file in a browser will reveal an interface similar to that shown in Figure 7.

Using the certificate and private key files generated from the AWS console, developers can then generate their aws_clientcredential_key.h configuration file. Once this has been done, compile the project and deploy the software onto the embedded target.

Image of certificate and private key that are generated in AWS

Figure 7: The certificate and private key that are generated in AWS are used to create the key configuration module that is loaded into the microcontroller and used to create a secure connection to AWS. (Image source: Amazon)

The only remaining step is for a developer to subscribe to their devices’ MQTT messages. This can be done within AWS by going to the test menu and then subscribing to: freertos/demos/echo

At this point a developer should see MQTT messages arriving securely to their AWS.

Tips and tricks for using Amazon FreeRTOS

Getting up and running with FreeRTOS is simple and easy for even an entry level engineer. Despite its ease, there are several tips and tricks that developers should keep in mind when starting out with Amazon FreeRTOS. These include:

  • During the design phase, evaluate the cost that is associated with using AWS by reviewing the following webpage: https://aws.amazon.com/iot-device-management/pricing/
  • During development, use the 12 month free trial period for AWS to setup and configure the embedded product.
  • Start with a pre-configured example rather than trying to configure one from scratch.
  • If possible, order a fully assembled development kit that is designed to work out of the box with Amazon FreeRTOS.
  • Don’t forget that FreeRTOS is an open-source RTOS and is not safety certified.
  • Take the time to work through the AWS 10 Minute tutorials that will provide a great foundation for how to use AWS effectively.
  • Consider using Amazon FreeRTOS’s built-in over-the-air (OTA) update feature.

Conclusion

The capabilities that are built into Amazon FreeRTOS can provide a way for embedded developers to easily connect their systems to the Internet. Amazon FreeRTOS itself is free, and developers can easily get started by purchasing a low-cost development kit and walking through the existing examples to determine whether or not Amazon FreeRTOS meets their design needs.

Disclaimer: The opinions, beliefs, and viewpoints expressed by the various authors and/or forum participants on this website do not necessarily reflect the opinions, beliefs, and viewpoints of Digi-Key Electronics or official policies of Digi-Key Electronics.

About this author

Jacob Beningo

Jacob Beningo is an embedded software consultant who currently works with clients in more than a dozen countries to dramatically transform their businesses by improving product quality, cost and time to market. He has published more than 200 articles on embedded software development techniques, is a sought-after speaker and technical trainer and holds three degrees which include a Masters of Engineering from the University of Michigan. Feel free to contact him at jacob@beningo.com, at his website www.beningo.com, and sign-up for his monthly Embedded Bytes Newsletter.

About this publisher

Digi-Key's North American Editors