MCU Bootloader Startup with Enable Timeout

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

MCU Bootloader Startup with Enable Timeout

2,788 Views
Ravikumar1
Contributor II

Hi,

I have FRDM-KL27Z board. 

Here, I am using NMI (SW1) for Enter (start) the bootloader mode and I continued the flashing/erasing Application program its fine.

However, I am going through below document and I want Enter the  ROMbootloader through EnableTimeout option (without using the NMI_SW1 switch).

I share the document link for reference

Ravikumar1_0-1659592854350.png

 

 

https://www.nxp.com/assets/block-diagram/en/MCUBOOT.pdf

 

Please tell me what will I do for this.

Thanks in Advance.

 

Regards

Ravikumar.

Tags (1)
0 Kudos
Reply
10 Replies

2,772 Views
Ravikumar1
Contributor II

Could anyone please guide me for ROM bootloader through Enable Timeout option (without using the NMI_SW1 switch).

Actually, I gone through below document KLFamily Reference Manual and I read that FOPT boot options in Page no 87&88. And we have selection BOOTPIN_OPT & BOOTSRC_SEL. So please any one tell me, How and where we are going to do this changes for Enable Timeout. Or do we have any steps for this. Please share those information.

link for the reference:

https://www.nxp.com/files-static/32bit/doc/ref_manual/KL27P64M48SF6RM.pdf?&fasp=1&WT_TYPE=Reference%...

 

 

Thanks in Advance,

Regards,

Ravikumar.

0 Kudos
Reply

2,760 Views
PabloAvalos
NXP TechSupport
NXP TechSupport

Hi @Ravikumar1 

 

Thanks a lot for the update! and thank you so much for your patience too. If yo do not have any inconvenience, I was assigned to serve you on this case, because I see that you tagged one of my teammates, but I will be more than happy to assist you.

 

In regards of what you are trying to do, I will highly suggest you to check one of these reference manuals for enter bootloader without the NMI (SW1) being pressed: https://www.nxp.com/docs/en/reference-manual/MCUBOOTRM.pdf

Or this one specifically for Kinetis, but it says almost the same: https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/kinetis/37592/1/Kinetis%20Bootloader%20v...

 

Hope this documents are helpful for you by following the start-up process on the BCA (Bootloader Configuration Area), please let me know if you have more questions.

 

Best Regards.
Pablo Avalos.

0 Kudos
Reply

2,731 Views
Ravikumar1
Contributor II

Hi @PabloAvalos 

 

I am new to ROM Bootloader I have few questions regarding,

1) Actually I can enter the ROM Bootloader mode with Pressing the NMI switch, however my electronics team want to design board without external hardware switch (NMI). Is it possible to enter the ROM bootloader mode without switch? .

2) I think ROM Bootloader code we cannot update after getting MCU from NXP, they already update the ROM Bootloader code in it. If yes please tell me how will I update ROM Boot code ?

I cannot get from the document you shared.

https://www.nxp.com/docs/en/reference-manual/MCUBOOTRM.pdf

 

Regards,

Ravikumar

 

0 Kudos
Reply

2,727 Views
bobpaddock
Senior Contributor III


The bootloader will only be entered if BOOT# is asserted during reset, or actual application jump to it.

Does your device have any other buttons?
One of those can be routed to NMI/BOOT# in addition where the button input goes.
Then that button only needs held at whatever would normally reset the device.

Not using BOOT# risks bricking the device, which then requires reprogramming with a SWD-Pod of some type.   Bricking can happen if something happens during reprogramming, like power failure, PC host crashes (have seen several of those over the years) etc.

You are correct that the ROM bootloader can not be updated.
The KL27 also has a bug in its bootloader that I previously showed solution for.

0 Kudos
Reply

2,697 Views
Ravikumar1
Contributor II

Hi @bobpaddock 

 

1)  I followed the below link

 https://mcuoneclipse.com/2017/07/12/getting-started-rom-bootloader-on-the-nxp-frdm-kl03z-board/

and 

I called bootloader from application with the following piece of code: 

static void RunRomBootloader(void) {
    uint32_t runBootloaderAddress;
    void (*runBootloader)(void *arg);
 
    /* Read the function address from the ROM API tree. */
    runBootloaderAddress = **(uint32_t **)(0x1c00001c);
    runBootloader = (void (*)(void * arg))runBootloaderAddress;
 
    /* Start the bootloader. */
    runBootloader(NULL);
}

 

But the problem is after reset the board its always be in bootloader mode only, its not entering the application. I waited 1 or 2 min also. Will you please guide me what is wrong with the process. and Where exactly I need to call this function.

 

2) I want to trying the process what you previously showed the solution, Actually I have startup_MKL27Z644.s file for vectors, can I place the below code in this file or do I need to create my own vectors.c file ?

 

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 */
}
}

 

 

 

Thanks in advance,

 

Regards,

Ravikumar

 
0 Kudos
Reply

2,692 Views
bobpaddock
Senior Contributor III

"I called bootloader from application with the following piece of code: "

That code starts the bootloader.  It will stay there until there is a reset or the bootloader completes a good upload. Despite documentation claiming some mystery timeout.  I've found many times that the chips never actually read the documentation.

"startup_MKL27Z644.s"

They claim the KL27 bootloader bug only happens on 256K and larger parts, which are the ones I have.
So that functions should not be needed by you in a 64K part.

If you don't want to rewrite that function in assembly, which you could do by looking at the compiler output in the .lss file, the function can be the first thing called in main() or the first run .c file.  Sometimes that is vectors.c.  It depends how your build system is set up.  

 

If the application never starts, either the FOPT and/or BCA addressed not set correctly, as Erich describes in the link you gave, or the application is not loading correctly which is less likely.
It is also possible that the NMI pin is stuck to ground in the hardware, as that would cause this symptom.

Look to see what code/data s being loaded at address 0x3C0 to 0x40F that hold BCA and FOPT, in the S19 file being loaded.

What tool chain are you using?

0 Kudos
Reply

2,688 Views
Ravikumar1
Contributor II

Hi @bobpaddock 

Thanks for the reply

Actually First time I am working on ROM Bootloader, where do I update BCA addressed.

I am using IAR Workbench.

and for 

Look to see what code/data s being loaded at address 0x3C0 to 0x40F that hold BCA and FOPT, in the S19 file being loaded. where do I check this code/ files.

Actually I don't have BCA, FOPT, and S19 files files, will you please share me if you have those files.

regards,

Ravikumar

0 Kudos
Reply

2,686 Views
bobpaddock
Senior Contributor III

 

The .s19 file is what the blhost program (The PC end) takes to program the chip via the bootloader.

It is a text files so open it with editor to check the address range 0x3C0 to 0x40F.  If there is nothing in that range then that area will default to 0xFF in the chip.  In Erich's KL03 article and the KL27 data sheet see what those defaults do.

I don't use IAR so can not help you with that.

You may be farther a head to use the MCUXpresso IDE from NXP, as it has integrated compiler (GCC), debugger (if you have a hardware pod) and programmer to get the chip programmed.

https://www.nxp.com/design/software/development-software/mcuxpresso-software-and-tools-/mcuxpresso-i...

 

 

 

 

0 Kudos
Reply

2,659 Views
Ravikumar1
Contributor II

Hi,

Will any one tell me, How will I connect NXP Technical team for my questions and clarifications on zoom/ meetings, because in these threads takes so much time to get one reply and, I am not get any required clarification.

regards,

Ravikumar.

0 Kudos
Reply

2,652 Views
bobpaddock
Senior Contributor III

 

File a case number here:

https://www.nxp.com/support/support:SUPPORTHOME

 

 

0 Kudos
Reply