6.1.5.2.2 Running the Application

  1. Mount the AVR128DB48 Curiosity Nano host board, the Serial Flash board and the RNWF11 Add On Board on Curiosity Nano base board at respective headers. For more details about the board placement in the Curiosity Nano base, refer to the Figure 6-1.
  2. Connect the debugger USB port on the AVR128DB48 Curiosity Nano board to computer using a micro USB cable.
  3. Change the configuration. There are two options to change the configuration:
    1. Option 1: Change the configuration manually in the code.
      1. Open the code in MPLAB IDE v6.00 or higher and add Home AP and device information in the application code.
        • In rnwf_app.h, add Wi-Fi configurations in HOME_AP_SSID, HOME_AP_PASSPHRASE, HOME_AP_SECURITY.
        • In rnwf_ota_service.h, OTA_CONF_PORT can be set if the port number at which OTA service runs needs to be changed.
    2. Option 2: Change the configuration via MCC Melody.
      • For more details about Wi-Fi configurations, refer Figure 3-5.
        1. The following fields can be configured via MCC Melody Wi-Fi settings:
          1. SSID
          2. Security Type
          3. Passphrase
      • Refer Figure 3-8 to understand how to make OTA configuration changes.
        1. The following fields can be configured via MCC Melody OTA configuration settings:
          1. OTA Tunnel Port
      • Refer to the Appendix A.4 - Merging Manual Changes Into Regenerated Code to understand how to merge code upon regeneration.
  4. Save the changes and then build and program the project.
    Figure 6-14. Make and Program Device Main Project
  5. Connect to the “USB to UART” COM port and configure the serial settings as follows:
    1. Baud – 115200
    2. Data – 8 Bits
    3. Parity – None
    4. Stop – 1 Bit
    5. Flow Control – None
  6. The board boots up and connects to Home-AP, as per the configurations given in step 3. After the successful Wi-Fi connection, the device opens up a TCP tunnel and wait for the OTA server and firmware image details from the configurator tool. In the first boot up, the device read the RNWF11 module firmware image and copies it to the SPI flash factory image partition as the SPI flash partitions are empty. SPI flash memory have three partitions:
    1. Factory image partition
    2. 1st image partition
    3. 2nd image partition
    These partition images are used for fail-safe recovery mechanism. In case the OTA firmware upgrade fails and corrupts RNWF11 program flash, the images stored in these partitions can be used for recovery. The fail-safe mechanism is implemented in rnwf_app.c
    Figure 6-15. Initial Firmware Version
    Note: The RN firmware image is copied to the SPI flash factory partition in the first boot as the SPI flash partition is empty. If the user wants to re-initialize the SPI flash and copy the RN firmware to factory partition again, user can press and hold PB2 button for 10 second on the AVR128DB48 Curiosity Nano host board to erase the SPI flash.
  7. Two example sample firmware binaries are available in the ./ota_demo/tools folder.
    Following are two image types:
    1. at_cmd_app_rtos.X.production.ota.bin – the image which contain the default FLFS contents. The FLFS contents include the certificates and keys for secure connection.
    2. at_cmd_app_rtos.X.production.without_flfs.ota.bin – the image which do not contain the FLFS contents. This image is used when the user prefer to retain the FLFS contents after DFU is performed.

    Start a python HTTP server using the following command.

    Figure 6-16. Loop HTTP Server
  8. Run the python OTA configurator tool from the ./ota_demo/tools folder, as illustrated in the following figure.
    Figure 6-17. OTA Configurator
  9. Now the device creates a HTTP link with the OTA server and starts downloading the image file.
    Figure 6-18. Image Download
  10. After successfully downloading the image, the DFU is triggered, and firmware is flashed into the RNWF11 module.
    Figure 6-19. DFU Progress
  11. Upon successful DFU, the host will Reset and print the RNWF11 module’s new firmware information.
    Figure 6-20. Updated Firmware