+ All Categories
Home > Documents > Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an...

Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an...

Date post: 13-Dec-2020
Category:
Upload: others
View: 9 times
Download: 0 times
Share this document with a friend
27
Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor development kit, which helps you to build custom applications. The package includes pressure, relative humidity, temperature, accelerometer, gyroscope and magnetometer sensors, as well as an analog microphone and the SPBTLE-1S Bluetooth low energy system-on-chip application processor. With the STEVAL-MKSBOX1V1 kit with BLE connectivity, you can monitor and log the algorithm output and sensor data using the STBLESensor app. The software runs on the STM32 microcontroller and includes all the necessary drivers for the STEVAL-MKSBOX1V1 evaluation kit. RELATED LINKS Visit the STM32Cube ecosystem web page on www.st.com for further information Getting started with the STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor development kit UM2626 User manual UM2626 - Rev 2 - April 2020 For further information contact your local STMicroelectronics sales office. www.st.com
Transcript
Page 1: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

IntroductionFP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor developmentkit, which helps you to build custom applications.

The package includes pressure, relative humidity, temperature, accelerometer, gyroscope and magnetometer sensors, as wellas an analog microphone and the SPBTLE-1S Bluetooth low energy system-on-chip application processor.

With the STEVAL-MKSBOX1V1 kit with BLE connectivity, you can monitor and log the algorithm output and sensor data usingthe STBLESensor app.

The software runs on the STM32 microcontroller and includes all the necessary drivers for the STEVAL-MKSBOX1V1evaluation kit.

RELATED LINKS Visit the STM32Cube ecosystem web page on www.st.com for further information

Getting started with the STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor development kit

UM2626

User manual

UM2626 - Rev 2 - April 2020For further information contact your local STMicroelectronics sales office.

www.st.com

Page 2: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

1 FP-SNS-STBOX1 software expansion for STM32Cube

1.1 Overview

FP-SNS-STBOX1 key features are:• Complete samples on how to:

– use ultra-low power implementation based on an RTOS for transmitting the data via BLE connectivity– create a BootLoader and an application for Firmware-Over-the-Air (FOTA) update– use the dual bank flash feature for rollback after a FOTA update– program the LSM6DSOX machine learning core (MLC) or its finite state machine (FSM), control the

output of its registers and transmit the results via BLE– easily send the data via BLE– save the sensor data to the SD card– visualize the sensor data with the Unicleo-GUI via PC serial terminal

• Compatible with STBLESensor application for Android/iOS, to perform sensor and audio data reading,motion algorithm feature demo, and FOTA via BLE connectivity

• Sample implementation available for the STEVAL-MKSBOX1V1 kit• Easy portability across different MCU families, thanks to STM32Cube• Free, user-friendly license terms

The software gathers the temperature, humidity, pressure, motion sensor drivers for the HTS221, LPS22HH,STTS751, LIS2DW12, LIS2MDL, LIS3DHH and LSM6DSOX devices for the STEVAL-MKSBOX1V1.

1.2 Architecture

This software is based on the STM32CubeHAL. It extends STM32Cube by providing a board support package(BSP) for the BLE, sensors, microphone and middleware components for communication with other BLE devices.It also provides some sample applications to demonstrate how to implement custom applications using theSensorTile.box Pro Mode.

The software layers used by the application software to access and use the SensorTile.box are:• the STM32Cube HAL layer, which provides a simple, generic, multi-instance set of application programming

interfaces (APIs) to interact with the upper application, library and stack layers. It has generic and extensionAPIs and is directly built around a generic architecture and allows successive layers like the middlewarelayer to implement functions without requiring specific hardware configurations for a given microcontrollerunit (MCU). This structure improves library code reusability and guarantees an easy portability on otherdevices.

• the board support package (BSP) layer, which supports all the peripherals on the STM32 Nucleo exceptthe MCU. This limited set of APIs provides a programming interface for certain board-specific peripheralslike the LED, the user button, etc. This interface also helps in identifying the specific board version.

Figure 1. FP-SNS-STBOX1 software architecture

FP

Applications

STM32Cube Hardware Abstraction Layer (HAL)

Middleware

HardwareAbstraction

Hardware STEVAL-MKSBOX1V1 evaluation kit

BLE

DataLogExtended

FPBLELowPowerRToS BLEDualProgram BLEFOTA

SDDataLogRToS BootLoader

USB Device FreeRTOS FatFs

BLESensors

BLEMLC

UM2626FP-SNS-STBOX1 software expansion for STM32Cube

UM2626 - Rev 2 page 2/27

Page 3: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

1.3 Folder structure

Figure 2. FP-SNS-STBOX1 package folder structure

The following folders are included in the software package:• Documentation contains a compiled HTML file generated from the source code which details the software

components and APIs.• Drivers contains the HAL drivers and the board-specific drivers for each supported board or hardware

platform, including the on-board components and the CMSIS vendor-independent hardware abstractionlayer for ARM Cortex-M processor series.

• Middlewares contains libraries and protocols for BlueNRG-2 Bluetooth low energy, FreeRTOS real-timeoperating system, USB Device Library and FATfs DOS/Windows compatible with FAT/exFAT filesystem.

• Projects contains applications and samples for creating customized Pro Mode applications for theSensorTile.box wireless multi sensor development kit (STEVAL-MKSBOX1V1). The available applicationsare:– BLEFOTA: Secure (PIN) BLE Firmware Over The Air update (works with the BootLoader application)– BLEDualProgram: Secure (PIN) BLE firmware that uses the dual bank flash features to allow update

and rollback functions– BLELowPowerRToS: FreeRTOS low Power BLE trasmission of sensor data– BLEMLC: Example to program the LSM6DSOX Machine Learning Core (MLC)– BLESensors: Simplest way for BLE trasmission of sensor data– SDDataLogRToS: SD card data log with FreeRTOS– BootLoader: BootLoader to enable the code update from Flash or from SD card (works with the

BLEFOTA application)– DataLogExtended: to send data via USB and Unicleo-GUI

All projects are available for IAR Embedded Workbench for ARM, RealView Microcontroller Development Kit(MDK-ARM-STR) and STM32CubeIDE multi-OS development tool.

• Utilities: contains the BootLoader binary ready to be flashed for the STEVAL-MKSBOX1V1 evaluation kit.

1.4 APIs

Detailed technical information with full user API function and parameter description are in a compiled HTML file inthe “Documentation” folder.

UM2626Folder structure

UM2626 - Rev 2 page 3/27

Page 4: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

2 Sample and application projects

FP-SNS-STBOX1 contains eight application projects in the Projects\STM32L4R9ZI-SensorTile.box\Applicationdirectory:• BLEFOTA: secure (with PIN) BLE FOTA (works with the BootLoader application)• BLEDualProgram: secure (with PIN) BLE FOTA that uses dual bank flash features to allow the update and

the rollback functions• BLELowPowerRToS: BLE trasmission of sensor data with low power features and FreeRToS• BLESensors: easy BLE trasmission of sensor data• BLEMLC: example of how to program the LSM6DSOX Machine Learning Core (MLC)• SDDataLogRToS: SD data log with FreeRTOS• BootLoader: to enable firmware-update-over-the-air (FOTA) in BLEFOTA application• DataLogExtend: to send sensors data via USB and using Unicleo-GUI

Sample and application projects are available for the STEVAL-MKSBOX1V1 evaluation board together with readyto be built projects for multiple IDEs (IAR, Keil and STM32CubeIDE).

2.1 BootLoader and BLEFOTA applications

The BootLoader and the BLEFOTA application work together and they must be loaded together on the STEVAL-MKSBOX1V1 to work properly.The on-board STM32L4R9ZI Flash memory (2 Mbytes) is split into three regions:• the first region (20 Kbytes of size) contains the BootLoader example• the second region contains the running BLEFOTA application• the last region is used by BLEFOTA to store updates before using it

The last two regions have the same size equal to the half of the Flash size not used by BootLoader [(2 Mbytes-20Kbytes)/2].The BootLoader controls the Boot Sequence and applies the FOTA stored in Region 3, received by BLEFOTAapplication.The BootLoader can also perform updates by searching the Update.bin file on the SD card.The BLEFOTA receives the new firmware from the STBLESensor application and saves it before passing controlto BootLoader samples.

Figure 3. Flash organization and Boot Sequence

UM2626Sample and application projects

UM2626 - Rev 2 page 4/27

Page 5: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

The BLEFOTA firmware can be updated Over-The-Air (FOTA) through an Android/iOS device via Bluetooth usingthe STBLESensor application (ver. 4.2.1 and above).The STBLESensor application sends the update and associated cyclic redundancy check (CRC) value, which theBLEFOTA checks against the hardware cyclic redundancy check calculation unit on the STM32L4R9ZI processorto ensure integrity. If the CRC calculation matches the STBLESensor CRC value, the new firmware is written atthe beginning of the third Flash region. A “magic number” signals to the STBLESensor that a firmware update hasbeen received and checked, and is ready to replace the current BLEFOTA firmware.The BootLoader checks whether the "magic number" is present and, if the case, the BootLoader replaces thecontent of Region 2 (previous BLEFOTA firmware) with the content of Region 3 (new BLEFOTA firmware), thendeletes the "magic number" present on Region 3 and restarts itself.If the magic number is not present, the BootLoader searches the Update.bin file on the SD card. If the SD cardcontains the file, the board replaces the content of Region 2 with the content of the Update.bin file (that is, thenew BLEFOTA firmware). If the file is not in the SD card, the BootLoader runs the actual BLEFOTA firmware inRegion 2.

Important:Flash the BootLoader and the BLEFOTA to the right Flash positions: each IDE project directory (IAR, Keil andSTM32CubeIDE) contains 2 or 3 different scripts that must be used if you recompile the BLEFOTA to add some modificationsand test them.

The CleanBLEFOTA.bat uses the ST-LINK Command Line for full Flash erase, for loading the BootLoader on theright position (it takes the pre-compiled BootLoader from Utilities directory), for loading the BLEFOTA in the rightposition (BLEFOTA.bin file) and for downloading the BootLoader and BLEFOTA (BLEFOTA_BL.bin) in a singlefile.

UM2626BootLoader and BLEFOTA applications

UM2626 - Rev 2 page 5/27

Page 6: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 4. CleanBLEFOTA.bat installation script

The CleanBLEFOTA_DFU.bat performs the same operation when the STEVAL-MKSBOX1V1 is in DFU mode.The STEVAL-MKSBOX1V1 enters DFU mode by pressing the boot button and the power button at the same timeor by sending the DFU command using the STBLESensor app debug console.To use this script, it is necessary to install the STM32CubeProg.The CleanBLEFOTA.sh script performs the same operation using OPENOCD. To use this script, it is necessary toset the right path and variable inside the script on the basis of the OPENOCD installation directory.

UM2626BootLoader and BLEFOTA applications

UM2626 - Rev 2 page 6/27

Page 7: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 5. Installation scripts

UM2626BootLoader and BLEFOTA applications

UM2626 - Rev 2 page 7/27

Page 8: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Important:For security reasons, the BLEFOTA allows connection only from paired devices. So when the STBLESensor application triesto connect to SensorTile.box running BLEFOTA, it is necessary to insert the right PIN (123456 as default - in VCP is notenabled).

Figure 6. PIN request

After connection, it is possible to send the firmware update to the SensorTile.box.

UM2626BootLoader and BLEFOTA applications

UM2626 - Rev 2 page 8/27

Page 9: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 7. BLEFOTA firmware update

The Binary directory contains two pre-compiled files:• BLEFOTA.bin: the binary used only for BLEFOTA (for firmware update)• BLEFOTA_BL.bin: used for the BootLoader plus BLEFOTA program. It can be used for flashing both

programs to the SensorTile.box, but not for firmware update

The BLEFOTA allows enabling the USBD Virtual Com Port (VCP) for visualizing printf to a terminal (forexample TeraTerm). In this way, it is possible to control the initialization and connection phases and, on boot, it ispossible to define the name the board will use for Bluetooth advertising.To enable the VCP it is necessary to recompile the code, enabling the compilation define calledSTBOX1_ENABLE_PRINTF at the beginning of the BLEFOTA/Inc/STBOX1_config.h file.

UM2626BootLoader and BLEFOTA applications

UM2626 - Rev 2 page 9/27

Page 10: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 8. Virtual Com Port

By enabling the VCP, the SensorTile.box replaces the default PIN used for security connection (123456) with arandom 6-digit number. In the above example, the new PIN is 555444 and the name used for BLE advertising isMyBoard.

2.2 BLEDualProgram application

The BLEDualProgram application shows how to use the dual bank flash features to allow Firmware-Over-the-Airupdate of a running program without using the BootLoader.The procedure for secure (PIN) BLE connection and FOTA sending is the same of the BLEFOTA application.In each IDE project directory, the CleanBLEDualProgram.bat script uses the ST-LINK Command Line for:• full flash erase• STM32 MCU user byte settings to start the boot procedure from bank1• BLEDualProgram.bin compiled binary installation on bank1

Before starting the boot procedure (which can start from bank1 or bank2), it is necessary to change STM32 MCUuser bytes.Once settings have been changed, the BLEDualProgram receives the new firmware from the STBLESensorapplication, saves it on one flash bank (either bank1 or bank2) and performs a reboot executing the new codesaved on the other flash bank.Even if the BootLoader allows more flexibility as you can split the flash memory into any number of regions, eachprogram related to a specific region can run in that region only.The BLEDualProgram application, however, can swap among different flash banks and each program can run inany flash memory bank.As the BLEDualProgram does not erase the previous version of the code after the update, it allows the rollback tothe previous program in case of a hardware fault. The application enables the hardware independent watchdog(IDWG) that must be refreshed every five seconds. If not refreshed in time (as in case of a hardware fault), theBLEDualProgram performs a reboot by executing the previous version of the code (rollback function).

UM2626BLEDualProgram application

UM2626 - Rev 2 page 10/27

Page 11: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 9. Rollback function

By pressing the user button, it is possible to simulate a hardware fault: after five seconds, as the IDWG is notrefreshed in time, the BLEDualProgram restarts by executing the code of the other flash bank.

2.3 DataLogExtended application

The DataLogExtended sample shows an application that, using the USBD Virtual Com Port, is able to dialog withthe Unicleo-GUI running on a PC connected via USB to the STEVAL-MKSBOX1V1 evaluation board, visualizingall the sensor data streamed from the board.

Figure 10. Unicleo-GUI main window

UM2626DataLogExtended application

UM2626 - Rev 2 page 11/27

Page 12: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 11. Unicleo-GUI motion sensor plot window

UM2626DataLogExtended application

UM2626 - Rev 2 page 12/27

Page 13: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 12. Unicleo-GUI finite state machine status

2.4 BLESensors application

The BLESensors sample shows how to easily send the STEVAL-MKSBOX1V1 inertial and environmental sensoroutput to STBLESensor application via Bluetooth.The BLESensors also enables the USBD Virtual Com Port (VCP) for visualizing printf to a terminal (forexample, TeraTerm) to control the initialization and connection phases and, at the boot, to define the name theSTEVAL-MKSBOX1V1 will use for Bluetooth advertising.To enable the VCP, it is necessary to recompile the code, enabling the compilation define calledSTBOX1_ENABLE_PRINTF at the beginning of BLESensors/Inc/STBOX1_config.h file.

UM2626BLESensors application

UM2626 - Rev 2 page 13/27

Page 14: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 13. STBLESensor application: environmental tab

UM2626BLESensors application

UM2626 - Rev 2 page 14/27

Page 15: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 14. STBLESensor application: plot tab

UM2626BLESensors application

UM2626 - Rev 2 page 15/27

Page 16: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 15. STBLESensor application: battery tab

2.5 BLELowPowerRToS application

The BLELowPowerRToS application shows how to use FreeRTOS and low power techniques to send theSTEVAL-MKSBOX1V1 inertial and environmental sensor output and the dB measured by the analog microphoneto STBLESensor application via Bluetooth.The BLELowPowerRToS also enables the USB Virtual Com Port (VCP) to visualize printf to a Terminal (forexample Tera Term) to control the initialization and connection phases and, at the boot, to define the name theSTEVAL-MKSBOX1V1 will use for Bluetooth advertising.To enable the VCP, it is necessary to recompile the code, enabling the compilation define calledSTBOX1_ENABLE_PRINTF at the beginning of BLELowPowerRToS/Inc/STBOX1_config.h file.The BLELowPowerRToS application sends the same data sent by the BLESensors application but, to show howto enable the capability of LSM6DSOX accelerometer to dected events like FreeFall, Single/Double Tap, WakeUp,Tilt and 6D orientation, it sends them also to STBLESensor.

UM2626BLELowPowerRToS application

UM2626 - Rev 2 page 16/27

Page 17: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 16. STBLESensor: LSM6DSOX hardware features tab

2.6 BLEMLC application

The BLEMLC application shows how to program the LSM6DSOX machine learning core (MLC) and its finite statemachine (FSM).In particular, this application programs the accelerometer to run an activity recognition algorithm for the MLC, andto run a 4D position recognition algorithm for the FSM; for both, the results are sent to the STBLESensorapplication (8 MLC output register values and 16 FSM output register values, respectively).The BLEMLC also enables the USBD Virtual Com Port (VCP)to visualize printf to a terminal (for example, TeraTerm) to control the initialization and connection phases and, during boot, to define the name the board will usefor Bluetooth advertising.To enable VCP, it is necessary to recompile the code, enabling the compilation define calledSTBOX1_ENABLE_PRINTF at the beginning of BLEMLC/Inc/STBOX1_config.h file.To enable the activity recognition algorithm on the MLC, you have to select the STBLESensor [ActivityRecognition] tab.

UM2626BLEMLC application

UM2626 - Rev 2 page 17/27

Page 18: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 17. LSM6DSOX MLC: activity recognition algorithm

The [Machine Learning Core] tab shows the ouput of the MLC decision trees.

UM2626BLEMLC application

UM2626 - Rev 2 page 18/27

Page 19: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 18. LSM6DSOX MLC: values of the 8 output registers

The [Finite State Machine] tab shows the output of the different programs running on the FSM.

UM2626BLEMLC application

UM2626 - Rev 2 page 19/27

Page 20: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 19. LSM6DSOX MLC: values of the 16 output registers

2.7 SDDataLogRToS application

The SDDataLogRToS application shows how to use FreeRTOS to save the STEVAL-MKSBOX1V1 inertial andenvironmental sensors and the analog microphone output to the SD card without loosing samples.After the boot, press the user button to start/stop the SD data log. At the end of each log, three different files aresaved on the SD card:• Sens000.csv which stores accelerometer/gyroscope/magnetometer/pressure/temperature/humidity values• Mic000.wav which stores the analog microphone wave file at 16 kHz• Rep000.txt which stores the summary of used FreeRTOS queues and maximum time to write the audio

buffer to the .wav file.

UM2626SDDataLogRToS application

UM2626 - Rev 2 page 20/27

Page 21: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Figure 20. Example of report file after a log section

UM2626SDDataLogRToS application

UM2626 - Rev 2 page 21/27

Page 22: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

3 System setup guide

3.1 STEVAL-MKSBOX1V1 evaluation kit

The STEVAL-MKSBOX1V1 (SensorTile.box) is a ready-to-use box kit with wireless IoT and wearable sensorplatform to help you use and develop apps based on remote motion and environmental sensor data, regardless ofyour level of expertise.The SensorTile.box board fits into a small plastic box with a long-life rechargeable battery, and the ST BLESensor app on your smartphone connects via Bluetooth to the board and allows you to immediately begin usingthe wide range of default IoT and wearable sensor applications.In Expert Mode, you can build customs apps from your selection of SensorTile.box sensors, operatingparameters, data and output types, and special functions and algorithms available. This multi sensor kit thereforeallows you to design wireless IoT and wearable sensor applications quickly and easily, without performing anyprogramming.SensorTile.box includes a firmware programming and debugging interface that allows professional developers toengage in more complex firmware code development using the STM32 Open Development Environment (STM32ODE), which includes a sensing AI function pack with neural network libraries.

Figure 21. STEVAL-MKSBOX1V1 evaluation kit

UM2626System setup guide

UM2626 - Rev 2 page 22/27

Page 23: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

3.2 Hardware setup

The following hardware components are needed:• One SensorTile.box evaluation kit (order code: STEVAL-MKSBOX1V1)• One ST-LINK/V2 debugger• One USB Micro-B cable• One USB type A to Mini-B USB cable

Figure 22. STEVAL-MKSBOX1V1 setup

3.3 Software setup

The following software components are required for the setup of a suitable development environment to createapplications for the STEVAL-MKSBOX1V1 evaluation board:• FP-SNS-STBOX1 firmware• a standard user terminal as Putty or Tera Term (v. 4.97 or higher)• STBLESensor app (only for BLE application)• Unicleo-GUI (v 1.11.0 or higher)• Development tool-chain and Compiler. The STM32Cube expansion software supports the three following

environments to select from:– IAR Embedded Workbench for ARM® toolchain + ST-LINK– RealView Microcontroller Development Kit toolchain + ST-LINK– STM32CubeIDE + ST-LINK

UM2626Hardware setup

UM2626 - Rev 2 page 23/27

Page 24: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Revision history

Table 1. Document revision history

Date Version Changes

02-Sep-2019 1 Initial release.

23-Apr-2020 2

Updated Section 1.1 Overview, Figure 1. FP-SNS-STBOX1 software architecture, Section 1.3 Folder structure, Section 2 Sample and application projects, Section 2.1 BootLoader andBLEFOTA applications, Section 2.6 BLEMLC application and Section 3.3 Software setup.

Added Section 2.2 BLEDualProgram application.

UM2626

UM2626 - Rev 2 page 24/27

Page 25: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

Contents

1 FP-SNS-STBOX1 software expansion for STM32Cube . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2

1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.2 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.3 Folder structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.4 APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Sample and application projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4

2.1 BootLoader and BLEFOTA applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.2 BLEDualProgram application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.3 DataLogExtended application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.4 BLESensors application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.5 BLELowPowerRToS application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.6 BLEMLC application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.7 SDDataLogRToS application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3 System setup guide. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22

3.1 STEVAL-MKSBOX1V1 evaluation kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3.2 Hardware setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

3.3 Software setup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24

UM2626Contents

UM2626 - Rev 2 page 25/27

Page 26: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

List of figuresFigure 1. FP-SNS-STBOX1 software architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Figure 2. FP-SNS-STBOX1 package folder structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Figure 3. Flash organization and Boot Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Figure 4. CleanBLEFOTA.bat installation script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Figure 5. Installation scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Figure 6. PIN request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Figure 7. BLEFOTA firmware update. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Figure 8. Virtual Com Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10Figure 9. Rollback function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Figure 10. Unicleo-GUI main window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Figure 11. Unicleo-GUI motion sensor plot window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Figure 12. Unicleo-GUI finite state machine status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Figure 13. STBLESensor application: environmental tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Figure 14. STBLESensor application: plot tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Figure 15. STBLESensor application: battery tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Figure 16. STBLESensor: LSM6DSOX hardware features tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17Figure 17. LSM6DSOX MLC: activity recognition algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Figure 18. LSM6DSOX MLC: values of the 8 output registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Figure 19. LSM6DSOX MLC: values of the 16 output registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20Figure 20. Example of report file after a log section. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Figure 21. STEVAL-MKSBOX1V1 evaluation kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Figure 22. STEVAL-MKSBOX1V1 setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

UM2626List of figures

UM2626 - Rev 2 page 26/27

Page 27: Getting started with the STM32Cube function pack for the ......Introduction FP-SNS-STBOX1 is an STM32Cube function pack for the Pro Mode of the SensorTile.box wireless multi sensor

IMPORTANT NOTICE – PLEASE READ CAREFULLY

STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and improvements to STproducts and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. STproducts are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgement.

Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design ofPurchasers’ products.

No license, express or implied, to any intellectual property right is granted by ST herein.

Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.

ST and the ST logo are trademarks of ST. For additional information about ST trademarks, please refer to www.st.com/trademarks. All other product or servicenames are the property of their respective owners.

Information in this document supersedes and replaces information previously supplied in any prior versions of this document.

© 2020 STMicroelectronics – All rights reserved

UM2626

UM2626 - Rev 2 page 27/27


Recommended