xreef / SimpleFTPServer

A simple FTP server for Arduino, ArduinoSAMD WiFiNINA, esp8266, esp32, stm32 and Raspberry Pi Pico W

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PATH --> / ...NOT EXIST! Error for SD Card with ESP8266 for FTP Server

outcastdreamer opened this issue · comments

Hi, I am trying to configure ESP8266 which is connected to a SD Module and the SD connection is successful in reading and writing data from the SD Card via the ESP8266. Now I want to use SimpleFTPServer to access the files on the SD Card using <SD.h> library to download the files via FTP client but I am facing error in the process.
This is what the debug report is showing :

Connecting to Saket1234
.........
WiFi connected
IP address: 
192.168.193.148
SD Card Initialization Successful!!
NOT ANONYMOUS
user_name
FTP SERVER BEGINS
------------------------------------------
 Ftp server waiting for connection on port 21
 Client connected!
-U-S-E-R- -u-s-e-r-_-n-a-m-e-
-
Command is: USER
USER: user_name user_name
-P-A-S-S- -p-a-s-s-
-
Command is: PASS
 Authentication Ok. Waiting for commands.
-S-Y-S-T-
-
Command is: SYST
-F-E-A-T-
-
Command is: FEAT
-O-P-T-S- -U-T-F-8- -O-N-
-
Command is: OPTS
200 OK, UTF8 ON
-P-W-D-
-
Command is: PWD
-C-W-D- -/-
-
Command is: CWD
PATH --> / ...NOT EXIST!
-T-Y-P-E- -A-
-
Command is: TYPE
-P-A-S-V-
-
Command is: PASV
 Connection management set to passive
 Listening at 192.168.193.148:50009
-M-L-S-D-
-
Command is: MLSD
List of file!!List Data stop!!

and this is what shows on the client side ( I have already tried FileZilla Client, AndFTP on android and WinSCP, this is the output from WinSCP) :
WinSCP : Could not retrieve directory listing...Can't open directory /

My code is as following :

#include <SimpleFTPServer.h>
#include <ESP8266WiFi.h>
#include <SPI.h>
#include <SD.h>

const char* ssid = "Saket1234";
const char* password = "saket1234";

FtpServer ftpSrv;  
void setup(void)
{
  Serial.begin(1200);
  WiFi.begin(ssid, password);
  Serial.println("");
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connecting to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
//  Serial.print("Initializing SD card...");

  while (1)
  {
    if (!SD.begin(4))
    {
        Serial.println("initialization failed!");
        Serial.println("Output : " + String(SD.begin(4)));
    }
    else
    {
      break;
    }
  }
  Serial.println("SD Card Initialized Succesfully!");
  ftpSrv.begin("user_name","pass");    
  Serial.println("FTP SERVER STARTED!");
}


void loop(void)
{
  ftpSrv.handleFTP(); 
}

Also, there is no possibility of Firewall issues as Passive connection is being used and I am using my personal wifi here.
I would really appreciate if you could add an example for ESP8266 FTP Server with SD Card just like you did for ESP32 in the repository, it will be of great help!

Thanks in advance for looking into this issue and all your blogs and libraries. They have been really helpful in my IoT Journey! 😄

Hi @outcastdreamer,
I try now with my esp8266 and SD card adapter, and It's working well.
I test It with frameworks 2.7.4 and 3.0.2.

I use the example with the library
`
#include <ESP8266WiFi.h>

#include <SimpleFTPServer.h>

#include <SPI.h>
#include <SD.h>

FtpServer ftpSrv;
const char* ssid = "your-ssid";
const char* password = "your-passwd";

const int chipSelect = SS;

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
WiFi.begin(ssid, password);
Serial.println("");

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

delay(1000);

Serial.print("Starting SD.");
while (!SD.begin(SS)) {
Serial.print(".");
}
Serial.println("finish!");

ftpSrv.begin("user","password"); //username, password for ftp.

}

void loop(void) {
ftpSrv.handleFTP(); //make sure in loop you call handleFTP()!!
}

remember to set also in the FTPServerKey.h file
#ifndef DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP8266
#define DEFAULT_FTP_SERVER_NETWORK_TYPE_ESP8266 NETWORK_ESP8266
#define DEFAULT_STORAGE_TYPE_ESP8266 STORAGE_SD
#endif

`

Bye Renzo

Hi @xreef
I didn't make changes in the FTPServerKey.h file. Your solution works like a charm now. Thanks once again for your time & the amazing blogs!! 🙌

Regards,
Saket (@outcastdreamer)