Zynq7000 based custom board FreeRTOS + FTP speed

Hello everyone,
I’m currently using Xilinx Zynq-7000 on a custom board. Also I’m run FreeRTOS and libraries. My problem is FTP download and upload speed. I’ve tested speeds by using Filezilla. I created a 100MB file then I send it to the board through Filezilla. In the beggining, I observed around 3 MB/s. To fix that, I increased the rx buffer size by using this macro define ipconfigFTP_RX_BUFSIZE. I reached the speed,from PC to the board, around 11MB/s. Next, I decided to test the speed from the board to PC. I used same file to test it. By using default settings, I reached the speed around 2.2 MB/s. In this case, I increased tx buffer size by using ipconfigFTP_TX_BUFSIZE macro. Then I test it again same setup but there is no change about the speed when transfer file from the board to PC, again I got 2.2 MB/s. What will could cause this problem? or is it not a problem? Also I tested the memory read and write speeds by using ff_fread() and ff_fwrite functions, I got 20MB/s for read and 15 MB/s for write. While I perform these testes I used 100 Mbit ethernet. I did not test the TCP send and receive functions explicitly. I also observed the communication from wireshark. I did not see any zero window warning etc. for the transfer from the board to PC. But I observed zero window warning for the transfer from PC to the board. For a while I cannot provide the wireshark output and ipconfig files. I will try to add the files as soon as possible.
For now, what do you suggest to me about increasing the transfer speed from the board to PC?

While I perform these testes I used 100 Mbit ethernet

First of all, I wonder why you can not use a Gbit Ethernet?

It is a long time ago that I measure the nett speeds for doing FTP transfers.

Which FTP library do you use? From one of the “protocol” libraries that I published?

Do you have iperf3 installed? Can you test the TCP speed?

And also, it may be interesting if you can send a PCAP of a transfer, one for sending, and one for receiving a file.

EDIT

Please find an iperf3 server here:

I just tested today’s drivers for Zynq-7000: +TCP and +FAT.

When I developed the FreeRTOS+FAT driver for Zynq, I encountered a problem: overruns when writing data to an SD-card. I never found an explanation for that, nor did I find a proper solution.

Before writing to disk, there is a short pause of ulSDWritePause µS. That happens in a simple loop.

I just tested the driver while skipping this delay, and then the writes to SD-card were a bit (15% or so) faster. But it is not recommended until the overrun problem is solved.

Tips:

  • About using WireShark: it may happen that running WireShark influences the measured throughput.

  • You can try out the following settings:

    ffconfigWRITE_BOTH_FATS = 0
    ffconfigWRITE_FREE_COUNT = 0
    ffconfigCACHE_WRITE_THROUGH = 0
    ffconfigPATH_CACHE = 1 / ffconfigPATH_CACHE_DEPTH = 8
    ffconfigSDIO_DRIVER_USES_INTERRUPT = 1

Be aware of the possible consequences if you use the above settings.

Then I test it again same setup but there is no change about the speed when transfer file from the board to PC, again I got 2.2 MB/s. What will could cause this problem?

That is a natural thing: you can increase the TCP window size up to 8 packets (8 x 1460 bytes). A larger TCP window size doesn’t make any difference because the peer starts sending ACK’s after so many segments.

or is it not a problem?

It is expected behaviour.

Also I tested the memory read and write speeds by using ff_fread() and ff_fwrite functions, I got 20MB/s for read and 15 MB/s for write.

I am surprised about the write speed, I get a write speed of at most 2 MB/sec. What grade of SD-cards do you use?

Measuring speeds is always unreliable. The actual numbers in daily life are influenced by numerous factors: other competing tasks, the traffic/load on the LAN, etc.

But when optimising for speed (-Os), and using a cheap SD-card, I get the following results:

DUT to host Host to DUT
iperf/tcp 35.20 13.50 MB/sec
FTP/ram 45.77 12.90
FTP/sd-card 13.13 1.21
Read SD-card Write SD-card
New file 8.26 0.72* MB/sec
Existing file 8.32 2.07

* The slowest task is “allocating clusters” while writing to a new file. When overwriting an existing file, the cluster chain will be re-used and writing is faster.

When I use the above ffconfig settings, the speed of writing to a new file has doubled.

mmmmm

speeds and clock dividers for everything will be set per the board config data for the bootloader set in Vivado in the XIlinx tools. but you can change them yourself from SW once it is going.

there is some problem with the zynq-7000 network inf that packets dont get notified in the interrupt system / RX FIFO until another one comes it right behind it…

HOWEVER !!!

as for the write speed of SDcards, it can be very very slow if it has to erase a page. like 0.1 to 0.2Mbytes/second for some … I use magnetic platter discs on my VMs at home. they are far faster to write. Is it any different with a ocmpletely bulk erase SD card ? (IE all pages clean) .

also

https://support.xilinx.com/s/article/55539?language=en_US

there are some SD card sequences to avoid !!! see SDIO section

known problem with RTX packets stuck in FIFO

https://support.xilinx.com/s/question/0D52E00006iHm7DSAS/zynq7000-frames-stuck-in-gigabit-ethernet-rx-fifo?language=en_US

Full errata

https://docs.xilinx.com/v/u/en-US/en257

glen english - XIlinx Alliance Partner.

1 Like

Hi again, thanks for your replies. I apologize for the delayed response. I was unable to address the post sooner.

First of all, I wonder why you can not use a Gbit Ethernet?

Actually I will use Gbit Ethernet but the resistor configuration of the board needs to be changed so for now, I use as 100Mbit.

Which FTP library do you use? From one of the “protocol” libraries that I published?

I believe so. The libraries were sourced from the FreeRTOS GitHub demo application, if I remember correctly.

Do you have iperf3 installed? Can you test the TCP speed?

I have installed iperf3 and conducted a test at 100Mbit. The result is as follows.(I can’t take screenshot hence I took photo.)

And also, it may be interesting if you can send a PCAP of a transfer, one for sending, and one for receiving a file.

I recorded it but I can not directly share the file, because there is a procedure to export file from local computer and it will take time. I will share the files as soon as possible.

I am surprised about the write speed, I get a write speed of at most 2 MB/sec. What grade of SD-cards do you use?

MTFC32GLDDQ-4MIT-Micron 32GB eMMC is used on the board.
I used XTime_GetTime() function to measure the emmc speed. I get the time right before the open file then I call the ff_fread(), next close the file, finally I get time again then calculate the speed.

I have attached the PCAP files for transferring a 100MB dummy file.
host_to_dut.zip (365.2 KB)
dut_to_host.zip (2.6 MB)
Also I performed iperf test for 1000Mbps link speed.
image
Again I tested it by using -R option and the result is
image
What are your thoughts on these transfer speeds? Do you consider them to be low? How might I improve them? By the way my code’s optimization level is currently set to -O0.

That looks more or less the same as what I measured.

If I were you I would investigate the suggestions given earlier in this post by Glen English.

Unfortunately at this moment, I do not have the time at this moment to work on this.

Hi everyone. I believe my problem has been solved. I figured this out while downloading a file from the board; it reads and sends 2048 bytes of data. I looked into the FTP server code and then found out where the 2048 bytes came from. I saw a configuration parameter named ipconfigTCP_FILE_BUFFER_SIZE . When I increased the ipconfigTCP_FILE_BUFFER_SIZE , I observed an increase in FTP speed in Filezilla. I found the most optimized value for it to be 32768. With this setting, I reached nearly 13 MiB/s file transfer speed from my board to PC.
I wonder if this solution could cause any problems?

It is hard to confirm without looking at the code that uses this parameter but in general, the only consequence should be increased RAM usage.

Thanks for replying. Yes, I understand that we can’t predict exactly which situation will cause which problem. It’s good to know what kind of problems we could face. I would consider the RAM usage. The parameters are defined here: [freertos/FreeRTOS-Plus/Demo/Common/Demo_IP_Protocols/include/FreeRTOS_server_private.h at master · particle-iot/freertos · GitHub]. You can access other files using this link if needed. I used files in the Common, FTP, and Include directories.

I took a quick look and it seem like ipconfigTCP_FILE_BUFFER_SIZE is used to control the size of the buffer used for sending and receiving data. Other than the more RAM usage, there should not be any issue. Since it is allocated dynamically, you may want to enable malloc failed hook during testing to catch any allocation failures because of increased heap usage.

1 Like