Filter results by

AWS IoT Embedded C SDK on ARTIK 05X

Using the AWS IoT Embedded C SDK on ARTIK 05x requires integration with Tizen RT. As the primary governing standards in Tizen RT are POSIX and ANSI standards, migrating 3rd party libraries to the OS is not complicated.


For the procedures described in this article, you'll need to set up a development environment on the host machine and cross compile Tizen RT source code with AWS IoT Embedded C SDK for the ARTIK 05x device.

Tizen RT requirements

The full Tizen RT source development environment is required (a procedure is not available using the ARTIK IDE/SDK at this time).

  • Follow the setup guide to install the Linux development environment and cross-compilation toolchain for ARTIK 05x devices.

  • Clone the latest Tizen RT tree to your Linux host machine.

    git clone

AWS requirements

To use the AWS IoT SDK on ARTIK Tizen RT modules, you need to have a basic understanding of AWS IoT. Refer to the AWS IoT device just-in-time registration (JITR) articles for an overview. We could use JITR here, but instead we'll keep it simple and let you register the device manually.

First, follow the introductory article to set up your AWS account and credentials.

Then, follow the AWS IoT Getting Started Guide to familiarize yourself with AWS IoT manual setup concepts:

  1. Sign in to the AWS IoT Console

  2. Register a Device in the Registry (here we show a Thing named ARTIK055s)

  3. Create and activate a Device Certificate. Download the certificate, private key and root CA for AWS, and save to your host machine. The AWS Root CA can be downloaded here.

  4. Create an AWS IoT Policy to specify what publish/subscribe rights your device will have

  5. Attach the policy to the device certificate

  6. Attach the certificate to your ARTIK055s Thing.

Getting Tizen RT, AWS IoT Device SDK sources

Download the file bundle for this tutorial.

A05X AWS IoT SDK bundle

Unzip the software bundle on your development system. You should find:

  • aws.tar.xz
  • aws_examples.tar.xz
  • certData.tar.xz
  • mbedtls_header.tar.xz
  • patch.tar.xz

In the Tizen RT source tree, you can find 3rd party libraries under the external directory, and example applications under apps/examples. You will need to move each of these tar files into the directory specified in the installation instructions that follow.

Prepare AWS IoT sample apps

cd ~/TizenRT/apps/examples

From the software bundle, copy the AWS IoT sample apps tar file, then extract the contents using

tar xvfz aws_examples.tar.gz

Prepare AWS IoT Embedded C SDK

We strongly suggest that you take advantage of the integration we have already done for you, especially if you don’t have time for the step-by-step integration. Otherwise, If you want to understand the nuts and bolts of Tizen RT integration, you can follow the full procedure.

To follow the shortcut approach:

  1. Copy over and untar the aws.tar.gz file in the directory noted.

    cd ~/TizenRT/external

    tar xvfz aws.tar.gz

    In aws.tar.gz, we already take care of configuring AWS and connecting the AWS sample app.

  2. Jump to Configure Dependencies.

  3. Continue with Configure Makefile, Kconfig

  4. When finished, jump directly to Configure Certificates and AWS IoT endpoints.

To perform the integration yourself:

  1. Check out AWS IoT Device SDK to the external directory.

    cd ~/TizenRT/external

    git clone

  2. Rename the AWS SDK folder to aws.

    mv aws-iot-device-sdk-embedded-C aws

  3. Proceed with all steps and sub-steps shown below.

Step 1: Configuring AWS IoT Embedded C SDK for TizenRT

Now, we will compile AWS IoT Embedded C SDK into libexternal.a

Copy over required Makefiles

  1. Rename the original SDK Makefile to a different name, and rename platform/linux and samples/linux directory to platform/TizenRT and samples/TizenRT. Under ~/TizenRT/external/, do the following.

    cd aws

    mv Makefile

    mv platform/linux platform/TizenRT

    mv samples/linux samples/TizenRT

  2. Install the patch. Start from the main directory.

    cd ~/TizenRT

  3. From the software bundle, copy the patch package, then extract the contents using

    tar xvfz patch.tar.gz

  4. Recursively copy over all the required Makefiles from the patch file to the SDK directory.

    cp –rp ./patch/external/aws/* ./TizenRT/external/aws/

Configure dependencies

The AWS IoT Device SDK requires mbedtls.

  1. Create external/include directory.

    cd ~/TizenRT/external
    mkdir include
    cd include

  2. From the software bundle, copy the mbedtls header tar file, then extract the contents using

    tar xvfz mbedtls_header.tar.gz

Configure external library Makefile, KConfig

The bold lines are required changes.

  1. In external/KConfig, search for the source "$EXTERNALDIR/sysview/Kconfig" block, and add the bold line before it. This will include AWS IoT Embedded C SDK configuration option into Tizen RT menuconfig.
    source “$EXTERNALDIR/aws/Kconfig”
    source “$EXTERNALDIR/sysview/Kconfig”
  2. In external/Makefile, add the bold lines below between lines in order to compile AWS IoT Embedded C SDK into Tizen RT.
    1. Look for ifeq ($(CONFIG_DM),y) and ifeq ($(CONFIG_SYSVIEW),y), and include the ifeq ($(CONFIG_AWS_SDK), y) block below in between.
      ifeq ($(CONFIG_DM),y)
      ifeq ($(CONFIG_AWS_SDK), y)
      include aws/Make.defs
      ifeq ($(CONFIG_SYSVIEW),y)
      include sysview/Make.defs
    2. Add the following lines right after the code above.
      # External Directories
      # BUILDIRS is the list of top-level directories containing 
      # Make.defs files
      BUILDIRS := $(dir $(wildcard */Make.defs))
      # CONFIGURED_EXT is the external directories that should be built
      # in the current configuration.
      define Add_EXTLIB
        include $(1)Make.defs
      $(foreach BDIR, $(BUILDIRS), $(eval $(call Add_EXTLIB,$(BDIR))))
      define SDIR_template
        $(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" EXTDIR="$(EXTDIR)"
      $(foreach SDIR, $(CONFIGURED_EXT), $(eval $(call SDIR_template,$(SDIR),all)))
      $(foreach SDIR, $(CONFIGURED_EXT), $(eval $(call SDIR_template,$(SDIR),depend)))
      $(foreach SDIR, $(BUILDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
      $(foreach SDIR, $(BUILDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))
    3. Look for the part that generates the final $(BIN) , and add the bold part below. This will include AWS SDK into the libexternal.a.

      $(BIN): $(OBJ) $(foreach SDIR, $(CONFIGURED_EXT), $(SDIR)_all) iotivity_build
        $(call ARCHIVE, $@, $(OBJS))
    4. Look for the part that cleans the binaries, and add the bold lines below.
      ifeq ($(CONFIG_ARTIK_SDK),y)
        $(Q) $(MAKE) -C artik-sdk clean
      ifeq ($(CONFIG_AWS_SDK), y)
        $(Q) echo "Cleaning AWS IoT Device SDK"
        $(Q) rm -f $(TOPDIR)/../external/aws/*.o
        $(foreach OBJFILE, $(OBJS), rm -f $(OBJFILE))
      clean: custom_clean iotivity_clean artiksdk_clean 
        $(call DELFILE, $(BIN))
        $(call CLEAN, $(OBJS))
        $(call CLEAN)
    If you configured your AWS SDK by using the aws.tar.gz we provided, you don’t need to go through the steps below. **Jump to step 4 directly.**
  3. Add the newly added mbedtls header file path external/include/ to the Makefile.
    CFLAGS += -Iinclude
    CFLAGS += -I../include
    CFLAGS += -Iexternal_libs/jsmn
    CFLAGS += -I$(AWS_PLATFORM_DIR)/common

Step 2. Connect AWS IoT sample app to AWS SDK library

The AWS sample apps under ~/TizenRT/apps/examples/aws directory actually link to the sample apps under ~/TizenRT/external/aws/samples.

We need to make few changes to the source code, all under external/aws/samples/TizenRT/

  1. In shadow_sample/shadow_sample.c
     int main(int argc, char argv)
    int aws_shadow(int argc, argv)

  2. In shadow_sample_console_echo/shadow_console_echo.c
     int main(int argc, char argv)
    int aws_shadow_console_echo(int argc, char argv)

  3. In subscribe_publish_library_sample/

     int main(int argc, char argv)
    int aws_subscribe_publish_library(int argc, char argv)

  4. In subscribe_publish_sample/subscribe_publish_sample.c
     int main(int argc, char argv)
    int aws_subscribe_publish(int argc, char argv)

Step 3. Prepare for compilation

Again, all listed changes are under external/aws/samples/TizenRT/

  1. In mbedtls/network_mbedtls_wrapper.c, add the line indicated.
    #include "aws_iot_error.h"
    #include "aws_iot_log.h"
    #include "network_interface.h"
    #include "network_platform.h"
    #include “certData.c”
  2. In the iot_tls_connect() function, make the following changes to match the function signature.
    1. Search for IOT_DEBUG(" . Loading the CA root certificate ..."); In the line below, replace
      ret = mbedtls_x509_crt_parse_file(&(tlsDataParams->cacert), pNetwork->tlsConnectParams.pRootCALocation);
      ret = mbedtls_x509_crt_parse(&(tlsDataParams->cacert), root_ca_pem, rootCaLen);
    2. Moving down a few lines, and look for
      IOT_DEBUG(" . Loading the client cert. and key...");
      In the line below, replace
      ret = mbedtls_x509_crt_parse_file(&(tlsDataParams->clicert), pNetwork->tlsConnectParams.pDeviceCertLocation);
      ret = mbedtls_x509_crt_parse(&(tlsDataParams->clicert), client_cert_pem, clientCertLen);
    3. Then look beneath it, and replace
      ret = mbedtls_pk_parse_keyfile(&(tlsDataParams->pkey), pNetwork->tlsConnectParams.pDevicePrivateKeyLocation, "");
      ret = mbedtls_pk_parse_key(&(tlsDataParams->pkey), client_private_key_pem, clientPrivateKeyLen, NULL, 0);
  3. In common/timer_platform.h, add the bold lines below.
    * definition of the Timer struct. Platform specific
    struct Timer {
      struct timeval end_time;
    /* Convenience macros for operations on timevals.
    * NOTE: \`timercmp' does not work for >= or <=. */
    #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
    #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
    #define timercmp(a, b, CMP) 
      (((a)->tv_sec == (b)->tv_sec) ? 
       ((a)->tv_usec CMP (b)->tv_usec) : 
       ((a)->tv_sec CMP (b)->tv_sec))
    #define timeradd(a, b, result) 
      do { 
          (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; 
          (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; 
          if ((result)->tv_usec >= 1000000) 
              (result)->tv_usec -= 1000000; 
      } while (0)
    #define timersub(a, b, result) 
      do { 
          (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; 
          (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; 
          if ((result)->tv_usec < 0) { 
             (result)->tv_usec += 1000000; 
      } while (0)
  4. In subscribe_publish_sample/aws_iot_config.h, look for
    #define DISABLE_METRICS false
    change it to
    #define DISABLE_METRICS 0

Step 4. Configure certificates and AWS IoT endpoints


From the software bundle, copy the certData.tar.gz file to the directory indicated and untar it.

cd ~/TizenRT/external/aws/certs/

tar xvfz certData.tar.gz

Configuring certificates

Open certData.c and follow the comments to copy the whole lines in the root CA certificate file (downloadable here), cert.pem, and privateKey.pem, and paste the lines in string format to arrays root_ca_pem, client_cert_pem and client_private_key_pem respectively.

Here is an example, using root_ca_pem, of how these arrays should look once formatted in your code – append \r\n to each line and enclose the line in quotes.

const unsigned char root_ca_pem[] =
"-----BEGIN CERTIFICATE-----\r\n"
"-----END CERTIFICATE-----\r\n";

Configuring endpoint and device name

In this tutorial, we will explore the subscribe_publish_sample application; the same configuration is required if you want to explore other sample apps.

Go to the AWS IoT Console and select Settings from the left pane to find the custom REST API endpoint for your device.

Navigate to the ~/TizenRT/external/aws/samples/TizenRT/subscribe_publish_sample directory and change configurations in aws_iot_config.h.

AWS_IOT_MQTT_HOST should be defined as your Rest API Endpoint.

AWS_IOT_MQTT_CLIENT_ID should be unique for every device. Here, we are using “ARTIK055s_1” as an example.

AWS_IOT_MY_THING_NAME is the Thing we defined, ARTIK055s.

#define AWS_IOT_MQTT_HOST "" ///< Customer specific MQTT HOST. The same is used for Thing Shadow

#define AWS_IOT_MQTT_PORT 443 ///< default port for MQTT/S



Building Tizen RT Image

To compile and load images to ARTIK 05x, refer to the tutorial.

Configure ARTIK055s build

cd ~/TizenRT/os

./ artik055s/extra

Configure menuconfig,

make menuconfig

Go to External Libraries by moving your cursor, enable “AWS IoT SDK”.

Exit this configuration page and from the main menu, go to Application Configuration->Examples-> enable “AWS demo application”

Exit menuconfig.

Build Tizen RT image and re-flash the device


make download ALL

Connecting ARTIK 05x to AWS IoT

Configure WiFi on ARTIK055s

Restart 055s, and configure Wi-Fi by following the Manually Set Up Wi-Fi section.

Configure device time

From TASH, configure your date to make sure it matches UTC time. This step is required; otherwise, the AWS server certificate cannot be verified.

TASH >> date –s Aug 12 12:00:05 2018

Alternatively, you can configure NTP settings programmatically. Refer to main.c in the MQTT article for an implementation reference.

Test AWS IoT integration

From TASH, you should be able to see a Tizen RT application aws_sample.

TASH>> aws_sample

usage : aws_sample <example_no>
ex) aws_sample 4 ==> runs aws_susbcribe_publish
1. aws_shadow
2. aws_shadow_console_echo
3. aws_subscribe_publish_library
4. aws_subscribe_publish

Launch the application with option 4, which invokes the subscribe_publish_sample app we configured earlier.

aws_sample 4

AWS IoT SDK Version 3.0.1-




Subscribe callback

sdkTest/subhello from SDK QOS0 : 0 hello from SDK QOS0 : 0

Subscribe callback

sdkTest/subhello from SDK QOS1 : 1 hello from SDK QOS1 : 1


Subscribe callback

sdkTest/subhello from SDK QOS0 : 2 hello from SDK QOS0 : 2

Subscribe callback

sdkTest/subhello from SDK QOS1 : 3 hello from SDK QOS1 : 3


Subscribe callback

Last updated on: