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

    download boot.py and main.py by ftp

    Scheduled Pinned Locked Moved Discussion
    ftppython
    12 Posts 4 Posters 3.1k Views 4 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.
    • M Offline
      misterlisty
      last edited by

      Trying to find example of downloading file by ftp? Is ftp a builtin library? Anyway example of how to download a file by ftp? Basically want to download a program logic by ftp and reboot to activate the new logic.

      robert-hhR 2 Replies Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @misterlisty
        last edited by

        @misterlisty Th eftp server is built in. For an ftp client, there is a library here: https://github.com/SpotlightKid/micropython-ftplib
        I tried that on LoPy and it works. There is an example using this ftplib in the OTA discussion: https://forum.pycom.io/topic/518/ota-or-not-ota-that-is-the-question/74
        I used that to download the firmware image.

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

          from ftplib import *
          

          File "main.py", line 13, in <module>
          MemoryError: memory allocation failed, allocating 662 bytes

          I'm using the ftplib from github as suggested, i just want to be able to update the boot and main files remotely..is this how other people are doing OTA? At the moment, i'm only updating the script files

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @misterlisty
            last edited by

            @misterlisty In ther esp8266 subdir of that repository there is a smaller version of ftplib. You may also put ftplib into frozen bytecode, or write you own little tool to download main.py and boot.py.

            M 2 Replies Last reply Reply Quote 0
            • M Offline
              misterlisty @robert-hh
              last edited by

              @robert-hh thanks whatis frozen bytecode? seems like something i need to know!

              robert-hhR 1 Reply Last reply Reply Quote 0
              • R Offline
                rvandam
                last edited by

                If you have a fresh Lopy, ftp is enabled by default. You will have a wifi network named lopy-wlan-xxxx

                If you connect to the wifi network (password is www.pycom.io) you can use a ftp program like Filezilla and transfer files in both directions.

                Server 192.168.4.1
                User: micro
                Pass: python

                1 Reply Last reply Reply Quote 0
                • robert-hhR Offline
                  robert-hh @misterlisty
                  last edited by

                  @misterlisty Frozen bytecode is a mechanism to store compiled python code in the flash memory. During execution, it will not use RAM for the code and static strings, only for the dynamic data it deals with. If you want to use that, you have to create your own firmware images. That is not really complicated, just the initial step seems a little bit complicated. The git repository is at: https://github.com/pycom/pycom-micropython-sigfox, the tailored esp-if is at https://github.com/pycom/pycom-esp-idf. The readme.md there gives you instructions on how to setup the build environment. Once you have set it up, you can copy the files to be placed in flash into the directory pycom-micropython-sigfox/esp23/frozen and start a build run. That all works best on unix, worst on Windows.
                  There is an intermediate solution of precompiling your python script on your PC and load the compiled version to the devices file system. The code will still be loaded to RAM, but not RAM is required for compiling. That helps if your run out of memory at the import statement. For that, you need the cross-compiler, which is also part of the github package, and would also required to setup the build environment. As a conveniene offer, I have pre-built verions of the cross compiler mpy-cross in my own repository at https://github.com/robert-hh/Shared-Stuff. The files mpy-cross-pycom.exe and mpy-cross-pycom-linux are the once suitable for the pycom products.

                  M 1 Reply Last reply Reply Quote 0
                  • M Offline
                    misterlisty @robert-hh
                    last edited by

                    @robert-hh thanks, one more questions, how to keep up with updates done by pycom, i assume i do a GET of github and merge the chaages?

                    robert-hhR 1 Reply Last reply Reply Quote 0
                    • robert-hhR Offline
                      robert-hh @misterlisty
                      last edited by

                      @misterlisty Once you have a local clone of that repository, you can run "git pull" to update that. However, Pycom is not very consistent in it's repository handling. So I had to delete and re-clone the repositories a few times. But that is also not a big deal.

                      1 Reply Last reply Reply Quote 0
                      • M Offline
                        misterlisty @robert-hh
                        last edited by

                        @robert-hh can i use ftplib.mpy will lopy recognise this? when i use the ftplib.py from the esp dir i get allocation memeory...this mean i have to bytefreeze it?

                        1 Reply Last reply Reply Quote 0
                        • robert-hhR Offline
                          robert-hh @misterlisty
                          last edited by

                          @misterlisty ftplib.mpy should work on a Lopy, give that you use the latest firmware and the mpy file was created with the proper mpy-cross program. You have to remove or rename ftplib.py from the file system, otherwise the .py file is used.

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

                            download boot.py and main.py by ftp

                            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