MCUXpresso_MIMXRT1052xxxxB/boards/evkbimxrt1050/aws_examples/ota_demo_wifi
Yilin Sun ded8674389
Updated to v2.12.1
Signed-off-by: Yilin Sun <imi415@imi.moe>
2022-12-08 23:33:41 +08:00
..
armgcc Updated to v2.12.0 2022-08-24 23:30:23 +08:00
config_files Updated to v2.12.0 2022-08-24 23:30:23 +08:00
linker SDK v2.11.1 2022-04-08 22:46:35 +08:00
mcux/linkscripts Updated to v2.12.1 2022-12-08 23:33:41 +08:00
app_config.h Updated to v2.12.1 2022-12-08 23:33:41 +08:00
board.c Updated to v2.12.0 2022-08-24 23:30:23 +08:00
board.h Updated to v2.12.0 2022-08-24 23:30:23 +08:00
clock_config.c SDK v2.11.1 2022-04-08 22:46:35 +08:00
clock_config.h SDK v2.11.1 2022-04-08 22:46:35 +08:00
dcd.c SDK v2.11.1 2022-04-08 22:46:35 +08:00
dcd.h SDK v2.11.1 2022-04-08 22:46:35 +08:00
flash_partitioning.h SDK v2.11.1 2022-04-08 22:46:35 +08:00
lwipopts.h SDK v2.11.1 2022-04-08 22:46:35 +08:00
main_wifi.c SDK v2.11.1 2022-04-08 22:46:35 +08:00
mcuboot_app_support.c Updated to v2.12.0 2022-08-24 23:30:23 +08:00
mcuboot_app_support.h SDK v2.11.1 2022-04-08 22:46:35 +08:00
ota_demo_wifi_v3_10.xml Updated to v2.12.0 2022-08-24 23:30:23 +08:00
pin_mux.c SDK v2.11.1 2022-04-08 22:46:35 +08:00
pin_mux.h SDK v2.11.1 2022-04-08 22:46:35 +08:00
readme.txt Updated to v2.12.0 2022-08-24 23:30:23 +08:00
readme_modules.txt SDK v2.11.1 2022-04-08 22:46:35 +08:00
sdmmc_config.c Updated to v2.12.0 2022-08-24 23:30:23 +08:00
sdmmc_config.h Updated to v2.12.0 2022-08-24 23:30:23 +08:00
wifi_bt_config.c SDK v2.11.1 2022-04-08 22:46:35 +08:00
wifi_bt_config.h SDK v2.11.1 2022-04-08 22:46:35 +08:00
wifi_config.h Updated to v2.12.1 2022-12-08 23:33:41 +08:00

readme.txt

Overview
========
This example demonstrates how to perform OTA firmware update of the board using AWS IoT.

For Wi-Fi connection:
Before building the example application select Wi-Fi module macro in the app_config.h. (see #define WIFI_<SoC Name>_BOARD_<Module Name>).
For more information about Wi-Fi module connection see:
    readme_modules.txt
    Getting started guide on supported modules configuration:
    https://www.nxp.com/document/guide/getting-started-with-nxp-wi-fi-modules-using-i-mx-rt-platform:GS-WIFI-MODULES-IMXRT-PLATFORM


Toolchain supported
===================
- IAR embedded Workbench  9.30.1
- Keil MDK  5.37
- GCC ARM Embedded  10.3.1
- MCUXpresso  11.6.0

Hardware requirements
=====================
- Micro USB cable
- evkbimxrt1050 board
- Personal Computer


Board settings
==============

Prepare the Demo
================
The demo requires MCUBoot bootloader to be present in the FLASH memory to function properly.
It is recommended to build and program the bootloader first, then go on with the application.
Please refer to respective readme of the mcuboot_opensource example and follow the steps there before you continue.

Prior launching the demo it is recommended to pre-build image of modified version of the application to test the OTA update process.
For the new version to get recognized it is required to use a higher version number in xAppFirmwareVersion structure. This may be achieved e.g. by modifying the initialization macros used.

For comprehensive guide on seeting up AWS OTA, please see "AWS OTA User Guide.pdf" document.

Before running the demo it is mecessary to configure AWS IoT Console and update some of project files:

1.  Create AWS Account: https://console.aws.amazon.com/console/home

2.  Configure device in the AWS IoT Console base on this guide: https://docs.aws.amazon.com/iot/latest/developerguide/iot-sdk-setup.html

    Make note of example's "Thing name" and "REST API endpoint". These strings need to be set in the "aws_clientcredential.h".

    Example:
        static const char clientcredentialMQTT_BROKER_ENDPOINT[] = "abcdefgh123456.iot.us-west-2.amazonaws.com";
        #define clientcredentialIOT_THING_NAME "MyExample"

    In the next step you will get the "device certificate" and the "primary key". The device certificate and private key needs to be opened in text editor and its content copied into the "aws_clientcredential_keys.h".
    Or you can use the CertificateConfigurator.html (mcu-sdk-2.0\rtos\freertos\tools\certificate_configuration) to generate the "aws_clientcredential_keys.h".

    Example:
        #define keyCLIENT_CERTIFICATE_PEM "Paste client certificate here."

        Needs to be changed to:

        #define keyCLIENT_CERTIFICATE_PEM "-----BEGIN CERTIFICATE-----\n"\
        "MIIDWTCCAkGgAwIBAgIUfmv3zA+JULlMOxmz+upkAzhEkQ0wDQYJKoZIhvcNAQEL\n"\
        .
        .
        .
        "mepuT3lKmD0jZupsQ9vLQOA09rMjVMd0YPmI9ozvvWqLpjVvNTKVhsf/3slM\n"\
        "-----END CERTIFICATE-----\n"

    In the same way update the private key array.

3.  In case your board connects to the Internet using WiFi, it is necessary to configure also WiFi parameters in "aws_clientcredential.h",
    namely "clientcredentialWIFI_SSID" and "clientcredentialWIFI_PASSWORD".
    Otherwise connect board's RJ45 to a network with Internet access.
    Either way the example expects IP configuration to be assigned by DHCP server.

4.  Open example's project and build it.
    Known issue: MDK linker issues warning about unused boot_hdr sections. This does not affect the functionality of the example.

5.  Connect a USB cable between the PC host and the OpenSDA USB port on the target board.

6.  Open a serial terminal on PC for OpenSDA serial device with these settings:
    - 115200 baud rate
    - 8 data bits
    - No parity
    - One stop bit
    - No flow control

Running the demo
================
To get the application properly executed by the bootloader, it is necessary to put signed application image to the primary application partition.
There are multiple options how to achieve that, however in principle the are two main methods (both presuming the bootlaoder is already in place):

a) programing signed application image to the primary application partition using an external tool (direct method)
b) jump-starting the application by debugger, performing OTA update with the signed image, resetting the board and letting the bootloader to perform update (indirect method)

The latter method is described step by step below:

1.  Load the demo project and build it.
    Known issue: MDK linker issues warning about unused boot_hdr sections. This does not affect the functionality of the example.
    
2.  Prepare signed image of the application from raw binary as described in the mcuboot_opensource readme.
     - In case of MCUXpress raw binary may not be generated automatically. Use binary tools after right clicking Binaries/.axf file in the project tree to generate it manually.
    
3.  Launch the debugger in your IDE to jump-start the application.
     - In case of MCUXpresso IDE the execution stalls in an endless loop in the bootloader. Pause the debugging and use debugger console and issue command 'jump ResetISR'.

4.  The OTA demo connects to the cloud service and expects an update package to be deployed.
    Plese refer to https://docs.aws.amazon.com/freertos/latest/userguide/ota-manager.html on how to create an update job with the signed image.
    Note: the image signed for MCUBoot (using imgtool) needs to be further signed for AWS OTA job. These are distinct signatures that are being checked at different stages of the OTA/boot process.
    
5.  After the OTA agent (that is part the the demo) gets notification about the update it starts downloading the image and storing it into secondary application partition.

6.  Once the image is downloaded, bootloader is notified about it and reboot in test-mode takes place.
    If the updated firmware is able to run without issues the update is made permanent automatically.