当前位置:网站首页>RT thread -- FTP of LwIP (2)
RT thread -- FTP of LwIP (2)
2022-07-06 03:32:00 【rou252051452】
RT-Thread--Lwip And FTP_rou252051452 The blog of -CSDN Blog This description is based on RTT Based on the completion of network communication function , See another tutorial for specific network implementation .https://blog.csdn.net/rou252051452/article/details/123084492https://blog.csdn.net/rou252051452/article/details/1230844921、 Package enable open RT-ThreadSetting Install the software package , Save effective documents 2、FTP Function initialization The main function contains ...https://blog.csdn.net/rou252051452/article/details/123086671 In the previous document FTP Enable and connect , But there is no file system in the development board , No catalog for FTP Visit , So in this chapter, we discuss the file system (spi flash) The implementation of the .
1、 Hardware enable
According to the schematic configuration of punctual atoms SPIflash The configuration is as follows :

2、RT-Thread Setting Set up


3、board.h File settings
increase #define BSP_USING_SPI5 Macro definition
4、 mount SPI flash
newly build drivers\drv_spiflash.c file , The contents are as follows
#include "board.h"
#include <rtthread.h>
#include <rtdevice.h>
#include "drv_spi.h"
#include "drv_config.h"
#include <string.h>
#include "spi_flash_sfud.h"
static int rt_hw_spi_flash_init(void)
{
__HAL_RCC_GPIOF_CLK_ENABLE();
rt_hw_spi_device_attach("spi5", "spi50", GPIOF, GPIO_PIN_6);
if (RT_NULL == rt_sfud_flash_probe("W25Q256", "spi50"))
{
return -RT_ERROR;
};
return RT_EOK;
}
/* Export to automatic initialization */
INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);
Compile and download , The serial port output is as follows

5、 File system mount
stay main.c The following functions are implemented in the file flash Mount the file system , The main function calls this function .
static int dfs_mount_init(void)
{
if(dfs_mount("W25Q256", "/", "elm", 0, 0) == 0)
{
rt_kprintf("dfs mount success\r\n");
return RT_EOK;
}
else
{
rt_kprintf("spi file system initialized faile\r\n");
if(dfs_mkfs("elm", "W25Q256") == 0)
{
rt_kprintf("W25QXX file system initialized\r\n");
if(dfs_mount("W25Q256", "/", "elm", 0, 0) == 0)
{
rt_kprintf("dfs mount success\r\n");
return RT_EOK;
}
else
{
rt_kprintf("dfs mount success\r\n");
return -RT_ERROR;
}
}
else
{
rt_kprintf("dfs mount success\r\n");
return -RT_ERROR;
}
}
}Download validation , The serial port output is as follows

6、 Modification of the mount directory
The above mounting process will flash Directly mounted to the root directory , If there are multiple mounted devices, we cannot distinguish . Therefore, you can mount different directories under the root directory through the following operations .
modify rt-thread\components\def\filesystems\romfs\romfs.c The documents are as follows , We added sdcard and w25qxx Two directories .
#include <rtthread.h>
#include <dfs_romfs.h>
#include "dfs.h"
static const struct romfs_dirent _romfs_root[] =
{
{ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0},
{ROMFS_DIRENT_DIR, "w25qxx", RT_NULL, 0}
};
const struct romfs_dirent romfs_root =
{
ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_romfs_root, sizeof(_romfs_root)/sizeof(_romfs_root[0])
};
int mnt_init(void)
{
if(dfs_mount (RT_NULL,"/","rom",0,&(romfs_root)) == 0)
{
rt_kprintf("ROM file system initializated;\n");
}
else
{
rt_kprintf("ROM file system initializate failed;\n");
}
return 0;
}
INIT_ENV_EXPORT(mnt_init);
Synchronous to main.c Medium dfs_mount_init Make changes
static int dfs_mount_init(void)
{
if(dfs_mount("W25Q256", "/w25qxx", "elm", 0, 0) == 0)
{
rt_kprintf("dfs mount success\r\n");
return RT_EOK;
}
else
{
rt_kprintf("spi file system initialized faile\r\n");
if(dfs_mkfs("elm", "W25Q256") == 0)
{
rt_kprintf("W25QXX file system initialized\r\n");
if(dfs_mount("W25Q256", "/w25qxx", "elm", 0, 0) == 0)
{
rt_kprintf("dfs mount success\r\n");
return RT_EOK;
}
else
{
rt_kprintf("dfs mount success\r\n");
return -RT_ERROR;
}
}
else
{
rt_kprintf("dfs mount success\r\n");
return -RT_ERROR;
}
}
}Download validation , The serial port is as follows

FTP View the information as follows :

边栏推荐
猜你喜欢

Svg drag point crop image JS effect

JS音乐在线播放插件vsPlayAudio.js

Pointer written test questions ~ approaching Dachang

NR modulation 1

Overview of super-resolution reconstruction of remote sensing images

深入刨析的指针(题解)

【SLAM】lidar-camera外参标定(港大MarsLab)无需二维码标定板

MPLS experiment

three. JS page background animation liquid JS special effect

Analyze 菜单分析
随机推荐
three. JS page background animation liquid JS special effect
Princeton University, Peking University & UIUC | offline reinforcement learning with realizability and single strategy concentration
Handwriting database client
Yyds dry inventory what is test driven development
Overview of OCR character recognition methods
Erreur de la carte SD "erreur - 110 whilst initialisation de la carte SD
Recommended foreign websites for programmers to learn
Pytoch foundation - (1) initialization of tensors
Edcircles: a real time circle detector with a false detection control translation
Performance test method of bank core business system
How to do function test well
1、工程新建
Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
February 14, 2022 Daily: Google long article summarizes the experience of building four generations of TPU
1.16 - 校验码
真机无法访问虚拟机的靶场,真机无法ping通虚拟机
Analyze menu analysis
2、GPIO相关操作
Shell pass parameters
Computer graduation project asp Net fitness management system VS development SQLSERVER database web structure c programming computer web page source code project