Custom K22FN256LH12 Bootloader

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom K22FN256LH12 Bootloader

Jump to solution
484 Views
burgeh
Contributor IV

Greetings!

Background:

I am currently using KDS v3.2 with Processor Expert. I have a K22FN256LH12 microcontroller that I would like to be able to put a bootloader on and update the application code through USB. I have completed this task similiar on the K22- FRDM Board.

Problem/Questions:

1. Am I supposed to use the KBOOT tower_bootloader or could I use the freedom_bootloader and do I need to change anything?

2. My USB pins are connected to the K22 as shown below. Is there any setup I need to do for my microcontroller to make use of that USB port for bootloading? Do I need a processor expert component to make use of this USB (such as USB-HID)?

pastedImage_2.png

3. I'm not sure as to why I am getting these errors when I try to setup my application for bootloading. Is there a wrong assumption I have? The first image below this is the default and the second is my calculated.

pastedImage_5.png

pastedImage_4.png

Thanks! Tagging Kerry since you seem to have a lot of experience with this and have been very helpful!

kerryzhou

1 Solution
120 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Christopher Burg,

   Yes, you can use the FRDM k22 bootloader in your K22FN256LH12 , but you need to do the following modification, actually, just modify the flash size.

1. memory_map_k22f512.c with this:

memory_map_entry_t g_memoryMap[] = {
    { 0x00000000, 0x0003ffff, kMemoryIsExecutable, &g_flashMemoryInterface },   // Flash array (256KB)
    { 0x1fffc000, 0x20007fff, kMemoryIsExecutable, &g_normalMemoryInterface },  // SRAM (48KB)
    { 0x40000000, 0x4007ffff, kMemoryNotExecutable, &g_deviceMemoryInterface }, // AIPS peripherals
    { 0x400ff000, 0x400fffff, kMemoryNotExecutable, &g_deviceMemoryInterface }, // GPIO
    { 0xe0000000, 0xe00fffff, kMemoryNotExecutable, &g_deviceMemoryInterface }, // M4 private peripherals
    { 0 }                                                                       // Terminator
};

2. MK22FN512xxx12_application_0x0000.ld, KDS IDE.

MEMORY
{
  m_interrupts          (RX)  : ORIGIN = 0x00000000, LENGTH = 0x00000400
  m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010
  m_text                (RX)  : ORIGIN = 0x00000410, LENGTH = 0x0003FBF0
  m_data                (RW)  : ORIGIN = 0x1FFFC000, LENGTH = 0x0000C000
}

No other point need to modify, yes, you need to use the reset pin to enter the bootloader mode.

If you still have problems, you also can try the UART bootloader on your own board, whether you UART bootloader have problems or not?

Besides, when you build the bootloader code, you can use the release mode, otherwise, the code size may larger than 0xa000, then you can't port your application to relocate in 0xa000.

From my own viewpoint, even you don't modify it, you also can download the code, because your bootloader didn't larger than 256K, so I think you can download freedom_bootloader.bin in folder NXP_Kinetis_Bootloader_2_0_0\targets\MK22F51212\iar\binaries to your own chip directly.

Please try it on your side.


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

4 Replies
120 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Christopher Burg,

    1.Bootloader :  I suggest you to use the freedom_bootloader.bin file.

      Folder:NXP_Kinetis_Bootloader_2_0_0\targets\MK22F51212\kds\freedom_bootloader

     2. About the USB hardware, please refer to our FRDM-K22F120M board schematic:

https://www.nxp.com/downloads/en/schematics/FRDM-K22F-SCH.pdf 

     When you use the HID, you need to power on the board, and connect the USB port, if you are using the FRDM-K22 board, you need to find 2 USB cable, and connect it to J5 and J16.

    I highly suggest you use our official FRDM-K22 board to test the HID bootloader at first, it works OK on my side.

     3. About the app PE configuration.

       I think it is the PE bugs, but don't worry, you can modify the ld file directly like this :

pastedImage_2.png

MEMORY {
  m_interrupts (RX) : ORIGIN = 0x0000a000, LENGTH = 0x00000198
  m_text      (RX) : ORIGIN = 0x0000a410, LENGTH = 0x0003FBF0-0XA000
  m_data_1FFFC000 (RW) : ORIGIN = 0x1FFFC000, LENGTH = 0x00004000
  m_data      (RW) : ORIGIN = 0x20000000, LENGTH = 0x00008000
  m_cfmprotrom  (RX) : ORIGIN = 0x0000A400, LENGTH = 0x00000010
}

After generate the .hex file, you can find APP is from 0xa000 like the following picture, if you still find the one line code from 0x400, you can delete it directly in the .hex file.

  

pastedImage_3.png

I attached my test bootloader and app.hex file, app function is the RED LED blink in the FRDM-K22 board.

This is the test result:

pastedImage_4.png

After download the app.hex to my FRDM-K22 board with HID bootloader, my red led is blinking.

Wish it helps you!


Have a great day,
Kerry

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

0 Kudos
120 Views
burgeh
Contributor IV

Thank you for replying,

   I have had no issues being able to do this on the K22-FRDM board, but should I use the FRDM_bootloader (which is for the K22FN512LH12) I am using the K22FN256LH12 chip. I have my USB attached to the same pins that K22-FRDM uses, Pins 5 and 6, but I cannot connect to my chip using the KinetisFlashTool.  I need to set my chip in some sort of bootloader mode correct? Using a reset pin maybe?

I noticed my old application code still runs after I flash my chip with the bootloader, that isn't right is it?

0 Kudos
121 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Christopher Burg,

   Yes, you can use the FRDM k22 bootloader in your K22FN256LH12 , but you need to do the following modification, actually, just modify the flash size.

1. memory_map_k22f512.c with this:

memory_map_entry_t g_memoryMap[] = {
    { 0x00000000, 0x0003ffff, kMemoryIsExecutable, &g_flashMemoryInterface },   // Flash array (256KB)
    { 0x1fffc000, 0x20007fff, kMemoryIsExecutable, &g_normalMemoryInterface },  // SRAM (48KB)
    { 0x40000000, 0x4007ffff, kMemoryNotExecutable, &g_deviceMemoryInterface }, // AIPS peripherals
    { 0x400ff000, 0x400fffff, kMemoryNotExecutable, &g_deviceMemoryInterface }, // GPIO
    { 0xe0000000, 0xe00fffff, kMemoryNotExecutable, &g_deviceMemoryInterface }, // M4 private peripherals
    { 0 }                                                                       // Terminator
};

2. MK22FN512xxx12_application_0x0000.ld, KDS IDE.

MEMORY
{
  m_interrupts          (RX)  : ORIGIN = 0x00000000, LENGTH = 0x00000400
  m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010
  m_text                (RX)  : ORIGIN = 0x00000410, LENGTH = 0x0003FBF0
  m_data                (RW)  : ORIGIN = 0x1FFFC000, LENGTH = 0x0000C000
}

No other point need to modify, yes, you need to use the reset pin to enter the bootloader mode.

If you still have problems, you also can try the UART bootloader on your own board, whether you UART bootloader have problems or not?

Besides, when you build the bootloader code, you can use the release mode, otherwise, the code size may larger than 0xa000, then you can't port your application to relocate in 0xa000.

From my own viewpoint, even you don't modify it, you also can download the code, because your bootloader didn't larger than 256K, so I think you can download freedom_bootloader.bin in folder NXP_Kinetis_Bootloader_2_0_0\targets\MK22F51212\iar\binaries to your own chip directly.

Please try it on your side.


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

120 Views
mjbcswitzerland
Specialist V

Hi Christopher

In case you prefer a more flexible loader for your K22 (with support) you can also check out the links below.

Regards

Mark


Kinetis: http://www.utasker.com/kinetis.html
Kinetis K22:
- http://www.utasker.com/kinetis/FRDM-K22F.html
- http://www.utasker.com/kinetis/TWR-K22F120M.html
- http://www.utasker.com/kinetis/BLAZE_K22.html
- http://www.utasker.com/kinetis/tinyK22.html
Serial Loader: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.pdf

Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M

For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html

0 Kudos