Command-line tutorial for NXP MCUXpresso SDK with Pelion
This tutorial shows you how to securely connect and update an device built with NXP Xpresso SDK over an IP connection.
The supported boards are NXP LPC54628
and i.MX RT1060 EVK
.
Note: The earlier revisions of LPCXpresso 546XX have different QSPI chip than the some of the later revisions. The application must specify at compile-time which revision it supports. Select the correct QSPI chip in the board configuration file (define_NXP_LPC54628.txt
). This depends on the board revision.
The tutorial is written using MCUXpresso SDK version 2.7.0 and a Linux PC (64-bit Ubuntu/XUbuntu OS desktop environment).
- Prerequisites.
- Configuring Device Management Client.
- Compiling and flashing Device Management Client.
- Connecting and performing a firmware update on your device.
Prerequisites
-
Configure MACRO for compiler:
export ARMGCC_DIR=/usr/local/gcc-arm-none-eabi-9-2019-q4-major
-
Ensure the development board has DAPlink installed. See the instructions for updating the LPCXresso firmware.
-
An access key (with
Administrators
group privileges) for your Device Management account.
For all other requirements, see the tools and accounts section. See also instructions for Mbed CLI.
Configure Device Management Client
-
Open a terminal and import the example repository to a convenient location in your development environment:
mbed import https://github.com/PelionIoT/mbed-cloud-client-example
-
Download a developer certificate from Device Management Portal.
-
Copy the
mbed_cloud_dev_credentials.c
file to the root folder of the example application. -
Create update-related configuration and credentials using the
manifest-tool
python package:- Upgrade to
manifest-tool
version 2.1.1 or higher:pip install --upgrade manifest-tool
- Initialize the developer environment:
manifest-dev-tool init --access-key <Device Management access key>
- Upgrade to
Configure and build for NXP MCUXpresso LPC54628
Download the SDK
To download the NXP SDK for the target board.
- Go to NXP MCUXpresso SDK Builder. Registration and login are required.
- Click Select Development Board.
- In the SDK Builder, use Search by Name to find and select LPCXpresso54628.
- Click Build MCUXpresso SDK.
- Select the SDK Version: 2.7.0 2019-12-19.
- Select Toolchain: GCC ARM Embedded.
- Select Host OS: Linux.
- Select the features Amazon FreeRTOS, sdmcc stack, mbedtls and lwIP.
- Click Download SDK.
Prepare sources
-
Create a new folder SDK_LPCXpresso54628 under
~/mbed-cloud-client-example/pal-platform/SDK/LPCXpresso54628/
. -
Unpack the SDK under
SDK_LPCXpresso54628
:tar -xzvf SDK_2.7.0_LPCXpresso54628.tar.gz -C mbed-cloud-client-example/pal-platform/SDK/LPCXpresso54628/SDK_LPCXpresso54628
-
Deploy remaining dependencies and configuration:
python pal-platform/pal-platform.py deploy --target=LPC54628_NXP generate
Compile Device Management Client
-
Run CMake and Make to compile the application:
cd __LPC54628_NXP cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./../pal-platform/SDK/LPCXpresso54628/SDK_LPCXpresso54628/tools/cmake_toolchain_files/armgcc.cmake -DEXTERNAL_DEFINE_FILE=./../define_NXP_LPC54628_update.txt -DUPDATE_LINKING=1 make mbedCloudClientExample.elf cd ..
-
Combine the image with a bootloader. This command is executed in the repository root-folder:
python pal-platform/SDK/LPCXpresso54628/tools/combine_bootloader_with_app.py -b pal-platform/SDK/LPCXpresso54628/tools/mbed-bootloader_rev_e_w25q.bin -a __LPC54628_NXP/Release/mbedCloudClientExample.bin -o mbedCloudClientExample_combined.bin -c 0x8400 -d 0x8000
Note: Depending on the selected QSPI chip, you need to select the corresponding bootloader binary. Available files are mbed-bootloader_rev_e_w25q.bin
, mbed-bootloader_rev_c_d_mt25q.bin
and mbed-bootloader_mx25r.bin
.
Configure and build for NXP i.MX RT1060 EVK
Download the SDK
To download the NXP SDK for the target board:
- Go to NXP MCUXpresso SDK Builder. Registration and login are required.
- Click Select Development Board.
- In the SDK Builder, use Search by Name to find and select ** EVK-MIMXRT1060**.
- Click Build MCUXpresso SDK.
- Select the SDK Version: 2.7.0 2019-12-19.
- Select Toolchain: GCC ARM Embedded.
- Select Host OS: Linux.
- Select the features Amazon FreeRTOS, sdmcc stack, mbedtls and lwIP.
- Click Download SDK.
Prepare sources
-
Create a new folder SDK_EVK-MIMXRT1060 under
~/mbed-cloud-client-example/pal-platform/SDK/EVK-MIMXRT1060/
. -
Unpack the SDK under
SDK_EVK-MIMXRT1060
:tar -xzvf SDK_2.7.0_EVK-MIMXRT1060.tar.gz -C mbed-cloud-client-example/pal-platform/SDK/EVK-MIMXRT1060/SDK_EVK-MIMXRT1060
-
Deploy remaining dependencies and configuration:
python pal-platform/pal-platform.py deploy --target MIMXRT1060_NXP generate
Compile Device Management Client
-
Run CMake and Make to compile the application:
cd __MIMXRT1060_NXP cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./../pal-platform/SDK/EVK-MIMXRT1060/SDK_EVK-MIMXRT1060/tools/cmake_toolchain_files/armgcc.cmake -DEXTERNAL_DEFINE_FILE=./../define_NXP_MIMXRT1060_update.txt -DUPDATE_LINKING=1 make mbedCloudClientExample.elf cd ..
-
Combine the image with a bootloader. This command runs in the repository root-folder:
python pal-platform/SDK/EVK-MIMXRT1060/tools/combine_bootloader_with_app.py -b pal-platform/SDK/EVK-MIMXRT1060/tools/mbed_bootloader.bin -a __MIMXRT1060_NXP/Release/mbedCloudClientExample.bin -o mbedCloudClientExample_combined.bin -c 0x10400 -d 0x10000
Flash the application
-
Connect your board to your PC over USB. It appears in your file browser.
-
Copy the application file
mbedCloudClientExample_combined.bin
to the board. Flash the image combined with the bootloader (_combined.bin
), not the one generated by Make.
Connect and perform a firmware update on your device
- Open a serial terminal with the COM port that Device Management uses and 115200 baud rate with no flow control.
- Reset the board.
When the client has successfully connected, the terminal shows:
Client registered
Endpoint Name: <Endpoint name>
Device ID: <Device ID>
To verify the connection with Device Management Portal:
- Log in to Device Management Portal.
- Select Device directory from the menu on the left.
- When your device is listed on the Devices page, it is connected and available.
Your device is now connected and ready for firmware updates. For development devices, the Endpoint name and Device ID are identical.
Update the firmware
To update the firmware on your device use either command depending on your board:
manifest-dev-tool update-v1 \
--payload-path <__LPC54628_NXP or __MIMXRT1060_NXP>/Release/mbedCloudClientExample.bin \
--device-id <Device ID>
--wait-for-completion
During the update flow, the client tracing log shows:
Firmware download requested
Authorization granted
...
Downloading: 100 %
Download completed
Firmware install requested
Authorization granted
After this, the device reboots automatically and registers to Device Management.