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

Well I just got a response from Adafruit on my issue:
Code:
... have not located a successful example of someone using a Teensy to run the pass through code.
and he references this post: https://forums.adafruit.com/viewtopic.php?f=53&t=171694

So I ordered a M0 which I should get tomorrow and see what happens when I attach that one

:D - which is funny as they have #ifdef for teensy in their pass through code.

Quick FYI - as I mentioned was able to do the breakout board again today... But being a glutton for punishment,
I ordered the Feather version, plus the doubler and an M4 Feather to try it out from Digikey... Supposed to arrive Monday
 
Well I just got a response from Adafruit on my issue:
Code:
... have not located a successful example of someone using a Teensy to run the pass through code.
and he references this post: https://forums.adafruit.com/viewtopic.php?f=53&t=171694

So I ordered a M0 which I should get tomorrow and see what happens when I attach that one

@All - Got SerialESPPassthrough.ino working with the Adafruit Airlift Featherwing. Was able to upload NINA_W102-1.7.4.bin an it successfully ran the ScanNeworks.ino sketch:)

Boy do I feel silly. It was basically two things that were wrong. First of all the Airlift serial pins are labeled different on the top of the board as apposed to the bottom of the board.
All I had to do was change the delays for ESP32_RESETN to 1000 from 100.

Here is the sketch that is working:
Code:
// SPDX-FileCopyrightText: 2018 Arduino SA 
//
// SPDX-License-Identifier: LGPL-2.1-or-later
/*
  SerialNINAPassthrough - Use esptool to flash the ESP32 module
  For use with PyPortal, Metro M4 WiFi...

  Copyright (c) 2018 Arduino SA. All rights reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include <Adafruit_NeoPixel.h>

unsigned long baud = 115200;

#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
  defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
  defined(ARDUINO_AVR_FEATHER32U4) || \
  defined(ARDUINO_NRF52840_FEATHER) || \
  defined(ADAFRUIT_ITSYBITSY_M0) || \
  defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
  defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || \
  defined(ARDUINO_NRF52_ITSYBITSY) || \
  defined(ARDUINO_PYGAMER_M4_EXPRESS)
  // Configure the pins used for the ESP32 connection
  #define SerialESP32   Serial1
  #define SPIWIFI       SPI  // The SPI port
  #define SPIWIFI_SS    13   // Chip select pin
  #define ESP32_RESETN  12   // Reset pin
  #define SPIWIFI_ACK   11   // a.k.a BUSY or READY pin
  #define ESP32_GPIO0   10
  #define NEOPIXEL_PIN   8
#elif defined(ARDUINO_AVR_FEATHER328P)
  #define SerialESP32   Serial1
  #define SPIWIFI       SPI  // The SPI port
  #define SPIWIFI_SS     4   // Chip select pin
  #define ESP32_RESETN   3   // Reset pin
  #define SPIWIFI_ACK    2   // a.k.a BUSY or READY pin
  #define ESP32_GPIO0   -1
  #define NEOPIXEL_PIN   8
#elif defined(TEENSYDUINO)
  #define SerialESP32   Serial1
  #define SPIWIFI       SPI  // The SPI port
  #define SPIWIFI_SS     5   // Chip select pin
  #define ESP32_RESETN   12 //6   // Reset pin
  #define SPIWIFI_ACK    9   // a.k.a BUSY or READY pin
  #define ESP32_GPIO0    10 //-1
  #define NEOPIXEL_PIN   8
#elif defined(ARDUINO_NRF52832_FEATHER )
  #define SerialESP32   Serial1
  #define SPIWIFI       SPI  // The SPI port
  #define SPIWIFI_SS    16  // Chip select pin
  #define ESP32_RESETN  15  // Reset pin
  #define SPIWIFI_ACK    7  // a.k.a BUSY or READY pin
  #define ESP32_GPIO0   -1
  #define NEOPIXEL_PIN   8
#elif !defined(SPIWIFI_SS)  // if the wifi definition isnt in the board variant
  // Don't change the names of these #define's! they match the variant ones
  #define SerialESP32   Serial1
  #define SPIWIFI       SPI
  #define SPIWIFI_SS    10   // Chip select pin
  #define SPIWIFI_ACK    7   // a.k.a BUSY or READY pin
  #define ESP32_RESETN   5   // Reset pin
  #define ESP32_GPIO0   -1   // Not connected
  #define NEOPIXEL_PIN   8
#endif

#if defined(ADAFRUIT_PYPORTAL)
  #define PIN_NEOPIXEL   2
#elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE)
  #define PIN_NEOPIXEL   40
#endif
#define PIN_NEOPIXEL   8

Adafruit_NeoPixel pixel = Adafruit_NeoPixel(1, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);

void setup() {
  Serial.begin(baud); // TEENSY
  pixel.begin();
  pixel.setPixelColor(0, 10, 10, 10); pixel.show();

  while (!Serial);
  pixel.setPixelColor(0, 50, 50, 50); pixel.show();

  delay(100);
  SerialESP32.begin(baud); //Serial1

  pinMode(SPIWIFI_SS, OUTPUT);
  pinMode(ESP32_GPIO0, OUTPUT);
  pinMode(ESP32_RESETN, OUTPUT);
  delay(100);
  
  // manually put the ESP32 in upload mode
  digitalWrite(ESP32_GPIO0, LOW);

  digitalWrite(ESP32_RESETN, LOW);
  delay(1000);
  digitalWrite(ESP32_RESETN, HIGH);
//  pixel.setPixelColor(0, 20, 20, 0); pixel.show();
  delay(1000);
}

void loop() {
  while (Serial.available()) {
//    pixel.setPixelColor(0, 10, 0, 0); pixel.show();
    SerialESP32.write(Serial.read());
  }

  while (SerialESP32.available()) {
//    pixel.setPixelColor(0, 0, 0, 10); pixel.show();
    Serial.write(SerialESP32.read());
  }
}

Used this to upload the firmware:
Code:
esptool.py --port /dev/ttyACM0 --before no_reset --baud 115200 write_flash 0 NINA_W102-1.7.4.bin

Output during the upload:
Code:
wwatson@wwatsonl1:~/Downloads$ esptool.py --port /dev/ttyACM0 --before no_reset --baud 115200 write_flash 0 NINA_W102-1.7.4.bin
esptool.py v3.3
Serial port /dev/ttyACM0
WARNING: Pre-connection option "no_reset" was selected. Connection may fail if the chip is not in bootloader or flasher stub mode.
Connecting...................
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: e8:9f:6d:d2:ef:24
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x0011afff...
Compressed 1159168 bytes to 633594...
Wrote 1159168 bytes (633594 compressed) at 0x00000000 in 56.1 seconds (effective 165.2 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Probably can play with the delays to optimize...
Gotta run an errand now but hopefully this will help:)
 
@wwatson
Glad you got it working but on the board I am using (adafruit featherwing coprocessor) the ESP32_reset in on pin 6 of the Teensy?? I have been using delay(100) as well


EDIT THAT CHANGE TO DELAY 1000 worked like a charm - strange!!!!!

Code:
esptool.py v3.3
Serial port com22
WARNING: Pre-connection option "no_reset" was selected. Connection may fail if the chip is not in bootloader or flasher stub mode.
Connecting...
Failed to get PID of a device on com22, using standard reset sequence.
.
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Failed to get PID of a device on com22, using standard reset sequence.
.
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: e8:9f:6d:d3:0b:e4
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x0011afff...
Compressed 1159168 bytes to 633594...
Wrote 1159168 bytes (633594 compressed) at 0x00000000 in 56.0 seconds (effective 165.7 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
 
@wwatson
Glad you got it working but on the board I am using (adafruit featherwing coprocessor) the ESP32_reset in on pin 6 of the Teensy?? I have been using delay(100) as well


EDIT THAT CHANGE TO DELAY 1000 worked like a charm - strange!!!!!

Code:
esptool.py v3.3
Serial port com22
WARNING: Pre-connection option "no_reset" was selected. Connection may fail if the chip is not in bootloader or flasher stub mode.
Connecting...
Failed to get PID of a device on com22, using standard reset sequence.
.
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Failed to get PID of a device on com22, using standard reset sequence.
.
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: e8:9f:6d:d3:0b:e4
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x0011afff...
Compressed 1159168 bytes to 633594...
Wrote 1159168 bytes (633594 compressed) at 0x00000000 in 56.0 seconds (effective 165.7 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Mike - I tried changing the clock speed at first all the way down to 24 Mhz with no success. So tonight after work I came home and thought what is the biggest problem we have with super sonic T4.x, delays:) Now onto getting an FTP server working?
 
Mike - I tried changing the clock speed at first all the way down to 24 Mhz with no success. So tonight after work I came home and thought what is the biggest problem we have with super sonic T4.x, delays:) Now onto getting an FTP server working?

Yeah - didn't even think of the making the delay larger. Tried smaller but that obvious didn't work :) and yes I tried reducing the clock all the way down as well :)

Have fun with the server - I gave it a quick try but didn't work got that connect/disconnect/connect message. There is probably some update that has to bet made to the bin file- maybe @Juraj can answer that one

Right now its late for me and need to go crash - had my 2nd booster yesterday and it wiping me out tody.
 
so now you have to build the patched nina-fw. it is not easy.
first make the build work. https://github.com/adafruit/nina-fw#building
then add code from my PR https://github.com/arduino/nina-fw/pull/79/files

I have a build, but for Arduino boards. Adafruit uses different SPI pins in SPI.cpp

Thanks - I remember the link to the Arduino forum discussion where you had the updated bin file. Hopefully over the next couple of days with update Adafruit NINA fw with your changes unless some one beats me to it. Think thats the only thing holding us up now to check if FTP server works.
 
@wwatson - @Juraj - @KurtE

well I incorporated the changes per https://github.com/arduino/nina-fw/pull/79/files and rebuilt the NINA Fimware :)

View attachment NINA_W102-1.7.5.bin.zip

But still not working so not sure if its the FTP server sketch or something else that I messed up in converting over to the changes but if anyone wants to double check:
Firmware update: https://github.com/mjs513/nina-fw/tree/accept()_mod
Adafruit NINA Library: https://github.com/mjs513/WiFiNINA/tree/accept

Ok I am done with this for awhile I think - hopefully someone will find the issue
 
@mjs513 - It's finally the weekend so I should have time to play more with this. At least things are progressing:) Also waiting for TD1.57B1...
I think there are still changes that will have to be made to the FTP server after updating NINA with the patches.
I really am green when it comes to this stuff:)
 
Last edited:
@mjs513 - It's finally the weekend so I should have time to play more with this. At least things are progressing:) Also waiting for TD1.57B1...
I think there are still changes that will have to be made to the FTP server after updating NINA with the patches.

Thanks - and probably was starting to look at it but running out of time
 
Decided to start from scratch now that the firmware has been updated so I went back to using the Adafruit WifiNINA library from Github and at least now I think its semi working with the updated firmware:

Output from Filezilla so far.
Code:
Status:	Connecting to 192.168.1.239:21...
Status:	Connection established, waiting for welcome message...
Status:	Insecure server, it does not support FTP over TLS.
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:	PASV
Response:	227 Entering Passive Mode (192,168,1,239,195,89)
Command:	MLSD
Response:	425 No data connection
Error:	Failed to retrieve directory listing

EDIT: Redid and pushed the update to the WifiNINA accept branch but no luck - maybe something with SD access
Capture.PNG
 
Last edited:
@mjs513 - Nice progress:) Better than what I am getting here. I have the firmware updated but am only getting _callback messages that you were getting before. Are you still working with SimpleFTPServer?
 
Yep - I updated my WifiNINA accept branch as well so maybe that will help if you havent already done that: https://github.com/mjs513/WiFiNINA/tree/accept

Haven't tried using the generic WifiNINA yet - thinking make be some wacky router or Norton setting that I can't figure out how to set

I was using Adafruit's 1.7.4 version. I fork your Repo and try that. As far as the SD access goes I am getting these warnings:
Code:
/home/wwatson/Arduino/libraries/SimpleFTPServer/FtpServer.cpp: In member function 'bool FtpServer::processCommand()':
/home/wwatson/Arduino/libraries/SimpleFTPServer/FtpServer.cpp:721:103: warning: invalid conversion from 'int' to 'const char*' [-fpermissive]
         open = openFile( path, ( CommandIs( "APPE" ) ? FTP_FILE_WRITE_APPEND : FTP_FILE_WRITE_CREATE ));
                                                                                                       ^
In file included from /home/wwatson/Arduino/libraries/SimpleFTPServer/FtpServer.cpp:49:0:
/home/wwatson/Arduino/libraries/SimpleFTPServer/FtpServer.h:595:8: note:   initializing argument 2 of 'bool FtpServer::openFile(char*, const char*)'
   bool openFile( char path[ FTP_CWD_SIZE ], const char * readType );
        ^
/home/wwatson/Arduino/libraries/SimpleFTPServer/FtpServer.cpp:724:54: warning: invalid conversion from 'int' to 'const char*' [-fpermissive]
         open = openFile( path, FTP_FILE_WRITE_CREATE );
                                                      ^
In file included from /home/wwatson/Arduino/libraries/SimpleFTPServer/FtpServer.cpp:49:0:
/home/wwatson/Arduino/libraries/SimpleFTPServer/FtpServer.h:595:8: note:   initializing argument 2 of 'bool FtpServer::openFile(char*, const char*)'
   bool openFile( char path[ FTP_CWD_SIZE ], const char * readType );
        ^
/home/wwatson/Arduino/libraries/SimpleFTPServer/FtpServer.cpp: In member function 'bool FtpServer::doMlsd()':

More do check out I guess...
 
Yeah I have been getting those warnings as well both with the adafruit and the model adafruit version. That was going to next next but running out of steam. Are u still getting the callback errors?
 
Yeah I have been getting those warnings as well both with the adafruit and the model adafruit version. That was going to next next but running out of steam. Are u still getting the callback errors?

Yep. It looks like there are other things that need to be setup as well for SD info like file size and total size.
This is a link to the author of SimpleFTPServer web site that shows how to setup SimpleFTPServer:
https://www.mischianti.org/2021/07/01/simple-ftp-server-library-now-with-support-for-wio-terminal-and-sd/

I have not had time to go through it all yet...
 
Just curious, is this failure Teensy specific or does it happen on other hardware as well?
My new versions of the hardware won't get here until Monday or Tuesday
 
Just curious, is this failure Teensy specific or does it happen on other hardware as well?
My new versions of the hardware won't get here until Monday or Tuesday

Have not tried with any other hardware. Just now got to the same point as @mjs513. I do have an Adafruit ESP32 Hazzah that I was trying to use with nina-1.7.4 but that did not work. Probably due to a possible difference of pinouts. The nice thing about that board was the onboard USB port for programing.
 
@mjs513 - Here is what I have now:
Code:
Status:	Connecting to 192.168.0.113: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...
Command:	PWD
Response:	257 "/" is your current directory
Command:	TYPE I
Response:	200 TYPE is now 8-bit binary
Command:	PASV
Response:	227 Entering Passive Mode (192,168,0,113,195,89)
Command:	MLSD
Response:	425 No data connection
Error:	Failed to retrieve directory listing

This is where it seems to be failing:
Code:
  else if( CommandIs( "LIST" ) || CommandIs( "NLST" ) || CommandIs( "MLSD" ))
  {
	DEBUG_PRINT("List of file!!");

    if( [COLOR="#FF0000"]dataConnect()[/COLOR]){
      if( openDir( & dir ))
      {
    	DEBUG_PRINT("Dir opened!!");

        nbMatch = 0;
        if( CommandIs( "LIST" ))
          transferStage = FTP_List;
        else if( CommandIs( "NLST" ))
          transferStage = FTP_Nlst;
        else
          transferStage = FTP_Mlsd;
      }
      else {
    	  DEBUG_PRINT("List Data stop!!");
    	  data.stop();
      }
    }
  }

Seems like there is a lot more to check out:(
 
@wwatson - at least you are seeing connecting - I did something so now I am not connecting again - argh.

@KurtE - haven't tried with anyother hardware except the T4 and the airlift
 
@wwatson - at least you are seeing connecting - I did something so now I am not connecting again - argh.

@KurtE - haven't tried with anyother hardware except the T4 and the airlift

I have done that a couple of times already. I really hate when I do that:) I had an FTP sever working with the ESP8266 and WifiSPI on the T3.6. I am going to find it (SOMEWHERE) and see if I can get some clues. SimpleFTPServer is not so simple...
 
@mjs513 - It's alive!!! In Filezilla I switched to active mode and got a directory listing.

This is what i saw on the Teensy side:
Code:
Connected to wswn
IP address: 192.168.0.113
SD opened!
NOT ANONYMOUS
wwatson
 Ftp server waiting for connection on port 21
 Client connected!
>>>>>>>>>>>>>>> _callback 0 1 1
CONNECTED
-U-S-E-R- -w-w-a-t-s-o-n-
Command is: USER
USER: wwatson wwatson
-P-A-S-S- -m-i-r-a-d-a-
Command is: PASS
 Authentication Ok. Waiting for commands.
-P-W-D-
Command is: PWD
-T-Y-P-E- -I-
Command is: TYPE
-P-O-R-T- -1-9-2-,-1-6-8-,-0-,-1-0-3-,-1-2-9-,-2-3-7-
Command is: PORT
 Data IP set to 192.168.0.103
 Data port set to 33261
-M-L-S-D-
Command is: MLSD
List of file!!Dir opened!!Connected!!
DIR MLSD 
DIR NEXT 
Type=file;Modify=19700101000000;Size=60148386; StatusQuoWhateverYouWant.wav
Connected!!
DIR MLSD 
DIR NEXT 
Type=file;Modify=19700101000000;Size=60148386; WhateverYouWant.wav
Connected!!
DIR MLSD 
DIR NEXT 
Type=file;Modify=19700101000000;Size=102878370; YoureLazyJimmyBarnesJoeBonamassa.wav
Connected!!
DIR MLSD 
DIR NEXT 
Type=dir;Modify=19700101000000;Size=32768; C
Connected!!
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!!

Switching Directories:
Code:
-C-W-D- -/-C-
Command is: CWD
PATH --> /C ...EXIST!
-P-O-R-T- -1-9-2-,-1-6-8-,-0-,-1-0-3-,-2-2-0-,-2-3-7-
Command is: PORT
 Data IP set to 192.168.0.103
 Data port set to 56557
-M-L-S-D-
Command is: MLSD
List of file!!Dir opened!!Connected!!
DIR MLSD 
All file readed!!

That is as far as I have gone today. Tried to transfer files but failed. I'm sure there is a lot more to do. Not sure why it's not working in passive mode yet.
In Filezilla, go to the edit menu and select 'Settings...'. Under that menu select 'FTP' then select the "Active' bullet.

Have not been able to transfer any files successfully yet:( Again more to do...
 
@wwatson
Ok what version of filezilla are you using - this is what I am seeing
View attachment 28324

3.46.3. I noticed that you selected FTP->Active. Just click on FTP and you will see a bullet for 'Passive (recommended)' and below that you will see another bullet 'Active' click on the 'Active' bullet.
Screenshot at 2022-05-08 16-58-04.png
 
Last edited:
Back
Top