Kl27 Applicaiton Firmware upgrade from ROM bootloader

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

Kl27 Applicaiton Firmware upgrade from ROM bootloader

3,460 Views
anilnadargi
Contributor II

Hi Team ,

We are working on customized board based on MKL27Z256VMP4 SOC . We are implementing firmware upgrade over USB from ROM boot-loader. Currently through below logic we are entering in ROOM code and trying to detect / enumerate USB in boot-loader mode on Host Windows PC .We were able to detect the USB on host PC for only one time . But later USB is never detected by PC even though we power cycled multiple times and run same logic to enter ROM boot-loader .

Code to enter bootloader 

void (*runBootloader)(void * arg);
uint32_t runBootloaderAddress;
// Read the function address from the ROM API tree.
//runBootloaderAddress = **(uint32_t **)(0x1c00001c);
runBootloaderAddress = **(uint32_t **)(0x1c000000);   //Tried both 0x1c00001c and 0x1c000000 address 
runBootloader = (void (*)(void * arg))runBootloaderAddress;
runBootloader(NULL);

Also we tried to enter ROM boot-loader after reset by modifying below flash configuration in startup_MKL27Z4.S file .

.section .FlashConfig, "a"
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFFFFFE   //Tried 3D with NMI pin settings , 

Please suggest . 

Also is there any way to detect that device is executing in ROM boot-loader ?

Thanks ,

Anil N

12 Replies

2,928 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Anil,

It seems that the chip's ROM-based bootloader do something wrong .

And It's good way to figure out the root cause of the issue to create a flash-reside bootloader demo.

In the attachment, the Chapter 10 has illustrated the steps of porting the Kinetis bootloader to an unsupported Kientis MCU, please refer to it for details.

Have a great day,
Ping

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

0 Kudos

2,928 Views
bobpaddock
Senior Contributor III

Where can we get the source code to the actual boot loader that is in the KL27?

2,928 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Bob,

Just as the Anil mentioned above, the KBOOT hasn't had the bootloader demo for the KL27 up to now.

However it's easy to port a supported target demo to the desired target MCU and in the attachment, the Chapter 10 has illustrated the steps of porting, please refer to it for details.
Have a great day,
Ping

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

0 Kudos

2,928 Views
bobpaddock
Senior Contributor III

"However it's easy to port a supported..."

Actually it is easier if Freescale/NXP just releases the code that they have already done for the KL27...


Why must we reinvent the wheel?

2,928 Views
anilnadargi
Contributor II

Hi Team ,

Yes , it be nice if you guys can release the source code for flash based bootloader for KL27 SOC .

Thanks ,

Anil N.

2,928 Views
anilnadargi
Contributor II

Hi Team ,

Please find below for the error message . 

Error: Connect device failed(Error: UsbHidPeripheral() cannot open USB HID device (vid=0x15a2, pid=0x0073, sn=).).

We were able to successfully boot from the boot-loader using force boot from ROM configuration based on FOPT register settings .Also we where able to see the USB device enumerated on Host PC ( WIndows 7 ) . But later on not for single time we are able to boot from ROM or USB enumeration on Host PC . 

Queries :

a. How do we check / verify that ROM bootloader is running and waiting for commands on over USB .

b. Does any configuration get changed after first booting from ROM bootloader which does not init USB in the bootloader 

Also we are looking for flash based bootloader as second option for firmware upgrade . We have downloaded the KBOOT latest version , but unable to find KL27 target .Please let us know how can we build KBOOT for Kl27 for booting from Flash .

Thanks ,

Anil N.

0 Kudos

2,928 Views
anilnadargi
Contributor II

Hi Team ,

Power cycle I  mean the board and using below Flash Configuration (Boot from ROM Boot-loader ) we were not getting the board (KL27 ) USB enumerated on the Windows PC .It got enumerated only once . 

section .FlashConfig, "a"
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFFFFFE  

We used blhost utility to communicate with board boot-loader but it gives errors that cannot find the USB device .

Can you please know how we can resolve this issue . Also how can we get to know the boot-loader is running or not .

Thanks ,

Anil N.

0 Kudos

2,928 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Anil,

I was wondering if you can illustrate the error message when you use the blhost utility to communicate with board boot-loader.

In addition,  you can select the COM terminal to communicate with board boot-loader.
Have a great day,
Ping

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

0 Kudos

2,928 Views
bobpaddock
Senior Contributor III

My comment stands.  Sometimes you have to unplug the PC's power from the wall, have had this happen several times.

Also don't use the same USB Hub that your mouse and keyboard use.  To much current drawn at start up can cause a port or hub to shut down.

0 Kudos

2,928 Views
bobpaddock
Senior Contributor III


Windows can be temperamental.

"USB is never detected by PC even though we power cycled multiple times and run same logic to enter ROM boot-loader ."

Do you mean you shutdown the PC via Windows or did you really cycle power by unplugging the PC from the wall?

If you're BIOS has features like 'wake up on keypress' then you really do need to unplug the PC form the wall to recover from some of these USB errors.

Also unplug any external USB hubs that might be in use too.

USBDeView: View any installed/connected USB device on your system is a great help to tell if something is really connected or not.

KBoot does have issues with restarting, on the bus analyzer it shows repeated enumeration failures, after programming and requires a board reset, what exactly happens depends on what FOPT got programmed to with the update just programmed.

0 Kudos

2,928 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Anil,

The modified FOPT boot options will force the MCU enter the Bootloader mode, and I'd highly recommend you to use the Blhost host utility program to communicate with the Kinetis bootloader.
Have a great day,
Ping

0 Kudos

2,928 Views
wangyilong
Contributor III

Hi, Jeremy

What's the latest version of blhost app, please? 2.6.2?

Is this blhost suitable to all Kinetis chip?

I have tried it, the blhost can not communicate with KL43, 27, 17.

Because blhost always trys to send 0x98 0x66 0x98 to detect the bootloader.

But the KL serials can only reply to 0x5a 0xa6.

Could you provide the latest blhost version?

Tks a lot!

0 Kudos