Skip to content

microchip-pic-avr-solutions/pic32cm-mc00-cnano-mdfu-solution-mplab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microchip logo

Microchip Device Firmware Update (MDFU) Bootloader Solution for PIC32CM-MC00 Curiosity Nano Evaluation Kit

This repository contains an optimized version of the Microchip Device Firmware Update (MDFU) bootloader client using the PIC32CM-MC00 Curiosity Nano Evaluation Kit. This example is designed to demonstrate a bootloader ecosystem using the MDFU Protocol on a Cortex®-M0+ microcontroller.

This project utilizes peripheral and device drivers generated by MPLAB® Harmony 3 but does not require Harmony to operate. Refer to the following links for more information.

This repository contains two MPLAB® X projects: one is a bootloader client that supports firmware updates via the MDFU Protocol over UART, and the other is a sample test application that blinks an LED and prints some information to the console.

To clone or download these applications from Github, go to the main page of this repository and then click Clone button to clone this repository or download as a .zip file.

Contents Summary

Folder Description
Bootloader Contains the MDFU bootloader for the PIC32CM-MC00 Curiosity Nano
Application Contains an example application for the PIC32CM-MC00 Curiosity Nano configured to work with the corresponding bootloader project
docs Client API documentation and Doxygen configuration file which can be used to generate the Doxygen document locally

Bootloader

Note: This content does not require MPLAB® Harmony 3 and uses custom start-up code and linker script that is not generated by Harmony. Be sure that you do not overwrite this logic if you intend on generating new code using Harmony.

The bootloader application supports basic features including:

  • File-Transfer based approach to DFU using the MDFU Protocol
  • CRC-32 verification using the Device Service Unit (DSU) peripheral supported on PIC32CM Cortex®-M0+ MCU
  • Software re-entry through a RAM defined memory region
  • LED indicator for the bootloader

Application

The example application includes the following features:

  • Demonstrates basic logic by printing messages to the serial terminal
  • Re-enters Bootloader mode when the on-board switch is pressed
  • Blinks an LED using a timer interrupt
  • Provides a default application image file (PIC32CM_DefaultTest.img) that can be flashed directly without requiring the application project to be compiled

Hardware and Software

Operation

  1. Open MPLAB® X IDE

  2. Open the bootloader project by navigating to File > Open Project.... Select the bootloader project from the file system navigator, <repository path>/Bootloader/PIC32CM_MDFU.X.

  3. In the Projects tab, right click on the PIC32CM_MDFU project folder and select Set as Main Project.

  4. From the Projects tab, right click again the PIC32CM_MDFU project folder and select Clean and Build.

  5. Again, right click the PIC32CM_MDFU project folder and select Make and Program Device.

The bootloader will indicate that it is running and ready to receive an image by illuminating the on-board LED.

  1. Open the application project by navigating to File > Open Project.... Select the application project from the file system navigator, <repository path>/Application/PIC32CM_TestApp.X.

  2. From the Projects tab, right click again the PIC32CM_TestApp project folder and select Clean and Build.

  3. Update the serial port found in the run script. From the Files tab, open the PIC32CM_TestApp > run.bat on Windows or the run.sh if you are on Mac or Linux. Update the port name as shown below.

pymdfu update -v debug --tool serial --port <Your Port Name> --baudrate 115200 --image PIC32CM_TestApp.img

Tip: You can use the MPLAB Data Visualizer to find the port name of the Curiosity Nano.

  1. From the Files tab, right click the run script you updated and then select Run from the menu.

Note: This process will execute the pymdfu update command through a MPLAB X console and print the output within the IDE. If you do not have access to your Python environment from within MPLAB X you can copy the command from inside the script into any terminal with access to the pymdfu Python tool.

$ > pymdfu -V
pymdfu version 2.5.1.9
MDFU protocol version 1.2.0

$ > pymdfu update --tool serial --port COM3 --baudrate 115200 --image PIC32CM_TestApp.img
Upgrade finished successfully

Tip: Adding the CLI flag -v debug onto the end of the pymdfu command will enable debug logging for the Python tool allowing you to see the data transfers with more detail.

  1. Observe that the LED is now flashing. Then connect your device to a terminal application and press the on-board switch to see a message printed to the console and re-enter the bootloader code.

Tip: You can use the MPLAB Data Visualizer to see the program print statements by opening the MPLAB Data Visualizer and selecting the Display as text in terminal button one the Curiosity Nano's port name.

Data Visualizer Settings:

  • Baudrate: 115200
  • Char Length: 8
  • Parity Bit: None
  • Stop Bits: 1
  • DTR: Enabled
  • RTS: Enabled
############ Example Bootloader Application ############

Application is running and the LED is blinking.

############ Switch was pressed, entering bootloader mode ############

############ Disconnect from the device port and load a new application using pymdfu ############
  1. After you have re-entered the bootloader code you will once again see the LED is illuminated and has stopped blinking. You are now free to disconnect your terminal from the Curiosity Nano's port and send a new application image using pymdfu.

Note: A default application image has been generated and included in the repo for testing purposes. If you do not wish to build the image using the steps above you can use the default test image for testing the client update logic.

$ > pymdfu update --tool serial --port COM3 --baudrate 115200 --image PIC32CM_DefaultTest.img
Upgrade finished successfully

References

For additional information, refer to the following resources:


Back to Top

Packages

No packages published

Languages