Author Topic: XMEGA Bootloader not able to start application  (Read 3106 times)

0 Members and 1 Guest are viewing this topic.

Offline cmcraesloTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: 00
XMEGA Bootloader not able to start application
« on: January 19, 2017, 11:04:12 am »
Hey guys.

I'm working on my own bootloader and I'm having problems jumping from the bootloader to application properly. I'm able to flash the application properly (If I set the BOOTRST to APPLICATION it works), but when I run the app from bootloader, it just doesn't work.

I'm using TCC0 timer in my bootloader and I disable it before jumping to 0x0. Even if I don't use the timers altogether, it still doesn't work.

There are many suggestions over the internet, I tried them all, but none of them worked for me.

Currently, I have this for going into the app:
Code: [Select]
CCP = CCP_IOREG_gc;
PMIC.CTRL = 0;
TCC0.INTCTRLA = 0;
asm("jmp 0x0");


I also tried enabling the watchdog and then checking for the RST.STATUS & WD first thing after booting:

When I want to start the application:
Code: [Select]
CCP = CCP_IOREG_gc;
WDT.CTRL = WDT_ENABLE_bm | WDT_CEN_bm | WDT_PER_8CLK_gc;
while(WDT.STATUS & WDT_SYNCBUSY_bm);

And then, first thing in main():
Code: [Select]
if (RST.STATUS & RST_WDRF_bm)
{
  asm("jmp 0x0");
}

This is driving me crazy :(

Thanks
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12494
  • Country: us
    • Personal site
Re: XMEGA Bootloader not able to start application
« Reply #1 on: January 19, 2017, 08:07:29 pm »
I'm not sure if "jmp #0" is appropriate for all situations. Try actual C way:
Code: [Select]
  void (*reset_vector)(void) = 0;
  reset_vector();
Alex
 

Offline krho

  • Regular Contributor
  • *
  • Posts: 233
  • Country: si
Re: XMEGA Bootloader not able to start application
« Reply #2 on: January 19, 2017, 08:14:35 pm »
I'm using xboot and I've looked at the code and at the end it also executes `jmp 0`. I'd say that you have something wrong with your fuses. Do you have a debugger to check where it's stuck? This would help you to find this in notime. Atmel ICE is pretty cheap.
 

Offline cmcraesloTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: 00
Re: XMEGA Bootloader not able to start application
« Reply #3 on: January 22, 2017, 02:57:48 am »
I do have ICE.

Not sure which thing worked, but this is the way i have it now and it works. Hopefully someone will find this helpful.

If I want to run the app, I reset it via WD:
Code: [Select]
cli();
CCP = CCP_IOREG_gc;
RST.STATUS = 0;
CCP = CCP_IOREG_gc;
PMIC.CTRL = 0;
CCP = CCP_IOREG_gc;
WDT.CTRL = WDT_ENABLE_bm | WDT_CEN_bm | WDT_PER_512CLK_gc;
while(WDT.STATUS & WDT_SYNCBUSY_bm);
while(1);

and then first thing in the bootloader:
Code: [Select]
if (RST.STATUS & RST_WDRF_bm && !(RST.STATUS & RST_PDIRF_bm))
{
CCP = CCP_IOREG_gc;
RST.STATUS = 0;
CCP = CCP_IOREG_gc;
PMIC.CTRL = 0;
CCP = CCP_IOREG_gc;
cli();
SP_LockSPM();
asm("jmp 0x0");
while(1);
}

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->