Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. Sensebender/Dualoptiboot OTA HowTo in Mysensors

Sensebender/Dualoptiboot OTA HowTo in Mysensors

Scheduled Pinned Locked Moved Hardware
25 Posts 10 Posters 12.9k Views 18 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vikasjee
    wrote on last edited by vikasjee
    #21

    Any sample optimised sketch for the OTA enabled sketch?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      manutremo
      wrote on last edited by
      #22

      I was looking for the same and found this:

      https://forum.mysensors.org/topic/4923/ota-firmware-updating-is-too-slow/13

      1 Reply Last reply
      0
      • scalzS scalz

        Hi.

        Here is an howto about OTA in Mysensors I made for jeedom french users when Mysensors 1.5 was released. So I translated it if it can be useful to you. Things should not have changed a lot I think. I have no time for the moment to check everything. So if you note differences, tell me here and I will update. I will update pics with latest revision of the software.

        OTA, or Over The Air, lets you upload your sketch without ftdi, it's done wirelessly. Can be useful if your nodes are not accessible or you need to make signing changes for instance. To get this nice feature, you need to burn a dedicated bootloader.

        In Mysensors, we can use two kind of OTA:

        • 1st option : MYSBootloader, created by Tekka from Mysensors Team.
        • 2nd option : Dualoptiboot or if you prefer Sensebender Bootloader (in Mysensors boards). But in this tutorial I will name it "Dualoptiboot". It comes from Lowpowerlab.

        Difference between these two methods (updated from Tekka post http://forum.mysensors.org/topic/3453/mysbootloader-1-3-pre-release-myscontroller-1-0-0beta/9)

        • MYSBootloader does not require external flash: OTA FW updates are transmitted offline, i.e. MYSBootloader communicates with the controller and receives new FW which is directly written to MCU, once FW is transmitted and CRC verified, MYSBootloader hands over to the new sketch/FW.
          Pro: recovery OTA possible, also with a faulty/buggy sketch (if sketch freezes, watchdog resets and MYSBootloader takes over), no external flash required
          Cons: Radio specific, i.e. different bootloader for RF24 and RFM69 radio (rfm69 work in progess) necessary, offline (no sensor data processing possible during ota).
        • Dualoptiboot requires external flash: OTA FW updates are transmitted online, i.e. while the node is active. Once all FW packets are transmitted and CRC verified, the node reboots, dualoptiboot copies FW from external flash to MCU and hands over to the new sketch/FW.
          That means too that you need to ftdi upload your node sketch the first time or ota won't work yet as it is handled in the sketch.
          Pro: Radio agnostic (no radio specific code in bootloader so can be used in different scheme/protocols..), online (while node processes sensor data)
          Cons: Faulty FW (e.g. freezing sketch due to bad coding) cannot be recovered OTA => recovery via serial port necessary, external flash required

        This tutorial is only for Dualoptiboot Bootloader, because I have not seen an howto for this option here yet. But some parts/pictures of this howto can be used for MYSBootloader upload.
        If you want to use MYSBootloader, howto is here: http://forum.mysensors.org/topic/3453/mysbootloader-1-3-pre-release-myscontroller-1-0-0beta/9

        By default, Dualoptiboot bootloader is 8Mhz Internal + 1.8V BOD.

        What do you need:

        • SPI eeprom, jedec compliant, like AT25DF512C-SSHN-B. For other eeprom and compatibility, you can check this post https://forum.mysensors.org/topic/3160/ota-flash-types-for-mysensors
        • for evaluation or some diy projects, I did this evalboard https://oshpark.com/shared_projects/m5Uugjx5 or you can find it on opensourcehardware. No need of course if you have a sensebender, moteino etc as eeprom is already there.
        • I use an USBASP to burn the bootloader
        • I use AVRDUDESS : http://blog.zakkemble.co.uk/avrdudess-a-gui-for-avrdude/ for fuse
        • arduino 1.6.x
        • Mysensors 1.5.x : http://www.mysensors.org/download/
        • MYSController : http://www.mysensors.org/controller/myscontroller
        • So in Arduino Ide, now you shoud see Sensebender Micro board in Boards\tools

        Burn Dualoptiboot in your node

        To keep things simple, or maybe not for others..imho it's so easy with a cheap usbasp (just few wire) than arduino as isp.

        What looks my usbasp (clone, USBASP 2.0 LC Technology) and connections to your arduino or node.

        0_1458993268264_737420usbasp.png
        Wiring on nano/micro/328p:

        MOSI : D11
        VTG : VCC 3.3V
        GND : GND
        RES : RESET
        SCK : D13
        MISO : D12
        

        Once it's wired, burn fuses with avrdudess. Here the conf:

        0_1458993338862_281987avrdudess.png

        Note : even if my usbasp is a clone, I choose genuine usbasp in the listbox.

        Just click on Write in "Fuses&Lock bits" section. Then read it to check fuses are well burned.

        Now don't disconnect your usbasp.

        • Go to arduino ide, choose SensebenderMicro, Processeur Atmel328 8Mhz, serial COM port, and USBASP programmer.
        • Click Tools\Burn bootloader. You will get few SCK warning but that's not a problem, it's because I have an usbasp clone.
          Note: you could use avrdudess to burn the bootloader too.

        0_1458993400230_236880arduino1.png

        0_1458993479899_889671arduino2.png

        Yeah, our OTA bootloader is burnt :)

        In sketch

        To enable OTA in your sketch, you need to add

        #define MY_OTA_FIRMWARE_FEATURE 
        

        or uncomment it in Myconfig.h

        OTA management is completely transparent. Everything is well handled in process() and wait() methods (when you do a gw.wait or mynode.wait for instance...)

        Important note :

        • Don't forget a sleeping node can't receive an OTA. You can wait after wakeup for instance to see if you have somethings coming or I have not tried it yet but it seems now in mysensors libs there is smartsleep() wich manage the wait() after wake up.
        • when you upload the new sketch, it is done during runtime, so you have to handle/optimize this in sketch. The best is if you detect an OTA msg, to pause process or sensors readings during the process or it will affect the speed of the OTA. I mean for instance if you read sensors, sometimes there are some delays in libs, all these things will delay ota or timeout it during main loop. Plus, if these optimization are not done and you run on battery, the longer time in TX/RX radio for the update, the more battery energy wasted. OTA can be fast 15-30sec if nothing slow it, or x minutes if not optimized :open_mouth:
          So it's up to you to manage this, use non blocking/asynchronous code. The rest of the process is again completely transparent. Great!

        How to upload a new sketch just with OTA

        For this I use MYSController. It's not an .ino file that you will upload but the .hex one. So to easily get this file:

        • In Arduino ide, go to File\Preferences, on bottom click on preferences.txt. It opens preferences.txt.

        0_1458993573312_121153arduino3.png

        • Keep this file opened and close arduino ide (otherwise your changes will be erased).
        • In preferences.txt, at the end, add this
        build.path=C:\Arduino-Output\
        

        or another preferred path. It will be there you will find your .hex compiled sketch files.

        • Open arduino ide and compile/check your node project. You should now see your compiled files in the path you have set.
        • Copy the .hex to Firmware path of MYSController

        Launch your OTA update

        • Launch MYSController and in Config/Serial, check the right serial com port.
        • Click on "Refresh FW repo" so you can use your new .hex file.
          Note : When I tested this it didn't work for me so I needed to do this
          In Firmware folder, edit firmware_config.csv and manually add your .hex. Here an example where I added a Humidity .hex file for tests.
        Type,Name,Version,File,Comments
        10,Blink,1,Blink.hex,blinking example
        20,TimeReporter,1,TimeReporter.hex,TimeReporter
        100,Sensebender Micro,1,SensebenderMicro.cpp.hex,Sensebender Micro
        110,Sensebender Blink,1,SensebenderBlink.cpp.hex,Sensebender Blink
        120,Sensebender HumidityTest,1,HumiditySensor.cpp.hex,HumidityTest
        
        • Now to wirelessly send your new sketch to your node, simply right click on the node you want to update. For sleeping battery node, choose "Battery powered Sleeping". So when your node will wake up, MYSController will resend the update. Awesome!
        • click on Assign FW,
        • choose the sketch

        and voilà! OTA should start, and then your node will reboot.

        0_1458993734904_399014arduino4.png

        I hope to have not missed something important. Please tell me, and I will add in this post.
        This howto was made some months ago, so I'm note sure if it's exactly still the same, but that should be almost ok. Try and test ;) and tell me. I hope it will help at least, as it is something often asked..If all is ok, don't hesitate to put it on a better place (I'm not sure if it's the best place here)

        Enjoy!

        C Offline
        C Offline
        cvdenzen
        wrote on last edited by
        #23

        @scalz A useful addition could be that the controller only runs on Windows. I bumped into this limitation after quite a few succesful steps. Is there a Linux or Java alternative?

        scalzS 1 Reply Last reply
        0
        • C cvdenzen

          @scalz A useful addition could be that the controller only runs on Windows. I bumped into this limitation after quite a few succesful steps. Is there a Linux or Java alternative?

          scalzS Offline
          scalzS Offline
          scalz
          Hardware Contributor
          wrote on last edited by scalz
          #24

          @cvdenzen
          will think about it :) afaik there isn't any simpler linux or java alternative yet. I'm windows user and MYSController is very handy.
          that said you can take a look here for controllers supporting FOTA https://www.mysensors.org/controller , maybe MyController.org ..

          M 1 Reply Last reply
          1
          • scalzS scalz

            @cvdenzen
            will think about it :) afaik there isn't any simpler linux or java alternative yet. I'm windows user and MYSController is very handy.
            that said you can take a look here for controllers supporting FOTA https://www.mysensors.org/controller , maybe MyController.org ..

            M Offline
            M Offline
            manutremo
            wrote on last edited by
            #25

            @scalz Mycontroller works fine, I just tested it with Dualoptiboot and last package version (ask in the forum).

            1 Reply Last reply
            1
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            24

            Online

            11.7k

            Users

            11.2k

            Topics

            113.1k

            Posts


            Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular