当前位置:网站首页>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 :
边栏推荐
- EDCircles: A real-time circle detector with a false detection control 翻译
- Python implementation of maddpg - (1) openai maddpg environment configuration
- 深入探究指针及指针类型
- MySQL Server层四个日志
- 1.16 - check code
- Teach you to build your own simple BP neural network with pytoch (take iris data set as an example)
- . Net 6 and Net core learning notes: Important issues of net core
- Pytoch foundation - (1) initialization of tensors
- [padding] an error is reported in the prediction after loading the model weight attributeerror: 'model' object has no attribute '_ place‘
- Leetcode problem solving -- 99 Restore binary search tree
猜你喜欢
Esbuild & SWC: a new generation of construction tools
2.2 STM32 GPIO operation
多项目编程极简用例
Résumé des méthodes de reconnaissance des caractères ocr
3.1 detailed explanation of rtthread serial port device (V1)
Problems encountered in 2022 work IV
Svg drag point crop image JS effect
IPv6 comprehensive experiment
NR modulation 1
Precautions for single chip microcomputer anti reverse connection circuit
随机推荐
3.1 rtthread 串口设备(V1)详解
3.2 detailed explanation of rtthread serial port device (V2)
SD card reports an error "error -110 whilst initializing SD card
BUUCTF刷题笔记——[极客大挑战 2019]EasySQL 1
Recommended foreign websites for programmers to learn
Princeton University, Peking University & UIUC | offline reinforcement learning with realizability and single strategy concentration
SWC介绍
Crazy, thousands of netizens are exploding the company's salary
Résumé des méthodes de reconnaissance des caractères ocr
Schnuka: visual positioning system working principle of visual positioning system
Performance analysis of user login TPS low and CPU full
出现Permission denied的解决办法(750权限谨慎使用)
Tidb ecological tools (backup, migration, import / export) collation
RT-Thread--Lwip之FTP(2)
Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
How to do function test well
Pytorch基础——(2)张量(tensor)的数学运算
Idea push rejected solution
MySQL Server层四个日志
SWC introduction