ST Microelectronics Nucleo-L476 Integration Guide

ST Microelectronics Nucleo-L476 Integration Guide

Overview

This document serves as a guide to build SDK examples for the Nucleo-L476 board with the NimbeLink Cat M modem serving as the communications module. Steps mentioned here are not required if compiling the SDK as a static library.

Before you begin

Here is a list of the following repositories and tools you will needaccess to prior to your build.
Item Item Description Version Source/vendor Purpose Link
1 Repository Latest Verizon Provide secured cloud interface for device communicate with ThingSpace services https://github.com/verizonlabs/ts_sdk_c
Latest Eclipse Paho MQTT C/C++ client for Embedded platforms https://github.com/verizonlabs/paho.mqtt.embedded-c
Latest Mbed TLS Open source TLS library for establishing TLS connection between device and ThingSpace server https://github.com/verizonlabs/mbedtls
Latest Verizon Hardware interface for Nucleo-l476 board https://github.com/verizonlabs/ts_sdk_c_platforms_none_nucleo-l476/blob/develop/ts_platform.c
2 ARM Latest ARM The GNU Embedded Toolchain for Arm is a ready-to-use, open source suite of tools for C, C++ and Assembly programming targeting Arm Cortex-M and Cortex-R family of processors. It includes the GNU Compiler (GCC) and is available free of charge directly from Arm for embedded software development on Windows, Linux and Mac OS X operating systems https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
3 ST Micro 1.11+ STM STM32Cube MCU Package for STM32L4 series and STM32L4 Plus series (HAL, Low-Layer APIs and CMSIS (CORE, DSP, RTOS), USB, Touch Sensing, File system, RTOS, Graphic - coming with examples running on ST boards: STM32 Nucleo, Discovery kits and Evaluation boards) http://www.st.com/en/embedded-software/stm32cubel4.html

Dependencies to the main SDK repository can be set up using the provided script and can be invoked as follows (from the top of the TS SDK C Binding repository):

$ ./scripts/get_submodules.sh

You will be asked for your GitHub username and password multiple times. You can also set up your git environment with your login information.

NOTE: Repositories other than the ones listed above might not be accessible to you.

Arrange the jumpers on the top of the Nimbelink Cat M development board in the following way:

Debugging output port

This board-modem setup uses a debug UART to output debug logs generated by the SDK and application.

Connect the RX pin of an FTDI cable to pin PC12 on connector CN7 (refer to the Nucleo-L476 board schematics).

Connect the ground pin of the FTDI cable to a ground pin on the board.

To view the debug logs on the host machine, use the following command (on UNIX based systems):

$ picocom --imap lfcrlf -b 115200 -p n -d 8 /dev/tty.usbserial-FTH0YJKJ

Certificates

The TLS library for this target is configured to accept the binary format (DER) of certificates and keys to avoid a run-time conversion from PEM to DER. This also helps reduce the firmware size. A helper script is provided to convert the certificates and key provided by the ThingSpace portal into the requisite format. It can be invoked as follows to (from the top of the TS SDK C Binding repository):

$ ./scripts/include_certs.sh \

thingspaceserver.pem \

357353080059530.cert.pem \

357353080059530.private.key \

The usage instructions can be pulled up by invoking the script without any parameters. The below invocation writes three C header files containing the certificates and the key into the include directory of the simple SDK application.

./examples/applications/simple/include

Configuring top-level CMakeLists.txt

Modify existing definitions in the top-level CMakeLists.txt:

Replace TS_CONTROLLER_NONE with TS_CONTROLLER_MONARCH (under "component selection").

Replace unix_raspberry-pi3 with none_nucleo-l476 (under "platform kernal and board configuration").

Replace TS_DRIVER_SOCKET with TS_DRIVER_UART (under "platform driver configuration").

Replace TS_PLATFORM_UNIX with TS_PLATFORM_NONE (under "platform driver configuration").

Sample application

Invoke CMake from the top of the TS SDK C Binding repository. The following will generate Makefiles for a debug build of the SDK and sample applications.

TOOLCHAIN_PREFIX points to the location where the toolchain is installed, MCU_HAL points to the location of the STM32 L4 HAL and the CMAKE_TOOLCHAIN_FILE points to the provided toolchain support file for the GNU arm-non-eabi toolchain. Without the BUILD_EXAMPLES and MCU_HAL directives, CMake will generate Makefiles to build the SDK only.

$ cmake . \

-B./cmake-build-debug \

-DBUILD_EXAMPLES=ON \

-DCMAKE_BUILD_TYPE=Debug \
-DTOOLCHAIN_PREFIX=/opt/cortexm/gcc-arm-none-eabi-7-2017-q4-major \
-DMCU_HAL=/opt/cortexm/STM32Cube_FW_L4_V1.11.0 \
-DCMAKE_TOOLCHAIN_FILE=/work/ts_sdk_c/toolchain/arm-none-eabi-gnu.cmake

Compile the SDK, its dependencies and the example applications:

$ cd cmake-build-debug

$ make

Flashing firmware

The build step leaves ELF format application binaries in cmake-build-debug/examples/applications. These can be uploaded to the board using a suitable firmware uploader. If using OpenOCD, the following command can be used to upload the example_simple sample application:

$ cd ./cmake-build-debug/examples/applications

$ openocd -f ../../../scripts/openocd-configs/stm32l4/board/st_nucleo_l476rg.cfg -c init -c "reset halt" -c "flash write_image erase ./example_simple" -c reset -c shutdown

Once uploaded, the board should have been automatically reset and the new firmware should have begun executing.