FRDM_KL27Z ROM Bootloader

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

FRDM_KL27Z ROM Bootloader

1,627 Views
Ravikumar1
Contributor II

Hi,

Actually I need to use ROM bootloader please tell me

1) is KL27MCUs supported ROM bootloader ?

2) If I want use ROM bootloader and flashing the Application firmware code through I2C what is the procedure/steps I should follow.

Thanks in advance

 

Regards

Ravikumar.

0 Kudos
7 Replies

1,600 Views
Ravikumar1
Contributor II

Hi

I gone through the Link what you shared and got document blhost User's Guide in the link 

https://www.nxp.com/docs/en/user-guide/MCUBLHOSTUG.pdf

In this document page no: 8 they mentioned This option is valid for Arm-Linux blhost 

but I am working on windows platform,

Actually I am having FRDM-KL27Z board and I want to use ROMBOOTLoader with I2C for firmware application on to this MCU device on windows platform,

So will you please provide specific/required document for ROMBOOTLoader with I2C,

and also tell me what are the Hardware requirement/ connections for I2C pins for this process.

Thanks in Advance,

 

Regards

Ravikumar

0 Kudos

1,599 Views
bobpaddock
Senior Contributor III

blhost.exe for Windows is part of MCUBoot, it should be part of the download package.

However that will not magically connect Windows to I2C.
Do you have some interface board?

The FRDM-KL27Z board connects via USB to Windows, with blhost.exe to use the KL27 bootloader.

I'm unclear why I2C is even entering the picture here?

If you are thinking of doing a custom board and using I2C to bootload, don't do it.
The KL27 has some bugs in its I2C implementation which you can find discussions of in the forum here.

There is also an errata on a bug in the KL27 bootloader.
I've posted code on how to work around that issue in the forum as well.

0 Kudos

1,561 Views
Ravikumar1
Contributor II

Thank you for the reply,

Now, I am using FRDM_KL27Z board and I can enter the bootloader mode through NMI switch. However I need to enter the Bootloader mode through TimeOut Enable option. 

Actually I gone through document and there is one option for the same 

 

Ravikumar1_0-1659590753626.png

And, I read the document for KLFamily Reference Manual and, in this document I can see that FOPT boot options in Page no 87&88. And we have selection options for BOOTPIN_OPT & BOOTSRC_SEL.

Will you please tell me how /where do I need to do this modifications/ or Steps follow for entering the ROM bootloader mode through TimeOut Enable option.

 

Thanks in Advance,

 

Regards,

Ravikumar. 

 

0 Kudos

1,557 Views
ErichStyger
Senior Contributor V

I recommend you have a read at the chapter 13 of the KL27 Reference Manual where the ROM bootloader is described.

>>1) is KL27MCUs supported ROM bootloader ?

Yes, see chapter 13 of the reference manual.

 

2) If I want use ROM bootloader and flashing the Application firmware code through I2C what is the procedure/steps I should follow.

See chapter 13.4.1 of the reference manual.

 

In addition to the timeout: the ROM bootloader is similar to the KL03Z, where I wrote https://mcuoneclipse.com/2017/07/12/getting-started-rom-bootloader-on-the-nxp-frdm-kl03z-board/, so you can use this as guidance.

If you want to use McuBoot and not the ROM bootloader, then I have a tutorial here: https://mcuoneclipse.com/2018/03/03/flash-resident-usb-hid-bootloader-with-the-nxp-kinetis-k22-micro...

I hope this helps,

Erich

0 Kudos

1,554 Views
Ravikumar1
Contributor II

Hi @ErichStyger,

Thank you for the reply,

Actually I gone through the link what you have shared for 

In addition to the timeout: the ROM bootloader is similar to the KL03Z, where I wrote https://mcuoneclipse.com/2017/07/12/getting-started-rom-bootloader-on-the-nxp-frdm-kl03z-board/, so you can use this as guidance.

 

Here, my doubt is where we should do these configurations, means

Ravikumar1_0-1659596783705.png

 

Ravikumar1_1-1659596824505.png

See the above,

Actually, we have to make BOOTPIN_OPT  = 01; and BOOTSRC_SEL = 10 or 11;  for entering ROM without NMI.

So, where do I can change these configurations, do I need implement my own Boot loader code or Its already done by NXP. If already done by NXP what is the procedure to enter in to ROM Bootloader mode through EnableTimeout. 

 

Regards,

Ravikumar.

0 Kudos

1,549 Views
bobpaddock
Senior Contributor III

I've done a lot of work with the MKL27 and its bootloader.
I have never encountered any 'timeout' and have never seen any documentation to enable such a timeout.

You really want to design your hardware so that asserting the BOOT pin gets you into the ROM bootloader of the chip.  Not doing it this way can lead to bricking devices that then must be recovered using a SWD programming pod, such as  J-Link or PE FX (which I use).

Place this code in your startup code in vectors.c (I've attached mine as example.  This is the code executed right out of reset) or equivalent, the comments explain why:

static void vectors_bootloader_mr_setup( void ) __attribute__( ( used, __aligned__( 4U ), section( ".after_vectors" ) ) );
static void vectors_bootloader_mr_setup( void )
{
/*
* RCM_MR Indicates the boot source, the boot source remains set
* until the next System Reset or software can write logic one to
* clear the corresponding mode bit. While either bit is set the
* NMI input is disabled and the vector table is relocated to the
* ROM base address at 0x1C00_0000. These bits should be cleared by
* writing logic one before executing any code from either Flash or
* SRAM.
*
* A reset is forced to clear out anything that the ROM
* bootloader did, so we are sure we have the data sheet reset
* values.

* This method works around the buggy KL43/27/17 bootloaders as
* described in: "Problem Analysis and solutions for booting from
* ROM BOOTLOADER in KL series".
*/
if( 0U != ( RCM_MR & RCM_MR_BOOTROM_MASK ) )
{
RCM_MR = RCM_MR_BOOTROM_MASK; /* Clear the bits that indicated a bootloader boot via ROM */
RCM_FM = 0U; /* Boot from Flash not ROM on next reset */

SCB_AIRCR = ( SCB_AIRCR_VECTKEY( 0x05FAU ) | SCB_AIRCR_SYSRESETREQ_MASK ); /* Force a Software Reset */
}
}


This code when called from the application will force the bootloader to start, which answers your question about when to use RCM_FM.  It is not a configuration thing nor directly related to the BOOT pin.

 

void __attribute__ ((noreturn)) reset_mcu( void )
{
/*
* A DSB is required before generating self-reset to ensure all
* outstanding transfers are completed. The use of the CPSID I
* instruction is optional.
*/
irq_disable();
sync_barrier_data();

SCB_AIRCR = (SCB_AIRCR_VECTKEY(0x05FAU) | SCB_AIRCR_SYSRESETREQ_MASK);

for(;;)
{
;
}
}

void boot_loader_start( void )
{
RCM_FM = RCM_FM_FORCEROM_MASK; /* Force next reset to jump to Bootloader ROM, */
reset_mcu(); /* now be the next reset */

for(;;) /* Pacify the compiler about returning from a no return function */
;
}

As I said previously, don't use I2C for the bootloader because the parts with double buffered I2C do not handle repeated start correctly.  Use serial port or USB.  See the KL27 manual for which specific serial port works with the bootloader.

0 Kudos

1,620 Views
_Leo_
NXP TechSupport
NXP TechSupport

Hi Ravikumar Besu,

Thank you so much for your interest in our products and for using our community.

Regarding your first question, the answer is yes.

And regarding your second question, I can suggest you using MCUBOOT. In the documentation section you will find the necessary documents on how to use this tool. You have the option to use a variety of serial communications and the ability to program or boot from external flash memory.

I hope this will help you. Please let me know if you have more questions about it.

Have a nice day!

0 Kudos