LowPowerLab Forum

Hardware support => Moteino => Topic started by: rgregor on November 28, 2013, 07:47:26 PM

Title: Software reset or jump to bootloader
Post by: rgregor on November 28, 2013, 07:47:26 PM
Hello, I want to implement in my sketch the automatic start of the bootloader. I have trie to use the same trick with watchdog but seems it is not working to me, at least I cannot see the led. But the reset is performed. My code:

void setup() {
  Serial.begin(115200);
  Serial.println("Starting...");
}
void loop() {
   if (stringComplete) {
       if (lowerCaseInput.startsWith("at+res")) {
           wdt_enable(WDTO_15MS);
           while(1);
       }
   }
}

So after I will send to serial port at+res I will got imediately Starting... No bootloader action. To have bootloader in action, I have to do HW reset.
Anyone has an idea why?

Robert
Title: Re: Software reset or jump to bootloader
Post by: Felix on November 29, 2013, 09:53:23 AM
There's a function called resetUsingWatchdog() in the wirelesshex lib that does that, take a look there: https://github.com/LowPowerLab/WirelessProgramming/blob/master/WirelessHEX69/WirelessHEX69.cpp
Title: Re: Software reset or jump to bootloader
Post by: rgregor on November 29, 2013, 10:03:08 AM
Hello thanks for the answer. Yes, this I did. The function looks like:

void resetUsingWatchdog(boolean DEBUG)
{
  //wdt_disable();
  if (DEBUG) Serial.print("REBOOTING");
  wdt_enable(WDTO_15MS);
  while(1) if (DEBUG) Serial.print('.');
}

It means it is the same thing, I am using. But still the bootloader is not called, but reset is done. Strange.....
Title: Re: Software reset or jump to bootloader
Post by: Felix on November 29, 2013, 11:45:41 AM
Hold on. What bootloader are you using?
Title: Re: Software reset or jump to bootloader
Post by: rgregor on November 29, 2013, 04:54:58 PM
Hello, I am using original motenio board (without SPI flash memory), I didnt change it, so I expect, that I have your DualOptiboot.
Title: Re: Software reset or jump to bootloader
Post by: Felix on November 30, 2013, 09:54:26 AM
Ok and how do you know it doesn't enter the bootloader?
Title: Re: Software reset or jump to bootloader
Post by: rgregor on November 30, 2013, 05:59:27 PM
I think, that bootloader will turn on the LED e.g. and it waits around 1 second for the data before it will start the normal processing. And it will not happen, the Starting... string is printed immediately.
Title: Re: Software reset or jump to bootloader
Post by: Felix on November 30, 2013, 06:13:27 PM
No, if there's nothing to do it will immediately skip the bootloader without waiting.
In your case, there's no FLASH chip and inherently no flash image to write, so it will jump to the program ASAP.