AWS IoT MSP432E4 Quick Start Guide
Table of Contents
Introduction
This guide is intended to assist users in the initial setup and demonstration of a MSP432E4 AWS IoT application using the MSP432E4 Plugin for AWS. The guide explains how to configure the boards, compile the software artifacts, program the MSP432E4 device, set up your AWS account and run an AWS application.
Hardware Requirements
Software Requirements
- TI SimpleLink MSP432E4 Software Development Kit (SDK), v2.40.00.11 or compatible
- A computer running a supported operating system listed in the Release Notes
- At least one of the following IDEs supported by the SimpleLink MSP432E4 SDK:
- FreeRTOSv10.0.0 (Optional)
- If the User wants to use FreeRTOS with the SDK, the user is expected to download the FreeRTOS sources from www.freertos.org
- Please refer to the SimpleLink MSP432E4 SDK documentation for more information about setting up FreeRTOS
Setup
It is assumed that the MSP432E4 SDK has already been installed in a directory we will refer to as MSP432E4_SDK_INSTALL_DIR.
Installing MSP432E4 Plugin for AWS IoT in CCS
- Download and open the MSP432E4 Plugin for AWS Installer (replace x’s with version number):
- Windows: aws_msp432e4_2_20_xx_xx.exe
- Linux: aws_msp432e4_2_20_xx_xx.run
- Note: If you have downloaded a zip file of the Plugin, then you should simply unzip it using your favorite unzip tool. The location you choose to unzip it to will be the installation directory (
AWS_INSTALL_DIR).
Select an installation directory. This will be referred to as
AWS_INSTALL_DIRin the rest of this document. It’s recommended that you install it in your CCS installation directory (default c:/ti) so it can be discovered automatically.Click Next > and finish the installation
Open CCS (close and re-open if already running) and you should see the Install Discovered Products window
Select the MSP432E4 Plugin for AWS and click Install
Hardware Setup
This example does not require special jumpers settings. Please refer to the SimpleLink MSP432E4 SDK documentation for more information if desired.
An Ethernet cable should be connected to the Ethernet port on the LaunchPad to provide it with Internet access.
Setting up a serial terminal
Plug the MSP432E4 Launchpad into a USB port on your PC.
Open a serial session to the appropriate COM port with the following settings:
Baudrate: 115200 Data bits: 8 Stop bits: 1 Parity: None Flow Control: NoneThe output of the examples will be displayed in the terminal.
AWS IoT Developer Setup
In order to run the example applications, it is necessary to complete the steps of the AWS IoT Developer Guide. In particular, the following steps of the guide must be completed:
- Create and Activate a Device Certificate
- Make sure you choose to download the certificate files, as these will be needed when setting up the examples.
- Note: you will also need a root CA certificate. You can download the root CA from here.
Note that Amazon has recently tailored the AWS IoT Developer Guide instructions specifically for the “AWS IoT Button.” You can ignore the mentions of the button, as your TI embedded device will be used in place of this. For more details on AWS IoT, please refer to the What Is AWS IoT page.
Building and running Examples in CCS
Several examples are provided in the MSP432E4 Plugin and can be found in the examples/ subdirectory. These steps refer to the subscribe_publish_sample application for the MSP432E4 device, but the same procedure applies to other examples, as well.
It is assumed that the MSP432E4 SDK has already been installed in a directory we will refer to as
MSP432E4_SDK_INSTALL_DIR. You should install it if you have not already done so, as the MSP432E4 Plugin for AWS depends on the MSP432E4 SDK.Open Code Composer Studio.
In CCS, import the
subscribe_publish_sampleby first selecting File > Import…In the Import window, select C/C++ > CCS Projects and hit the Next button
In the Import CCS Eclipse Projects window, hit the browse button to browse to the location corresponding to
AWS_INSTALL_DIR\examples\rtos\MSP_EXP432E401Y\aws\subscribe_publish_sample. Select the checkbox next to thesubscribe_publish_samplefor TIRTOS (or FreeRTOS) for CCS (or GCC) and hit the Finish button.
Two projects should appear in the Project Explorer tab in CCS: one for the
subscribe_publish_sampleexample itself, and another which corresponds to the OS chosen.Update the example to use the proper certificates and AWS account, as specified in the section Example Pre-Build Steps
- If TIRTOS is your OS, you can simply right-click on the
subscribe_publish_sampleproject, and select Build Project to build.
- If you are using FreeRTOS for your OS, you need to set the installation directory of FreeRTOS in both projects before building:
- In CCS, select Window > Preferences
- Navigate to Code Composer Studio > Build > Variables
- Click Add
- For Variable name, enter
FREERTOS_INSTALL_DIR - For Type, select directory
- For Value, enter the installation directory of FreeRTOS
- Hit OK until you get back to the main window in CCS
- To build the
subscribe_publish_sampleproject, right-click on it, and select Build Project.
Setting Up Code Composer Studio Before Running The Examples
In Code Composer Studio, open the CCS Debug Perspective - Windows menu > Open Perspective > CCS Debug
Open the Target Configurations View - Windows menu > Show View > Target Configurations
Right-click on User Defined. Select New Target Configuration.
Use
MSP432E4.ccxmlas “File name”. Hit Finish.In the Basic window, select “Texas Instruments XDS110 USB Debug Probe” as the “Connection”, and then type
MSP432E401Yin the “Board or Device” text field. Check the box next to “MSP432E401Y”. Hit Save.Right-click “MSP432E4.ccxml” in the Target Configurations View. Hit Launch Selected Configuration.
Under the Debug View, right-click on “Texas Instruments XDS110 USB Debug Probe_0/Cortex_M4_0”. Select “Connect Target”.
Running an Example in CCS
Ensure that your MSP432E4 device is connected in CCS.
Select Run > Load > Load Program…, and browse to the file
subscribe_publish_sample_MSP_EXP432E401Y_tirtos_ccs.out, found in your project. Hit OK. This will load the program onto the board. (The same procedure applies to other examples by substitutingsubscribe_publish_samplewith the name of the example you are working with)Run the application by pressing F8. The output will appear in your serial terminal session:
Service Status: DHCPC : Enabled : : 000 Service Status: DHCPC : Enabled : Running : 000 Network Added: If-1:192.168.1.109 Service Status: DHCPC : Enabled : Running : 017 startSNTP: Current time: Tue Aug 7 19:05:49 2018 AWS IoT SDK Version 3.0.1- Connecting... Subscribing... -->sleep Subscribe callback sdkTest/sub hello from SDK QOS0 : 0 Subscribe callback sdkTest/sub hello from SDK QOS1 : 1 -->sleep
Building and running Examples in IAR
Download and Installation of IAR
For instructions on downloading and setting up IAR properly for use with the MSP432E4 SDK, please refer to the Quick Start Guide document that is included in the SimpleLink MSP432E4 SDK. As part of the procedure, make sure to import the custom argvars for the SDK.
Configuring the IAR environmental variables for the AWS IoT Plugin
Before starting to work with any of the AWS IoT example projects, you need to load a set of environment variables that will be set to your current workspace (custom argvars), in addition to the ones from the SDK.
The custom argvars can be found at
<AWS_INSTALL_DIR>/tools/iar/AWS_MSP432E4_SDK.custom_argvars. If you need to modify the default path for the plugin’s installation directory, edit the variableAWS_MSP432E4_INSTALL_DIRin the file to correct the paths.
Open the IAR IDE
Choose Tools > Configure Custom Argument Variables
Click Global > Import
Browse to
<AWS_INSTALL_DIR>/tools/iar. Import the custom argvars from the Plugin.Restart IAR
Importing your First Project
All Code Examples that are shipped with the plugin under the examples directory come with an IAR workspace. Double-Clicking the specific workspace (e.g. subscribe_publish_sample.eww) from the file manager allows you to open the project on disk and build it.
Start a debug session
Select Project > options from the menu, and select the Debugger category.
By default, the project Debug settings are configured for the TI XDS110, but the user may change them as needed.
Go to the TI XDS Category, the settings should be TI XDS110 Emulator as the emulator, and SWD as the interface
You can override the path for code composer studio base according to the code composer installation path.
Load and run the Example
Select Project > Download and Debug
Click the
Gobutton in IAR to run the ExampleThe Example output is displayed in the serial terminal, as shown here.
Building with makefiles
To build the subscribe_publish_sample application on the command-line using the provided makefile:
Update the
imports.makfile in the<AWS_INSTALL_DIR>root folder with the appropriate paths. This file relies on the settings in theimports.makfile of the MSP432E4 SDK, so please ensure you have updated the latter with the appropriate paths as well if you have not done so previously.Navigate to the OS directory corresponding to your OS and toolchain of choice. For example,
<MSP432E4_SDK_INSTALL_DIR>/kernel/tirtos/builds/MSP_EXP432E401Y/release/ccsfor TI-RTOS and TI compiler.Run ‘make’ to build the OS. If you develop on a Windows machine and do not have the ‘make’ utility, you can alternatively run ‘gmake’ from your TI XDCTOOLS installation (e.g. ‘C:\ti\xdctools_3_51_00_15_core\gmake.exe’). Normally XDCTOOLS are installed along with the MSP432E4 SDK, but if you need to download it, it is available here
Navigate to the example folder specific to your OS and toolchain
<AWS_INSTALL_DIR>/examples/rtos/MSP_EXP432E401Y/aws/subscribe_publish_sample/tirtos/ccsTo build, run ‘make’ to generate
subscribe_publish_sample.outYou can load and debug the generated
subscribe_publish_sample.outin CCSThe Example output is displayed in the serial terminal, as shown here.
Example Pre-Build Steps
The steps in this section are common to CCS, IAR and command line environments.
Before building a specific application, you must complete the following steps in order to successfully connect to AWS (these steps refer to the subscribe_publish_sample application, but the same procedure applies to other examples as well):
Update the AWS configuration file
If you are using Windows, open a Windows command prompt. If you are using Linux, open a terminal window.
Use the following AWS CLI command to to retrieve your AWS account-specific AWS IoT endpoint:
aws iot describe-endpointIn a text editor, open the
aws_iot_config.hfile, found in thesubscribe_publish_sampleproject.Update the value of the macro “AWS_IOT_MQTT_HOST” with string output from this command (for example, it will have a format similar to the following:
<random-string>.iot.us-east-1.amazonaws.com)Update the value of the macro “AWS_IOT_MQTT_CLIENT_ID” to a unique name for your device
Update the value of the macro “AWS_IOT_MY_THING_NAME” with the name of the thing you created during the steps on the Register a Device in the Thing Registry web page
The certificate file variables “AWS_IOT_ROOT_CA_FILENAME”, “AWS_IOT_CERTIFICATE_FILENAME”, and “AWS_IOT_PRIVATE_KEY_FILENAME” can be updated to specify the location to where the files should be written in flash on the device. You can use the default values, if desired.
Update the Example to use the certificates
The certificate files used by the examples need to be obtained from the AWS CLI tool and/or the AWS IoT website directly. If you have not already done so, follow Amazon’s steps to get the certificates for your device.
Open the file
certs.h, found in thesubscribe_publish_sampleproject.Search for “USER STEP” and update the CA root certificate string, the client certificate string, and the client (private) key string. These should be extracted from certificate (.pem) files downloaded from AWS. Each line of the certificate must be updated to end with the character sequence
\r\n. A typical string would be similar to the following (example) format. Be sure to update the array using the contents of your actual root CA:unsigned char root_ca_pem[] = "-----BEGIN CERTIFICATE-----\r\n" "ABCD1234hxS39SFVT43STY#fdsiEIOFiu2=y!8cZxzXMh+12wDCy21h+8vJsDh4\r\n" <...> "rzcuMZt6oPq6YJMtP3kSaik+bWyzRkdMOPGVL4TiPLAuyAZP1NXl\r\n"; "-----END CERTIFICATE-----";