By Paolo Alcantara
USB device firmware update (DFU) bootloader provides an easy and reliable way to load new user applications to devices having preloaded the USB DFU bootloader. After loaded, the new user application is be able to run in the MCU. The USB DFU bootloader requires an application running on a PC (USB DFU PC application). The DFU PC application supports loading the firmware to the device by using specific requests as stated in the USB DFU specification class.
The USB DFU bootloader is able to enumerate in two ways:
-USB composite device mode: also know as run time mode. It’s formed of a DFU device plus another USB device class. For this implementation, human interface
device (HID) mouse device is used to avoid increasing the bootloader memory size. The MCU must be in the following conditions prior to enter to this mode:
-DFU device mode: used when DFU is ready to upload or download firmware images by a request made from the USB DFU PC Application. Prior to this mode, the MCU was in USB composite device mode.
A bootloader is a small application that is used to load new user applications to devices. Therefore, the bootloader needs to be able to run in both, the user application and bootloader mode. As an example:
After reset, the device attempts to run the user application. If the user application is not found or corrupted, the device automatically runs into bootloader mode. In case the application is valid and user wants to run bootloader program, external intervention is
required such as pressing a specific key at reset time to force the device entering to bootloader mode.
Full application note and software attached.
Thanks a lot for this very useful app note.
I would like to know if it is possible to modify the USB VID/PID (since my company owns a vendor id...) ?
Will this work with MCF51JM?
I have tried it on IAR EW650+FRDM-KL25Z. It doesn't work. When I look into debugger. It has nothing to do with GPIO differences between TWR and FRDM. I found it is hung in clock setup pll_init().
SIM_CLKDIV1 = 0x1003000 // OUTDIV1 = 0x01, OUTDIV4 = 0x03
MCG_C2 = 0x2D // RANGE=2, HGO=1, EREFS=1, LP=0, IRCS=1
MCG_C1 = 0x98 // CLKS=2, FRDIV=3
/* wait for oscillator to initialize */
while (!(MCG_S & MCG_S_OSCINIT_MASK)) //<=== loop forever for OSCINIT
I am not familiar with KL25Z so far. Would you please give some suggestions?
Change the value of MCG_C2 as the following:
// MCG_C2 = MCG_C2_RANGE(2) | MCG_C2_HGO_MASK | MCG_C2_EREFS_MASK | MCG_C2_IRCS_MASK;
MCG_C2 = (MCG_C2_LOCRE0_MASK | MCG_C2_RANGE0(1) | MCG_C2_EREFS0_MASK);
Yes, the VID and PID are defined in the usb_descriptor.c file.
The VID and PID in the PC inf file are also needed to be modified.
Thanks for your comments. The PLL passed. The code works, I will test the bootloader with my own code.
The code should be revised on website.
Is the source code for the DFU PC Demo software available (or can it be made available)?