Application fails to run after leaving uTasker bootloader

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

Application fails to run after leaving uTasker bootloader

Jump to solution
532 Views
akimata
Contributor IV

Hi,

After a while i'm back to my project where i use uTasker bootloader but i'm struggling to run my application from it.

Bootloader is setup for MSD and it's working perfectly fine but when i load my application using it, it runs but the clocks are wrong(pwm outputs are off, rgb diodes acts weird, usb enumartion fails etc).

I tried to setup SOPT and SCGC registers to defaults before i run my code but it doesn't help.

The application runs just fine without bootloader.

Here is beggining of the main:

SCB -> VTOR = 0x1fffe000;
memcpy((uint32_t*)0x1fffe000,(uint32_t*)0x00008080,0x200);

SIM->SOPT1 =0;
SIM->SOPT2 =0x1000;
SIM->SOPT4 =0;
SIM->SOPT5 =0;
SIM->SOPT7 =0;
SIM->SOPT8 =0;

SIM->SCGC4= 0x100000;
SIM->SCGC5= 0x00;
SIM->SCGC6= 0x01;
SIM->SCGC7= 0x02;

BOARD_InitBootClocks();

The biggest problem is that i can't debug my application while bootloader is flashed so i'm unable to see what went wrong and why my clocks are off :smileysad:

Attaching also picture of main code clock setup:

clocks.PNG

Any ideas what i can do to make it work?

0 Kudos
1 Solution
480 Views
mjbcswitzerland
Specialist V

Hi

Such a problem is typically due to the fact that the clock initialisation in the application doesn't handle the case when it has already been configured and relies on something being at a reset value (which isn't).

It should be possible to debug if you connect to the board (not load code to it) and set a break point at the start of your code. The boot loader will run, jump to the application and then stop so that you can continue stepping the code. If you do a screen shot of the MCG and other related registers at this point after the serial loader has run you can do the same and compare when you run just your application; the difference should be visible so that you know which (other) register(s) to write.

Another technique is to configure the serial loader to use the same clock configuration that the application will use. Then you can completely remove any clock configuration in the application.

Regards

Mark

View solution in original post

0 Kudos
1 Reply
481 Views
mjbcswitzerland
Specialist V

Hi

Such a problem is typically due to the fact that the clock initialisation in the application doesn't handle the case when it has already been configured and relies on something being at a reset value (which isn't).

It should be possible to debug if you connect to the board (not load code to it) and set a break point at the start of your code. The boot loader will run, jump to the application and then stop so that you can continue stepping the code. If you do a screen shot of the MCG and other related registers at this point after the serial loader has run you can do the same and compare when you run just your application; the difference should be visible so that you know which (other) register(s) to write.

Another technique is to configure the serial loader to use the same clock configuration that the application will use. Then you can completely remove any clock configuration in the application.

Regards

Mark

0 Kudos