STM32L4 Amazon FreeRTOS Hands-on Workshop
File info: application/pdf · 77 pages · 3.90MB
STM32L4 Amazon FreeRTOS Hands-on Workshop
STM32L4 Discovery Kit IoT Node 7 •STM32L4 MCU enables your IoT projects with the combination of ultra-low power and high performance •STM32L4 Discovery Kit IoT is a compact, yet powerful board to explore
STM32L4 Discovery Kit IoT Node 7 •STM32L4 MCU enables your IoT projects with the combination of ultra-low power and high performance •STM32L4 Discovery Kit …
Full PDF Document
If the inline viewer fails, it will open the original document in compatibility mode automatically. You can also open the file directly.
Extracted Text
STM32L4 Amazon FreeRTOS Hands-OnTraining: Simplifying AWS IoT Cloud Platform Connectivity for Embedded Devices
Ernesto Manuel Cantone, STMicroelectronics Daniel Griffin, STMicroelectronics Anton Shmagin, Amazon Web Services Scott Francis, Amazon Web Services
� Introduction � Training Material and installation needs � Connect to Amazon Workspaces � Create your Device ("Thing") on AWS � Compile "Hello World" demo project � Connect to AWS IoT & Send Data � Compile Sensors demo project � Send sensors data to the AWS IoT � Store and transform data in AWS ....
Agenda 2
ST Has all the Building Blocks for the IoT 3
"Thing" you know how to build. Plus what "Smart"? Pieces from different sources and and no building instructions... ...or
Connect Sense Translate Move Actuate Power Secure Process
Supporting the IoT Movement 4
Pre-integrated SW for vertical applications
Development Ecosystem
STM32L475 Discovery Kit IoT Node 5 B-L475E-IOT01A
SW Libraries for STM32L4 MCU & Sensors Low-power long-range communication (SubGHz) Direct Wi-Fi connection to cloud servers Environmental awareness: humidity, pressure, temp Detection hub: motion, proximity, audio
Workshop Deliverables 6
� For the workshop ST will provide
Discovery Kit IoT node
https://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-mpu-evaltools/stm32-mcu-mpu-eval-tools/stm32-discovery-kits/b-l475e-iot01a.html
USB 2.0 A-Male to Micro B Cable
STM32L4 Discovery Kit IoT Node 7
� STM32L4 MCU enables your IoT projects with the combination of ultralow power and high performance
� STM32L4 Discovery Kit IoT is a compact, yet powerful board to explore various connectivity options
� Next Steps
� You can add BLE, NFC and sensors features to the Amazon FreeRTOS project to create an application that can connect to the cloud and also has short range connectivity with your smartphone
� Post your projects or ideas on the ST Community website to gather feedback and get support: https://community.st.com/community/share-your-activities/pages/overview
� Refer to Amazon FreeRTOS user guide for more examples.
Lab Deliverables 8
Training Material on AWS S3 Bucket (USB Key Backup)
Navigate to: https://sttt.signin.aws.amazon.com/console with credentials distributed to you In Find Services search box type "S3" Under sttechnologytour\1_tools you'll find
.\MacOS\WorkSpaces.pkg .\Windows\teraterm-4.102.exe .\Windows\Amazon+WorkSpaces.msi .\Windows\7\en.stsw-link009.zip .\en.stm32cubeprog.zip .\This presentation
Install WorkSpaces.pkg
Install Amazon+Workspaces.msi Unzip en.stsw-link009.zip and run dpinst_amd64.exe (W7 Only)
No Client available for Linux (Web Browser)
Amazon Web Services
IoT on AWS
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
If you knew the state of everything and could reason on top of that data... what problems would you solve?
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What customers are doing with AWS IoT
Predictive maintenance
Wellness & health solutions
Remote patient monitor
Connected buildings & city systems
Maintain device fleets
Monitor energy efficiency
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
IoT payment &
Safeguard manufacturing
connected commerce
facilities
Nobody just buys IoT technology... they seek business outcomes
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Business outcomes with IoT
New services & business models
Products that get better with time
Better relationship with customers
Increased efficiency
Intelligent decision making
Data driven discipline
Revenue growth
IoT data drives business growth
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Operational efficiency
IoT data decreases OpEx
IoT solutions are complex & multidimensional
Devices & sensors
Onboard, provision, manage
Connectivity & infrastructure
Connect, communicate,
secure
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Analytics & insights
Analyze, visualize,
act
Applications & services
Engage, empower,
delight
Change management
Transform, shift culture
Our concept of IoT
Things Sense & Act
Cloud Storage & Compute
Intelligence Insights & Logic Action
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Things Sense & Act
AWS IoT Architecture
Secure device connectivity and messaging
Cloud Storage & Compute
Intelligence Insights & Logic Action
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Things Sense & Act
Endpoints
Secure local triggers, actions,
and data sync
Gateway
AWS IoT Architecture
Cloud Storage & Compute
Secure device connectivity and messaging
Fleet onboarding, management and
SW updates
Fleet audit and protection
IoT data analytics and intelligence
Intelligence Insights & Logic Action
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS IoT Core
Secure Device Connectivity and Messaging
Identity Service
Device Gateway
Message Broker
Rules Engine
Device Shadow
Registry
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How can I extend AWS cloud capabilities to the edge?
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Greengrass
Extend AWS IoT to the Edge
AWS Greengrass extends AWS IoT onto your devices, so that they can act locally on the data they generate, while still taking advantage of the cloud.
Edge
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Law of Physics Law of Economics Law of the Land
Cloud
AWS Greengrass
Extend AWS IoT to the Edge
A
Local Messages and Triggers
Local Message Broker
Local Actions
Lambda Functions
Data and State Sync
Local Device Shadows
Security
AWS-grade security
Local Resource
Access
Lambdas Interact With Peripherals
Machine Learning Inference
Protocol Over the Adapters Air Updates
Local Execution of ML Models
Easy Integrations With Local Protocols
Easily Update Greengrass Core
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How can I
securely connect
constrained, microcontroller-
?
based devices?
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon FreeRTOS
IoT Operating System for Microcontrollers
Amazon FreeRTOS, based on the popular FreeRTOS, is a microcontroller operating system that makes small, low powered edge devices easy to
program, deploy, secure, connect, and maintain.
10101011010
10111010110
10101010101 00101010101 00101001010
?
10111010101
10011001011
00100101101
Will it work on my chip?
Does it have the functionality I need?
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Where do I get it?
How do I start?
Amazon FreeRTOS
IoT Operating System for Microcontrollers
Amazon FreeRTOS, based on the popular FreeRTOS, is a microcontroller operating system that makes small, low powered edge devices easy to
program, deploy, secure, connect, and maintain.
EMBEDDED APPS
HELLO
SECURTI Y LIBRARIES CONNECTIVITY LIBRARIES OVER THA AIR (OTA) AGENT
CLOUD & GREENGRASS
LIBRARIES
FreeRTOS HW DRIVERS
Will it work on my chip?
Does it have the functionality I need?
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Where do I get it?
How do I start?
Amazon FreeRTOS
IoT Microcontroller OS
Based on FreeRTOS kernel
Local Connectivity Libraries
AWS Greengrass
Cloud Connectivity Libraries
AWS IoT Core
Security Connectivity
Libraries
OTA Beta & Code Signing
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Based on #1 Real-Time Operating System for Microcontrollers
� 15 years, trusted, and widely distributed
� 40+ supported architectures
� Broad ecosystem support
� Free and open source
� Introducing version 10
� MIT Open Source License
� Improved Inter-Process Communication (IPC) capabilities with stream and message buffers
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Local Connectivity Libraries
Connect with AWS Greengrass
� Local communication with edge gateways and a Wi-Fi stack, including AWS Greengrass discovery support
� Wi-Fi management library implements an abstraction layer for Wi-Fi features such as setup, configuration, provisioning, security, and power management
� Continue communicating, collecting data, and taking actions without a cloud connection
� Support for many network topologies and use cases
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Greengrass
Cloud Connectivity Libraries
� Connectivity to AWS IoT Core � MQTT Pub/Sub messaging � Device Shadow support � Take advantage of IoT Core
benefits like IoT Device Management, scalable architecture, and pay as you go pricing � Fastest way to get started on IoT microcontrollers
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS IoT Core
Security Connectivity Libraries
� Secure sockets using TLS � Certificate-based authentication � PKCS#11 interface for key
management � Secure by default � No open network ports � Only run trusted code � Clear, modular implementation
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Over-the-Air Firmware Updates
� Use AWS IoT Device Management to assign updates to groups
� Code sign new firmware images � Stream updates to your device
over MQTT � Validate signature on device � APIs to control installation and
reboot logic � Simple to manage groups � Control authorship and ensure
devices only run trusted code � Memory efficient updated client
� 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Let's get started!
AWS Console Login 52
� Navigate to: https://sttt.signin.aws.amazon.com/console � Login with credentials distributed to you
Get the credentials file from S3 bucket 53
� On your laptop open the browser and login to AWS Console � Navigate to S3 service (Services -> type S3 -> Select S3)
Get the credentials file from S3 bucket 54
� Open sttechnologytour/studentXX folder � Download studentXX_credentials.txt file
Set up Amazon Workspaces client 55
Use webclient ONLY(!) if you cannot use Windows/Mac/Chromebook client
Windows Desktop
Client (W7, W8, W10)
MacOS Desktop Client (Mac OS X 10.8.1 and above)
https://clients.amazonworkspaces.com/
Web Client (Chrome or Firefox v48 or later)
https://clients.amazonworkspaces.com/webclient
Log in to your Workspace 56
� Run client, click Options -> Manage Registrations, register with WSpdx+P2D4ZD � Login with credentials you have in your file
Clone the repository 57
� Run GitHub Desktop � Press Skip this step, then Continue, then Finish � Click Clone a repository from Internet ... and provide URL found in
studentXX_credentials.txt file
Click Show in Explorer
Import the project to System Workbench 58
� Run System Workbench for STM32
� Accept default location of your Eclipse workspace � Click File -> Open Projects from File System ...
Provision Thing, and device credentials 59
� In System Workbench click File -> Open file... and navigate to D:\Users\studentXX/Documents\GitHub\sttt-workshop/tools/aws_config_quick_start/configure.json
� Edit it content to match example in studentXX_credentials.txt and save the changes
Provision Thing, and device credentials 60
� Run Windows Command Prompt and configure AWS CLI by issuing aws configure command (make sure the region is us-west-2 and format is json)
� AWS Access and Secret keys are in the studentXX_credentials.txt file
Provision Thing, and device credentials 61
� Change directory to
D:\Users\studentXX\Documents\GitHub\sttt-workshop\tools\aws_config_quick_start
� Run Provisioning script: python SetupAWS.py setup
Provision Thing, and device credentials 62
� Start Firefox browser � In the AWS Console click Services and type iot core � Select IoT Core service � Make sure your region is set to Oregon.
Provision Thing, and device credentials 63
� Examine Thing, Certificate and Policy created in the AWS IoT Core � Click Manage ->Things and type studentXX to search for your thing
Provision Thing, and device credentials 64
� Drill down
Provision Thing, and device credentials 65
� Run python SetupAWS.py cleanup in Windows Command Prompt
� In AWS Console verify that your Thing, Certificate and Policy are gone
� Run python SetupAWS.py setup in Windows Command Prompt to provision your device again
Edit the MQTT topic you will be publishing 66
� Return to System Workbench � In the aws_demos project, navigate to application_code/common_demos/source/aws_hello_world.c
file � On line 90 change "freertos/demos/echo" to "freertos/demos/echo/studentXX"
� Save the file
Examine all the changes 67
� Open GitHub Desktop and see all the changes that were made to the project
There are 2 files you edited And 5 files generated/modified by provisioning script
Inspect them and ask the mentors if you do not understand the purpose of each change
Build the project 68
� Return to System Workbench. Highlight aws_demos project. Press Ctrl+B � Switch to SW Console tab and check output files
Transfer firmware binary to your laptop 69
� In the AWS Workspace open the browser and login to AWS Console � Navigate to S3 service (Services -> type S3 -> Select S3)
Transfer firmware binary to your laptop 70
� Navigate to sttechnologytour bucket -> studentXX prefix � Click on Upload button. Upload aws_demos.bin file by dragging it from SW to
S3 upload interface
Transfer firmware binary to your laptop 71
� Login to the AWS Console from your laptop � Navigate to S3 service -> sttechnologytour bucket -> studentXX prefix � Click on aws_demos.bin file and download it
Reset Button User Button
How to Flash the IoT DK 72
1
Connect to STLINK USB Port
IoT DK
USB 2.0 A-Male to Micro B Cable
2
Drag'n'Drop
aws_demos.bin
into
DIS_L4IOT (F: in the example)
This action will flash the board with the
new FW
3 Press the Reset Button to restart program
How to Flash the IoT DK (Opt 2) 73
Reset Button User Button
2 Click CONNECT 3 BROWSE to
aws_demos.bin
4 START PROGRAMMING
1
5 Press the Reset Button to restart program
Connect to
STLINK USB Port
IoT DK
USB 2.0 A-Male to Micro B Cable
2
3 4
Local Machine 74
Serial Terminal
MQTT TLS
STLINK USB Port
IoT DK
USB 2.0 A-Male to Micro B Cable
Verify that your firmware functions properly 75
� Open Console and verify your device can connect to WiFi, AWS MQTT broker, and publish/receive messages on freertos/demos/echo/studentXX topic
� In AWS Console open IoT Core->Test and subscribe to freertos/demos/echo/studentXX topic. Observe MQTT messages
Change Git branch 76
� Open GitHub desktop and change branch to "sensors-demo"
� In the System Workbench click on aws_demos project and verify that branch is changed from master to sensors-demo
Compile and run 77
� Build the project in System Workbench
(In some cases you might need to clean your previous build first)
� Transfer file using your S3 bucket/folder to the laptop
� Flash firmware to the board
Sensor values in the local console 78
� Open Console and observe sensor values transmitted
Sensor values received by MQTT broker 79
� Check MQTT messages in AWS Console -> AWS IoT Core The topic is freertos/demos/sensors/studentXX
AWS IoT Topic Rules 80
� In the AWS Console go to Services -> IoT Core � Click on Act tab and inspect 2 rules currently provisioned
Store every MQTT message as a file 81
� Publish to S3 bucket rule
(check the SQL syntax operation on JSON)
Store every MQTT Message as a file 82
� Publish to S3 bucket rule action
(notice the usage of functions to create dynamic S3 key) https://docs.aws.amazon.com/iot/latest/developerguide/iot-sql-functions.html
Check the files published to S3 83
� In the AWS Workspace open the browser and login to AWS Console � Navigate to S3 service (Services -> type S3 -> Select S3)
Check the files published to S3 84
� Navigate to sttechnologytour bucket -> studentXX/sensorsData prefix � Inspect the files created and open one of the files
Aggregate messages 85
� Check Publish2KinesisFirehose rule
� It aggregates messages from all boards, buffer them for 60 seconds in Kinesis stream and then publish to S3
Aggregate messages 86
� Check Publish2KinesisFirehose rule
� It aggregates messages from all boards, buffer them for 60 seconds in Kinesis stream and then publish to S3
Appendix: Software and Other Pre-requisites
System Workbench for STM32 88 (requires registration to openstm32.org)
http://www.openstm32.org/Downloading+the+System+Workbench+for+STM32+installer � install_sw4stm32_win_64bits-v2.5.exe � install_sw4stm32_macos_64bits-v2.5.run
� Warning: To run System Workbench for STM32 on MAC OSX systems, XCode may be required. To download it, please refer to the Apple developer website (registration as Apple Developer is required)
� The downloaded installer is an executable binary file. Your web browser might have removed the execution right of the file. Please set the execution right to the installer file (chmod 755 install_sw4stm32.run then ./install_sw4stm32.run) OR Launch it with /bin/bash (/bin/bash install_sw4stm32.run)
� If an error message saying the installer "is damaged and can't be opened. You should move it to the Trash.", please modify the installation access right in the Gatekeeper. On latest version of MAC OSX, go in the terminal:
� On older version of MAC OSX: � Go in the "System Preferences" > "Security & Privacy", then select "Allow downloaded app from :" "Anywhere". When the installation is done, restore
the setting value back at "Mac App Store and identified developers"
� install_sw4stm32_linux_64bits-latest.run
� The installer in GUI-mode requires gksudo. On Ubuntu, gksudo is in package gksu, that you can install by sudo apt-get install gksu. If gksudo is not installed, the installer can still be launched in command-line.
� The downloaded installer is an executable binary file. Your web browser might have removed the execution right of the file. Please set the execution right to the installer file (chmod 755 install_sw4stm32.run then ./install_sw4stm32.run) OR launch it with /bin/bash (/bin/bash install_sw4stm32.run)
Software and Others Pre-requisites 89 Windows (Win7, Win8, Win10)
� STM32 ST-Link Utility: STSW-LINK004 (requires registration to my.st.com)
� NOTE: Required for Window 7
� ST-LINK, ST-LINK/V2, ST-LINK/V2-1 USB driver signed for Windows7, 8, 10: STSW-LINK009 (requires registration to my.st.com)
� NOTE: Required for Window 7
� Serial line monitor: Tera Term (https://ttssh2.osdn.jp/ )
� Install from USB .\Windows\teraterm-4.99.exe
Tera Term Setup 90
Tera Term Setup 91
Software and Others Pre-requisites 92 Mac OS: PicoCom
Serial line monitor: PicoCom or Screen � Launch Spotlight by pressing Cmd + Space. Type terminal and select
the Terminal app. � In the Terminal window, enter the commands
� $ brew install picocom � $ ls �l /dev/tty*usbmodem*
� Example: /dev/tty.usbmodem413
� $ picocom --imap lfcrlf -b 115200 -p 1 -d 8 �c <usb device file>
� Example: $ picocom --imap lfcrlf -b 115200 -p 1 -d 8 �c /dev/tty.usbmodem413
Software and Others Pre-requisites 93 Mac OS: Screen (native app)
Serial line monitor: PicoCom or Screen
� Launch Spotlight by pressing Cmd + Space. Type terminal and select the Terminal app.
� In the Terminal window, enter the command: ls /dev/cu.usb*
� In the list of devices, look for a device that contains cu.usbserial or cu.usbmodem; in the example below IoT DK is mapped to /dev/cu.usbmodem1413
� Launch the from the terminal the screen utility by entering the command:
screen �L /dev/cu.usbmodem1413 115200 �L
usb device name
� The screen command will open a serial terminal connected to the device. Reset the board to see log messages from the device
Serial terminal baudrate
Software and Others Pre-requisites 94 Linux (Ubuntu)
Serial line monitor: Putty or Picocom � Putty
� $ sudo apt-get update (This command updates the Ubuntu package list with latest one)
� $ sudo apt-get install -y putty
� Picocom
� $ sudo apt-get install picocom � $ ls �l /dev/tty*usbmodem*
� Example: /dev/tty.usbmodem413
� $ picocom --imap lfcrlf -b 115200 -p 1 -d 8 -c <usb device file>
� Example: $ picocom --imap lfcrlf -b 115200 -p 1 -d 8 �c /dev/tty.usbmodem413
Ubuntu 95
Open and Configure Serial Terminal (Putty)
� Open a Linux terminal and enter
� Open Putty
command: dmesg
Note down device name for Discovery Kit
/STM32 @ST_World st.com/e2e
Releasing Your Creativity 96
www.st.com/stm32
