FreeRTOS versus the AWS IoT Device SDK for Embedded C (C-SDK)

5 minute read
Content level: Advanced
1

Are you building a resource-constrained device that will connect to AWS IoT Core? Maybe you’re aware of FreeRTOS and the AWS IoT Device SDK for Embedded C (C-SDK), but you’re unclear what each is for. Perhaps you want to use a real-time operating system (RTOS) other than FreeRTOS, or no RTOS at all. This article explains how FreeRTOS and the C-SDK are similar, and how they’re different, helping you to pick the right option for your device.

Introduction

FreeRTOS and the AWS IoT Device SDK for Embedded C (C-SDK) are the primary AWS IoT device software options when building a resource-constrained device that will connect to AWS IoT Core using MQTT. FreeRTOS consists of a kernel and a set of IoT libraries. As will be shown in this article, these IoT libraries include all of the C-SDK libraries, meaning that FreeRTOS essentially contains the C-SDK. If you wish to build your device with a different real-time operating system (RTOS), or you want to build a bare metal device, you should probably use the C-SDK.

What's in the C-SDK?

The AWS IoT Device SDK for Embedded C (C-SDK) repository uses Git submodules to include the following feature libraries:

These eleven libraries are lean and highly-portable C code, with no dependencies on FreeRTOS or on any other operating system. The backoffAlgorithm, coreHTTP, coreJSON, coreMQTT and corePKCS11 libraries are located in the FreeRTOS organization on GitHub despite having no FreeRTOS dependencies.

As shown in Figure 1, the C-SDK groups these libraries as Git submodules in two categories:

  1. AWS libraries that implement AWS-specific features such as AWS IoT Device Shadows, AWS IoT Jobs, AWS IoT Over the Air (OTA) updates, AWS IoT Device Defender and AWS IoT fleet provisioning.
  2. Standard libraries that implement functionality that could be useful even when not connecting to AWS IoT services. For instance, the coreMQTT library has no dependencies on AWS IoT Core and could be used as a general MQTT client with many different MQTT brokers.

Figure 1: C-SDK libraries

Figure 1: C-SDK libraries

The source code that’s committed into the C-SDK repository itself is essentially a collection of demos of these feature libraries. These demos are designed to be built and run on your development machine, not on your embedded target. Consequently, they’re mainly built with OpenSSL, rather than an embedded TLS stack like mbedTLS. You should build and run these demos if you need to explore the capabilities of the individual feature libraries.

C-SDK releases are delivered as source code of the feature libraries. You can compose your device firmware by simply importing these source files into your project, and building your application on top of them. You’re free to pick and choose only those libraries and features that you’ll actually use in your device. At a minimum, your device should include coreMQTT, coreJSON and backoffAlgorithm to achieve robust MQTT connection, along with message publish and subscribe.

What's in FreeRTOS?

As can be seen in Figure 2, the FreeRTOS repository likewise uses Git submodules to include the same collection of feature libraries as the C-SDK.

Figure 2: FreeRTOS and C-SDK common libraries

In this regard, FreeRTOS could be thought of as a superset of the C-SDK, supplementing it with many other optional libraries, but also supplementing it with the FreeRTOS kernel itself. Unlike the libraries shared with the C-SDK, these supplemental FreeRTOS libraries do have dependencies on FreeRTOS, and these libraries could be the the differentiating factor in your decision between FreeRTOS and the C-SDK. These supplemental libraries include the FreeRTOS-Plus libraries, the FreeRTOS-Labs libraries, the FreeRTOS Cellular Interface library, coreSNTP, the CoreMQTT Agent, and more.

The FreeRTOS repository includes demos of the kernel for many micro-controllers, but also includes demos of the feature libraries. Like the C-SDK demos, these feature library demos are not intended to be run on your embedded target, but rather on your development host. However the FreeRTOS GitHub organization includes reference integrations demonstrating the kernel and libraries ported to partner hardware. These reference integrations are likely a valuable resource for your project.

What's in FreeRTOS-LTS?

FreeRTOS long term support (LTS) releases are FreeRTOS releases that receive security updates and critical bug fixes for at least two years following their release. This enables you to consume maintenance updates into your product without the disruption of having to update the major version of your FreeRTOS libraries.

The FreeRTOS GitHub organization includes a FreeRTOS-LTS repository that holds all of the FreeRTOS-LTS releases.

Not all of the libraries in the FreeRTOS repository are included in LTS releases. As shown in Figure 3, FreeRTOS 202210.01-LTS contains the eleven feature libraries that FreeRTOS shares with the C-SDK, supplemented by 4 other libraries: the FreeRTOS Kernel, the FreeRTOS Plus TCP stack, the FreeRTOS Cellular Interface and coreSNTP.

FreeRTOSv202210.01-LTS
└── FreeRTOS-LTS
    ├── aws
    │   ├── device-defender-for-aws-iot-embedded-sdk
    │   ├── device-shadow-for-aws-iot-embedded-sdk
    │   ├── fleet-provisioning-for-aws-iot-embedded-sdk
    │   ├── jobs-for-aws-iot-embedded-sdk
    │   ├── ota-for-aws-iot-embedded-sdk
    │   └── sigv4-for-aws-iot-embedded-sdk
    ├── CHANGELOG.md
    ├── CODE_OF_CONDUCT.md
    ├── CONTRIBUTING.md
    ├── FreeRTOS
    │   ├── backoffAlgorithm
    │   ├── coreHTTP
    │   ├── coreJSON
    │   ├── coreMQTT
    │   ├── corePKCS11
    │   ├── coreSNTP
    │   ├── FreeRTOS-Cellular-Interface
    │   ├── FreeRTOS-Kernel
    │   └── FreeRTOS-Plus-TCP
    ├── LICENSE.md
    ├── manifest.yml
    └── README.md

Figure 3: FreeRTOSv202210.01-LTS release contents

It may not be immediately apparent from the FreeRTOS-LTS name, but if you wish to use just the C-SDK in your product, you can still benefit from FreeRTOS LTS. You can simply not use the 4 libraries that have FreeRTOS dependencies, and instead only select from the eleven libraries that are shared with the C-SDK.

Related questions

profile pictureAWS
EXPERT
Greg_B
published 6 months ago855 views