1.4.6 PIC32WM BZ6 Curiosity Evaluation Board: Building and Running the QSPI Flash Bootloader Applications

Downloading and Building the Application

To clone or download this application from GitHub, go to the main page of this repository and then click Clone button to clone this repo or download as zip file. This content can also be download using content manager by following these instructions.

Path of the application within the repository is apps/qspi_flash_bootloader/.

To build the application, refer to the following table and open the project using its IDE.

Bootloader Application

Project NameDescription
bootloader/firmware/pic32wm_bz6_curiosity.XMPLAB X Project for PIC32WM BZ6 Curiosity Evaluation Board

Programmer Application

Project NameDescription
app_programmer/firmware/pic32wm_bz6_curiosity.XMPLAB X Project for PIC32WM BZ6 Curiosity Evaluation Board

Setting Up PIC32WM BZ6 Curiosity Evaluation Board

  • Connect the Debug USB port on the board to the computer using a micro USB cable

Setting Up the Host Script

  • Refer to the UART Host Script Help for setting up the uart_host.py utility used to send the application binary from host PC
    • There will be no reset command sent from host after programming by default
    • Reboot command has to be sent separately only after successful programming to trigger bootloader from programmer application

Running the Application

  1. Open the bootloader project bootloader/firmware/pic32wm_bz6_curiosity.X in the IDE.
  2. Ensure that the app_programmer/firmware/pic32wm_bz6_curiosity.X is added as a loadable project to bootloader application.
    • As the QSPI Flash memory may not have any valid binary required by bootloader for the first time. Adding the app_programmer as loadable allows MPLAB X to create a unified hex file and program both these applications in their respective memory locations based on their linker script configurations.
  3. Build and program the bootloader application using the IDE.
  4. Once programming is done, bootloader starts execution and directly jumps to application space to run the programmer application.
    • RGB_LED (GREEN) starts blinking every 500 ms indicating that the programmer application is running
  5. Open the programmer application project app_programmer/firmware/pic32wm_bz6_curiosity.X in the IDE.
  6. Update app_programmer/firmware/src/app.c to reduce the LED blink duration from 500 ms to 100 ms as below.
    APP_TIMER_DelayMs(100);
  7. Clean and Build the project to generate the binary (Do not program the binary).
  8. Run the uart_host.py from command prompt to program the updated programmer application binary in QSPI Flash memory.
    python <harmony3_path>/bootloader_apps_serial_memory/tools/uart_host.py -v -i <COM PORT> -d PIC32WM_BZ6 -a 0x1003000 -f <harmony3_path>\bootloader_apps_serial_memory\apps\qspi_flash_bootloader\app_programmer\firmware\pic32wm_bz6_curiosity.X\dist\pic32wm_bz6_curiosity\production\pic32wm_bz6_curiosity.X.production.bin
    
  9. Following figure shows output of successfully programming the programmer application.
    • RGB_LED_RED should still be blinking every 500 ms
  10. To update the firmware, the user can either:
    • Press USR BTN 1, then press NMCLR twice, OR
    • Run uart_host.py from the command prompt to send a Reboot command, then press NMCLR. This process updates the MetaData and triggers the Bootloader, which programs the updated binary from QSPI Flash to Internal Flash.
      python <harmony3_path>/bootloader_apps_serial_memory/tools/uart_host.py -v -i -r
  11. Once Firmware Update is successful, RGB_LED_RED should start blinking every 100 ms indicating updated programmer application running.
    • If there was any error, the user may need to power cycle the device to retry firmware upgrade
  12. Update app_programmer/firmware/src/app.c to revert LED blink duration to 500 ms from 100 ms as below.
    APP_TIMER_DelayMs(500);
  13. Clean and Build the project to generate the binary (Do not program the binary).
  14. Repeat Step 8-9.
    • The user should see RGB_LED (RED) still blinking every 100 ms
  15. Press the Switch USR BTN 1 and then press NMCLR twice to update MetaData and trigger Bootloader to program the updated binary from QSPI Flash to Internal Flash.
  16. Once Firmware Update is successful, RGB_LED (RED) should start blinking every 500 ms indicating updated programmer application running.
    • If there was any error, the user may need to power cycle the device to retry firmware upgrade

Additional Steps (Optional)