MiniCore icon indicating copy to clipboard operation
MiniCore copied to clipboard

Cannot upload reliably using Bluetooth and an HC-05

Open mgurzixo opened this issue 4 years ago • 0 comments

This is a duplicate of Optiboot issue #334. I do not know which repository is the best for this discussion...

When connecting an Arduino pro mini to an HC-05, I was not able to upload a sketch reliably OTA. The long story is there .

My solution was to patch the function verifySpace() inside Optiboot like this:

void verifySpace() {
  if (getch() != CRC_EOP) {
#ifdef CLASSIC_VERIFY_SPACE
    watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
    while (1)            // and busy-loop so that WD causes
      ;              //  a reset and app start.
#else
    putch(STK_NOSYNC);
#endif
  }
  else {
    putch(STK_INSYNC);
  }
}

So that, if there is noise on the line, Optiboot sends back STK_NOSYNC instead of resetting, allowing AVRDUDE to resynchronize nicely.

Doing that allows now for a very reliable OTA sketch upload.

As an added benefit, Optiboot is now 2 bytes smaller :)

Any comments?

Michel

mgurzixo avatar Nov 30 '21 13:11 mgurzixo