Setting up Kinetis bootloader on MK22FN128 unsuccessful.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting up Kinetis bootloader on MK22FN128 unsuccessful.

Jump to solution
2,915 Views
arjunnair
Contributor II

Setting up Kinetis bootloader on MK22FN128 unsuccessful.

I am a bit stuck with the bootloader. Any help is appreciated.

I have a custom PCB with a MK22FN128VLH10 microcontroller. The significant peripherals are :
1) 20-pin J-Tag connector for connecting the SEGGER J-Link debugger.
2) USB micro-B port connected to the microcontroller.
3) Few pins connected to a header (for I/O).
4) Few LEDs as indicators.

Stuff that is already working :
I have written a program to blink LEDs, read Analog Input and send data through the USB as a virtual com port. This program was flashed to the board using the SEGGER J-Link debugger and tested. It works exactly as intended.

The problem :
I want to use USB to flash the program. But the bootloader isn't working for some reason.

What I have tried :
- Downloaded Kinetis Bootloader v2 from NXP website.
- Imported the project 'flashloader' into KDS (Kinetis Design Studio).
- Built the project (in 'release' configuration) and created 'flashloader.elf'.
- Used the python scripts provided and generated 'flashloader_image.c'.
- Imported the project 'flashloader_loader' into KDS.
- Added the file 'flashloader_image.c' to the 'flashloader_loader' project and fixed the #include to point to the right file.
- Built the project (release) and flashed the microcontroller using the J-Link debugger.

So far, everything looks fine. I connected the USB to my computer and executed the following command with blhost -

$./blhost -u -- get-property 1

It's a success. I get the expected response from the microcontroller.

Next, I execute the following commands to flash the microcontroller through the bootloader -

$./blhost -u -- flash-erase-all

$./blhost -u -- write-memory 0xA000 AppICreated.bin
$./blhost -u -- reset

All three commands run successfully.

And that's it. Nothing else happens. I reset the controller, turned off power and turned it on, waited for a few minutes. My program doesn't execute. Also, the bootloader doesn't work anymore.

I tried the same thing with Kinetis FlashTools (in a Windows system) at location 0xA000 and it gives the same result. But, the bootloader continues to works in this case.

I also tried writing to location 0x0. The program starts working, but I'm pretty sure the bootloader is overwritten and lost. I used the code in "Kinetis Bootloader v2.0.0 Reference manual" page 19 to call the bootloader within my code when I send a character through the virtual com, but the controller just stops working till I reset it.

Please let me know if you need to know more. I spent a lot of time and tried a lot of useless hacks to try to fix it.

If anybody knows what I did wrong, I would love to know. Thank you.

Labels (1)
1 Solution
2,357 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Arjun Nair,

    flashloader and flashloader_loader is the flash bootloader which can just be used one time, after you download the application code successfully, this bootloader will be disappear.

    If you want the flash bootloader always work, even after you download the application code, you need to use the tower_bootloader or freedom_bootloader.

   Please open KBOOT2.0:NXP_Kinetis_Bootloader_2_0_0\NXP_Kinetis_Bootloader_2_0_0\targets\MK22F12810

 1  Use tower bootloader:

pastedImage_1.png

2 Download this bootloader to your chip, then modify your application code, and relocate it to 0XA000, build and generate the app.bin file.

3. You can use kinetisFlashTool to download your application code, the tool can be found in folder:

 NXP_Kinetis_Bootloader_2_0_0\NXP_Kinetis_Bootloader_2_0_0\bin\Tools\KinetisFlashTool\win

After you download the application code successfully, you still can download the new application with the fixed flash bootloader again.

With it helps you!

If you still have question, please let me know!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

3 Replies
2,358 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Arjun Nair,

    flashloader and flashloader_loader is the flash bootloader which can just be used one time, after you download the application code successfully, this bootloader will be disappear.

    If you want the flash bootloader always work, even after you download the application code, you need to use the tower_bootloader or freedom_bootloader.

   Please open KBOOT2.0:NXP_Kinetis_Bootloader_2_0_0\NXP_Kinetis_Bootloader_2_0_0\targets\MK22F12810

 1  Use tower bootloader:

pastedImage_1.png

2 Download this bootloader to your chip, then modify your application code, and relocate it to 0XA000, build and generate the app.bin file.

3. You can use kinetisFlashTool to download your application code, the tool can be found in folder:

 NXP_Kinetis_Bootloader_2_0_0\NXP_Kinetis_Bootloader_2_0_0\bin\Tools\KinetisFlashTool\win

After you download the application code successfully, you still can download the new application with the fixed flash bootloader again.

With it helps you!

If you still have question, please let me know!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,649 Views
nibabajohn
Contributor I

In flashloader_loader mode,how to load flashloader,with blhost?!But,as reference manual said,"The image on the flash has 2 programs: flashloader_loader and flashloader".If like this,how do they laid in the flash? I buid my own flashloader_loader and flashloader with IDE sdk,I dont know how to deal with them. 

0 Kudos
2,358 Views
arjunnair
Contributor II

Thank you very much. :smileyhappy:

0 Kudos