Error Switching from Bootloader to User Application

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

Error Switching from Bootloader to User Application

995 Views
tgc-yilmaz
Contributor III

Hello,

 

I am using MPC5644A. I have two different projects: bootloader and user application. I am installing the user application with bootloader. But even if the user application is running, I want the code to start again from the bootloader every time the power is turned off and on.


For this, I placed the reset vectors of the bootloader and user application, paying attention to the order of priority attached. I want the code to always start from the bootloader when the power is turned off and on, and I want to switch to the user application after the user application is installed or after a certain time if the application is already installed.
But I couldn't get the code to run in the user application. How can I do this and is there any way to do this without making changes to the startup code?

pastedImage_1.png

Thank you for your help...

Labels (1)
0 Kudos
4 Replies

759 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

here is an example from https://community.nxp.com/servlet/JiveServlet/download/427962-1-279359/bootloader.zip :

It's for MPC5634M, but it doesn't matter, it's about principle:

Linker file of bootloader can be updated in this way:pastedImage_1.png

Only first 64KB is used for the bootloader. It occupies the first location of RCHW, so the bootloader will be always started after reset.

Linker file of user application can be updated like this:

pastedImage_2.png

... so it occupies rest of the flash (everything above first 64KB).

You do not need to jump to the user application directly in the startup files. You can do that in main function. Just use pointer to function. But I strongly recommend to put everything back to default reset state before jump and also disable all interrupts (if some were enabled) - by local enable bits in peripherals, by MSR[EE] and also by priority registers. This is very important and it can eliminate a lot of troubles.

Regards,

Lukas

0 Kudos

759 Views
tgc-yilmaz
Contributor III

Thank you for your answer.

As you specified, I set the reset vectors and tried to do the jump with the following code snippet in the main. However, after this process, the data in the memory block where the user application is located changes and the user application can not run.

I am not using any interrupt in my bootloader project. Can you help with this?

pastedImage_3.png

0 Kudos

759 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

There's no problem with the jump, this code is correct.

If you can see that the data in flash memory are "changing" then it is caused by wrong configuration of flash wait states, most likely.

pastedImage_1.png

In CodeWarrior project, the initialization is done in FlashConfig function in __ppc_eabi_init.c file (it must be executed from RAM).

Second option I can see is that you have reconfigured MMU.

So, more debugging will be needed...

Regards,

Lukas

0 Kudos

759 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

edit - sorry, I mismatched the threads, so I deleted this post.

0 Kudos