Program the MKL25z with a bootloader (MCUX)

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

Program the MKL25z with a bootloader (MCUX)

Jump to solution
2,307 Views
huy_dang
Contributor III

Hi support,

I want to be able to program the MKL25z via USB port without using JTAG/SWD except for the first time. I need to set the MKL25z up as a mass storage device and copy binaries onto it to program. Any idea where I should start or what project should I take a look at? I'm using MCUX and SDK 2.2 by the way. 

Edit:

I know I have to start with MCUBOOT but I have no idea how to port it to my project since the KL25 is not a supported device (I think). 

Thanks in advance, 

Huy

Tags (3)
0 Kudos
1 Solution
2,074 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Huy,

You could try enabling the timeout of the bootloader, I think the problem would be that is using direct boot. The KBOOT has an option that will accept any incoming message until a timeout is reach and the first message send by any peripheral will enable the bootloader.

I think this could be an option instead of using a button.

Best Regards,

Alexis Andalon

View solution in original post

0 Kudos
9 Replies
2,074 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Huy,

 

As you mention the KL25 is not supported in the MCUBoot but in the legacy KBoot was supported.

 

In the MCUBoot webpage you can download this package and in the targets folder you can find the source code, unfortunately this is not supported in MCUXpresso but you could check the code and port it to MCUXpresso.

 

Let me know if this helps you.

 

Best Regards,

Alexis Andalon

0 Kudos
2,074 Views
huy_dang
Contributor III

Hi Alexis,

Sorry about the late reply. I was able to port the project to KL25 and got the bootloader to enumerate as an MSD device now. Then I follow this guide right here to create an sb file to drop on to the MSD device. 

USB MSD Bootloader Implementation 

However, my console display this error when I dropped the file onto the device. 

pastedImage_2.png

I look it up and found out that this error is a protection memory error so I'm wondering if there's extra command I need to issue in my .bd file. 

pastedImage_1.png

Appreciate the help!

Huy

0 Kudos
2,074 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Huy,

Have you tried using the Kinetis Flash Tool? This is in the following route: 

NXP_Kinetis_Bootloader_2_0_0\bin\Tools\KinetisFlashTool\win

Also in the documentation folder there's the following document Kinetis Flash Tool User's Guide that can help you flash the binary to your MCU.

Best Regards,

Alexis Andalon

0 Kudos
2,074 Views
huy_dang
Contributor III

Hi Alexis,

So I found out that this problem is due to my bootloader exceed 0xa000 in size and I have to move the address of the application in the memory to 0x10000. I no longer have a problem with memory error.

Now, I notice a different problem. The MSD device only enumerates after I program it via SWD. As soon as I power cycle the board, I don't see the drive enumerates anymore. I wonder what could be a problem here?

Edit: I think the problem right now that I have is the board being boot into the application program instead of the bootloader on power up. Is there a way I can go to the bootloader from the application program. (I'm using the MKL25z128VLK4, not the FRDM board so I don't have a boot pin).

Best,

Huy

0 Kudos
2,075 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Huy,

You could try enabling the timeout of the bootloader, I think the problem would be that is using direct boot. The KBOOT has an option that will accept any incoming message until a timeout is reach and the first message send by any peripheral will enable the bootloader.

I think this could be an option instead of using a button.

Best Regards,

Alexis Andalon

0 Kudos
2,074 Views
huy_dang
Contributor III

Hi Alexis,

Thank you so much, this is the correct answer and now I got the bootloader to work correctly. Turns out I commented out the systick_timer in the bootloader by mistake and that caused it to be a direct boot.

A different but somewhat related question I have now is after putting my program in the bootloader, I noticed that the uart interrupt no longer work correctly. 

pastedImage_1.png

I'm receiving nonsense on my UART0 communication port. I tested out with the example program in the SDK (frdmkl25z_driver_examples_uart_interrupt) and the same thing is happening. Any ideas what is causing this?

Edit: I forgot to include but if either JTAG or USB port is connected then the UART behaves correctly but if they are both disconnected then I run into this problem.

Best,

Huy

0 Kudos
2,074 Views
baldurthorgilss
Contributor III

Hi 

I have a similar problem. I like to be able to use the MCUBOOT for firmware upgrades to my own-designed KL46Z board either via MSD or USB. I am using MXUXpresso and this controller is not supported in the MCUBOOT package. I tried to get the source to compile but was not successful. Is there any trick to it? What steps did you take to get the project to compile for KL25?

Best regards,

Baldur

0 Kudos
2,074 Views
huy_dang
Contributor III

Hi Baldur,

I follow this guide right here in order to port the project to my KL25Z. https://community.nxp.com/message/1033065?commentID=1033065#comment-1033065. Keep in mind since the guide is using a different board, your drivers will be different and you will have to adjust.

Good luck,

Huy

0 Kudos
2,074 Views
huy_dang
Contributor III

Nevermind, I was just missing a common ground on the UART cable. Always check the hardware!

0 Kudos