Page 1 of 1

Copy lots of files in the mcus

Posted: Wed Jan 11, 2017 3:43 pm
by Lornioiz
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!

Re: Copy lots of files in the mcus

Posted: Wed Jan 11, 2017 4:40 pm
by Roberthh
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..

Re: Copy lots of files in the mcus

Posted: Wed Jan 11, 2017 11:52 pm
by ernitron
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

Re: Copy lots of files in the mcus

Posted: Fri Jan 13, 2017 1:48 pm
by Lornioiz
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!

Re: Copy lots of files in the mcus

Posted: Sat Jan 14, 2017 12:46 am
by tannewt
Tony just added recursive put to ampy too: https://github.com/adafruit/ampy/commit ... a77059cefa