当前位置:网站首页>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 :
边栏推荐
- Arabellacpc 2019 (supplementary question)
- Research on cooperative control of industrial robots
- 3.2 detailed explanation of rtthread serial port device (V2)
- Leetcode problem solving -- 173 Binary search tree iterator
- Pytoch foundation - (2) mathematical operation of tensor
- Pointer for in-depth analysis (problem solution)
- An article about liquid template engine
- The next industry outlet: NFT digital collection, is it an opportunity or a foam?
- StrError & PERROR use yyds dry inventory
- MySQL Server层四个日志
猜你喜欢
three.js网页背景动画液态js特效
Pointer written test questions ~ approaching Dachang
3.1 detailed explanation of rtthread serial port device (V1)
[Li Kou] the second set of the 280 Li Kou weekly match
2.2 fonctionnement stm32 GPIO
暑期刷题-Day3
11. Container with the most water
遥感图像超分辨率论文推荐
深入探究指针及指针类型
MADDPG的pythorch实现——(1)OpenAI MADDPG环境配置
随机推荐
Idea push rejected solution
three. JS page background animation liquid JS special effect
Data analysis Seaborn visualization (for personal use)
Introduction to DeNO
暑期刷题-Day3
1.16 - 校验码
Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
The solution of permission denied (750 permissions should be used with caution)
Restful style
Deno介绍
SD card reports an error "error -110 whilst initializing SD card
JS音乐在线播放插件vsPlayAudio.js
Image super resolution using deep revolutionary networks (srcnn) interpretation and Implementation
Derivation of anti Park transform and anti Clarke transform formulas for motor control
真机无法访问虚拟机的靶场,真机无法ping通虚拟机
3.2 detailed explanation of rtthread serial port device (V2)
Quartz misfire missed and compensated execution
js凡客banner轮播图js特效
Tomb. Weekly update of Finance (February 7 - February 13)
Microsoft Research, UIUC & Google research | antagonistic training actor critic based on offline training reinforcement learning