Author Topic: MotetinoMega wireless programming mystery  (Read 2417 times)

letcher

  • NewMember
  • *
  • Posts: 12
MotetinoMega wireless programming mystery
« on: March 29, 2016, 09:18:33 PM »
I have a couple of MoteinoMegas, one in a remote location and one for development.  While trying to reprogram the remote (deployed) device with the current wireless programmer it appeared to work as expected.  However, when testing the device it did not have the code changes I had made.  To further test I changed some ascii messages that are sent and they stayed the same as the original code.

Next I wirelessly programmed my development device and the changes were there as expected.  I then assumed I had damaged the dual optiboot loader and so I swapped the development device with the deployed device.  The deployed moteinoMega programs just fine now with the wireless programmer.

Today I spent a LOT of time installing AVRStudio 6 so I could reflash the bootloader with a AVRISP tool.  I eventually succeeded and then I also loaded the hex file of my working code while I had everything connected.  I made a dump file of the flash memory while connected to the AVRISP and compared the dump file to the hex file generated by the Arduino IDE.  They appear to be the same.

Since the reflashed MoteinoMega seemed to work correctly I assumed the reflash of the bootloader had worked.  However, although it appears to be programmed wirelessly it still did not change the loaded code.  Its as though the new code is loaded into the eprom but not transferred to the flash memory. Any idea of what is going on here?

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6867
  • Country: us
    • LowPowerLab
Re: MotetinoMega wireless programming mystery
« Reply #1 on: March 29, 2016, 09:29:27 PM »
Can you confirm the Moteino is restarted (via WDT) after the transfer of the new sketch HEX is done?

letcher

  • NewMember
  • *
  • Posts: 12
Re: MotetinoMega wireless programming mystery
« Reply #2 on: March 29, 2016, 09:58:55 PM »
It appears to reboot.  As a simple test I opened a serial terminal via the IDE and then reprogrammed with the wireless program.  Here is a fragment of the result:

adio [24] > 464c583a3335323a8d147f14e1140d0a006e616e00696e66
FLX:352:OK
radio [14] > 464c583a3335333a006f76660000
FLX:353:OK
FLX?OK
UNShifting channel to 915000000
FLASH IMG TRANSMISSION SUCCESS!
REBOOTING...þSerial initialized
Transmitting at 915 Mhz...
mail_maga.ino 3-23-2016
Interrupts enabled

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6867
  • Country: us
    • LowPowerLab
Re: MotetinoMega wireless programming mystery
« Reply #3 on: March 29, 2016, 10:19:24 PM »
Yup it looks like it reboots.
So same everything, except a different target MoteinoMEGA, and that works? And this one MoteinoMEGA doesn't?

letcher

  • NewMember
  • *
  • Posts: 12
Re: MotetinoMega wireless programming mystery
« Reply #4 on: March 30, 2016, 12:13:05 AM »
Yep.  I'll try further test if you think of a direction.  Seems like we could learn something.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6867
  • Country: us
    • LowPowerLab
Re: MotetinoMega wireless programming mystery
« Reply #5 on: March 30, 2016, 08:33:22 AM »
Libs have to be up to date, on all parts involved, I assume you've already checked that.
I would check what the state of the HEX is on the FLASH MEM. You can use the sample sketch and do a dump ('d') to see the first 256 bytes. The important part is the first bytes of the header. It gets a little tedious to look at hex bytes and try to figure out if all is good. The header is of the form FLXIMG:nnnn:xxxxxx...x where nnnn is the byte count and the xxxxx..x is the actual hex image bytes.
If it's not missing anything then the bootloader has some issue. I've seen where the image is written but the header is missing some part and thus the bootloader skips to the existing sketch. The byte count (nnnn) is written last by the WirelessHEX lib after the image is completely transferred.