Debbuging Bootloader and Application Using KDS
Debbuging Bootloader and Application Using KDS
Software versions
The steps described in this document are valid for the following versions of the software tools:
KDS v3.2.0
KBOOT v1.2.0
Contents
1. Overview and concepts ............................................................................................................................. 3
1.1 Kinetis Bootloader............................................................................................................................... 3
1.2 GDB Server .......................................................................................................................................... 3
2. Flashing Bootloader and Application ........................................................................................................ 4
2.1 Flashing freedom_bootloader project ................................................................................................ 4
2.2 Loading demo application using the Kinetis Updater ......................................................................... 8
2.3 Flashing demo application and bootloader using the P&E advanced programming options .......... 14
3. Debugging Bootloader and Application .................................................................................................. 17
3.1 Debugging bootloader and demo application projects using the P&E interface ............................. 17
3.2 Debugging bootloader and demo application projects using the Segger interface ......................... 24
4. Conclusion. .............................................................................................................................................. 31
Appendix A - References ............................................................................................................................. 32
NXP Semiconductor
blhost - command line debug tool to send individual commands to the bootloader .
Kinetis Updater - GUI application to download and flash an application image.
tower_bootloader bootloader designed to execute from target flash memory on the Tower
platform.
freedom_bootloader bootloader designed to execute from target flash memory on the Freedom
platform.
flashloader bootloader designed to execute from target RAM memory on either the Freedom or
Tower platform.
flashloader_loader bootstrap loader designed to execute from flash memory on either the
Freedom or Tower platform. This loader copies an image of the flashloader into RAM, then executes
the flashloader from RAM.
NXP Semiconductor
Import the freedom_bootloader project to KDS by clicking on Menu > File > Import:
NXP Semiconductor
NXP Semiconductor
Build the project and then click on Menu > Run > Debug Configurations:
The debug configurations will open, choose the Segger interface and click on Debug. The same
steps apply when using the P&E interface:
NXP Semiconductor
The Debug session will start and the bootloader is now flashed on the board:
NXP Semiconductor
Before executing the Kinetis Updater tool we need to generate the binary file of the demo application
that will be flashed to the MCU.
-
Extract the K64F12_Led_Demo project and import it to KDS by clicking on Menu > File > Import:
NXP Semiconductor
NXP Semiconductor
Build the project and the binary file will be generated in the Debug folder:
Now open the Kinetis Updater tool and click on Select Device:
NXP Semiconductor
Select your device and click on Connect, if the connection is not established perform a reset to
the board:
NXP Semiconductor
Browse for the binary file that was generated by the demo project and update the Base address
to 0x0000A000, this address is where the demo application starts:
NXP Semiconductor
Click on the Update button and the application will be loaded to the MCU, the RGB led will start
to toggle indicating that the bootloader jumped to the application:
At this point you can now proceed to the section 3.2 Debugging bootloader and demo
application projects using the Segger interface.
NXP Semiconductor
2.3 Flashing demo application and bootloader using the P&E advanced
programming options
Refer to the sections 2.1 and 2.2 that explain how to import and build both the freedom_bootloader
and K64F12_Led_Demo projects.
Once that both projects are in you workspace and have been built click on Menu > Run > Debug
Configurations:
NXP Semiconductor
Choose the corresponding P&E connection for the bootloader project and generate 1 additional
ELF field:
NXP Semiconductor
Browse for the *.elf file generated by the demo application, click on Apply then on Debug:
The Debug session will start and both the bootloader and demo application are now flashed on
the MCU, you can now proceed to the section 3.1 Debugging bootloader and demo application
projects using the P&E interface.
NXP Semiconductor
After the bootloader and the demo application have been flashed to the MCU using the P&E
advanced programming options click on Menu > Run > Debug Configurations:
NXP Semiconductor
Choose the corresponding P&E connection for the bootloader project and go to the Debugger
tab:
NXP Semiconductor
Now we need to specify an additional symbol file to be used in the debug session, this will be
done by using the following GDB command:
NXP Semiconductor
Here are the updated debug configurations, after the GDB command is added, click on Apply
then Debug:
NXP Semiconductor
NXP Semiconductor
Open the main.c file of the K64F_Led_Demo and set a breakpoint in the init_hardware()
function:
NXP Semiconductor
At this point you can step through the bootloader program and then jump to the demo
application and continue debugging it:
NXP Semiconductor
3.2 Debugging bootloader and demo application projects using the Segger
interface
-
After the bootloader has been flashed to the MCU and the demo application was loaded using
the Kinetis Updater tool go to KDS, make sure both projects are opened and click on Menu >
Run > Debug Configurations:
NXP Semiconductor
Choose the corresponding Segger connection for the bootloader project and go to the Debugger
tab:
NXP Semiconductor
Now we need to specify an additional symbol file to be used in the debug session, this will be
done by using the following GDB command:
NXP Semiconductor
Here are the updated debug configurations, after the GDB command is added click on Apply
then Debug:
NXP Semiconductor
NXP Semiconductor
Open the main.c file of the K64F_Led_Demo and set a breakpoint in the init_hardware()
function:
NXP Semiconductor
At this point you can step through the bootloader program and then jump to the demo
application and continue debugging it:
NXP Semiconductor
4. Conclusion.
This document has demonstrated how to use Kinetis Design Studio to flash a bootloader and an
application to an MCU and how to debug the bootloader and application at the same time using the
GDB command add-symbol-file filename address that specifies an additional symbol file to be used in
the debug session.
NXP Semiconductor
Appendix A - References
-
KDS webpage:
www.nxp.com/kds
KBOOT webpage:
www.nxp.com/kboot
NXP Semiconductor