MYSBootloader node contantly resets



  • Last year I started experimenting with OTA upgrades using MYSBootloader (using the pre-built one from Github (pre3 version? Not sure). I built a small test environment with a handfull of nodes and managed to successfully change the sketch over the air.

    Happy with the results I upgraded some existing "production" sensors to MySensors 2.1.1 and in the process swapped the bootloader of those nodes to MYSBootloader, so they would be OTA ready for the next round of upgrades. After successfully doing this to a handfull of nodes I repeated it on a different node and noticed in the logfile of Domoticz that the node was continuously presenting itself to the controller (about each 25 seconds or so). Otherwise the node seemed to work (updated temperature and humidity, but did not sleep for five minutes as it was supposed to). The previous nodes were Arduino Nano based and this one was Arduino Pro Mini based. So at first I thought it would be a Pro Mini issue (which would be peculiar as like the Nano it was also using an Atmega 328p @16MHz). But when I would try another Nano that one would also reset itself continuously(!). If I revert the bootloader back to the Nano or Pro Mini one and try the same sketch the resets are gone. It's driving me insane and I'm at a loss why I cannot produce MYSBootloader nodes anymore that don't reset themselves.

    In the process of troubleshooting I found out that MYSBootloader needs to be compiled with the same channel settings as the gateway it connects to. My "production" environment uses a different (non-default) channel, so the nodes that do have MYSBootloader need to be redone (doh!). I have also managed to download the sources, set the correct channel and build it. Unfortunately these bootloaders also show the resets.

    Other things I tried:

    • Clear the EEPROM, burn the bootloader and load the sketch (using USB cable)
    • Use brand new Arduino's
    • Change the NRF modules
    • Revert to previous library versions and boards.txt files used when I successfully used MYSBootloader
    • Tried different fuse settings

    No differences unfortunately. Does this sound familiar to anyone? What am I overlooking? I really would like to get this working again as I love the OTA idea (and have some nodes hidden away without easy access).


  • Admin

    @tsjoender For recovery reasons, MYSBootloader comes with wdt enabled, i.e. make sure you either reset the wdt in regular intervals in the main loop() using

    wdt_reset();
    

    or disable it in setup(), using

    wdt_reset();
    wdt_disable();
    


  • @tekka Thanks for the quick response (and the work done on this bootloader). I’ll give that a try in the coming days and report back.



  • @Tekka You steered me in the right direction. Thanks again! I did a search on wdt_reset to get a better idea of what it does and then found posts describing that if something keeps the CPU occupied for a prolonged time that the watchdog can kick in thinking the MCU has stalled/froze. I also understood that the MySensor library will reset the watchdog timer regularly.

    Looking at my sketch I found that I used delay() at certain points. The five minute sleep was done using wait(). Replacing delay() with wait() throughout the sketch fixed the issue for me! It has not reset overnight where otherwise I would see it reset every 25 seconds or so. Now I will look at the other examples that would reset itself.

    I'm in good shape now to roll out MYSBootloader and upgrade my nodes to 2.2.0 at the same time.


 

369
Online

8.0k
Users

8.8k
Topics

94.3k
Posts