USB DFU boot loader for MCUs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB DFU boot loader for MCUs

USB DFU boot loader for MCUs

By Paolo Alcantara

RTAC Americas

Mexico 2012

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:

  • MCU doesn’t contain a valid firmware image or doesn’t contain firmware.
  • An external action is applied to MCU such as pressing a button during a reset event. This is dependant of the USB DFU bootloader implementation.

-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:

SocialMedia.JPG

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.



Attachments
Comments

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...) ?

Best regards,

AV

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().

main_kinetis.c 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

       ......

        #ifndef EXTERNAL_OSC

            /* wait for oscillator to initialize */

            while (!(MCG_S & MCG_S_OSCINIT_MASK)) //<=== loop forever for OSCINIT

            {;}

        #endif

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.

Yes

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)?

No ratings
Version history
Last update:
‎09-24-2012 01:56 PM
Updated by: