1 Introduction
Previously we used sd card to upgrade the program. We have to insert the sd card into the computer every time, copy the program to the sd card, and then insert it into the sd card slot of mcu to update the program. This method seems to be a bit troublesome, so we implemented a more convenient method. It no longer needs to insert or remove the SD card from PC and MCU. Use the usb function of mcu to recognize mcu as a storage U disk. When we need to update the program, connect the MCU’s usb interface to PC. After the computer recognizes it, copy the program that needs to be burned in. Then the bootloader will recognize the file and then upgrade the application. Bootloader detects changes of the file, not the existence of the file. In other words, if the a000.bin file has already existed in the sd card, the application will not be updated. When this a000.bin is overwritten with another a000.bin, the operation of updating the application will be performed.
2 Bootloader’s implementation
The schematic for SD card is shown below. The board uses SDHC module to communicate with SD card.

Figure 1. Figure 1.Schematic for SD card
We use the 2.6.0 version of FRDM-K64F’s SDK. You can download the SDK in our website.
The link is “mcuxpresso.nxp.com”.
The schematic for USB is shown below.
Figure 2. Schematic of USB
Bootloader uses SDHC, fatfs, usb, flash, So we should add files to support them. Our code is based on the example “usb_device_msc_sdcard_lite” that belongs to usb example.
In main code, the program will initialize the usb, sd and fatfs. Then the computer will communicate will MCU. Finally, PC will recognize the mcu as a u-disk.

Figure 3.u-disk
The method of how to update the program and prepare the application has written in this document. You can refer it. https://community.nxp.com/docs/DOC-344903
Use a variable “wrFlag” to check the modification of the file. When we put file into the u-disk, this variable will be set.

Figure 4. Modification of flag
When this variable is set, the program will open the “a000.bin”. Then update the application. Finally, go to the application.

Figure 5. Update the application
3 Run the demo
- Download this bootloader
- Prepare a user application program. We use the “led blinky” as an example. Use it to generate the binary file. Name it as “a000.bin”. Put it into the u-disk. You will see some log in the uart.

- The application will execute automatically
