1.3.1 PIC32 WFI32E Curiosity Board: Building and Running the SPI 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/spi_flash_bootloader/.
To build the application, refer to the following table and open the project using its IDE.
Bootloader Application
| Project Name | Description |
|---|---|
| bootloader/firmware/pic32mz_w1_curiosity.X | MPLAB X Project for PIC32 WFI32E Curiosity Board |
Programmer Application
| Project Name | Description |
|---|---|
| app_programmer/firmware/pic32mz_w1_curiosity.X | MPLAB X Project for PIC32 WFI32E Curiosity Board |
Setting Up PIC32 WFI32E Curiosity Board
- Connect the Debug USB port on the board to the computer using a micro USB cable
- On the GPIO Header (J207), connect U1RX (Pin 13) and U1TX (Pin 23) to TX and RX pin of any USB to UART converter (e.g., USB UART Click board)
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
- Open the bootloader project bootloader/firmware/pic32mz_w1_curiosity.X in the IDE.
- Ensure that the
app_programmer/firmware/pic32mz_w1_curiosity.X is added as a
loadable project to bootloader application.
- As the SPI 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.

- Build and program the bootloader application using the IDE.
- Once programming is done,
bootloader starts execution and directly jumps to application space to run the
programmer application.
- RED LED (D202) starts blinking indicating that the programmer application is running
- Open the programmer application project app_programmer/firmware/pic32mz_w1_curiosity.X in the IDE.
- Update
app_programmer/firmware/src/config/pic32mz_w1_curiosity/user.h to
use GREEN LED (D204) instead of RED LED (D202) as
below.
#define LED_TOGGLE() LED_GREEN_Toggle()
- Clean and Build the project to generate the binary (Do not program the binary).
- Run the uart_host.py
from command prompt to program the updated programmer application binary in SPI
Flash
memory.
python <harmony3_path>/bootloader_apps_serial_memory/tools/uart_host.py -v -i <COM PORT> -d pic32mzw -a 0x90000000 -f <harmony3_path>/bootloader_apps_serial_memory/apps/spi_flash_bootloader/app_programmer/firmware/pic32mz_w1_curiosity.X/dist/pic32mz_w1_curiosity/production/pic32mz_w1_curiosity.X.production.bin - Following figure shows output of
successfully programming the programmer application.
- RED LED (D202) should still be blinking

- Run the uart_host.py
from command prompt to send a Reboot command. This command updates MetaData and
triggers Bootloader to program the updated binary from SPI Flash to Internal
Flash.
python <harmony3_path>/bootloader_apps_serial_memory/tools/uart_host.py -v -i <COM PORT> -r

- Once Firmware Update is
successful, GREEN LED (D204) should start blinking indicating updated programmer
application running.
- If there was any error, the user may need to power cycle the device to retry firmware upgrade
- Update
app_programmer/firmware/src/config/pic32mz_w1_curiosity/user.h to
revert to RED LED (D202) from GREEN LED (D204) as
below.
#define LED_TOGGLE() LED_RED_Toggle()
- Clean and Build the project to generate the binary (Do not program the binary).
- Repeat Step 8-9.
- The user should see GREEN LED (D204) still blinking
- Press the Switch SW1/SW200 to update MetaData and trigger Bootloader to program the updated binary from SPI Flash to Internal Flash.
- Once Firmware Update is
successful, RED LED (D202) should start blinking 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)
- To bootload any other application
refer to the Application ConfigurationsNote: This application should have programming capabilities to SPI Flash Memory.
- Once done, repeat the applicable steps mentioned in Running the Application
