AWS Open Source Blog
How being open led to greater customer value with the AWS IoT Device SDK for Embedded C
The AWS IoT Device SDK for Embedded C (C-SDK) is composed of a set of MIT-licensed libraries that demonstrate simplified, lightweight, and secure connectivity to AWS IoT Core and device-side operations to AWS IoT services. The AWS IoT C-SDK can work on a variety of operating systems, such as Linux, macOS, and Windows, or a real-time operating system (RTOS), such as FreeRTOS. In this post, you’ll learn how adopting and collaborating with leading open source projects helped developers make the AWS IoT C-SDK more trustworthy and flexible, while increasing ease of use.
In early 2015, the AWS IoT C-SDK was released under the Apache-2.0 license and coincided with the beta launch of AWS IoT Core. Apache-2.0 requires that if there are any modifications to the code, changes are listed. This posed a potential barrier for some AWS customers and partners who port the AWS IoT C-SDK to work with their specific hardware and software stack. After the embedded community’s positive feedback to releasing the popular FreeRTOS kernel with an MIT license in November 2017, and its preference to have similar licensing up the stack, the AWS IoT C-SDK shifted to an MIT license in January 2019.
The FreeRTOS kernel is popular real-time operating system (RTOS) used on microcontrollers and small microprocessors around the world. The FreeRTOS project includes the kernel and additional libraries for connectivity, security, operations with AWS IoT services, and more. With a permissive license across libraries, highly optimized for performance and low memory footprint, and a thriving community of users and contributors, FreeRTOS is a great model for an open source embedded project like the AWS IoT C-SDK. To simplify the experience and bring the communities together, in late 2020 the AWS IoT C-SDK shifted to git submoduling the FreeRTOS libraries for connectivity, security, and AWS IoT services. The AWS IoT C-SDK includes demos using those libraries that are ported to work with Linux systems with OpenSSL version >1.1.0.
Collaboratively raising the quality development bar
As a result of combining resources, the number of commits to the AWS IoT C-SDK grew at an accelerated pace. Customers can use the submodules as a single source of truth for each library to centralize where to track patches, file issues, or submit pull requests. AWS IoT C-SDK customers can lean on the discourse in the FreeRTOS Community Forums for support and ideas related to the libraries. Additionally, partners and customers contribute to the development to reach a higher-quality bar and richer set of features before an official release is pushed.
The FreeRTOS libraries used in the AWS IoT C-SDK are MISRA compliant, and use an automated reasoning technique to ensure memory safety. The result of applying the best practices required for MISRA compliance is that the code is easily readable, easier to debug and maintain, and ensures a level of safety, security, and reliability by a third party. The usage of automated reasoning techniques involves creating models (mathematical proofs) to confirm the absence of important security issues (for example, buffer overflows). These proofs are tested against the code base using a software model checker called C Bounded Model Checker (CBMC). By passing these tests, projects using the libraries have validated assurance of code quality and security for all possible execution paths—not just limited to the coverage of available unit tests.
Increasing flexibility and removing dependencies
In addition to those benefits inherited by the AWS IoT C-SDK from using the FreeRTOS libraries, the libraries themselves do not have other dependencies, and they are highly efficient for use in even small microcontrollers. All of the libraries in the AWS IoT C-SDK use approximately 53KB of statically allocated memory. You can review the CMakeLists.txt files used by the CMake build system to link necessary dependencies and files before compiling. As an example, to use the AWS IoT Device Shadow demo, you can start by reviewing the specific lines of the CMakeLists.txt located at the root of the project to see the requirements of the entire project before diving in to the requirements of the individual demos.
The only dependency listed here is a flag for CMake to use the standard C libraries of C90. The platform folder includes porting files to work on Linux (POSIX) systems—a clue that the shared libraries are not dependent on the FreeRTOS kernel. The individual demos will specify exactly which libraries that demo requires. An example is the AWS IoT Device Shadow library demo’s CMakeLists.txt:
As shown in the contents of the file, to run the shadow demo, it uses coreMQTT for the MQTT client, the exponential backoff algorithm library to manage the connection retry rate, coreJSON to parse the incoming JSON messages, and the AWS IoT Device Shadow library to perform device shadow state operations. Additionally, it’s using OpenSSL and the POSIX clock for establishing TLS; otherwise, the entire demo is only dependent on the standard C library.
The dependencies for the shadows demo and other demos are only for the included demos. The libraries themselves do not have any dependencies to each other—only the standard C library. As an example, you could use the AWS IoT Device Shadow library with your own MQTT client, your own JSON parser, or backoff algorithm through the library’s configuration file. This level of compossibility lets you choose the libraries that you might need or prefer. Watch a demonstration of the compossibility of the coreMQTT library on YouTube.
Collaborating with other open source projects
For our silicon partners who have been part of the FreeRTOS ecosystem for more than 15 years, the familiarity of the shared libraries, decoupling of interdependencies, and MIT licensing has enabled them to port the AWS IoT C-SDK to their hardware platforms or incorporate the software into their tools with reduced effort. For customers, this means that the AWS IoT C-SDK works and fits into their platform development workflow out of the box or with minimal modification.
The AWS IoT C-SDK is able to demonstrate connectivity to AWS IoT Core and perform device-side operations to AWS IoT services with secure, simple, and lightweight libraries. The benefits of adopting increased open source values, collaborating with other leading projects, incorporating best practices, removing dependencies, and adding third-party validation all comes together to create software that is secure, feature rich, and compossible to your needs. The AWS IoT C-SDK brings those benefits to a wide set of device types and enables a broad set of connected use cases. Using trustworthy, open source software makes deploying devices at scale easier, making it possible for billions of connected devices to deliver experiences that we have yet to imagine.