nailbuster / esp8266FTPServer

Simple FTP Server for using esp8266/esp32 SPIFFs
GNU Lesser General Public License v2.1
209 stars 126 forks source link

esp8622 crash.. #24

Open wchpikus opened 5 years ago

wchpikus commented 5 years ago

esp with working wifi, www server, spiffs, socket, oled via spi. added ftp, and when transfering file esp crash. using filezilla, disconnect client when choiced transfer file (i have to connect again, wait for connection).

Monarch73 commented 5 years ago

@wchpikus do you mind trying out my ESP-FTP-Server? Its a single .h-File that you can copy and paste into your project. It just depends on the AsyncTCP-Library from @me-no-dev

Please note that it is required that you limit the number of concurrent connections to 1 in filezilla. Filetransfers are done via PORT-Command, so it supports non-passive mode only.

https://github.com/Monarch73/MicroHomebridgeAlexaEsp8266/blob/master/MicroHomebridgeAlexaEsp8266/FtpServ.h

wchpikus commented 5 years ago

hi

ESP8266FtpServer.h and ESP8266FtpServer.cpp files, and setup in main and setup in ino. connections is only1 in filezilla and non-passive mode.

I can remove, see dir and rename, but upload made crash:( you write about this file FtpServ.h? i can try it.

Monarch73 commented 5 years ago

@wchpikus You seem to misunderstand... I am not the author of THIS (esp8266FTPServer) project. But I had trouble using THIS library as well and ended up writing my own ftp-server

wchpikus commented 5 years ago

yes, i corrected post:)

now i will thy our ftp.

Could you send me some more info about that?

e.g how to use?

FtpServ(char username, char password) = FtpServ(test,test); i see, but do you need inicialize or handle something?

Monarch73 commented 5 years ago
FtpServ *srv = new FtpServ("username","password");
srv->begin();

Put that code somewhere in the setup() Note that for now username and password is ignorened when you login. Security was not my concern, when I created this...it'll simply accept any user/pass you give it.

wchpikus commented 5 years ago

https://github.com/me-no-dev/ESPAsyncTCP/tree/master/src can i get it ESPAsyncTCP.h and ESPAsyncTCP.cpp from this link?

Monarch73 commented 5 years ago

https://github.com/me-no-dev/ESPAsyncTCP/archive/master.zip

download this zip and in arduino studio you click "sketch" -> "library" -> add from zzip

wchpikus commented 5 years ago

ok i now test it.. is it works with spiffs?

Monarch73 commented 5 years ago

yes, it works with spiffs. Please note though, that it only has very little error handling. It assumes, that spiffs is formatted and ready to go. It won't work if spiffs is not available.

wchpikus commented 5 years ago

ok work, but not all

data received from client 192.168.11.2 PWD

new client has been connected to server, ip: 192.168.11.2 data received from client 192.168.11.2 USER volvoaux sending user

data received from client 192.168.11.2 PASS wchpikus sending pass

data received from client 192.168.11.2 CWD /

data received from client 192.168.11.2 TYPE I

data received from client 192.168.11.2 PASV

ok i try send some file

data received from client 192.168.11.2 SIZE c8_d7_b0_1a_34_e4.txt

data received from client 192.168.11.2 MDTM c8_d7_b0_1a_34_e4.txt

data received from client 192.168.11.2 TYPE A

data received from client 192.168.11.2 PASV

data received from client 192.168.11.2 TYPE I

data received from client 192.168.11.2 PASV

data received from client 192.168.11.2 SIZE c8_d7_b0_1a_34_e4.txt

data received from client 192.168.11.2 MDTM c8_d7_b0_1a_34_e4.txt

data received from client 192.168.11.2 TYPE A

data received from client 192.168.11.2 PASV

data received from client 192.168.11.2 TYPE I

data received from client 192.168.11.2 PASV

data received from client 192.168.11.2 SIZE c8_d7_b0_1a_34_e4.txt

data received from client 192.168.11.2 MDTM c8_d7_b0_1a_34_e4.txt

data received from client 192.168.11.2 TYPE A

data received from client 192.168.11.2 PASV

data received from client 192.168.11.2 TYPE I

data received from client 192.168.11.2 PASV

data received from client 192.168.11.2 PWD

from filezila:

Status: Starting upload of G:\oled animation\OLED-esp-aux_phone_english_www_spiffs_ftp_v6\c8_d7_b0_1a_34_e4.txt Status: Retrieving directory listing of "/"... Command: TYPE I Response: 200 JAAAA MANNN! Command: PASV Response: 500 Unknown command. Command: SIZE c8_d7_b0_1a_34_e4.txt Response: 500 Unknown command. Command: MDTM c8_d7_b0_1a_34_e4.txt Response: 500 Unknown command. Command: TYPE A Response: 200 JAAAA MANNN! Command: PASV Response: 500 Unknown command. Error: File transfer failed Status: Retrieving directory listing of "/"... Command: TYPE I Response: 200 JAAAA MANNN! Command: PASV Response: 500 Unknown command. Error: Failed to retrieve directory listing Status: Sending keep-alive command Status: Sending keep-alive command Status: Sending keep-alive command

wchpikus commented 5 years ago

Spiifs ready, 4M ( 3M spiffs for data).

Monarch73 commented 5 years ago

Hey, at least you see no crashes :-). But I just realized forgot to meantion a few more things:

Monarch73 commented 5 years ago

also please make sure, that you don't use any connection security features.. SIZE and MDTM are not supported...(and not required)

wchpikus commented 5 years ago

ok setuped to activ:

Status: Connecting to 192.168.11.1:21... Status: Connection established, waiting for welcome message... Status: Server does not support non-ASCII characters. Status: Logged in Status: Retrieving directory listing... Status: Directory listing of "/" successful Status: Disconnected from server Status: Connecting to 192.168.11.1:21... Status: Connection established, waiting for welcome message... Status: Server does not support non-ASCII characters. Status: Logged in Status: Starting upload of G:\oled animation\OLED-esp-aux_phone_english_www_spiffs_ftp_v6\c8_d7_b0_1a_34_e4.txt Status: File transfer successful, transferred 17 140 bytes in 1 second Status: Retrieving directory listing of "/"... Status: Directory listing of "/" successfu

ok but when i send 160kb file...crash:)

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

dataconnection received data from 192.168.11.2

Exception (0): epc1=0x4020ab3c epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: sys sp: 3ffff790 end: 3fffffb0 offset: 01a0

stack>>> 3ffff930: 4000050c 07672d1f 401021f2 00000100
3ffff940: 400043df 00000030 3fffc248 4000050c
3ffff950: 40004225 00000030 00000014 ffffffff
3ffff960: 4000420c 00000000 3ffffa40 08000000
3ffff970: 60000200 00000002 02000000 02000000
3ffff980: 02000000 00000018 04000102 60000200
3ffff990: 3ffffb80 00000010 001543c8 00000030
3ffff9a0: 00000000 4000422e 60000200 3ffffa24
3ffff9b0: 00000100 40004aa0 000000fc 00153d04
3ffff9c0: 00000100 3ffffa20 3fffc718 00153d04
3ffff9d0: 00000004 4010551e 40105a64 00000004
3ffff9e0: 3ffffa20 3ffffa20 00000000 3ffffa64
3ffff9f0: 3fffc718 3ffffa20 000000fc 00154104
3ffffa00: 402170e1 402170d6 00153d04 00000004
3ffffa10: 00153d05 00153d04 00000001 40219f20
3ffffa20: ffffff7e 3ffffa60 00000000 000000c4
3ffffa30: 00000000 4000444e 0000000c c0000000
3ffffa40: 00000002 4000420c 60000200 3ffffb80
3ffffa50: 00000100 40004aa0 000000f8 00154308
3ffffa60: 00000100 3ffffac0 3fffc718 00154308
3ffffa70: 000000d0 4010551e 40105a64 000000d0
3ffffa80: 3ffffac0 3ffffac0 00154308 000000e7
3ffffa90: 3fffc718 3ffffac0 60000200 3fff5bd4
3ffffaa0: 00154308 402170d6 00154308 000000d0
3ffffab0: 001543d8 001543d8 000000d3 40219ed8
3ffffac0: 41746857 7858464b 6e684943 68200a0d
3ffffad0: 74343449 32566c57 43437175 58326543
3ffffae0: 5437694f 446e4e56 53563541 7678774d
3ffffaf0: 4a636f6e 39335855 616e7870 314c746f
3ffffb00: 58623258 7842772f 45356962 6d527468
3ffffb10: 4535764a 79494568 5a200a0d 776f7049
3ffffb20: 597a5164 34416937 65374653 75655a56
3ffffb30: 36776552 442b6d6e 38684a38 66786358
3ffffb40: 514c7571 6266766f 76686144 5243624a
3ffffb50: 74494945 4d453870 64786a73 544c3650
3ffffb60: 7454634f 37200a0d 6b613651 666d7865
3ffffb70: 42384347 494a4b6c 45655438 61523162
3ffffb80: 6c543852 4b394750 774c6330 4d5a4979
3ffffb90: 41702f58 74515671 65326144 73516855
3ffffba0: 52675356 6c657577 4c2f4d70 4770616b
3ffffbb0: 4b323731 53625246 00000000 00000029
3ffffbc0: 3fff417c 00154000 3fff32f0 3fff4190
3ffffbd0: 3fff417c 00154000 3fff32f0 40206d95
3ffffbe0: 00000100 3ffffcd3 00000000 3fff41a4
3ffffbf0: 00000000 40101f8c 3fffc200 4021f388
3ffffc00: 3ffffd30 3ffe8304 3ffffc90 4021b2f1
3ffffc10: 3ffeacf5 3fff496c 3ffffc40 40204710
3ffffc20: 40101be1 3ffee6e0 00000000 3ffffc90
3ffffc30: 4021f388 3ffffd30 3fff496c 4021b6ac
3ffffc40: 00000100 3fff3aac 00000000 00000001
3ffffc50: 3ffe8304 0767c0c1 401021f2 00000100
3ffffc60: 00000000 400042db 3ffeb570 00000100
3ffffc70: 3fff32f0 00054000 0000002a 40204710
3ffffc80: 00000000 00000080 00000000 00002e23
3ffffc90: 00000001 00002e22 00000000 0000ffff
3ffffca0: 3fff3aac 00000001 00000020 00000100
3ffffcb0: 00000002 00000000 00000002 40219dbc
3ffffcc0: 3fff5ccf 000000d0 000000d0 00000200
3ffffcd0: 3fff5cd2 3ffffd30 3fff32f0 40204b31
3ffffce0: 00000000 00000000 3ffffd34 000000d3
3ffffcf0: 3fff5ccf 00154305 3fff32f0 40206e94
3ffffd00: 3fff4190 00000007 3fff417c 3fff42b8
3ffffd10: 3fff5b8a ffffffff ffffffff 3fff32f0
3ffffd20: 00000300 00000100 3ffffd90 40204d98
3ffffd30: 00000002 0005002a 3fff32f0 0000004a
3ffffd40: 3fff0018 3fff5ccf 000000d3 00000000
3ffffd50: 00000001 00002000 00100000 402212e8
3ffffd60: 00000008 3fff2ab8 00000000 3fff32f0
3ffffd70: 00000003 3fff39ac 3fff40b4 4020593c
3ffffd80: 00000001 3ffffd98 3fff2bf0 40227100
3ffffd90: 01770018 0521eefc 05410542 00000521
3ffffda0: 00000145 00016e68 00000177 00000000
3ffffdb0: 00000003 00000002 00000000 000000d3
3ffffdc0: 00000218 3fff5b8a 00000175 00000100
3ffffdd0: 3fff16e8 00000008 3ffffde0 3fff5b8a < 3ffffde0: 00016e68 00000218 00016e68 402031e5
3ffffdf0: 63657220 65766965 61642064 66206174
3ffffe00: 206d6f72 2e323931 2e383631 3fff5b8a
3ffffe10: 00000218 00016e68 3fff32f0 402038fc
3ffffe20: 3fff40b4 3ffffe30 00000008 402184b5
3ffffe30: 3fff40b4 00000218 3fff496c 0000ff00
3ffffe40: 3fff16c0 0000038f 0000038f 00000000
3ffffe50: 3fff5894 00000218 3fff4f2c 402194c5
3ffffe60: 2e323931 2e383631 3fff5b8a 4021a4d1
3ffffe70: 3fff5894 00000218 3fff5b8a 4020ab14
3ffffe80: 00000000 00000000 00000000 401071f0
3ffffe90: 020ba8c0 00000008 3ffef928 00000030
3ffffea0: 3fff5894 3fff5b44 00000000 4021a096
3ffffeb0: 3fff0000 00000000 3fff2a4c 40215e50
3ffffec0: 3fff5974 00000001 3ffeab24 00000064
3ffffed0: 00000860 3ffea988 3ffea988 3fff2a6c
3ffffee0: 3fff5974 3fff2a50 3fff2a4c 40215e94
3ffffef0: 3fff5974 3fff2a50 3fff2a51 40223cd4
3fffff00: 010ba8c0 0000000a 3ffea988 00000000
3fffff10: 00000000 0000024e 3fffff80 3fff5b62
3fffff20: 3fff2bf0 3fff5b44 3fff2cd8 40227c01
3fffff30: 00000014 0000038f 0000038f 3fff2bf0
3fffff40: 3fffdc80 3fff3194 3fff496c 3fff3214
3fffff50: 00000008 3fff2bf0 3fff5b44 40221259
3fffff60: 3fffdc80 3fff3194 3fff496c 4010453c
3fffff70: 4023e7fe 3fff3194 3fff496c 4023e810
3fffff80: 3fff5b54 3fff5b44 00000000 3fffdcb0
3fffff90: 3ffeffd8 00000000 3fff496c 40240773
3fffffa0: 40000f49 3fffdab0 3fffdab0 40000f49
<<<stack<<<

btw, Status: Retrieving directory listing of "/"... listing works Small file work well:

File system (SPIFFS): Total KB: 2880.13 KB Used KB: 19.85 KB Block size: 8192 Page size: 256 Maximum open files: 5 Maximum path length: 32

SPIFFS directory {/} : /c8_d7_b0_1a_34_e4.txt / 17140

Monarch73 commented 5 years ago

I don't think that crash is related to the ftp-server code. It must be something in the sdk. Do you know what version of sdk you use?

wchpikus commented 5 years ago

How to check it in arduino?

wchpikus commented 5 years ago

AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1

Monarch73 commented 5 years ago

2.4.1 That should do....even thou you should be able to update to 2.4.2...but I don't think that will fix the problem. Let me check when I am back at my desk...I must admit that I never tested this with files >100k

Monarch73 commented 5 years ago

In the meantime, you can try to reformat spiffs...might be corrupted or something...

wchpikus commented 5 years ago

I formated few times..it is no flash problem;)

Please try it and write..and what sdk have you.

Monarch73 commented 5 years ago

I always work with the latest release, so its 2.4.2 for me.... But I also work with Visual Studio Community with VMicro plugin, so I would not know how you can update your Arduino Studio....

Monarch73 commented 5 years ago

another thing you can try: Create a new project with just the ftpServer-code in it. This way you make sure that no other parts of your code are causing the crash...

wchpikus commented 5 years ago

Ok i try.

wchpikus commented 5 years ago

give me some time, i have to update and install new release:)

wchpikus commented 5 years ago

ng core 'esp8266' from platform in folder: AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.2

ok updated, i test it now...

Monarch73 commented 5 years ago

I have bad news for you. I just uploaded a 300KB File to my nodemcu-Module with no problems...

I used the following code

FtpServ *ftpServer;
void setup() {
    Serial.begin(115200);
    delay(20);
    SPIFFS.begin();
    // create access point
    WiFi.mode(WIFI_STA);
    WiFi.begin("xxxx", "xxxx");

    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }

    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
    ftpServer = new FtpServ("1", "2");
    ftpServer->begin();
}

// the loop function runs over and over again until power down or reset
void loop() {

}
wchpikus commented 5 years ago

now i disabling all process (www, mdns..)to eliminate problem.. please wait:)

Monarch73 commented 5 years ago

I just noticed that ftp-code does not do a SPIFFS.begin()....that needs to be done in the setup()-function as well

wchpikus commented 5 years ago

SPIFFS.begin() I have.. This is not a problem..some of my function destruct stack.. i have find what.. now i'll test your code.

wchpikus commented 5 years ago

hmm, you have right...your code works well, so i have to find what do not want to work with this.. i thing this is connected with # and client.connect(gateway,httpPort) (i listening on 23 port from other device).. i try to disable it when using ftp..

wchpikus commented 5 years ago

Did you test of size of file after and before upload? I have some strange value

Monarch73 commented 5 years ago

Nope...the code does not check filesizes...its working fine for me, too...

also, having multiple connections should generally not be an issue. Maybe you want to try a different board?

wchpikus commented 5 years ago

Only your code works on the same board, so this is isue of rest of my firmware..but i will check it all, disable one by one..

Monarch73 commented 5 years ago

ok...maybe you want to consider changeing your code to use AsyncTCP too.

a bit of technical background: Synchronous I/O in a realtime environment like the ESP8266 can be problematic. When execution-path does not leave the loop()-function from time to time, the Realtime-Operating-system of the board will not have enough time to take care of the TCP-Stack.

This is why my loop()-function has as little to do as possible, and I keep recommending this to people...do not block the operating-system from getting its job done!

wchpikus commented 5 years ago

i see, but you know, i have oled spi,telnet (two ways),and it could be no time, or interrupt some function, when receive data and got some data from other socket (telnet). i check it, i have lot of work with them, but i see your code works.. Maybe this first also works, it must be clear, for future:)

wchpikus commented 5 years ago

did you see difference between generic and nodemcu?

Monarch73 commented 5 years ago

what you mean "generic"? What board do you have? (amazon-link)

wchpikus commented 5 years ago

nodemcu (aliexpress) i write about compile to generic esp module vc nodemcu.

wchpikus commented 5 years ago

i disable all function from loop, still crash. could you (if you have experience, in setup i connect client (client.connect(gateway,httpPort) ) to 23 port. and do not disconnect them.. your ftp make new connection to port 21 to client or different port? i thing this is problem, nothing more i do not have run when client connecting to ftp server.

Monarch73 commented 5 years ago

where is "FtpServ * srv=new FtpServ(...)"-line in your code? Inside setup() or outside? Try to move the declaration in a global scope-right below the #include-lines.....

Monarch73 commented 5 years ago

I can't believe that the port-number could cause these kind of problems....

wchpikus commented 5 years ago

where is "FtpServ * srv=new FtpServ(...) is de fact in setup, but on stand alone function.

wchpikus commented 5 years ago

but it must be below spiffs.begin() so this is not good to move there?

Monarch73 commented 5 years ago

follow the way I did it....

FtpServ *ftpServer; <--- this goes below the include lines

ftpServer=new FtpServ(.... ftpServer->begin() <---- these two lines in the setup

Monarch73 commented 5 years ago

I am suspecting that the ftpServer instance gets picked up by the garbage collector....

wchpikus commented 5 years ago

i test it now..sorry, but after upgrade sdk compilation was terrible slow:(

Monarch73 commented 5 years ago

I could guide you through the installation of visual studio community 2017 and Visual Micro Plugin. Its a really comfortable development environment and its free

wchpikus commented 5 years ago

yes...i hate arduino.. Eclipse of visual studio..or some normal editor:)

Monarch73 commented 5 years ago

https://visualstudio.microsoft.com/de/thank-you-downloading-visual-studio/?sku=Community&rel=15 and https://www.python.org/downloads/release/python-2715/

these are the two things, that you need to install....

Monarch73 commented 5 years ago

make sure, you tell visual studio setup to install the c++-development component