Mistake on this page? Email us

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).

  1. Prerequisites.
  2. Configuring Device Management Client.
  3. Compiling and flashing Device Management Client.
  4. 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

  1. 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
    
  2. Download a developer certificate from Device Management Portal.

  3. Copy the mbed_cloud_dev_credentials.c file to the root folder of the example application.

  4. Create update-related configuration and credentials using the manifest-tool python package:

    1. Upgrade to manifest-tool version 2.1.1 or higher:
      pip install --upgrade manifest-tool
      
    2. Initialize the developer environment:
      manifest-dev-tool init --access-key <Device Management access key>
      

Configure and build for NXP MCUXpresso LPC54628

Download the SDK

To download the NXP SDK for the target board.

  1. Go to NXP MCUXpresso SDK Builder. Registration and login are required.
  2. Click Select Development Board.
  3. In the SDK Builder, use Search by Name to find and select LPCXpresso54628.
  4. Click Build MCUXpresso SDK.
  5. Select the SDK Version: 2.7.0 2019-12-19.
  6. Select Toolchain: GCC ARM Embedded.
  7. Select Host OS: Linux.
  8. Select the features Amazon FreeRTOS, sdmcc stack, mbedtls and lwIP.
  9. Click Download SDK.

Prepare sources

  1. Create a new folder SDK_LPCXpresso54628 under ~/mbed-cloud-client-example/pal-platform/SDK/LPCXpresso54628/.

  2. 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
    
  3. Deploy remaining dependencies and configuration:

    python pal-platform/pal-platform.py deploy --target=LPC54628_NXP generate
    

Compile Device Management Client

  1. 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 ..
    
  2. 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:

  1. Go to NXP MCUXpresso SDK Builder. Registration and login are required.
  2. Click Select Development Board.
  3. In the SDK Builder, use Search by Name to find and select ** EVK-MIMXRT1060**.
  4. Click Build MCUXpresso SDK.
  5. Select the SDK Version: 2.7.0 2019-12-19.
  6. Select Toolchain: GCC ARM Embedded.
  7. Select Host OS: Linux.
  8. Select the features Amazon FreeRTOS, sdmcc stack, mbedtls and lwIP.
  9. Click Download SDK.

Prepare sources

  1. Create a new folder SDK_EVK-MIMXRT1060 under ~/mbed-cloud-client-example/pal-platform/SDK/EVK-MIMXRT1060/.

  2. 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
    
  3. Deploy remaining dependencies and configuration:

    python pal-platform/pal-platform.py deploy --target MIMXRT1060_NXP generate
    

Compile Device Management Client

  1. 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 ..
    
  2. 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

  1. Connect your board to your PC over USB. It appears in your file browser.

  2. 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

  1. Open a serial terminal with the COM port that Device Management uses and 115200 baud rate with no flow control.
  2. 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:

  1. Log in to Device Management Portal.
  2. Select Device directory from the menu on the left.
  3. 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.