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.