1 Star 0 Fork 0

郑权 / esp-idf-ftpServer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

esp-idf-ftpServer

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.

Software requirements

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.

Installation

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.

Partition table

# 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).
config_flash_size

Configuration

config-main config-app

File System Selection

ESP32 supports the following file systems.
You can select any one using menuconfig.

  • FAT file system on FLASH
  • FAT file system on SPI peripheral SDCARD
  • FAT file system on SDMMC peripheral SDCARD(Valid only for ESP32/ESP32S3)
  • FAT file system on SPI Flash Memory like Winbond W25Q64(Not supported in this project)
  • FAT file system on USB Memory Stick(Not supported in this project)

Besides this, the ESP32 supports the SPIFFS filesystem, but I don't use it because it can't handle directories.

config-filesystem-1 config-filesystem-2

When using MMC SDCARD, you can select 1 Line mode or 4 Line mode.
config-filesystem-3 config-filesystem-4

Note:
The connection when using SDSPI, SDMMC will be described later.

WiFi Setting for Station-MODE

config-wifi-sta

You can connect using the mDNS hostname instead of the IP address.
config-wifi-2

You can use static IP.
config-wifi-3

WiFi Setting for AccessPoint-MODE

config-wifi-ap

Using mDNS hostname

  • esp-idf V4.4
    If you set CONFIG_MDNS_STRICT_MODE = y in sdkconfig.defaults, the firmware will be built with MDNS_STRICT_MODE.
    If MDNS_STRICT_MODE is not set, mDNS name resolution will not be possible after long-term operation.
  • esp-idf V4.4.1
    mDNS component has been updated.
    If you set CONFIG_MDNS_STRICT_MODE = y in sdkconfig.defaults, the firmware will be built with MDNS_STRICT_MODE.
    Even if MDNS_STRICT_MODE is set, mDNS name resolution will not be possible after long-term operation.
  • esp-idf V5.0 or later
    mDNS component has been updated.
    Long-term operation is possible without setting MDNS_STRICT_MODE.
    The following lines in sdkconfig.defaults should be removed before menuconfig.
    CONFIG_MDNS_STRICT_MODE=y

FTP Server Setting

config-server

Using FAT file system on SPI peripheral SDCARD

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

config-filesystem-SDSPI

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.

Using FAT file system on SDMMC peripheral SDCARD

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

config-filesystem-SDMMC-ESP32

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

config-filesystem-SDMMC-ESP32S3

Note about GPIO2 (ESP32 only)

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.

  • Some boards have pulldown and/or LED on GPIO2. LED is usually ok, but pulldown will interfere with D0 signals and must be removed. Check the schematic of your development board for anything connected to GPIO2.

Note about GPIO12 (ESP32 only)

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:

  • For boards which don't use the internal regulator (VDD_SDIO) to power the flash, GPIO12 can be pulled high.
  • For boards which use 1.8V flash chip, GPIO12 needs to be pulled high at reset. This is fully compatible with SD card operation.
  • On boards which use the internal regulator and a 3.3V flash chip, GPIO12 must be low at reset. This is incompatible with SD card operation.
    • In most cases, external pullup can be omitted and an internal pullup can be enabled using a 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.
    • Another option is to burn the flash voltage selection efuses. This will permanently select 3.3V output voltage for the internal regulator, and GPIO12 will not be used as a bootstrapping pin. Then it is safe to connect a pullup resistor to GPIO12. This option is suggested for production use.

Using long file name support

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.
config_long_file_name_support-1

Long File Name on FLASH.
config_long_file_name_support-2

Long File Name on SDCARD.
config_long_file_name_support-3

Short File Name on SDCARD config_long_file_name_support-4

Limitations

  • The server does not support multiple connections.
  • The server does not support active connection.
    Only passive connections are supported.
    Unfortunately, Windows standard ftp.exe does not allow passive mode (PASV) connections.
    If you have to make a passive mode connection On Windows, you need to use another software such as FFFTP / WinSCP / FileZilla to connect in passive mode.
  • The server can only process these commands.
    • SYST
    • CDUP
    • CWD
    • PWD
    • XPWD(Same as PWD)
    • SIZE
    • MDTM(Always GMT)
    • TYPE
    • USER
    • PASS
    • PASV
    • LIST
    • RETR
    • STOR
    • DELE
    • RMD
    • MKD
    • RNFR(Rename From)
    • RNTO(Rename To)
    • NOOP
    • QUIT
    • APPE
    • NLST

Using LilyGo ESP32-S2

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.

LilyGo-esp32-s2-1 LilyGo-esp32-s2-2

Windows ftp client

I tested these client.
You need to set the connection type to Passive Mode.

  • WinSCP
    WinSCP

  • FileZilla
    You need to make this setting when using FileZilla. FileZilla-2 FileZilla

  • FFFTP
    FFFTP

Troubleshooting

I sometimes get this error when using external SPI SD card readers.
Requires a PullUp resistor.
sd-card-1

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);

Reference

https://github.com/nopnop2002/esp-idf-ftpClient

MIT License Copyright (c) 2021 nopnop2002 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

复制自https://github.com/nopnop2002/esp-idf-ftpServer 展开 收起
C
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C
1
https://gitee.com/Wedone123/esp-idf-ftpServer.git
git@gitee.com:Wedone123/esp-idf-ftpServer.git
Wedone123
esp-idf-ftpServer
esp-idf-ftpServer
main

搜索帮助