AnsweredAssumed Answered

Bootloader problem for Kinetis KL15 (Hard Fault)

Question asked by Faine on Mar 16, 2015
Latest reply on Mar 22, 2015 by Kerry Zhou

Hello All,

I’m writing a bootloader for a Kinetis KL15Z128VFM4  to load a program through a UART. The problem that I have is that I get a Hard Fault error in the middle of the process.

Previously to that I have made the same process in a Kinetis K10 project without problems.


The process that a try to do is the next:

  1. Start condition: The only code I have in KL15 flash is the bootloader program.
  2. When start the KL15 the bootloader copy the needed functions to RAM.
  3. Disable all interrupts.
  4. Jump to main bootloader function to start the process (located in RAM).
  5. Start a PC program that sends the commands and data to load the new code in the KL15 flash with the next sequence:
    1. Erase the flash above bootloader area (that allows that if the power supply fails the bootloader start again).
    2. Send the code to fill the erased flash area.
    3. Erase the initial flash area occupied by the bootloader
    4. Send the code to fill the initial flash area.
    5. Make a KL15 reset to start the new program.


When I try to do this process I get a jump to Hard Fault interrupt (interrupt number 3 located at address 0x0000000C of vectortable). This interrupt occurs at the step 5.c : after deleting the flash sector number 2,  when the PC program sends a new command interruption occurs.

I can see the problem because I run the program through the debugger.

If I run the program step by step (F5, F6 KDS debug) I can not get the problem appears.

I have checked all the program and once started the bootloader in RAM I no longer call any routine in flash.

Serial communications I make by pooling because I cannot use any interrupt.

In my old project running on a K10 have no problem using the same method.


Any suggestions to solve the problem? (It seems a particular problem of  KL15)


Thanks in advance,