Copy lots of files in the mcus

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
Lornioiz
Posts: 36
Joined: Wed Aug 03, 2016 11:39 am
Location: Florence, Italy

Copy lots of files in the mcus

Post by Lornioiz » Wed Jan 11, 2017 3:43 pm

Hello,

I need to put in the filesystem a large quantity of text files (.txt) that contain precompiled datas.
Those files are in the order of the hundreds (minimum requirement is 100). Instead of copying them one by one I thought to embed them in the image.
I tried putting them in the \script folder but I once I flashed the image seems that they can't be read (or I don't know how to read them).
What is the fastest way to copy hundreds of file in the mcu?

Thanks you!

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Copy lots of files in the mcus

Post by Roberthh » Wed Jan 11, 2017 4:40 pm

The files in the scripts and modules folders that go into flash cannot be read, only imported as python scripts. You could try my ftp script in https://github.com/robert-hh/ESP8266-FTP-Server.git. It is too large to run as python soource The best is to put that into the /modules folder and create an flash image, or to pre-compile it with mpy-cross and load the .mpy file.
The ftp server supports the mput command of the command line ftp. You could also use filezilla or fireftp for the transfer, which give you a nice two-pane view of the files. Just be careful to configure these for single session only..

User avatar
ernitron
Posts: 89
Joined: Fri Jun 03, 2016 5:53 pm
Location: The Netherlands

Re: Copy lots of files in the mcus

Post by ernitron » Wed Jan 11, 2017 11:52 pm

I'd give a try to ampy:

Code: Select all

ls *.txt | xargs -n 1 ampy --port /dev/ttyUSB0 --baud 115200 put
(assuming all your txt files are in one directory)
adjust port and especially baud to have the most reliability

OR (with bash):

Code: Select all

for f in `ls *.txt`;
   do ampy put $f ;
done;
OR with webrepl (assuming 192.168.1.100 is your device address)

Code: Select all

for f in `ls *.txt`;
   do webrepl_cli.py put $f 192.168.1.100/$f;
done;
check of course to have in the path ampy and webrepl_cli.py

Lornioiz
Posts: 36
Joined: Wed Aug 03, 2016 11:39 am
Location: Florence, Italy

Re: Copy lots of files in the mcus

Post by Lornioiz » Fri Jan 13, 2017 1:48 pm

Thank you both!
I went for a bash script this time, but I will add the ftp module in all my images from now on. I didn't test it yet, but you never know when it can comes in handy and saves the day!

Thanks and regards!

tannewt
Posts: 51
Joined: Thu Aug 25, 2016 2:43 am

Re: Copy lots of files in the mcus

Post by tannewt » Sat Jan 14, 2017 12:46 am

Tony just added recursive put to ampy too: https://github.com/adafruit/ampy/commit ... a77059cefa

Post Reply