当前位置:网站首页>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 :
边栏推荐
- Leetcode problem solving -- 173 Binary search tree iterator
- pytorch加载数据
- 【paddle】加载模型权重后预测报错AttributeError: ‘Model‘ object has no attribute ‘_place‘
- Problems encountered in 2022 work IV
- 深入刨析的指针(题解)
- 真机无法访问虚拟机的靶场,真机无法ping通虚拟机
- SAP ALV color code corresponding color (finishing)
- Deno介绍
- SD card reports an error "error -110 whilst initializing SD card
- Data analysis Seaborn visualization (for personal use)
猜你喜欢
SWC introduction
Pointer written test questions ~ approaching Dachang
1. New project
1.16 - 校验码
Eight super classic pointer interview questions (3000 words in detail)
ESBuild & SWC浅谈: 新一代构建工具
JS music online playback plug-in vsplayaudio js
2. GPIO related operations
Python implementation of maddpg - (1) openai maddpg environment configuration
2、GPIO相关操作
随机推荐
SAP ALV单元格级别设置颜色
记录一下逆向任务管理器的过程
Recommended foreign websites for programmers to learn
Restful style
Schnuka: what is visual positioning system and how to position it
[slam] orb-slam3 parsing - track () (3)
Cross origin cross domain request
Brush questions in summer -day3
施努卡:什么是视觉定位系统 视觉系统如何定位
Redis cache breakdown, cache penetration, cache avalanche
BUAA喜鹊筑巢
three. JS page background animation liquid JS special effect
遥感图像超分辨率论文推荐
3857 Mercator coordinate system converted to 4326 (WGS84) longitude and latitude coordinates
2.2 STM32 GPIO operation
Overview of OCR character recognition methods
Research on cooperative control of industrial robots
How to write compile scripts compatible with arm and x86 (Makefile, cmakelists.txt, shell script)
【RISC-V】外部中断
【Qt5】Qt QWidget立刻出现并消失