Port MCUBoot2.0.0 to TWR-K60D100

Document created by Jing Pan Employee on Aug 2, 2018Last modified by Jing Pan Employee on Aug 2, 2018
Version 2Show Document
  • View in full screen mode


MK60 is a popular MCU in Kinetis K family. NXP has prepared some kinds of bootloader for TWR-K60D100. But as we all know, MCUBoot2.0.0 is the most update bootloader for Kinetis family. It is a configurable flash programming utility that operates over a serial connection on Kinetis MCUs. It enables quick and easy programming of Kinetis MCUs through the entire product life cycle, including application development, final product manufacturing, and beyond. But sinceTWR-K60D100 is a relatively old platform compare to K22 and K64/K65/K66, MCUBoot2.0.0 did not add MK60 to its target board. If customer don’t like those old bootloader, they have to port it by themselves. This article tries to guide user to port MCUBoot to TWR-K60D100 base on Chapter 10 in Kinetis Bootloader v2.0.0 Reference Manual. This time we use KDS.


Software requirement:

Kinetis Design Studio 3.2

MCUBootloader 2.0.0 (KBoot 2.0.0)

MCUXpresso Config Tools v4.0


  • Porting flow


Step 1:

First I copy NXP_Kinetis_Bootloader_2_0_0\targets\MK64F12 to NXP_Kinetis_Bootloader_2_0_0\targets\MK60D100. The reason I select MK64 is more likely to MK60 than other target, especially in clock distribution, system integration module and signal multiplexing. In mk60d100\src directory, rename the following files:

  • clock_config_mk64f12.c > clock_config_mk60d100.c
  • hardware_init_mk64f12.c > hardware_init _ mk60d100.c
  • memory_map_mk64f12.c > memory_map _ mk60d100.c
  • peripherals_ mk64f12.c > peripherals _ mk60d100.c

Then copy system_MK60D10.c and system_MK60D10.h from SDK_2.2_TWR-K60D100M to mk60d100\src\startup, copy startup_MK60D10.S from SDK_2.2_TWR-K60D100M to mk60d100\src\startup\gcc.

Step 3:

Then I copy \src\platform\devices\MK64F12 to \src\platform\devices\mk60d100, copy SDK_2.2_TWR-K60D100M\devices\MK60D10\fsl_device_registers.h, MK60D10.h, and MK60D10_features.h to this new directory.

Step 4:

Open the KDS project in MK60D100 and replace above old file with new file. After that, I change some setting.

Figure 1. Target Processor change


K64 has hardware FPU, but K60D100 hasn’t. So, Float ABI must be changed to software.

There is a C/C++ preprocessor define that is used by the bootloader source to configure the bootloader based on the target MCU. This define must be updated to reference the correct set of device-specific header files.

Figure 2. Preprocessor change


As to the link file, it needn’t to be change. We can use K64’s link file.

TWR-K60D100 use an old version PE debugger. So, the debugger setting must be changed.

Figure 3. Debug setting

Step 5:

MK60’s clock distribution structure is different with MK64. We must modify this part. As it is very complex, use MCUXpresso Config Tools to generate this config code is a sensible choice.

Open the tools and step clock structure as below:

Figure 4. clock setting

After that, generate the code and save them to \src\platform\devices\mk60d100. Since MCUBoot2.0.0 is not base on SDK2.x, we must copy some related driver file from SDK2.x package, include fsl_smc.c, fsl_smc.h, fsl_rtc.c, fsl_rtc.h. Then add them to project.

In clock_config_mk60d100.c line 168, the code is

clock_mode_switch(s_currentClockMode, kClockMode_FEI_48MHz);

Replace it with:

     BOARD_BootClockUSB(); // this function was generated by MCUXpresso Config Tool

Then add the head file of “clock_config.h”.


Step 6:

TWR-K60D100 use UART5 as the debug UART port. Please refer to https://community.nxp.com/docs/DOC-340954 for detail. MCUBootloader2.0.0 do not support UART5. User must add its code in pinmux_utility_common.c.


Step 7:

Modify usb_clock_init() in hardware_init_MK60D100.c as below

bool usb_clock_init(void)




   SIM->CLKDIV2 = (uint32_t)0x00L;

   SIM->SOPT2 |= SIM_SOPT2_USBSRC_MASK | SIM_SOPT2_PLLFLLSEL(0x01);     //k60 PLLFLLSEL change from 3 to 1




//   USB0->CLK_RECOVER_IRC_EN = 0x03;



//   USB0->CLK_RECOVER_CTRL |= 0x20;


   return true;



Modify memory_map_MK60D100.c as below:

memory_map_entry_t g_memoryMap[] = {

   { 0x00000000, 0x0007ffff, kMemoryIsExecutable, &g_flashMemoryInterface },   // Flash array (512KB)

   { 0x1fff0000, 0x2000ffff, kMemoryIsExecutable, &g_normalMemoryInterface }, // SRAM (256KB)

{ 0x40000000, 0x4007ffff, kMemoryNotExecutable, &g_deviceMemoryInterface }, // AIPS peripherals


   { 0x400ff000, 0x400fffff, kMemoryNotExecutable, &g_deviceMemoryInterface }, // GPIO

   { 0xe0000000, 0xe00fffff, kMemoryNotExecutable, &g_deviceMemoryInterface }, // M4 private peripherals

   { 0 }                 // Terminator



Modify bl_uart_irq_config_common.c as below:

void UART_SetSystemIRQ(uint32_t instance, PeripheralSystemIRQSetting set)


   switch (instance)


       case 0:


       case 1:

#endif // #if (FSL_FEATURE_SOC_UART_COUNT > 1)


       case 2:

#endif // #if (FSL_FEATURE_SOC_UART_COUNT > 2)


       case 3:

#endif // #if (FSL_FEATURE_SOC_UART_COUNT > 3)


       case 4:

#endif // #if (FSL_FEATURE_SOC_UART_COUNT > 4)

#if (FSL_FEATURE_SOC_UART_COUNT > 5)          // add UART5 support

       case 5:

#endif // #if (FSL_FEATURE_SOC_UART_COUNT > 5)


           if (set == kPeripheralEnableIRQ)












In target_config.h, modify kMaxCoreClock value to 100.


Step 8:

After all of the above work, compile the project and download to TWR-K60D100 board. You’ll find KinetisFlashTool.exe can recognize the device by UART. If you establish a Tower system with TWR-SER board, KinetisFlashTool can also recognize the device by USB.


  • Conclusion:


K60 is the base of many Kinetis K series MCU, include K10, K20, K61, K70. If you want to port MCUBoot2.0.0 to these MCU, you just want to update the clock_config file.