Teensy 4.1 - Adafruit Airlift Featherwing Co-Processor FTP Server not opening Port 21

Fascinating - that worked like a charm !!!!! but I noticed in Filezilla that the SD Card contents don't show in Filezilla?
Code:
Status:	Connection established, waiting for welcome message...
Response:	220---Welcome to Simply FTP server ---
Response:	220---   By Renzo Mischianti   ---
Response:	220 --    Version 2022-03-11    --
Status:	Plain FTP is insecure. Please switch to FTP over TLS.
Command:	USER esp8266
Response:	331 Ok. Password required
Command:	PASS *******
Response:	230 Ok
Status:	Server does not support non-ASCII characters.
Status:	Logged in
Status:	Retrieving directory listing...
Command:	PWD
Response:	257 "/" is your current directory
Command:	TYPE I
Response:	200 TYPE is now 8-bit binary
Command:	PORT 192,168,1,181,198,22
Response:	200 PORT command successful
Command:	MLSD
Response:	150 Accepted data connection to port 50710
Response:	150 Accepted data connection to port 50710
[COLOR="#FF0000"]Error:	Failed to retrieve directory listing[/COLOR]
 
@mjs513 - Here is a screen shot of connection with Filezilla:
Screenshot at 2022-05-08 17-26-59.png

This is what I have with handleFTP():
Code:
uint8_t FtpServer::handleFTP() {
#ifdef FTP_ADDITIONAL_DEBUG
//    int8_t data0 = data.status();
	ftpTransfer transferStage0 = transferStage;
	ftpCmd cmdStage0 = cmdStage;
	ftpDataConn dataConn0 = dataConn;
#endif

	if ((int32_t) (millisDelay - millis()) <= 0) {
		if (cmdStage == FTP_Stop) {
			if (client.connected()) {
				DEBUG_PRINTLN(F("Disconnect client!"));
				disconnectClient();
			}
			cmdStage = FTP_Init;
		} else if (cmdStage == FTP_Init)  {  // Ftp server waiting for connection
			abortTransfer();
			iniVariables();
			DEBUG_PRINT(F(" Ftp server waiting for connection on port "));
			DEBUG_PRINTLN(cmdPort);

			cmdStage = FTP_Client;
		} else if (cmdStage == FTP_Client) {    // Ftp server idle

//#if (FTP_SERVER_NETWORK_TYPE == NETWORK_WiFiNINA)
//			if (client && !client.connected()) {
//				client.stop();
//				DEBUG_PRINTLN(F("CLIENT STOP!!"));
//			}
//			byte status;
//			client = ftpServer.available(&status);
			/*
			 *   CLOSED      = 0,
  LISTEN      = 1,
  SYN_SENT    = 2,
  SYN_RCVD    = 3,
  ESTABLISHED = 4,
  FIN_WAIT_1  = 5,
  FIN_WAIT_2  = 6,
  CLOSE_WAIT  = 7,
  CLOSING     = 8,
  LAST_ACK    = 9,
  TIME_WAIT   = 10
			 *
			 */
//			DEBUG_PRINTLN(status);
//#elif defined(ESP8266)
//		  if( ftpServer.hasClient())
//		  {
//		    client.stop();
//		    client = ftpServer.available();
//		  }
//#else
//			if (client && !client.connected()) {
//				client.stop();
//				DEBUG_PRINTLN(F("CLIENT STOP!!"));
//			}
			client = ftpServer.accept();
//#endif
			if (client.connected())             // A client connected
			{
				clientConnected();
				millisEndConnection = millis() + 1000L * FTP_AUTH_TIME_OUT; // wait client id for 10 s.
				cmdStage = FTP_User;
			}
		} else if (readChar() > 0)             // got response
 
@wwatson - double checked what I am using for handleFtp and its the same as what you posted. Still getting the error an no directory display for some reason. Have been reading and seems everybody seems to be using active mode with Filezilla - not sure why it doesn't work with passive mode.

@Juraj - so far so good and will do.
 
@wwatson - are you using the accept branch of WifiNina or the master branch? I still can't get filezilla to display the directory
 
@wwatson - are you using the accept branch of WifiNina or the master branch? I still can't get filezilla to display the directory

I think it is the accept branch. One more thing that I did not remember yesterday Is that in the site manager you have to also set Active mode in the transfer tab.

Like This:
Screenshot at 2022-05-09 15-17-12.png

The leftmost icon on the menu bar will take you to the site manager. There are three settings: 'Default' 'Active' and 'passive'. Make sure you have Default or Active selected. I would select Active to be on the safe side.

Got a couple of errands to run. Will gather up all info on the libraries I am using and get back with you.
 
I think it is the accept branch. One more thing that I did not remember yesterday Is that in the site manager you have to also set Active mode in the transfer tab.

Like This:
View attachment 28331

The leftmost icon on the menu bar will take you to the site manager. There are three settings: 'Default' 'Active' and 'passive'. Make sure you have Default or Active selected. I would select Active to be on the safe side.

Got a couple of errands to run. Will gather up all info on the libraries I am using and get back with you.

Thanks - got that one checked as well. Not sure why yours is working and mine is not. If you get a chance export your filezilla setting and post them for me - pretty sure I got them right but who knows.
 
@mjs513 - I zipped up everything that I have at this point that is working including the original Arduino FtpServer by Jean-Michel Gallego. I spent all of last Sunday modifying his latest version which finally led me to the solution. Mind you there is so much more to do. At this point we can only get directory listings and change directories. the file sizes are right but the dates and times are incorrect. I only worked with the T4.1 built in SD card. I am quite sure that file transfers are not setup properly as well as passive mode. I remember having problems with passive mode when I had the T3.6 and ESP8266 setup with WiFiSPI. As you stated it sounds like Active mode is used more.

Here is everything that I am using:
https://github.com/wwatson4506/nina-fw/tree/accept()_mod
No mods to this...

Here is the rest that fit as a zip:
View attachment SerialESPPassthrough.zip I think you already have this.
View attachment SimpleFTPServer.zip A completely incomplete version:)
View attachment WiFiNINA-accept.zip Unmodified...
View attachment FtpServer.zip The original simpleFTPServer is based on. Also incomplete.

I am running these on a Adafruit ESP32 Airlifit Featherwing.

Hopefully next weekend I can play with it more. I feel kinda guilty not testing MSC more with TD1.57B1:)
 
@mjs513 - I zipped up everything that I have at this point that is working including the original Arduino FtpServer by Jean-Michel Gallego. I spent all of last Sunday modifying his latest version which finally led me to the solution. Mind you there is so much more to do. At this point we can only get directory listings and change directories. the file sizes are right but the dates and times are incorrect. I only worked with the T4.1 built in SD card. I am quite sure that file transfers are not setup properly as well as passive mode. I remember having problems with passive mode when I had the T3.6 and ESP8266 setup with WiFiSPI. As you stated it sounds like Active mode is used more.

Here is everything that I am using:
https://github.com/wwatson4506/nina-fw/tree/accept()_mod
No mods to this...

Here is the rest that fit as a zip:
View attachment 28333 I think you already have this.
View attachment 28334 A completely incomplete version:)
View attachment 28335 Unmodified...
View attachment 28336 The original simpleFTPServer is based on. Also incomplete.

I am running these on a Adafruit ESP32 Airlifit Featherwing.

Hopefully next weekend I can play with it more. I feel kinda guilty not testing MSC more with TD1.57B1:)

Looks like I am using the same libraries that you are using - not sure why I can not get the directory listing. Are you using the nina-fw bin file that I generated?

Oh figured out get Passive mode to connect. Try this:
Code:
FtpServer ftpSrv(21, 20);
then I get the connection through port 21 but I get no data connection message.
 
Looks like I am using the same libraries that you are using - not sure why I can not get the directory listing. Are you using the nina-fw bin file that I generated?

Oh figured out get Passive mode to connect. Try this:
Code:
FtpServer ftpSrv(21, 20);
then I get the connection through port 21 but I get no data connection message.

Was playing with this after work tonight. the server is really unstable. I can connect and get a directory listing and then change back and forth between directories. When I try to disconnect Filezilla the T4.1 locks up here:
Code:
DIR MLSD 
DIR NEXT 
Type=file;Modify=19700101000000;Size=32768000; 32MEGfile.dat
Connected!!
DIR MLSD 
DIR NEXT 
Type=file;Modify=19700101000000;Size=1975361; WhiteTrashSouthernCultureOnTheSkids.mp3
Connected!!
DIR MLSD 
All file readed!!
The only way to reconnect is to reset the T4.1 or wait for the server to timeout then I can reconnect. It all seems very unstable and I really haven't got a clue as to where to start. I guess the best place would be gettiing stable connection and disconnection with both passive and active modes. Will probably start with the FTPServer version I had working on the T3.6 and ESP8266:(
 
@wwatson
Still playing to see what I can see - I did fix, I think, all the warnings etc with SD but still not working for me.

One last question before I quit on this, are you using GPI0?
 
@wwatson
Still playing to see what I can see - I did fix, I think, all the warnings etc with SD but still not working for me.

One last question before I quit on this, are you using GPI0?

No I'm not. Only for uploading new firmware. I'm going to keep picking at it and see what I can come up with. I just wonder if it still has to do with the speed of the T4.1. From what the specs say SPI speed is 8MHz to the Airlift...
 
No I'm not. Only for uploading new firmware. I'm going to keep picking at it and see what I can come up with. I just wonder if it still has to do with the speed of the T4.1. From what the specs say SPI speed is 8MHz to the Airlift...

Just looked in wifinina library (
Code:
void SpiDrv::spiSlaveSelect()
{
    WIFININA_SPIWIFI->beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
    digitalWrite(WIFININA_SLAVESELECT, LOW);

    // wait for up to 5 ms for the NINA to indicate it is not ready for transfer
    // the timeout is only needed for the case when the shield or module is not present
    for (unsigned long start = millis(); (digitalRead(WIFININA_SLAVEREADY) != HIGH) && (millis() - start) < 5;);
}
 
Just looked in wifinina library (
Code:
void SpiDrv::spiSlaveSelect()
{
    WIFININA_SPIWIFI->beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
    digitalWrite(WIFININA_SLAVESELECT, LOW);

    // wait for up to 5 ms for the NINA to indicate it is not ready for transfer
    // the timeout is only needed for the case when the shield or module is not present
    for (unsigned long start = millis(); (digitalRead(WIFININA_SLAVEREADY) != HIGH) && (millis() - start) < 5;);
}

I think now I have passive mode figured out. In the main sketch we have this in setup():
Code:
//      ftpSrv.setCallback(_callback);
//      ftpSrv.setTransferCallback(_transferCallback);

After commenting these out I was able to connect consistently in passive mode. Still cannot disconnect gracefully without resetting the t4.1 or waiting for it to time out on inactivity and the server disconnect...

Edit: Dang, Failed again. totally inconsistent:( That's it for tonight...
 
Last edited:
I think now I have passive mode figured out. In the main sketch we have this in setup():
Code:
//      ftpSrv.setCallback(_callback);
//      ftpSrv.setTransferCallback(_transferCallback);

After commenting these out I was able to connect consistently in passive mode. Still cannot disconnect gracefully without resetting the t4.1 or waiting for it to time out on inactivity and the server disconnect...

Edit: Dang, Failed again. totally inconsistent:( That's it for tonight...

Well - finally feel like I made some progress - I switched to using SDFat2 instead of SD just for the heck of it, turned debug off and was able to connect and get the directory listing. And was able to navigate the directories and transfer files;
Code:
tatus:	Disconnected from server
Status:	Connecting to 192.168.1.239:21...
Status:	Connection established, waiting for welcome message...
Status:	Plain FTP is insecure. Please switch to FTP over TLS.
Status:	Server does not support non-ASCII characters.
Status:	Logged in
Status:	Retrieving directory listing...
Status:	Directory listing of "/" successful
Status:	Retrieving directory listing of "/2001"...
Status:	Directory listing of "/2001" successful
Status:	Starting download of /2001/calculations.wav
Status:	File transfer successful, transferred 426,300 bytes in 1 second
Status:	Retrieving directory listing of "/GIF"...
Status:	Directory listing of "/GIF" successful
Status:	Disconnected from server

Will update what I have and post in the morning. A bit tired now after some trial and error to get it working.
 
So now I have some new shiny stuff like the same airwing...

Might have to see if any of it works :D
 
@mjs513 - I was able to get as far as you did. Noticed that uploading or downloading would create a file but the actual file did not transfer. File size was zero. Also used the basic ftp command to check out make and deleting directories. That all works ok. It seems that doStore and doRetrieve is failing. Keeps losing the data connection for some reason...
Got to catch some zzzz...
 
@mjs513 - I was able to get as far as you did. Noticed that uploading or downloading would create a file but the actual file did not transfer. File size was zero. Also used the basic ftp command to check out make and deleting directories. That all works ok. It seems that doStore and doRetrieve is failing. Keeps losing the data connection for some reason...
Got to catch some zzzz...

That seemed to happen to me more when I transferred from the client to the server. going from server to client it always failed.
 
Back
Top