Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Over the air (OTA) firmware update (LoPy4)

    Scheduled Pinned Locked Moved Firmware
    lopy
    13 Posts 6 Posters 1.8k Views 6 Watching
    Loading More Posts
    • 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.
    • A Offline
      Asb
      last edited by Asb

      Hi

      I am trying to do a OTA firmware update using this guide, where I ran into some issues.

      Issue:
      From the docs:
      Firmware: These files should be named in the format firmware_VERSION.bin, where VERSION is a a version number compatible with the python LooseVersion versioning scheme (http://epydoc.sourceforge.net/stdlib/distutils.version.LooseVersion-class.html).

      This file should be in the format of the appimg.bin created by the Pycm firmware build scripts.

      I downloaded 1.18.1.r1 firmware from here and got the following files after unpackaging:
      appimg.bin, bootloader.bin, lopy.bin, partitions.bin and script.file
      Do I simply rename the appimg.bin to firmware_1.18.1.r1.bin and place it in the directory specified in the docs?

      Thanks.

      1 Reply Last reply Reply Quote 0
      • I Offline
        iwahdan
        last edited by

        Hi @Asb , actually appimg.bin and lopy4.bin , are identical (redundant) binarys, I recommend you rename the lopy4.bin to firmware_1.18.1.r1.bin because we are planning to remove the appimg.bin from the firmware package eventually.

        Wahdan

        robert-hhR A 2 Replies Last reply Reply Quote 1
        • robert-hhR Offline
          robert-hh @iwahdan
          last edited by robert-hh

          @iwahdan The ftp.updater expects the target name to be:
          /flash/sys/appimg.bin
          So you are not free to give the image any name when uploading. Of coures you can do that on your PC, but it should include the target platform. And when uploading, the file name for storing must also be pre-defined.

          I 1 Reply Last reply Reply Quote 2
          • I Offline
            iwahdan @robert-hh
            last edited by

            @robert-hh yes sure, but using OTA update via the HTTP server, only require firmware to be named firmware_VERSION where VERSION should be following python LooseVersion versioning scheme, so it is the same weather to rename appimg.bin or lopy4.bin
            As for ftp updater, considering removing appimg.bin from FW packages, will require update to ftp server for sure.

            Thanks

            Wahdan

            1 Reply Last reply Reply Quote 1
            • A Offline
              Asb @iwahdan
              last edited by Asb

              @iwahdan, @robert-hh Thanks.

              I renamed the lopy4.bin to firmware_1.18.1.r1.bin, similar for the 1.16.0.b1 firmware and have the following directory:

                - server directory
                  |- OTA_server.py
                  |- 1.0.0
                  |  |- flash
                  |  |   |- lib
                  |  |   |  |- OTA.py
                  |  |   |- main.py
                  |  |   |- boot.py
                  |  |   |- config.py
                  |- 1.0.1
                  |  |- flash
                  |  |   |- lib
                  |  |   |  |- OTA.py
                  |  |   |- main.py
                  |  |   |- boot.py
                  |  |   |- config.py
                  |- firmware_1.16.0.b1.bin
                  |- firmware_1.18.1.r1.bin
              

              Inside config.py (in both 1.0.0 and 1.0.1 folder) I have the following:

              WIFI_SSID = "not show here"
              WIFI_PW = "not shown here"
              SERVER_IP = "127.0.0.1"
              

              My main.py is the same as the one shown in the docs, only thing I've changed is removing the need to send a downlink message from the things network to initiate the OTA update, therefore my main loop looks like this:

              while True:
                  print("Performing OTA")
                  # Perform OTA
                  ota.connect()
                  ota.update()
              
                  sleep(5)
              

              When I try to initiate the OTA update:
              I run the OTA_server.py script using Python 3.7.1 and get no errors. Then I upload the project folder to the lopy like this (folder 1.0.0):
              0_1540448216862_1.0.0.PNG

              Then I get this following error:
              0_1540448208051_firmware_error http.PNG

              Thanks

              I R 2 Replies Last reply Reply Quote 0
              • I Offline
                iwahdan @Asb
                last edited by iwahdan

                @Asb I think you are putting the wrong Server IP, 127.0.0.1.is the local host and you are running this code from LoPy4 so you must enter correct Server IP.

                Wahdan

                A 1 Reply Last reply Reply Quote 2
                • A Offline
                  Asb @iwahdan
                  last edited by

                  @iwahdan
                  I tried again today, but got the same error, this time my SERVER_IP was the one I found after writing ipconfig in cmd (IPv4 address).
                  Is this the correct address to use?

                  I 1 Reply Last reply Reply Quote 0
                  • R Offline
                    rskoniec @Asb
                    last edited by rskoniec

                    @asb I thing that version folder names should correspond with the fw file names (firmware_VERSION.bin = folder name VERSION) so:
                    for firmware_1.16.0.b1.bin your version folder name should be 1.16.0.b1
                    for firmware_1.18.1.r1.bin your version folder name should be 1.18.1.r1

                    The machine is working as good as it's code.

                    1 Reply Last reply Reply Quote 1
                    • I Offline
                      iwahdan @Asb
                      last edited by

                      @asb yes, Also make sure your Lopy4 is on the same network as your OTA server.

                      Wahdan

                      A 1 Reply Last reply Reply Quote 0
                      • A Offline
                        Asb @iwahdan
                        last edited by

                        @iwahdan @rskoniec thanks.
                        I am however still having problems.
                        I just renamed all the 1.16.0.b1 files to 1.0.0 and 1.18.1.r1 to 1.0.1 to avoid this as stated in the OTA_server.py (because I dont know how to):

                        # In order for the URL's to be properly formatted you are required to send a
                        # "host" header along with your HTTP get request e.g:
                        # GET /manifest.json?current_ver=1.0.0 HTTP/1.0\r\nHost: 192.168.1.144:8000\r\n\
                        

                        In my IDE where I am running the OTA_server.py I get the following error message when requesting:

                        Got query for: /manifest.json?current_ver=1.0.0
                        192.xxx.xx.xx - - [26/Oct/2018 11:12:31] "GET /manifest.json?current_ver=1.0.0 HTTP/1.0" 200 -
                        Generating a manifest from version: 1.0.0
                        ----------------------------------------
                        Exception happened during processing of request from ('192.xx.xx.xx', 53954)
                        Traceback (most recent call last):
                          File "C:\Python37\lib\socketserver.py", line 313, in _handle_request_noblock
                            self.process_request(request, client_address)
                          File "C:\Python37\lib\socketserver.py", line 344, in process_request
                            self.finish_request(request, client_address)
                          File "C:\Python37\lib\socketserver.py", line 357, in finish_request
                            self.RequestHandlerClass(request, client_address, self)
                          File "C:\Python37\lib\socketserver.py", line 717, in __init__
                            self.handle()
                          File "C:\Python37\lib\http\server.py", line 426, in handle
                            self.handle_one_request()
                          File "C:\Python37\lib\http\server.py", line 414, in handle_one_request
                            method()
                          File "C:\Users\user\Desktop\OTA\OTA_server.py", line 156, in do_GET
                            manifest = generate_manifest(current_ver, host)
                          File "C:\Users\user\Desktop\OTA\OTA_server.py", line 278, in generate_manifest
                            latest = get_latest_version()
                          File "C:\Users\user\Desktop\OTA\OTA_server.py", line 184, in get_latest_version
                            if latest is None or LooseVersion(latest) < LooseVersion(d):
                          File "C:\Python37\lib\distutils\version.py", line 52, in __lt__
                            c = self._cmp(other)
                          File "C:\Python37\lib\distutils\version.py", line 337, in _cmp
                            if self.version < other.version:
                        TypeError: '<' not supported between instances of 'str' and 'int'
                        ----------------------------------------
                        

                        I placed some x's in my IP adress to hide it, and replaced my username with "user" in the code block above, fyi.
                        Thanks.

                        A 1 Reply Last reply Reply Quote 0
                        • A Offline
                          Asb @Asb
                          last edited by

                          Additional info:
                          I am able to do an OTA update, i.e. changing from green to blue light as in the script/guide previously linked. However, its when I add the firmware.bin files to the directory I get errors, like the one shown in the post before this one.

                          1 Reply Last reply Reply Quote 0
                          • M Offline
                            Milan
                            last edited by

                            This post is deleted!
                            1 Reply Last reply Reply Quote 0
                            • S Offline
                              svonbentzel
                              last edited by

                              Has anyone runs the ota service without errors?

                              My ota service ran into an error at rename files from boot.py to boot.py.new

                              But why??

                              1 Reply Last reply Reply Quote 0

                              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                              With your input, this post could be even better 💗

                              Register Login
                              • 1 / 1
                              • First post
                                Last post

                              Pycom on Twitter

                              Pycom