Ok thank you very much!
I already put these files boot.py, main.py, ftplib.py, and ftplib.mpy on my /home/pi/ directory since I'm using my Raspberry Pi as a Linux machine.
Now, I executed these commands on my Raspberry Pi's Terminal so that I can send those 4 files on my NodeMCU.
sudo ampy --port /dev/ttyUSB0 put boot.py
sudo ampy --port /dev/ttyUSB0 put main.py
sudo ampy --port /dev/ttyUSB0 put ftplib.py
sudo ampy --port /dev/ttyUSB0 put ftplib.mpy
After the transfer, I executed these commands on my Raspberry Pi's Terminal.
sudo ampy --port /dev/ttyUSB0 run boot.py
sudo ampy --port /dev/ttyUSB0 run main.py
NOTE: main.py is just a simple script for doing an FTP, the code came from the official python ftplib.
After I run the 'main.py', I still got some errors. Here is the error.
Traceback (most recent call last):
File "/usr/local/bin/ampy", line 8, in <module>
sys.exit(cli())
File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/ampy/cli.py", line 337, in run
output = board_files.run(local_file, not no_output)
File "/usr/local/lib/python3.7/dist-packages/ampy/files.py", line 303, in run
out = self._pyboard.execfile(filename)
File "/usr/local/lib/python3.7/dist-packages/ampy/pyboard.py", line 273, in execfile
return self.exec_(pyfile)
File "/usr/local/lib/python3.7/dist-packages/ampy/pyboard.py", line 267, in exec_
raise PyboardError('exception', ret, ret_err)
ampy.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n File "<stdin>", line 1, in <module>\r\nImportError: cannot import name FTP\r\n')
Any help?
Thank you very much!
ESP32: How to send files from internal flash to PC
- mkcastillote
- Posts: 4
- Joined: Mon Mar 16, 2020 10:35 am
Re: ESP32: How to send files from internal flash to PC
You do not need both ftplib.py and ftplib.mpy. And the .mpy file is most likely outdated anyhow, sine the bytecode version changed a few times in the past. But then, I cannot load ftplib.py due to memory restrictions. Loading the .mpy versions after recomppiling works.
Testing through a tool like ampy is a little bit difficult, because messages from ampy, Rpi and the targets are mixed.
Try to connect via a terminal emulator like picocom to the board and run your script from the REPL prompt. That gives you less spoiled errors.
Note: You do not have ot run boot.py and main.py manually. They are executed on every device boot anyhow.
Testing through a tool like ampy is a little bit difficult, because messages from ampy, Rpi and the targets are mixed.
Try to connect via a terminal emulator like picocom to the board and run your script from the REPL prompt. That gives you less spoiled errors.
Note: You do not have ot run boot.py and main.py manually. They are executed on every device boot anyhow.
- mkcastillote
- Posts: 4
- Joined: Mon Mar 16, 2020 10:35 am
Re: ESP32: How to send files from internal flash to PC
Thank you very much Roberthh.
-
- Posts: 2
- Joined: Mon Jul 26, 2021 6:18 am
Re: ESP32: How to send files from internal flash to PC
I just wrote a very simple tool to fetch files from a MicroPython board (I am using a Raspi pico), you can grab it from here:
https://github.com/udi-hakim/Tools
https://github.com/udi-hakim/Tools
-
- Posts: 30
- Joined: Thu Jun 30, 2022 3:21 am
Re: ESP32: How to send files from internal flash to PC
If you use Thonny and keep the files on the esp32 in one directory; you can download the files in batch by downloading the parent directory.