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. General Discussion
  3. Over the air updates

Over the air updates

Scheduled Pinned Locked Moved General Discussion
87 Posts 15 Posters 50.4k Views 12 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.
  • greglG Offline
    greglG Offline
    gregl
    Hero Member
    wrote on last edited by
    #69

    Hi @ToSa

    Do you know if your OTA Bootloader uses more flash mem on the atmega328 vs the Optiboot bootloader?

    I have a sketch which needs Optiboot to fit and really hoping i can one day use your cool OTA stuff.

    Looking at your github it seems MyOtaBootloader.hex is 9.36k whereas Optiboot v5,0a the optiboot_atmega328.hex is 1.418k ( but there is also a optiboot_atmega328.lst file at 19.778k - I dont know enough to know if this is part of the bootloader or if its just the source???)

    Cheers,
    Greg

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      Zeph
      Hero Member
      wrote on last edited by
      #70

      OptiBoot fits in 1/2 KiB (the binary on-chip size, not the hex file).
      The OTA Bootloader is obviously larger. If you are using close to 31.5KiB on an ATMega328p, it won't fit with any bootloader larger than OptiBoot.
      .
      Make sure you use the latest compiler - 1.5.7 seems to squeeze harder (smaller binary), and I presume 1.0.6 (which has also been upgraded to a newer compiler) will also do so.

      How big does the compiler say your sketch is, at the end of a compile?

      1 Reply Last reply
      0
      • greglG Offline
        greglG Offline
        gregl
        Hero Member
        wrote on last edited by
        #71

        @Zeph said:

        use the latest compiler - 1.5.7 seems to squeeze harder (smaller binary), and I presume 1.0.6 (which has also been upgraded to a newer compiler) will also do so.

        How big does the compiler say your sketch is, at the end of a compile?

        I'll check when i get home tonight.

        Very interesting about the new compiler. I'm pretty sure im using 1.0.5-r2, and i've recently begun using Atmel studio with Visual Micro addon - just soooo much better when dealing with long sketches!!!

        Cheers,
        Greg

        T 1 Reply Last reply
        0
        • greglG gregl

          @Zeph said:

          use the latest compiler - 1.5.7 seems to squeeze harder (smaller binary), and I presume 1.0.6 (which has also been upgraded to a newer compiler) will also do so.

          How big does the compiler say your sketch is, at the end of a compile?

          I'll check when i get home tonight.

          Very interesting about the new compiler. I'm pretty sure im using 1.0.5-r2, and i've recently begun using Atmel studio with Visual Micro addon - just soooo much better when dealing with long sketches!!!

          Cheers,
          Greg

          T Offline
          T Offline
          ToSa
          Code Contributor
          wrote on last edited by
          #72

          @gregl the fuses determine how much space is reserved for the bootloader. I don't have the datasheet at hand but I think it varies from .5k to 4k. Optiboot is one of the smallest out there and the OTA bootloader consumes the full space because it needt to includs the (shrinked) wireless driver.

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            Zeph
            Hero Member
            wrote on last edited by Zeph
            #73

            I think the OTA bootloader which does not rely on any extra memory is a great option!

            And I think the option of having external flash may work out well too. Sending an image to be written to SPI flash might not expand the application code as much (it already has the library). Then the bootloader just has to copy from SPI to application flash. I'm thinking that might make for a smaller total footprint, since there would be no need to fit 2 nRF libraries in the 32KiB flash - a trimmed down nRF library in the boot section plus the full nRF library in application section.

            Of course, if the application gets hosed, you would not be able to do OTA bootloading and would have to physically access the node to recover, but if it's a matter of fitting or not fitting into FLASH, that might be a risk one is willing to take.

            marceltrapmanM 1 Reply Last reply
            0
            • Z Zeph

              I think the OTA bootloader which does not rely on any extra memory is a great option!

              And I think the option of having external flash may work out well too. Sending an image to be written to SPI flash might not expand the application code as much (it already has the library). Then the bootloader just has to copy from SPI to application flash. I'm thinking that might make for a smaller total footprint, since there would be no need to fit 2 nRF libraries in the 32KiB flash - a trimmed down nRF library in the boot section plus the full nRF library in application section.

              Of course, if the application gets hosed, you would not be able to do OTA bootloading and would have to physically access the node to recover, but if it's a matter of fitting or not fitting into FLASH, that might be a risk one is willing to take.

              marceltrapmanM Offline
              marceltrapmanM Offline
              marceltrapman
              Mod
              wrote on last edited by
              #74

              @Zeph said:

              Sending an image to be written to SPI flash might not expand the application code as much (it already has the library).

              Because I am sure that Flash memory will come in handy sooner or later I have added the Winbond W25X40 to the first version of my board already :).

              Fulltime Servoy Developer
              Parttime Moderator MySensors board

              I use Domoticz as controller for Z-Wave and MySensors (previously Indigo and OpenHAB).
              I have a FABtotum to print cases.

              1 Reply Last reply
              0
              • tekkaT Offline
                tekkaT Offline
                tekka
                Admin
                wrote on last edited by
                #75

                just managed to optimize the OTA bootloader to under 2k - 2k more for sketches with OTA.

                T 1 Reply Last reply
                0
                • tekkaT tekka

                  just managed to optimize the OTA bootloader to under 2k - 2k more for sketches with OTA.

                  T Offline
                  T Offline
                  ToSa
                  Code Contributor
                  wrote on last edited by
                  #76

                  @tekka
                  That sounds great! Can you post your code (or share a pull request)? This would either allow us to free up the remaining space or to add encryption :)
                  The only neck-breaker would be if any of the size reduction increases the risk for a bricked node that needs manual intervention (e.g. reset / power cycle etc.).

                  1 Reply Last reply
                  1
                  • tbowmoT Offline
                    tbowmoT Offline
                    tbowmo
                    Admin
                    wrote on last edited by
                    #77

                    what is the current status of the OTA firmware updates? Is external flash necessary at all? Is someone working on it?

                    Right now I am trying to get DualOptiboot from lowpowerlabs.com to work with my board, and an external flash / eeprom. But was wondering if it would be used at all.

                    Then when I got the bootloader working, I need to test firmware updates, but the road is still long and windy to get there (at the moment, only have 1 hour here, and there, to work on the hardware)

                    1 Reply Last reply
                    1
                    • tekkaT Offline
                      tekkaT Offline
                      tekka
                      Admin
                      wrote on last edited by
                      #78

                      @tbowmo
                      Did some work on the OTA bootloader: combined optiboot (for uploads via IDE / avrdude) + OTA bootloader with some major modifications. Current version is stable and works for regular OTA updates :)

                      I will post the source once I find some spare time to clean and comment it.

                      1 Reply Last reply
                      3
                      • klimK Offline
                        klimK Offline
                        klim
                        wrote on last edited by
                        #79

                        hi, is your work on ota based on internal o external flash?

                        1 Reply Last reply
                        0
                        • tekkaT Offline
                          tekkaT Offline
                          tekka
                          Admin
                          wrote on last edited by
                          #80

                          @tbowmo
                          internal: FW streaming via controller

                          1 Reply Last reply
                          1
                          • tbowmoT Offline
                            tbowmoT Offline
                            tbowmo
                            Admin
                            wrote on last edited by
                            #81

                            @tekka

                            I have been thinking about OTA the last couple of days, while trying to get DualOptiboot working (using external SPI flash). If program directly, then the firmware needs to be send in a ordered way by the controler, in order for the bootloader to get things done.. What if a single package is missed?

                            What if we have 100 nodes, that all needs software update at the same time? Is the system able to handle that?

                            A part of me says, go with the direct method (that is, skipping external SPI flash) for my minimized module, but then again.. I realy want to have the added "security" of having an external flash, where I can download to, and only when checksums are correct, then I can issue a "Reload software command" to the node.

                            In theory, I could send the software to 100 nodes, and then when they all are ready, broadcast an "restart node" to all the affected nodes.. (future plans I know..)

                            Just my thoughts rambling around in my head :)

                            tekkaT 1 Reply Last reply
                            1
                            • tbowmoT tbowmo

                              @tekka

                              I have been thinking about OTA the last couple of days, while trying to get DualOptiboot working (using external SPI flash). If program directly, then the firmware needs to be send in a ordered way by the controler, in order for the bootloader to get things done.. What if a single package is missed?

                              What if we have 100 nodes, that all needs software update at the same time? Is the system able to handle that?

                              A part of me says, go with the direct method (that is, skipping external SPI flash) for my minimized module, but then again.. I realy want to have the added "security" of having an external flash, where I can download to, and only when checksums are correct, then I can issue a "Reload software command" to the node.

                              In theory, I could send the software to 100 nodes, and then when they all are ready, broadcast an "restart node" to all the affected nodes.. (future plans I know..)

                              Just my thoughts rambling around in my head :)

                              tekkaT Offline
                              tekkaT Offline
                              tekka
                              Admin
                              wrote on last edited by
                              #82

                              @tbowmo

                              Yes, in the current setup, the node requests FW blocks the way they will flashed, i.e. page-wise. If one block is missing, the bootloader will re-request that block several times and reboot after a few unsuccessful attempts. The nRF24L01 has CRC on the payload and auto-retransmission of corrupt payloads (see RFInit; 15x every 150us).
                              As soon as the OTA update is initiated, the CRC is invalidated and the sensor remains in the bootloader until the update is successful and the CRC is valid.

                              Updating 100 nodes simultaneously: for my understanding, the limitations are if the gateway and/or repeater nodes can handle the traffic and the connection quality). Updating sensors semi-sequentially (e.g. 5 nodes at a time) works from my experience.

                              Having added "security" with an external flash is certainly a nice feature (and opens other very interesting applications), but is it that important for OTA updating nodes with a down-time of a few minutes? Again, one could instruct the controller to update the nodes in a controlled fashion...

                              1 Reply Last reply
                              1
                              • tbowmoT Offline
                                tbowmoT Offline
                                tbowmo
                                Admin
                                wrote on last edited by
                                #83

                                @tekka

                                Sure for a temperature sensor, downtime of a couple of minutes is not an issue, but there might be other types of nodes that shouldn't have downtime.

                                What if we bring in the WAF? Let's say the node we want to update is the one that turns on light in the wife's walk in closet, And she is getting ready for a night out with the girlfriends :-) Then "a few" minutes downtime could be fatal to your own health :-)

                                tekkaT 1 Reply Last reply
                                0
                                • tbowmoT tbowmo

                                  @tekka

                                  Sure for a temperature sensor, downtime of a couple of minutes is not an issue, but there might be other types of nodes that shouldn't have downtime.

                                  What if we bring in the WAF? Let's say the node we want to update is the one that turns on light in the wife's walk in closet, And she is getting ready for a night out with the girlfriends :-) Then "a few" minutes downtime could be fatal to your own health :-)

                                  tekkaT Offline
                                  tekkaT Offline
                                  tekka
                                  Admin
                                  wrote on last edited by
                                  #84

                                  @tbowmo
                                  ...lol ;) shouldn't you be preparing for bar hopping instead of updating the sensors?
                                  as mentioned previously, no big deal to have different updating options/sources in the bootloader, I will think about that :)

                                  tbowmoT 1 Reply Last reply
                                  1
                                  • tekkaT tekka

                                    @tbowmo
                                    ...lol ;) shouldn't you be preparing for bar hopping instead of updating the sensors?
                                    as mentioned previously, no big deal to have different updating options/sources in the bootloader, I will think about that :)

                                    tbowmoT Offline
                                    tbowmoT Offline
                                    tbowmo
                                    Admin
                                    wrote on last edited by
                                    #85

                                    @tekka said:

                                    @tbowmo
                                    ...lol ;) shouldn't you be preparing for bar hopping instead of updating the sensors?

                                    Someone had to be at home watching the kids. And when the wife is out, we have the time to spend on fun projects, instead of doing the laundry or whatever tasks she could figure out she wanted help with :-)

                                    1 Reply Last reply
                                    0
                                    • DammeD Damme

                                      @ToSa I finally figured out why my OTA bootloader didn't read any answers from my GW (Both on I_FIND_PARENT and I_ID_REQUEST) - The answers came to quick! First I tried hardcode a delay 125ms on the GW and it worked, so I changed the code on send write to the following and now all messages arrive. Been testing it for a couple of reboots now. I'm using 5v (at 3.3v) and 16MHz
                                      edit; noticed it misses packages sometimes now but not close to 100% like before, more like 5% now. I'llinvestigate futher then I'm trying to upload data.

                                        static uint8_t sendAndWait(uint8_t reqType, uint8_t resType) {
                                        	msg.type = reqType;
                                        	for (uint8_t i = 0; i < 10; i++) {
                                        		sendWrite(msg);
                                        		for (uint8_t j = 0; j < 20; j++) {
                                        			for (uint8_t j = 0; j < 100; j++) {
                                        				uint8_t pipe;
                                        				boolean avail = available(&pipe);
                                        				wdt_reset();
                                        				if (avail && pipe<=6) {
                                        					read(rmsg.array,pipe);
                                        					if(!(mGetVersion(rmsg) == PROTOCOL_VERSION))
                                        						continue;
                                        					if (rmsg.destination == nc.nodeId) {
                                        						if (mGetCommand(rmsg) == C_INTERNAL) {
                                        							if (rmsg.type == I_FIND_PARENT_RESPONSE) {
                                        								if (rmsg.data[0] < nc.distance - 1) {
                                        									nc.distance = rmsg.data[0] + 1;
                                        									nc.parentNodeId = rmsg.sender;
                                        									eeprom_write_byte((uint8_t*)EEPROM_PARENT_NODE_ID_ADDRESS, nc.parentNodeId);
                                        									eeprom_write_byte((uint8_t*)EEPROM_DISTANCE_ADDRESS, nc.distance);
                                        								}
                                        							}
                                        						}
                                        						if ((mGetCommand(rmsg) == mGetCommand(msg)) && (rmsg.type == resType))
                                        							return 1;
                                        					}
                                        				}
                                        				delaym(1);
                                        			}
                                        		}
                                        	}
                                        	return 0;
                                        }
                                      
                                      D Offline
                                      D Offline
                                      Dheeraj
                                      Plugin Developer
                                      wrote on last edited by
                                      #86

                                      @Damme Is OTA working for you..I am also getting the same message from Gw.

                                      1 Reply Last reply
                                      0
                                      • skywatchS Offline
                                        skywatchS Offline
                                        skywatch
                                        wrote on last edited by
                                        #87

                                        I would really like to get OTA working here as it's freezing outside and I have to go there to update the software in the greenhouse control system.

                                        So please, can we have a 'how to' step-by-step guide to OTA? Please?

                                        S.

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


                                        19

                                        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