FTP Server for esp-idf using FAT file system.
I found this information.
So, I ported from here.
Since it uses the FAT file system instead of SPIFFS, directory operations are possible.
Also, compared to SPIFFS, writing is about three times faster.
ESP-IDF V4.4/V5.x.
ESP-IDF V5.0 is required when using ESP32-C2.
ESP-IDF V5.1 is required when using ESP32-C6.
git clone https://github.com/nopnop2002/esp-idf-ftpServer
cd esp-idf-ftpServer/
idf.py set-target {esp32/esp32s2/esp32s3/esp32c2/esp32c3/esp32c6}
idf.py menuconfig
idf.py flash monitor
If you need more storage space on FLASH, you need to modify partitions_example.csv.
# Name, Type, SubType, Offset, Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 1M,
storage, data, fat, , 0xF0000, ---> This is for FAT file system
If your ESP32 has 4M Flash, you can get more space by changing this.
The maximum partition size of the FAT file system that can be specified on the 4M Flash model is 0x2F0000 (=2,960K).
ESP32 supports the following file systems.
You can select any one using menuconfig.
Besides this, the ESP32 supports the SPIFFS filesystem, but I don't use it because it can't handle directories.
When using MMC SDCARD, you can select 1 Line mode or 4 Line mode.
Note:
The connection when using SDSPI, SDMMC will be described later.
You can connect using the mDNS hostname instead of the IP address.
You can use static IP.
CONFIG_MDNS_STRICT_MODE=y
ESP32 | ESP32S2/S3 | ESP32C2/C3/C6 | SPI card pin | Notes |
---|---|---|---|---|
GPIO23 | GPIO35 | GPIO01 | MOSI | 10k pullup if can't mount |
GPIO19 | GPIO37 | GPIO03 | MISO | |
GPIO18 | GPIO36 | GPIO02 | SCK | |
GPIO14 | GPIO34 | GPIO04 | CS | |
3.3V | 3.3V | 3.3V | VCC | Don't use 5V supply |
GND | GND | GND | GND |
You can change it to any pin using menuconfig.
Note:
This project doesn't utilize card detect (CD) and write protect (WP) signals from SD card slot.
On ESP32, SDMMC peripheral is connected to specific GPIO pins using the IO MUX.
GPIO pins cannot be customized.
GPIO2 and GPIO12 cannot be changed.
So using 4-line SD mode with ESP32 is very tricky.
Please see the table below for the pin connections.
ESP32 pin | SD card pin | Notes |
---|---|---|
GPIO14 | CLK | 10k pullup |
GPIO15 | CMD | 10k pullup |
GPIO2 | D0 | 10k pullup or connect to GPIO0 |
GPIO4 | D1 | not used in 1-line SD mode; 10k pullup in 4-line SD mode |
GPIO12 | D2 | not used in 1-line SD mode; 10k pullup in 4-line SD mode |
GPIO13 | D3 | not used in 1-line SD mode, but card's D3 pin must have a 10k pullup |
N/C | CD | not used in this project |
N/C | WP | not used in this project |
3.3V | VCC | Don't use 5V supply |
GND | GND |
On ESP32-S3, SDMMC peripheral is connected to GPIO pins using GPIO matrix.
This allows arbitrary GPIOs to be used to connect an SD card.
ESP32-S3 pin | SD card pin | Notes |
---|---|---|
GPIO36 | CLK | 10k pullup |
GPIO35 | CMD | 10k pullup |
GPIO37 | D0 | 10k pullup |
GPIO38 | D1 | not used in 1-line SD mode; 10k pullup in 4-line SD mode |
GPIO33 | D2 | not used in 1-line SD mode; 10k pullup in 4-line SD mode |
GPIO34 | D3 | not used in 1-line SD mode, but card's D3 pin must have a 10k pullup |
N/C | CD | not used in this project |
N/C | WP | not used in this project |
3.3V | VCC | Don't use 5V supply |
GND | GND |
GPIO2 pin is used as a bootstrapping pin, and should be low to enter UART download mode. One way to do this is to connect GPIO0 and GPIO2 using a jumper, and then the auto-reset circuit on most development boards will pull GPIO2 low along with GPIO0, when entering download mode.
GPIO12 is used as a bootstrapping pin to select output voltage of an internal regulator which powers the flash chip (VDD_SDIO). This pin has an internal pulldown so if left unconnected it will read low at reset (selecting default 3.3V operation). When adding a pullup to this pin for SD card operation, consider the following:
gpio_pullup_en(GPIO_NUM_12);
call. Most SD cards work fine when an internal pullup on GPIO12 line is enabled. Note that if ESP32 experiences a power-on reset while the SD card is sending data, high level on GPIO12 can be latched into the bootstrapping register, and ESP32 will enter a boot loop until external reset with correct GPIO12 level is applied.By default, FATFS file names can be up to 8 characters long.
If you use filenames longer than 8 characters, you need to change the values below.
Long File Name on FLASH.
Long File Name on SDCARD.
Short File Name on SDCARD
The LilyGo ESP32-S2 development board has a micro SD card slot on the board.
It is connected to the ESP32 by SPI, and the peripheral power is supplied from GPIO14.
With this, you can easily build an FTP server.
No equipment other than the development board is required.
It works very stably.
I tested these client.
You need to set the connection type to Passive Mode.
WinSCP
FileZilla
You need to make this setting when using FileZilla.
FFFTP
I sometimes get this error when using external SPI SD card readers.
Requires a PullUp resistor.
You can see all the logging on the server side by commenting it out here.
void ftp_task (void *pvParameters)
{
ESP_LOGI(FTP_TAG, "ftp_task start");
//esp_log_level_set(FTP_TAG, ESP_LOG_WARN); ------------> Comment out
strcpy(ftp_user, CONFIG_FTP_USER);
strcpy(ftp_pass, CONFIG_FTP_PASSWORD);
ESP_LOGI(FTP_TAG, "ftp_user:[%s] ftp_pass:[%s]", ftp_user, ftp_pass);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。