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/pic18f56q24-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 PIC18F56Q24 Curiosity Nano Evaluation Kit

Introduction

This repository contains two MPLAB® X projects designed to showcase the utilization of the 8-Bit MDFU Client library in creating an efficient development ecosystem within MPLAB® X, which also facilitates firmware updates.

Hardware Requirements

Software Requirements

Hardware Setup

  1. Connect the PIC18F56Q24 Curiosity Nano Evaluation Kit to the PC using the USB-A to UBS-C.

Note: Brand-new device of this kind is programmed with a simple application that blinks the LED. So it is not a problem if you begin to see the device blinking the LED after this setup step.

images/PIC18F56Q24_Hardware.jpg

Demonstration

Introduction

  1. Bootloader Client Project:

    • UART Communication: UART transfers the new application program data from the Host to the Client through the debugger's CDC ports.
      • Baudrate 115200
      • TX: RB5
      • RX: RB4
    • 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 0x4000: The client firmware is configured to install the application code at address 0x4000 and the bootloader partition will include all of PFM from address 0x0000 to 0x3FFF.
  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: RB5
      • RX: RB4
    • 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 builds the firmware images that can be loaded through the client firmware.
      • Combined Configuration: This project configuration combines 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 concurrently.

Execution

  1. Open MPLAB® X IDE.

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

images/openAppProject_basic.PNG

  1. Right click PIC18F56Q24_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. During this time we can 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 aim to demonstrate how to call 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 terminal directly instead of running this script from your file explorer.

References

For additional information, refer to the following resources:

Back to Top