K27Z : Implementing IAP using bootloader on Flash

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

K27Z : Implementing IAP using bootloader on Flash

1,167 Views
praveenpujari
Contributor I

Hello Everyone,

I am working on a project where it requires firmware update using blue-tooth radio. I have done a lot of reading and research, however I have some un-answered questions. 

I hope one of you could answer,

1. How to create a boot loader section on Flash that can perform IAP ?

2. What is the default booting process in KL27Z ?

3. Is there an example for implementing a boot-loader that updates firmware from some external storage ?

Thanks in advance,

Praveen

0 Kudos
5 Replies

823 Views
rastislav_pavlanin
NXP Employee
NXP Employee

Hello Praveen,

is the device you selected K27 or KL27?

KL27 device includes ROM with bootloader. You can use dedicated communication interface (LPUART, I2C, SPI, USB) which allow you to re-flash the device.

The Kinetis bootloader can also be placed within the Kinetis devices flash if applicable from customer application code point of view. For more information see here:

Kinetis Bootloader|NXP 

regards

R.

0 Kudos

823 Views
praveenpujari
Contributor I

Thank you for the reply,

Yes it is KL27 indeed, I do not want to use ROM boot loader in my application. I wish to dedicate some memory of internal flash for boot loader and use it to download the application program into the rest of the flash memory.

Could you please indicate steps to follow or tools to use ? 

Could you please explain how KDS downloads and runs programs on the board ? Does it interact with ROM boot loader ? or does it directly writes the application program to flash ?

Thanks,

Praveen

0 Kudos

823 Views
rastislav_pavlanin
NXP Employee
NXP Employee

Praveen,

from your last message it looks like you want to write bootloader by your own.

The booting proces of KL27:

- boot to ROM (default) or boot to FLASH

 The boot configuration is available through FOPT->BOOTSRC_SEL within flash configuration field (at address 0x40D). Based on the value placed (which is copied into the FTFA_FOPT register before system reset release) in FOPT flash the CPU decides where to boot.

For example:

In your case the boot source will be FLASH (FOPT value in flash configuration field should be 0x3F). Then couple of flash sectors at the beginning of the flash need to be protected agains write. Within these sectors your bootloader need to be placed. The first sector size (0x0000 - 0x0400) will include bootloader vector table. The reset vector (address 0x0004, value which will be automatically loaded into PC after reset) should point to the bootloader start code, e.g. starting address 0x0410 (which is directly after vector table + flash configuration field). In bootloader code the dedicated peripheral (UART, SPI, I2C, USB) should be properly initialized and code need to wait for response from. If response is not recognized (no communication on interface) the bootloader code need to setup the correct application code vector table (set VTOR) and jump to the application code. If not application code recognized it is recommened to enter some of the lower power modes. 

NOTE: this is just very simple explanation. 

In our case we have PC application where you select the image code you want to download into the flash (the output file (hex, srec etc.)). After CPU reset it boot to ROM at the PC application start transfer imagine data and bootloader start to program the chip.

Not sure I have understood your meaning in last question. Usually the development enviroment (KDS, IAR, KEIL) use special flash algorithms to download the image to the chip flash using slected debugger driver (CMSIS-DAP, J-link, etc) with SWD/JTAG interface.

regards

R.

0 Kudos

823 Views
praveenpujari
Contributor I

Dear Rastislav,

I really appreciate your time.

You are right, I want to install the bootloader on the flash and I want the boot loader to perform application firmware update if necessary using "some communication interface" or jump to the pre-installed application program. I hope you have already figured out this part.

1. I tried to port MKL25Z boot loader to MKL27Z by following the instruction in the reference manual. I bumped into a lot of build errors.

2. I tried to connect to ROM boot loader using the Kinetis Flash Tool, it appears that there is a deadlock

    * The COM port disappears if I force the device into boot loader mode by pressing reset button during the start.

    * If I don't press reset and try to communicate with boot loader it doesn't work because the application will be running on the flash.

    * I read in one of the documents that, if I have to force it into boot loader the flash has to be erased so the board stays in boot loader mode.

      I do not know how to erase the flash without connecting using one of the tools such as Kinetis Flash or MfgTool.

I kindly request help in porting the MKL25Z boot loader to Flash Resident Boot loader for KL27Z and edit linker script such that it jumps to demo-led application. 

I am trying a lot of things but none of them seem to work, 

Kind Regards,

Thanks in advance,

0 Kudos

823 Views
rastislav_pavlanin
NXP Employee
NXP Employee

Hello Praveen,

"... if necessary using "some communication interface""? what diid you mean by this? is there any other way you want to update firmware?

1. yes, I can imagine there will be build error as KL25 and KL27 are completely different silicons which uses different peripherals (which are located at different addresses etc.). For example: KL27 use LPUART instead of UART modules used by KL25, KL27 does not support OTG just USB device, the clock managers are completely different KL27 uses just Lithe verison (no PLL, no FLL) etc. You need to consider this differences when porting and I believe it is difficult. However, our bottloader team does not consider KL27 in target as it includes ROM bootloader built on the same principle. Couple of differences are also highlighted in migration guide here:

http://www.nxp.com/files/microcontrollers/doc/app_note/AN4997.pdf?fasp=1&WT_TYPE=Application%20Notes... 

What kind of bootloader are you using (what version 1.1, 1.2, 2.0)? it si your own written code or is it our older bootloader code?

2.  * looks like you flash configuration field is pre-programed by configuration to boot to flash. In such case you are unable to enter ROM bootloader (if it is not called in the application code within flash). The value at address 0x40C need to be at list 0xFFFFFFFE (unsecured chip with boot to ROM bootloader). If it is e.g. 0xFFFF3FFE then it means unsecure chip with boot to flash (on our pre-programed boards e.g. FRDM-KL27 we usually use this configuration).

* You need to press enter before doing any updates done by KinetisFlashTool regarding to ROM bootloader

* well, not really as mentioned above flash configuration filed (especially FOPT at address 0x40C) need to be pre-programed to enable boot to ROM and ofcourse be unsecure sate.

Porting KL25 based flash bootloader to KL27 target requires lot of effort and from my point of view seem to be meaningless as it is already available in KL27 ROM.

Anyway, if reuqired it needs to consider all differences between the devices.

regards

R.

0 Kudos