The bootloader is a firmware program, and in our case, with our microcontroller is resided in flash memory. Basically loads main functionality of all interface and peripherals and has command line interface tools to make an upgrade of our existing application.
This bootloader was done by Freescale Semiconductors and for future freescale devices this will be incorporated in future devices. There are several flavors of bootloaders (FLASH and ROM based).
Remember, the use of a serial bootloader, in this case, do not replace debugging tools for project development, it is just only a solution for implement In-System-Reprogramming easily without stopping a process. The bootloading sequence is done using the OpenSDA interface but basically is serial based bootloader to the MCU.
A better use of a bootloader is to implement in a serial line of devices ready to flash; companies use a bootloader to program lots of units and ship pre-programmed or in a facility, the commodity to re-program a line of devices in a sub-network if you are far away from them.
Below is demonstrated the functionality of the bootloader when inserted on chip.
Some other features of advantage of using a bootloader are:
- C/C++ Source code provided under a permissive BSD open source license
- Supported Serial communications with active peripheral detection
- Common packet-based protocol for all peripherals
- Packet error detection and retransmission
- Configurable for flash-based and ROM-based bootloaders
- Flash security and flash region protection options
- Command-line and GUI tools provided for Windows
- And so on.
This demonstration uses the Flash Bootloader precompiled and tells you how to update to the OpenSDA interface. When you buy the FRDM-K64F Board it is ready to use with mbed, so you have to make a manual process to update to the bootloader application.
What is OpenSDA
OpenSDA is an open-standard serial and debug adapter, is a hardware and software approach using the serial port to debug and program Freescale Microcontrollers (Kinetis). It is based on Kinetis K20 MCU because it has USB capability.
The current and detailed in this guide OpenSDA i use is the OpenSDAv2. OpenSDAv2 is an open source bootloader and it comes by default with your freedom board, it enables you the use of your microcontroller with the mbed platform and is called CMSIS-DAP.
OpenSDA Firmware (Look Carefully)
You can use any of these OpenSDAv2 firmware:
- mbed CMSIS-DAP for FRDM-K64F
- The current version up to march 2015 is 0221_k20dx128_k64f_0x5000.bin
- P&E Micro
- Segger JLink
- Install the J-Link Software and Documentation Pack for Windows on the Segger page.
- Use the JLink_OpenSDA_V2.bin
I tested all above firmwares with the Freedom K64F board and i can mention you that if you don’t want problems, just beleive me and go for it.
Updating Firware to OpenSDAv2 – P&E Micro.
Step 1. Entering Bootload Option.
First recognize the buttons and interface to use with the Kinetis Freedom Board.
- Disconnect the board from the PC. Remember, we are using the Open SDA port.
- Hold the RESET Button
- Plug again the USB port on the PC
- After a few seconds, release the reset button.
The result, in hardware should a GREEN LED flashing at a estimated rate of 1 second.
The result, in the PC should be the bootloader window.
Step 2. Download OpenSDAv2 Firmware, mbed
As explained in the previous section, install the firmware corresponding to the CMSIS-DAP for mbed platform, update to the latest firmware.
The result in hardware must be the same GREEN LED flashing approximately three (3) times per second, this told us that the mbed CMSIS-DAP download is complete.
Step 3. Reboot the FRDM-K64F Board.
- Unplug the board
- Plug again the board (do not hold the reset button)
The result in the PC can be seen in the explorer window declared as a mass storage device and in the Device Manager window, listed as a CDC USB device.
Step 4. Download the Bootloader to the FRDM-K64F Board
- Navigate and download the bootloader files on the freescale website.
- Unzip to the desired location
- Navigate to the folder:
- Drag and drop the file: freedom_bootloader,bin
- Reset the board. Important!
The result in the PC must be the same figure as in step 3.
The result in hardware must be the GREEN LED in ON state, fixed.
Step 5. Try the blhost application.
- Open a CMD window and navigate to:
- Write this command to check the bootloader status (in my case is COM5, you can check in device manager)
- blhost -p COM6 — get-property 1
- Write this command to check the version (in my case doesn’t work).
- blhost -u — get-property 1
Step 6. Test the Bootloader Application
- Navigate to the location <install_path>\FSL_Kinetis_Bootloader_1_1_0\bin\win\KinetisUpdater
- Launch Kinetis Updater and follow the images below.
- In Device Configuration, select the COM port corresponding to the OpenSDA
- Press Home to return
- In Select Image, navigate to
- Select the file led_demo_FRDM-K64F_a000.bin
- Return Home
- In Update
- Press the update button
- The board must boot itself and the application must be running with the led changing colors.
Step 7. Returning from Application to Bootloader Mode.
- Simply hold the SW2 button.
- Press the RESET button
- Follow step 6 if you want to burn another application.
- Remember the start address of the flash now must be 0xA000.
- You are done!
Basically I made this tutorial using the Freedom K64F Bootloader Demo User Guide in Freescale site, named F64FBTLDRDEMOUG.
I recommend you read the file: Bootloader Solution for Kinetis MCUs FTF-SDS-F0108.
All source code is on the <install_path>\FSL_Kinetis_Bootloader_1_1_0\src\ folder.
You can check the complete documentation of this bootloader on the Kinetis Bootloader Page.