Low level debug or free memory on wio terminal

Hi all,
I have a problem with wio terminal, I’m starting the porting of my ftp server implementation. but i have some trouble.

If i try to get the list of file from the setup() and I have the correct list, ,inside the lib dir is opened but on openNextFile no return,
and after first client.available() It freeze (same behavior for esp32 esp8266 and Arduino Ethernet work good).

So I’d like to ask if there is a debug mode to get low level information of the device, or a method to check the free memory (to prevent the freeze).

Bye Renzo

Hi @renzo.mischianti , for debugging you can use SWD (https://wiki.seeedstudio.com/Wio-Terminal-Getting-Started/). I’m using a J-Link debugger on PlatformIo IDE.

I did not explain myself well, I did not intend to debug, but ongli to have the core information like an esp32 with the instruction
Serial2.setDebugOutput (true);
to have all the logs of the central units.

Or a command to recover the available ram memory, in order to investigate the problem.

Thanks RM

Ah, I understand. At the moment I only remember how to get logging messages from the WiFi libraries, see this link:
-rpcWiFi library only working intermittently

// Memory usage Wio Terminal
// 20000000 First 64 K Ram Block
// 2000FFFF
// 20010000 Second 64 K Ram Block
// 2001FFFF
// 20020000 Third 64 K Ram Block
// 2002FFFF

// Heap goes upwards from about 2000A4A0 (in my application)
// Stack goes downwards from 2000FFFF

In one of my applications I had not enough stack, so I put some larger buffers in the not used third 64 K Ram block

Thanks RoSchmi,
I enable the log, but It going freeze without any alert. Probably It’s a memory leak when try to read from communication client and read from SD.
If you remember how to extend the stack please write here.
Thanks again Renzo

But I think It’s a bug (that generate freeze) inside the wifi library, or a different management of WiFiClient, the same code work good with Ethernet, SD card and Arduino UNO.
But It’s very difficult to get information from logging.
Bye RM

I fixed the freeze,
It was the command dir.close()
now network work correctly, but if I try to retrieve list of files from main program (in setup() or loop()) work correctly, in the library dir was every time empty.
It’s very strange.

Interesting project, however without seeing the code it is difficult to contribute. If you would open a branch on Github one could perhaps have an idea.
I would be interested to try your project on the Wio Terminal

I push a wio terminal version.

It isn’t well documented, so I try to explain the first handshake.
Fist you must configure the Filezilla (or other ftp client) as described in my article relative to the library


than after the first login hand shake in FTPServer.cpp (or after a refresh if you are previously connected) MLSD command is called check line from 515 ti 535, but the problem start on openDir at 519 line tha call lines from 909 to 941, STORAGE_MANAGER define
try to call open of directory /, but the resulting File “dir” on dir.openNextFile(); get 0 value and so no files are loaded.

But If you instantiate
File dir2 = SD.open("/");
and than try
you can get the files.

I think It’s a scope problem, but I need time to discover It.

Thank Renzo

So, I got it running and can confirm your observation. After first tests I think that the issue comes from Seed Arduino FS ff.c.
If I let it run on PlatformIO, use the debugger and set a breakpoint in the line:
if (!obj || !obj->fs || !obj->fs->fs_type || obj->fs->id != obj->id || (disk_status(obj->fs->drv) & STA_NOINIT)) {
and continue after it reaches this line the files are listed

Edit: No, I spoke too early. It doesn’t work. The program complains that: Dir is opened, Perhaps it must be closed after the first access.

Hi RoShmi,
I had a working version of FTP server with WIO Terminl, but I change the library to manage SD, I activate Library SdFat version >= 2.0.2 .
And now working good.

I pushed the updated example and updated FtpServerKey.h, you must add the library upper and all go well.

So I think there is a bug on scope of Seeed_SD library, but I think It’s difficult to explain in a issue on github, if you have some additional information to create a good issue on https://github.com/Seeed-Studio/Seeed_Arduino_FS write here so I’m going to integrate the information.

thanks Renzo

Hi @renzo.mischianti, Great !!! I can confirm that it is working with https://github.com/greiman/SdFat. I used the latest version v2.06.
As the Client on an iPhone I used the App ‘FTPManager Pro’.
Apparently your App is not supposed to work with TLS, is this correct?
Thanks a lot for sharing this valuable application.

Hi @RoSchmi,
no not support TLS.
I create a issue on https://github.com/Seeed-Studio/Seeed_Arduino_FS/issues/8 to fox that problem on FS, if they fix I can add also the management of internal spi flash.

Now I’d like to add callback on some internal ftp function (connect disconnect transfer freespace change) do do a monitor of FTP to show on TFT.

Thank again and Bye Renzo

Hi @renzo.mischianti, I got some things working using the Seeed libraries.
In FTPServer.cpp in the functions

I added:
File fileDir = SD.open(dir.name());
fileDir = dir.openNextFile();

otherwise in ‘ff.c’
FRESULT validate (…
returned with

Hi RoShmi,
I integrate your changes in wio_terminal_branch.
I add also the management of subdirectory in wio terminal SD and I add the event call back features.
Thanks Renzo

Hi RoSchmi,
the bug was solved, now work with the SD native library also.
Bye Renzo

Great, I’ll have a closer look next week.
Best regards