Skip to content

This repository contains two MPLAB® X projects designed to showcase the 8-Bit MDFU Client library and the ecosystem it creates.

Notifications You must be signed in to change notification settings

microchip-pic-avr-solutions/pic16f18446-cnano-8bit-mdfu-solution-mplab-mcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microchip Technologies Inc.

8-Bit Microchip Device Firmware Update (MDFU) Solution for the PIC16F18446 Curiosity Nano Evaluation Kit

Introduction

This repository provides two MPLAB® X projects that work together to demonstrate how the 8-Bit MDFU Client library can be used to create an efficient development ecosystem in MPLAB® X that also supports firmware updates.

Hardware Requirements

Software Requirements

Hardware Setup

  1. Connect the PIC16F18446 Curiosity Nano Evaluation Kit to the PC using the USB-A to UBS Micro B.

images/PIC16F18446_Hardware.jpg

Demonstration

Introduction

  1. Bootloader Client Project

    • UART Communication: UART is being used to transfer the new application program data from the Host to the Client through the debugger's CDC ports.
      • Baudrate 115200
      • TX: RB4
      • RX: RB6
    • CRC32 Verification: The client firmware will compute a CRC32 over the application code and compare that value against a known CRC stored at an absolute address at the end of the application image.
    • Entry Pin Enabled: The bootloader sequence can be initiated through a hardware IO pin if held down at reset.
    • Indicator Pin Enabled: The client firmware will indicate if the bootloader is running by holding the LED on.
    • Application Start Address is 0x1000 (word address): The client firmware is configured to install the application code at address 0x1000 and the bootloader partition will include all of PFM from word address 0x0000 to 0xFFF.
  2. Application Project:

    • Supports push button DFU initialization: The application firmware supports pushing the on-board switch to initiate a DFU by using the forced entry mechanism of the bootloader client.
    • Supports message based DFU initialization: The application firmware supports receiving an 'r' character over the CDC ports to erase the footer data of the application and cause a DFU to be initialized.
      • Baudrate 9600
      • TX: RB4
      • RX: RB6
    • Blinks the LED using a timer interrupt: The application firmware is configured to blink the on-board LED at a rate of 200 ms using a timer interrupt.
    • Multiple project configurations:
      • Standalone Configuration: This project configuration is used to build the firmware images that can be loaded through the client firmware.
      • Combined Configuration: This project configuration is used to combined the bootloader firmware and the application firmware into one single hex file. This is a very helpful practice that allows the debugger to be run on both projects at one time.

Execution

  1. Open MPLAB® X IDE.

  2. Select File>Open Project>PIC16F18446_Application.X.

images/openAppProject_basic.PNG

  1. Right click PIC16F18446_Application in the Projects tab and select Set as Main Project.

images/setAppAsMain_basic.PNG

  1. Build the application configurations.

    a. Select Standalone from the Set Project Configuration drop-down menu and then select Clean and Build Main Project.

    images/buildStandaloneImage_basic.PNG

    b. Next, select Combined from the Set Project Configuration drop-down menu.

    images/setAppConfig_basic.PNG

  2. Open the Data Visualizer and connect to the device through the COM port connected to the on-board debugger.

images/openDataVisualizer_basic.PNG

  1. Select Make and Program Device Main Project and then watch the Data Visualizer console to watch the application begin running.

images/runningAppDV_basic.PNG


images/runningApp_basic.gif

  1. Send an 'r' character to the application code using the Data Visualizer to initiate a device firmware updated.

images/initiateDFU_basic.PNG


images/BootModeRunning_basic.jpg

At this point in the demonstration, the MDFU Client firmware has taken control of the MCU core and is waiting for protocol commands to be sent to it over UART. At this point in time we can begin to send the new application firmware image.

  1. Disconnect from the device's serial port by clicking on the red stop button available on the Data Visualizer.

  2. Open the example update script file by navigating to Projects>Important Files>run_pymdfu.bat or Projects>Important Files>run_pymdfu.sh and update the name of the target serial port to the same name shown in the Data Visualizer.

  3. Right click on the script file and select Run

images/runUpdateExampleScript_basic.PNG


images/updateSuccessful_basic.PNG

IMPORTANT: To run these update scripts from within MPLAB® X you must include your Python instance in your PATH variable. If the tools are not executable from within MPLAB® X for any reason you can run the same scripts from another terminal or reinstall your Python instance with the correct PATH configuration.

Example Scripts

This repository has provided a collection of scripts that demonstrate how to call the various python tools used to create this efficient ecosystem.

Script Name Description
build_image.bat/build_image.sh This script can be called by the post build step of the Standalone application configuration to build the application binary image. This script can also be run on its own and it will assume that the application hex is found in the dist/Standalone/production path.
run_pymdfu.bat/run_pymdfu.sh This script can be run from within MPLAB® X by right clicking on the script file (e.g., Projects Tab>Important Files>run_pymdfu.bat) and selecting Run. This could also be run as a standalone script but it would be just as easy to copy the command out and use it in your own terminal directly instead of running this script from your terminal.

References

For additional information, refer to the following resources:

Back to Top