2.3.4.1 DFU Utility

The DFU utility is a Python-based tool that supports erase and write operations on the WINCS02IC Flash memory. It also enables modification of image sequence number and source address in the header section. For more details on the DFU utility, go to WINCS02PE (rnwf-utilities-vx.x.x\dfu).
Figure 2-8. DFU Utility Path

To use the DFU utility, the user needs to meet certain hardware and software requirements. The following are the hardware and software requirements:

Hardware

The following are the hardware requirements:

  • PIC32WM-BW1 Curiosity Board or PIC32WM-BW1 Wi-Fi® and Bluetooth® Low Energy Combo MCU Module
  • FTDI cable (TTL-232R-3V3)

Software

The following are the operating system requirements:
  • For Windows: FTDI D2XX Direct Driver for Windows.
  • For Linux (Ubuntu): The Linux operating system loads the Virtual COM Port (VCP) driver (by default), during the process the script takes care of loading the appropriate driver D2XX/VCP.
    Note: sudo permissions are required to run the script.
  • For more details about the D2XX driver installation, refer to the AN_220 FTDI Drivers Installation Guide for Linux (FT_000723).
     $ tar zxvf libftd2xx-x86_64-1.4.27.tgz 
     $ sudo cp -r release/build/lib* /usr/local/lib 
     $ cd /usr/local/lib/ 
     $ sudo ln -s libftd2xx.so.1.4.27 libftd2xx.so 
     $ sudo chmod 0755 libftd2xx.so.1.4.27 
     $ sudo ldconfig /usr/local/lib/

Python 3

  • ftd2xx==1.3.2
  • pyserial==3.5

Hardware Setup for DFU

The PIC32WM-BW1 Curiosity Board/PIC32WM-BW1 Wi-Fi and Bluetooth Low Energy Combo MCU Module exposes the following pins to perform DFU. To perform the DFU on the PIC32WM-BW1 Wi-Fi and Bluetooth Low Energy Combo MCU Module, the user needs to set up the hardware as follows:

Table 2-1. PIC32WM-BW1 Wi-Fi® and Bluetooth® Low Energy Combo MCU Module Pin Descriptions for DFU
PIC32WM-BW1 Wi-Fi® and Bluetooth® Low Energy Combo MCU ModulePinDescriptionPin# on FTDI Header (J8) from PIC32WM-BW1 Curiosity Board
W_MCLR52Master Clear Reset (MCLR)J8.2
DFU_Rx/Strap1/W_PB054DFU pattern clock/UART RxJ8.4
DFU_Tx/Strap2/W_PB153DFU pattern data/UART TxJ8.5
GND32 or 33GNDJ8.1
Note: While performing the DFU, the PIC32WM-BW1 Curiosity Board/PIC32WM-BW1 Wi-Fi® and Bluetooth® Low Energy Combo MCU Module must be powered ON.

DFU Setup

The DFU utility simplifies the dependencies installation by providing a requirement file with all the necessary Python modules. Before running the DFU utility, navigate to rnwf_utilities_vX.X.X\dfu, and install all the requirements using the following Python command.
>python -m pip install -r requirements.txt
The following is the DFU utility command syntax:
> python do_dfu.py [-h] [-b BIN_FILES BIN_FILES | -e ERASE [ERASE ...]] [-s SEQ_NUM] [-p PORT] [-v]

options:
  -h, --help            show this help message and exit
  -b BIN_FILES BIN_FILES
                        Write option: Erase and write binary file to hexadecimal starting address or section (low,
                        high, file-system).
  -e ERASE [ERASE ...]  Erase option: Provide either the hexadecimal starting address and whole number of 4096 byte
                        pages to erase, or just the section to erase (low, high, file-system).
  -s SEQ_NUM            Modifies image sequence number. Example format: -s 0xffeeddcc
  -p PORT, -port PORT   User specific serial number of the FTDIport, else autodetect mechanism will be used.
  -v, -verbose
Figure 2-9. PIC32WM-BW1 Curiosity Board DFU Setup

The following section provides command examples for flashing and erasing the different image partitions.

Update Single/Combined Image

The single image update flashes both image1 and image2 partitions along with the file system (certificate store). The user can specify the partition as low or by its starting address (0x60000000).
python do_dfu.py -b test_binaries/wincs02.bootable.bin 0x60000000
Figure 2-10. Update Single/Combined Image

Update Over-The-Air (OTA) Image

The OTA image only includes the header and the firmware image and does not include the filesystem. The OTA image can be updated in the image1 (low) partition or image2 (high) partition.
python do_dfu.py -b test_binaries/wincs02_dfu_ota.bootable.bin low
To update the sequence number of the given firmware image, use the -s option as follows:
do_dfu.py -b test_binaries/wincs02_dfu_ota.bootable.bin low -s 0xffffffc0
Figure 2-11. Update OTA Image

Erase Partition

The DFU utility is flexible to erase only the given partition of the Flash map. Use the -e option to erase either low (image1) or high (image2). The erase option is useful to switch the bootable image from other partitions of the Flash map.
python do_dfu.py -e high
Figure 2-12. Erase Partition