Go Down

Topic: Ftp Server on Arduino (Read 59953 times) previous topic - next topic

gallegojm

#60
Feb 24, 2015, 06:01 pm Last Edit: Mar 04, 2015, 12:56 am by gallegojm
Hi QWang2015
Those are good news!

About W5500
I am not surprised you got approximatively the same upload/download times than with W5200 because it seems they have the same SPI characteristics.

About the 3 seconds delay
I use Wiz820io and connect his Reset pin to a digital output of the Due (pin 8 ). So I can send a reset pulse to the chip in the setup() routine. (Look at FtpServerTest.ino)
In the shield you use, reset pin of W5200 chip is directly connected to reset pin of Arduino Due, so it is reseted at the same time as the other components of the application. I don't think a so long delay ( 3 seconds ) is necessary.

About transfer speeds
Your download speed of 255 kB/s is very similar to mines ( from 251 to 269 kB/s, varying with the type of card, the client, the operative system )
But I am surprised with the upload speed. 130 seconds for 13,5 MB corresponds to 103 kB/s. This the half of what I obtain (up to 216 kB/s)
It would be interesting to know if the difference is due to the driver of the ethernet module, the driver of the SD card or something else.

gallegojm

I upload to GitHub the last version of my Ftp Server for Arduino Due and Ide 1.6.0

I add the command MDTM (File Modification Time)
Note that FTP clients do not manage the same way the handling of last modified time of files:
  - FtpRush use MDTM command to set the time of an uploaded file the same than original local file
  - FileZilla let the server register the time when was uploaded the file. In that case you need to have a RTC implemented in your server.

Command ABORT must now close correctly a file when an upload is interrupted.

You need to update libraries FatFs and FatLib
I also update the patch for the W5200 based shields.


romanyork

gallegojm,
This is my first Arduino post. I have been using Arduino for one month with Mega2560 +ethernet shield r3 (5100) and Arduino 1.6.2

I have yet to successfully compile ftp server using your March 2015 release at Github with libs and instruction from your readme. Can you verify that your latest git will compile with Mega 2560 with sd?
My power just went out so I cannot post the compile errors. They were not file not found errors.

I am also interested in Due + Ethernet.   In normal Ethernet apps that I have created I find Mega 2560 + Ethernet Shield R3 have very high current.  Mega = 85mA at 5V, ethershield is 170mA 3.3V at  idle. Can you check due + 5200 current?
Thank you in advance,

romanyork

gallegojm,
It took me a while to get my boards going but I did get it to work and I have successfully created files on SD and transferred files over the air to my Arduino system that is connected to a cellular router.
Perhaps my biggest problem was figuring out how the library system works in Arduino.

I have a couple of things that I can pass along for now.
One problem that caused me a lot of grief is my assuming that a #define of FAT_SYST at line 1 in the .ino is not seen at all of the include files.  I tried to define a global define that would automatically make changes from Due to Mega.
One item I did change that is important is the EthernetClient connected.  If you change the files in the Arduino root and install new Arduino it seems to clobber the entire Arduino install directory so the modified ethernetserver files are wiped out.  I made a new ethernet.h called EthernetConnected.h, modified the affected files, then installed the new library in my personal libraries.

Arduino 1.6.3
Arduino 2560
Ethernet Shield with W5100.


Thanks for this great project!

gallegojm

Hi romanyork
Thank you for the interest in my work!

For my last release in Github, I abandon the compatibility with Arduino Mega.
The reason is that the latest ide introduced some changes with the spi library. I do not understand the goal of those changes but they introduce a lot code that, I think, is not necessary for Arduino Due. May be they are for ARM Arduinos like the Mega.
So I try to optimize the code for Due only.
But this only interfere with the code to manage the SD card and the ethernet module
So, if you are working with an Arduino Mega, you can use the last version of ftpserver. But I think that you should use the SdFat and FatLib versions of February.
I would appreciate to inform me of your results.

About the current consumption, I think it is difficult to measure it. Remember you must also include the consumption of the SD card.
 
Quote
One problem that caused me a lot of grief is my assuming that a #define of FAT_SYST at line 1 in the .ino is not seen at all of the include files.
Yes, Arduino IDE has sometime as strange way to manage #define...

Quote
I made a new ethernet.h called EthernetConnected.h
I like this idea, because as you say, each time you install a new ide, you have to rewrite the modifications.

romanyork

 gallegojm,
I have gotten FTP to work with FTPRush and SmartFTP but that's all I tried on my PC.
Do you have any suggestions for iPHone or windows phone?

My code compiles to 39,3952kB Flash and 5,354 RAM.  Any quick suggestions for getting the RAM down?  My Ethernet server/NTP server code that I want to integrate with already uses 3.5kB RAM.
I will convert your text strings to Flash and let you know how low the RAM gets.

Can you pull the SD Card from your Due and see what current is like?  My project will be inactive most of the time.

Thanks for the reply,

Roman

romanyork

I've just done a file compare between your project and the reference libraries that you provide and my final project.

The only think I'd change to your ReadMe is adding these lines under the SdFat instructions.
From earlier posts in this stream:
>>Comment out lines 40 - 46 in iostream.h
>>comment out the error line 25 in SDVolume.h

My final project compiled on 1.6.2 without updating any of the libraries in Library manager.
During development I had updated some of the libraries but I don't remember which ones.  I reinstalled Arduino 1.6.0 and then went back to 1.6.2 because of the IDE bugs in 1.6.0.

I think that's it.  I'll repost if I find anything else.

gallegojm

Hi Roman
Thank you for the feedback

Quote
The only think I'd change to your ReadMe is adding these lines under the SdFat instructions.
From earlier posts in this stream:
>>Comment out lines 40 - 46 in iostream.hRight
Right. I make this comment in message #17 and forgot to include it in the ReadMe. I have to update it

Quote
>>comment out the error line 25 in SDVolume.h
I am surprised than you got this error. Normally the file SdVolume.h is not included during compilation and you don't need it. Did you explicitly include this file in your sketch?
A search for #include "SdVolume.h" give no result in the whole SdFat library.

Quote
Any quick suggestions for getting the RAM down?
...
I will convert your text strings to Flash
I admit ftpserver.cpp is not optimized in size. An example is the string "500 Command line too long\r\n" that appears 10 times
That is because I was concerned about the logic of ftp protocol more than code optimization.
But the compiler does its job and there is only one occurrence of the string in the .hex file. I am not sure if the string, witch is a constant, is located in flash or ram. Did you have the answer?
If you want to reduce the size, most of message sent by the server can be reduced to the three-digit code. The following english sentence is for human, not machine  :)
So, for example, you can replace "500 Command line too long\r\n" with "500 \r\n" (with a space after the three digits),
"350 RNFR accepted - file exists, ready for destination\r\n" with "350 \r\n"
and so on.
Messages that include a parameter can not all be simplified. And may be it depends on the client.
For example I just test with success  to replace ( reponse to 'CWD'):
Code: [Select]
    client << "200 Ok. Current directory is " << cwdName << "\r\n";

with
Code: [Select]
    client << "200 Ok." << "\r\n";


and (response to 'PWD'):
Code: [Select]
    client << "257 \"" << cwdName << "\" is your current directory\r\n";

with
Code: [Select]
    client << "257 \"" << cwdName << "\"\r\n";


It works with FTPRush
But you have to test with your clients.

Quote
I have gotten FTP to work with FTPRush and SmartFTP but that's all I tried on my PC.
Do you have any suggestions for iPHone or windows phone?
Sorry, I have none of these phones.
I use AndFTP on my android tablet and SIC Ftp on my Nokia N8



romanyork

gallegojm,
I removed the SDVolume comment and it seemed to compile.  It must have been residue from my initial attempt.


I like the verbose messages because it helps me debug.
After moving most of text to Flash seems to lower both RAM and Flash usage.
I'm at
37k Flash
4,046 RAM


gallegojm

Hi romanyork
Quote
I like the verbose messages because it helps me debug
Yes, I agree, and that is why I copied most of the messages from a server that works under Pure-FTPd and is more 'talkative' than others.

gallegojm

I upload to GitHub the last version of my Ftp Server for Arduino Due and Ide 1.6.0

It was possible to rename a file with a name starting with a space (commands RNFR and RNTO). Then it was impossible to access this file.

On the other hand I have reduced the ram memory usage using the same buffer for file transfers and for storing the original directory in command RNFR and RNTO.
The size of this buffer is defined by the value of FTP_BUF_SIZE in ftpserver.h
A value of 1024 gives satisfactory results for speed file transfers. It can be reduced to 512 if speed is not a major factor. It mus be a least equal to the longest possible path.

I also update the ReadMe.txt file thanks to comments made by romanyork

I have not updated to ide 1.6.3 because of the many messages describing problems with that version.

tarakmpc

Hi,

I want to test your code on an arduino ethernet R3 but the size of the compiled .hex file is too big for the arduino . Is there any possibility to reduce the size.

gallegojm

Hi Tarakmpc
Honestly, I do not think that's possible. Look at the last comment of romanyork.
Look also my comment #67

If you study the possibility of buying a new board, have a look at this post

Takanashi

Hi.
Can u help me?
I do all on u readme and instruction but sketch dont compiling
IDE try to compile but friz on 20% w/o any error.


Code: [Select]

Используем библиотеку Streaming в папке: D:\Arduino\Sketch\libraries\Streaming (legacy)
Используем библиотеку SPI в папке: D:\Arduino\hardware\arduino\avr\libraries\SPI
Используем библиотеку Ethernet в папке: D:\Arduino\libraries\Ethernet
Используем библиотеку SdFat в папке: D:\Arduino\Sketch\libraries\SdFat (legacy)

D:\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -ID:\Arduino\hardware\arduino\avr\cores\arduino -ID:\Arduino\hardware\arduino\avr\variants\mega -ID:\Arduino\Sketch\libraries\Streaming -ID:\Arduino\hardware\arduino\avr\libraries\SPI -ID:\Arduino\libraries\Ethernet\src -ID:\Arduino\Sketch\libraries\SdFat C:\Users\Annakin\AppData\Local\Temp\build6482561312992056710.tmp\FtpServer.cpp -o C:\Users\Annakin\AppData\Local\Temp\build6482561312992056710.tmp\FtpServer.cpp.o

gallegojm

Hi Takanashi
Without error message, it is difficult to find the error!
Which version of Ide are you using?
I never tried with a higher version than 1.6.0

Go Up