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.
Lornioiz
Posts: 26
Joined: Wed Aug 03, 2016 11:39 am

Copy lots of files in the mcus

Postby 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: 442
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Copy lots of files in the mcus

Postby 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: 83
Joined: Fri Jun 03, 2016 5:53 pm
Location: The Netherlands

Re: Copy lots of files in the mcus

Postby 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: 26
Joined: Wed Aug 03, 2016 11:39 am

Re: Copy lots of files in the mcus

Postby 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: 23
Joined: Thu Aug 25, 2016 2:43 am

Re: Copy lots of files in the mcus

Postby tannewt » Sat Jan 14, 2017 12:46 am

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


Return to “ESP8266 boards”

Who is online

Users browsing this forum: No registered users and 9 guests