ARM单片机FATFS文件系统的移植

2023-10-27

  • FreeRTOS10.0.1
  • FATFS FF14A
  • SFUD V1.1.0
  • STM32F103ZET6

FATFS在STM32上特别是由CubeMX工具移植变得简单,相对在其他芯片平台没有这个工具时,清晰的了解移植的方法步骤变得更加重要了。

测试效果

在这里插入图片描述

前提条件

FATFS移植需要做的:

  • 配置FATFS,裁剪相关功能
  • 完善使用操作系统时的互斥锁接口
  • 完善内存管理接口
  • 完善diskio.c中对存储设备的操作接口

本工程,使用W25Q16BVspi flash芯片,所以移植SFUD完善对FLASH的操作接口
本工程源码

下载所需源码

FATFS 文件系统

下载地址,可能需代理工具

SFUD万能驱动

官方移植方法参考
本博客移植参考

加入工程

port目录下皆是需要修改的的文件diskio.c需配合disk_port.c做出微调,其他无需修改
在这里插入图片描述

接口驱动

diskio.c调整如下:
包含驱动接口头文件disk_port.h
调用disk_drv_array里的相关函数

/*-----------------------------------------------------------------------*/
/* Low level disk I/O module SKELETON for FatFs     (C)ChaN, 2019        */
/*-----------------------------------------------------------------------*/
/* If a working storage control module is available, it should be        */
/* attached to the FatFs via a glue function rather than modifying it.   */
/* This is an example of glue functions to attach various exsisting      */
/* storage control modules to the FatFs module with a defined API.       */
/*-----------------------------------------------------------------------*/

#include "ff.h"			/* Obtains integer types */
#include "diskio.h"		/* Declarations of disk functions */
#include "disk_port.h"
/*-----------------------------------------------------------------------*/
/* Get Drive Status                                                      */
/*-----------------------------------------------------------------------*/

DSTATUS disk_status (
	BYTE pdrv		/* Physical drive nmuber to identify the drive */
)
{
	return disk_drv_array[pdrv].get_disk_status_port();
}



/*-----------------------------------------------------------------------*/
/* Inidialize a Drive                                                    */
/*-----------------------------------------------------------------------*/

DSTATUS disk_initialize (
	BYTE pdrv				/* Physical drive nmuber to identify the drive */
)
{
	return disk_drv_array[pdrv].disk_init_port();
}



/*-----------------------------------------------------------------------*/
/* Read Sector(s)                                                        */
/*-----------------------------------------------------------------------*/

DRESULT disk_read (
	BYTE pdrv,		/* Physical drive nmuber to identify the drive */
	BYTE *buff,		/* Data buffer to store read data */
	LBA_t sector,	/* Start sector in LBA */
	UINT count		/* Number of sectors to read */
)
{
  return disk_drv_array[pdrv].disk_read_port(buff, sector, count);
}



/*-----------------------------------------------------------------------*/
/* Write Sector(s)                                                       */
/*-----------------------------------------------------------------------*/

#if FF_FS_READONLY == 0

DRESULT disk_write (
	BYTE pdrv,			/* Physical drive nmuber to identify the drive */
	const BYTE *buff,	/* Data to be written */
	LBA_t sector,		/* Start sector in LBA */
	UINT count			/* Number of sectors to write */
)
{
  return disk_drv_array[pdrv].disk_write_port(buff, sector, count);
}

#endif


/*-----------------------------------------------------------------------*/
/* Miscellaneous Functions                                               */
/*-----------------------------------------------------------------------*/

DRESULT disk_ioctl (
	BYTE pdrv,		/* Physical drive nmuber (0..) */
	BYTE cmd,		/* Control code */
	void *buff		/* Buffer to send/receive control data */
)
{
  return disk_drv_array[pdrv].disk_ioctl_port(cmd, buff);
}


disk_port.c磁盘驱动接口

/**
 *  @file disk_port.c
 *
 *  @date 2021-01-05
 *
 *  @author aron566
 *
 *  @copyright None.
 *
 *  @brief 磁盘接口驱动映射
 *
 *  @details None.
 *
 *  @version V1.0
 */
#ifdef __cplusplus ///<use C compiler
extern "C" {
#endif
/** Includes -----------------------------------------------------------------*/
/* Private includes ----------------------------------------------------------*/
#include "disk_port.h"
#include "rtc_opt.h"
/** Privated typedef ----------------------------------------------------------*/

/** Private macros -----------------------------------------------------------*/

/** Private constants --------------------------------------------------------*/

/** Private variables --------------------------------------------------------*/

/** Private function prototypes ----------------------------------------------*/

/** Private user code --------------------------------------------------------*/
/**
 * @defgroup SPI FLASH DRIVE FUNC
 * @{
 */
static DSTATUS spi_flash_disk_status(void);
static DSTATUS spi_flash_disk_initialize(void);
static DRESULT spi_flash_disk_read(BYTE *buff, LBA_t sector, UINT count);
static DRESULT spi_flash_disk_write(const BYTE *buff, LBA_t sector, UINT count);
static DRESULT spi_flash_disk_ioctl(BYTE cmd, void *buff);
/** @}*/
/** Public variables ---------------------------------------------------------*/
DISK_DRV_FUNC_MAP_Typedef_t disk_drv_array[DEV_TYPE_MAX] = 
{
  [DEV_SPI_FLASH] = {
                      .get_disk_status_port = spi_flash_disk_status,
                      .disk_init_port       = spi_flash_disk_initialize,
                      .disk_read_port       = spi_flash_disk_read,
                      .disk_write_port      = spi_flash_disk_write,
                      .disk_ioctl_port      = spi_flash_disk_ioctl
                    },
};

osMutexDef_t disk_mutex_array[DEV_TYPE_MAX] = {0};
/** Private application code -------------------------------------------------*/
/*******************************************************************************
*
*       Static code
*
********************************************************************************
*/

/**
  ******************************************************************
  * @brief   spi磁盘状态读取
  * @param   [in]None
  * @return  1 Drive not initialized 2 No medium in the drive 4 Write protected
  * @author  aron566
  * @version V1.0
  * @date    2020-01-04
  ******************************************************************
  */
static DSTATUS spi_flash_disk_status(void)
{
    sfud_flash *flash = sfud_get_device(SFUD_W25Q16BV_DEVICE_INDEX);
    if(flash == NULL)
    {
        return STA_NOINIT;
    }
    uint8_t status;
    sfud_read_status(flash, &status);
	return (DSTATUS)status;
}

/**
  ******************************************************************
  * @brief   spi磁盘初始化
  * @param   [in]None
  * @return  0 OK 1 Drive not initialized 2 No medium in the drive 4 Write protected
  * @author  aron566
  * @version V1.0
  * @date    2020-01-04
  ******************************************************************
  */
static DSTATUS spi_flash_disk_initialize(void)
{
    sfud_flash *flash = sfud_get_device(SFUD_W25Q16BV_DEVICE_INDEX);
    if(flash == NULL)
    {
        return STA_NOINIT;
    }
    sfud_err result = sfud_device_init(flash);
    if(result != SFUD_SUCCESS)
    {
        return STA_NOINIT;
    }
	return 0;
}

/**
  ******************************************************************
  * @brief   spi磁盘读取指定扇区数的数据到缓冲区
  * @param   [out]buff 缓冲区
  * @param   [in]sector 起始扇区号
  * @param   [in]count 扇区数
  * @return  0: Successful 1: R/W Error 2: Write Protected 3: Not Ready 4: Invalid Parameter
  * @author  aron566
  * @version V1.0
  * @date    2020-01-04
  ******************************************************************
  */
static DRESULT spi_flash_disk_read(BYTE *buff, LBA_t sector, UINT count)
{
    sfud_flash *flash = sfud_get_device(SFUD_W25Q16BV_DEVICE_INDEX);
    if(flash == NULL)
    {
        return RES_PARERR;
    }
    sfud_err result = sfud_read(flash, sector*512, 512*count, (uint8_t *)buff);
    if(result != SFUD_SUCCESS)
    {
        return RES_ERROR;
    }
	return RES_OK;
}

/**
  ******************************************************************
  * @brief   spi磁盘写入数据到指定扇区数
  * @param   [in]buff
  * @param   [in]sector
  * @param   [in]count
  * @return  0: Successful 1: R/W Error 2: Write Protected 3: Not Ready 4: Invalid Parameter
  * @author  aron566
  * @version V1.0
  * @date    2020-01-04
  ******************************************************************
  */
static DRESULT spi_flash_disk_write(const BYTE *buff, LBA_t sector, UINT count)
{
    sfud_flash *flash = sfud_get_device(SFUD_W25Q16BV_DEVICE_INDEX);
    if(flash == NULL)
    {
        return RES_PARERR;
    }
    sfud_err result = sfud_erase_write(flash, sector*512, 512*count, (const uint8_t *)buff);
    if(result != SFUD_SUCCESS)
    {
        return RES_ERROR;
    }
	return RES_OK;
}


/**
  ******************************************************************
  * @brief   spi磁盘特殊操作
  * @param   [in]cmd
  * @param   [in]buff
  * @return  0: Successful 1: R/W Error 2: Write Protected 3: Not Ready 4: Invalid Parameter
  * @author  aron566
  * @version V1.0
  * @date    2020-01-04
  ******************************************************************
  */
static DRESULT spi_flash_disk_ioctl(BYTE cmd, void *buff)
{
//#define CTRL_SYNC			0	/* Complete pending write process (needed at FF_FS_READONLY == 0) */
//#define GET_SECTOR_COUNT	1	/* Get media size (needed at FF_USE_MKFS == 1) */
//#define GET_SECTOR_SIZE		2	/* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
//#define GET_BLOCK_SIZE		3	/* Get erase block size (needed at FF_USE_MKFS == 1) */
//#define CTRL_TRIM			4	/* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
    switch(cmd)
    {
        case CTRL_SYNC:
            
            return RES_OK;
        case GET_SECTOR_COUNT:
            *(DWORD*)buff = 4096;/**< PAGE SIZE:256,SECTOR SIZE:4KB,BLOCK SIZE:32/64KB,W25Q16BV TOTOAL SIZE:512*4KB*/
            return RES_OK;
        case GET_SECTOR_SIZE:
            *(DWORD*)buff = FF_MAX_SS;/**< if use 512Byte then erase size is 2 PAGE SIZE, if use 4KB then erase size is 1 SECTOR SIZE.*/
            return RES_OK;
        case GET_BLOCK_SIZE:
            *(DWORD*)buff = 1;/**< 擦除扇区的最小个数(1*512Byte = 2 PAGE SIZE),per 32K/64K block size to erase*/
            return RES_OK;
        case CTRL_TRIM:
            return RES_PARERR;/**< 通知扇区数据不使用--未开启功能*/
        default:
            break;
    }
	return RES_PARERR;
}

/** Public application code --------------------------------------------------*/
/*******************************************************************************
*
*       Public code
*
********************************************************************************
*/
/**
  ******************************************************************
  * @brief   获取当前时间秒数
  * @param   [in]None
  * @return  s
  * @author  aron566
  * @version V1.0
  * @date    2020-01-04
  ******************************************************************
  */
DWORD disk_get_rtc_time_s(void)
{
  return RTC_Current_Time_S();
}

#ifdef __cplusplus ///<end extern c
}
#endif
/******************************** End of file *********************************/

disk_port.h磁盘驱动接口

/**
 *  @file disk_port.h
 *
 *  @date 2021-01-04
 *
 *  @author aron566
 *
 *  @brief 磁盘接口驱动
 *  
 *  @version V1.0
 */
#ifndef DISK_PORT_H
#define DISK_PORT_H
#ifdef __cplusplus ///<use C compiler
extern "C" {
#endif
/** Includes -----------------------------------------------------------------*/
#include <stdint.h> /**< nedd definition of uint8_t */
#include <stddef.h> /**< need definition of NULL    */
#include <stdbool.h>/**< need definition of BOOL    */
#include <stdio.h>  /**< if need printf             */
#include <stdlib.h>
#include <string.h>
#include <limits.h> /**< need variable max value    */
/** Private includes ---------------------------------------------------------*/
#include "main.h"
#include "ff.h"
#include "diskio.h"
/** Private defines ----------------------------------------------------------*/

/** Exported typedefines -----------------------------------------------------*/
/*磁盘状态读取*/
typedef DSTATUS(*pdisk_status_func)(void);
/*磁盘初始化*/
typedef DSTATUS(*pdisk_initialize_func)(void);
/*磁盘读取数据*/
typedef DRESULT(*pdisk_read_func)(
	BYTE *buff,		/* Data buffer to store read data */
	LBA_t sector,	/* Start sector in LBA */
	UINT count		/* Number of sectors to read */
);
/*磁盘写入数据*/
typedef DRESULT (*pdisk_write_func)(
	const BYTE *buff,	/* Data to be written */
	LBA_t sector,		/* Start sector in LBA */
	UINT count			/* Number of sectors to write */
);
/*磁盘控制*/
typedef DRESULT (*pdisk_ioctl_func)(
	BYTE cmd,		/* Control code */
	void *buff		/* Buffer to send/receive control data */
);

typedef struct disk_drv
{
  pdisk_status_func get_disk_status_port;
  pdisk_initialize_func disk_init_port;
  pdisk_read_func disk_read_port;
  pdisk_write_func disk_write_port;
  pdisk_ioctl_func disk_ioctl_port;
}DISK_DRV_FUNC_MAP_Typedef_t;
/** Exported constants -------------------------------------------------------*/

/** Exported macros-----------------------------------------------------------*/
/* Definitions of physical drive number for each drive */
#define DEV_RAM		0	/* Example: Map Ramdisk to physical drive 0 */
#define DEV_MMC		1	/* Example: Map MMC/SD card to physical drive 1 */
#define DEV_USB		2	/* Example: Map USB MSD to physical drive 2 */
#define DEV_SPI_FLASH 3
#define DEV_TYPE_MAX DEV_SPI_FLASH+1
/** Exported variables -------------------------------------------------------*/
extern DISK_DRV_FUNC_MAP_Typedef_t disk_drv_array[DEV_TYPE_MAX];/**< 磁盘设备驱动接口*/

extern osMutexDef_t disk_mutex_array[DEV_TYPE_MAX];/**< 磁盘同步锁*/
/** Exported functions prototypes --------------------------------------------*/
DWORD disk_get_rtc_time_s(void);
#ifdef __cplusplus ///<end extern c
}
#endif
#endif
/******************************** End of file *********************************/

ffsystem.cFATFS的信号量动态内存管理

/*------------------------------------------------------------------------*/
/* Sample Code of OS Dependent Functions for FatFs                        */
/* (C)ChaN, 2018                                                          */
/*------------------------------------------------------------------------*/


#include "ff.h"
#include "disk_port.h"

#if FF_USE_LFN == 3	/* Dynamic memory allocation */

/*------------------------------------------------------------------------*/
/* Allocate a memory block                                                */
/*------------------------------------------------------------------------*/

void* ff_memalloc (	/* Returns pointer to the allocated memory block (null if not enough core) */
	UINT msize		/* Number of bytes to allocate */
)
{
	return pvPortMalloc(msize);	/* Allocate a new memory block with POSIX API */
}


/*------------------------------------------------------------------------*/
/* Free a memory block                                                    */
/*------------------------------------------------------------------------*/

void ff_memfree (
	void* mblock	/* Pointer to the memory block to free (nothing to do if null) */
)
{
	vPortFree(mblock);	/* Free the memory block with POSIX API */
}

#endif



#if FF_FS_REENTRANT	/* Mutal exclusion */

/*------------------------------------------------------------------------*/
/* Create a Synchronization Object                                        */
/*------------------------------------------------------------------------*/
/* This function is called in f_mount() function to create a new
/  synchronization object for the volume, such as semaphore and mutex.
/  When a 0 is returned, the f_mount() function fails with FR_INT_ERR.
*/

//const osMutexDef_t Mutex[FF_VOLUMES];	/* Table of CMSIS-RTOS mutex */


int ff_cre_syncobj (	/* 1:Function succeeded, 0:Could not create the sync object */
	BYTE vol,			/* Corresponding volume (logical drive number) */
	FF_SYNC_t* sobj		/* Pointer to return the created sync object */
)
{
	/* Win32 */
//	*sobj = CreateMutex(NULL, FALSE, NULL);
//	return (int)(*sobj != INVALID_HANDLE_VALUE);

	/* uITRON */
//	T_CSEM csem = {TA_TPRI,1,1};
//	*sobj = acre_sem(&csem);
//	return (int)(*sobj > 0);

	/* uC/OS-II */
//	OS_ERR err;
//	*sobj = OSMutexCreate(0, &err);
//	return (int)(err == OS_NO_ERR);

	/* FreeRTOS */
//	*sobj = xSemaphoreCreateMutex();
//	return (int)(*sobj != NULL);

	/* CMSIS-RTOS */
	*sobj = osMutexNew(&disk_mutex_array[vol]);
	return (int)(*sobj != NULL);
}


/*------------------------------------------------------------------------*/
/* Delete a Synchronization Object                                        */
/*------------------------------------------------------------------------*/
/* This function is called in f_mount() function to delete a synchronization
/  object that created with ff_cre_syncobj() function. When a 0 is returned,
/  the f_mount() function fails with FR_INT_ERR.
*/

int ff_del_syncobj (	/* 1:Function succeeded, 0:Could not delete due to an error */
	FF_SYNC_t sobj		/* Sync object tied to the logical drive to be deleted */
)
{
	/* Win32 */
//	return (int)CloseHandle(sobj);

	/* uITRON */
//	return (int)(del_sem(sobj) == E_OK);

	/* uC/OS-II */
//	OS_ERR err;
//	OSMutexDel(sobj, OS_DEL_ALWAYS, &err);
//	return (int)(err == OS_NO_ERR);

	/* FreeRTOS */
//  vSemaphoreDelete(sobj);
//	return 1;

	/* CMSIS-RTOS */
	return (int)(osMutexDelete(sobj) == osOK);
}


/*------------------------------------------------------------------------*/
/* Request Grant to Access the Volume                                     */
/*------------------------------------------------------------------------*/
/* This function is called on entering file functions to lock the volume.
/  When a 0 is returned, the file function fails with FR_TIMEOUT.
*/

int ff_req_grant (	/* 1:Got a grant to access the volume, 0:Could not get a grant */
	FF_SYNC_t sobj	/* Sync object to wait */
)
{
	/* Win32 */
//	return (int)(WaitForSingleObject(sobj, FF_FS_TIMEOUT) == WAIT_OBJECT_0);

	/* uITRON */
//	return (int)(wai_sem(sobj) == E_OK);

	/* uC/OS-II */
//	OS_ERR err;
//	OSMutexPend(sobj, FF_FS_TIMEOUT, &err));
//	return (int)(err == OS_NO_ERR);

	/* FreeRTOS */
//	return (int)(xSemaphoreTake(sobj, FF_FS_TIMEOUT) == pdTRUE);

	/* CMSIS-RTOS */
	return (int)(osMutexWait(sobj, FF_FS_TIMEOUT) == osOK);
}


/*------------------------------------------------------------------------*/
/* Release Grant to Access the Volume                                     */
/*------------------------------------------------------------------------*/
/* This function is called on leaving file functions to unlock the volume.
*/

void ff_rel_grant (
	FF_SYNC_t sobj	/* Sync object to be signaled */
)
{
	/* Win32 */
//	ReleaseMutex(sobj);

	/* uITRON */
//	sig_sem(sobj);

	/* uC/OS-II */
//	OSMutexPost(sobj);

	/* FreeRTOS */
//	xSemaphoreGive(sobj);

	/* CMSIS-RTOS */
	osMutexRelease(sobj);
}

#endif

#if !FF_FS_READONLY && !FF_FS_NORTC
/**
  ******************************************************************
  * @brief   获取当前时间秒数
  * @param   [in]None
  * @return  s
  * @author  aron566
  * @version V1.0
  * @date    2020-01-04
  ******************************************************************
  */
DWORD get_fattime (void)
{
  return disk_get_rtc_time_s();
}
#endif

ffconf.hFATFS配置文件

/*---------------------------------------------------------------------------/
/  FatFs Functional Configurations
/---------------------------------------------------------------------------*/
#ifndef FF_CONFIG_H
#define FF_CONFIG_H

#define FFCONF_DEF	80196	/* Revision ID */

/*---------------------------------------------------------------------------/
/ Function Configurations
/---------------------------------------------------------------------------*/

#define FF_FS_READONLY	0
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
/  Read-only configuration removes writing API functions, f_write(), f_sync(),
/  f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
/  and optional writing functions as well. */


#define FF_FS_MINIMIZE	0
/* This option defines minimization level to remove some basic API functions.
/
/   0: Basic functions are fully enabled.
/   1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
/      are removed.
/   2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
/   3: f_lseek() function is removed in addition to 2. */


#define FF_USE_STRFUNC	2
/* This option switches string functions, f_gets(), f_putc(), f_puts() and f_printf().
/
/  0: Disable string functions.
/  1: Enable without LF-CRLF conversion.
/  2: Enable with LF-CRLF conversion. */


#define FF_USE_FIND		0
/* This option switches filtered directory read functions, f_findfirst() and
/  f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */


#define FF_USE_MKFS		1
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */


#define FF_USE_FASTSEEK	1
/* This option switches fast seek function. (0:Disable or 1:Enable) */


#define FF_USE_EXPAND	0
/* This option switches f_expand function. (0:Disable or 1:Enable) */


#define FF_USE_CHMOD	1
/* This option switches attribute manipulation functions, f_chmod() and f_utime().
/  (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */


#define FF_USE_LABEL	0
/* This option switches volume label functions, f_getlabel() and f_setlabel().
/  (0:Disable or 1:Enable) */


#define FF_USE_FORWARD	0
/* This option switches f_forward() function. (0:Disable or 1:Enable) */


/*---------------------------------------------------------------------------/
/ Locale and Namespace Configurations
/---------------------------------------------------------------------------*/

#define FF_CODE_PAGE	936
/* This option specifies the OEM code page to be used on the target system.
/  Incorrect code page setting can cause a file open failure.
/
/   437 - U.S.
/   720 - Arabic
/   737 - Greek
/   771 - KBL
/   775 - Baltic
/   850 - Latin 1
/   852 - Latin 2
/   855 - Cyrillic
/   857 - Turkish
/   860 - Portuguese
/   861 - Icelandic
/   862 - Hebrew
/   863 - Canadian French
/   864 - Arabic
/   865 - Nordic
/   866 - Russian
/   869 - Greek 2
/   932 - Japanese (DBCS)
/   936 - Simplified Chinese (DBCS)
/   949 - Korean (DBCS)
/   950 - Traditional Chinese (DBCS)
/     0 - Include all code pages above and configured by f_setcp()
*/


#define FF_USE_LFN		3
#define FF_MAX_LFN		255
/* The FF_USE_LFN switches the support for LFN (long file name).
/
/   0: Disable LFN. FF_MAX_LFN has no effect.
/   1: Enable LFN with static  working buffer on the BSS. Always NOT thread-safe.
/   2: Enable LFN with dynamic working buffer on the STACK.
/   3: Enable LFN with dynamic working buffer on the HEAP.
/
/  To enable the LFN, ffunicode.c needs to be added to the project. The LFN function
/  requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and
/  additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled.
/  The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can
/  be in range of 12 to 255. It is recommended to be set it 255 to fully support LFN
/  specification.
/  When use stack for the working buffer, take care on stack overflow. When use heap
/  memory for the working buffer, memory management functions, ff_memalloc() and
/  ff_memfree() exemplified in ffsystem.c, need to be added to the project. */


#define FF_LFN_UNICODE	2
/* This option switches the character encoding on the API when LFN is enabled.
/
/   0: ANSI/OEM in current CP (TCHAR = char)
/   1: Unicode in UTF-16 (TCHAR = WCHAR)
/   2: Unicode in UTF-8 (TCHAR = char)
/   3: Unicode in UTF-32 (TCHAR = DWORD)
/
/  Also behavior of string I/O functions will be affected by this option.
/  When LFN is not enabled, this option has no effect. */


#define FF_LFN_BUF		128
#define FF_SFN_BUF		12
/* This set of options defines size of file name members in the FILINFO structure
/  which is used to read out directory items. These values should be suffcient for
/  the file names to read. The maximum possible length of the read file name depends
/  on character encoding. When LFN is not enabled, these options have no effect. */


#define FF_STRF_ENCODE	3
/* When FF_LFN_UNICODE >= 1 with LFN enabled, string I/O functions, f_gets(),
/  f_putc(), f_puts and f_printf() convert the character encoding in it.
/  This option selects assumption of character encoding ON THE FILE to be
/  read/written via those functions.
/
/   0: ANSI/OEM in current CP
/   1: Unicode in UTF-16LE
/   2: Unicode in UTF-16BE
/   3: Unicode in UTF-8
*/


#define FF_FS_RPATH		2
/* This option configures support for relative path.
/
/   0: Disable relative path and remove related functions.
/   1: Enable relative path. f_chdir() and f_chdrive() are available.
/   2: f_getcwd() function is available in addition to 1.
*/


/*---------------------------------------------------------------------------/
/ Drive/Volume Configurations
/---------------------------------------------------------------------------*/

#define FF_VOLUMES		10/**< 逻辑驱动号就是挂载的设备号0:,也对应设备驱动号DEV_SPI_FLASH*/
/* Number of volumes (logical drives) to be used. (1-10) */


#define FF_STR_VOLUME_ID	0
#define FF_VOLUME_STRS		"RAM","NAND","CF","SD","SD2","USB","USB2","USB3"
/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
/  When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
/  number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
/  logical drives. Number of items must not be less than FF_VOLUMES. Valid
/  characters for the volume ID strings are A-Z, a-z and 0-9, however, they are
/  compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is
/  not defined, a user defined volume string table needs to be defined as:
/
/  const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",...
*/


#define FF_MULTI_PARTITION	0
/* This option switches support for multiple volumes on the physical drive.
/  By default (0), each logical drive number is bound to the same physical drive
/  number and only an FAT volume found on the physical drive will be mounted.
/  When this function is enabled (1), each logical drive number can be bound to
/  arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
/  funciton will be available. */


#define FF_MIN_SS		512
#define FF_MAX_SS		512
/* This set of options configures the range of sector size to be supported. (512,
/  1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
/  harddisk. But a larger value may be required for on-board flash memory and some
/  type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured
/  for variable sector size mode and disk_ioctl() function needs to implement
/  GET_SECTOR_SIZE command. */


#define FF_LBA64		0
/* This option switches support for 64-bit LBA. (0:Disable or 1:Enable)
/  To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */


#define FF_MIN_GPT		0x10000000
/* Minimum number of sectors to switch GPT as partitioning format in f_mkfs and
/  f_fdisk function. 0x100000000 max. This option has no effect when FF_LBA64 == 0. */


#define FF_USE_TRIM		0
/* This option switches support for ATA-TRIM. (0:Disable or 1:Enable)
/  To enable Trim function, also CTRL_TRIM command should be implemented to the
/  disk_ioctl() function. */



/*---------------------------------------------------------------------------/
/ System Configurations
/---------------------------------------------------------------------------*/

#define FF_FS_TINY		0
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
/  At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
/  Instead of private sector buffer eliminated from the file object, common sector
/  buffer in the filesystem object (FATFS) is used for the file data transfer. */


#define FF_FS_EXFAT		0
/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
/  To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
/  Note that enabling exFAT discards ANSI C (C89) compatibility. */


#define FF_FS_NORTC		0
#define FF_NORTC_MON	1
#define FF_NORTC_MDAY	1
#define FF_NORTC_YEAR	2020
/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
/  any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
/  the timestamp function. Every object modified by FatFs will have a fixed timestamp
/  defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
/  To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
/  added to the project to read current time form real-time clock. FF_NORTC_MON,
/  FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.
/  These options have no effect in read-only configuration (FF_FS_READONLY = 1). */


#define FF_FS_NOFSINFO	0
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
/  option, and f_getfree() function at first time after volume mount will force
/  a full FAT scan. Bit 1 controls the use of last allocated cluster number.
/
/  bit0=0: Use free cluster count in the FSINFO if available.
/  bit0=1: Do not trust free cluster count in the FSINFO.
/  bit1=0: Use last allocated cluster number in the FSINFO if available.
/  bit1=1: Do not trust last allocated cluster number in the FSINFO.
*/


#define FF_FS_LOCK		0
/* The option FF_FS_LOCK switches file lock function to control duplicated file open
/  and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
/  is 1.
/
/  0:  Disable file lock function. To avoid volume corruption, application program
/      should avoid illegal open, remove and rename to the open objects.
/  >0: Enable file lock function. The value defines how many files/sub-directories
/      can be opened simultaneously under file lock control. Note that the file
/      lock control is independent of re-entrancy. */

#include "cmsis_os.h"	// O/S definitions 
#define FF_FS_REENTRANT	1
#define FF_FS_TIMEOUT	1000
#define FF_SYNC_t		osMutexId
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
/  module itself. Note that regardless of this option, file access to different
/  volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
/  and f_fdisk() function, are always not re-entrant. Only file/directory access
/  to the same volume is under control of this function.
/
/   0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect.
/   1: Enable re-entrancy. Also user provided synchronization handlers,
/      ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
/      function, must be added to the project. Samples are available in
/      option/syscall.c.
/
/  The FF_FS_TIMEOUT defines timeout period in unit of time tick.
/  The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
/  SemaphoreHandle_t and etc. A header file for O/S definitions needs to be
/  included somewhere in the scope of ff.h. */


#endif
/*--- End of configuration options ---*/

测试代码

/**
 *  @file fatfs_opt.c
 *
 *  @date 2021-01-05
 *
 *  @author aron566
 *
 *  @copyright None.
 *
 *  @brief 文件系统操作
 *
 *  @details 1、
 *
 *  @version V1.0
 */
#ifdef __cplusplus ///<use C compiler
extern "C" {
#endif
/** Includes -----------------------------------------------------------------*/
/* Private includes ----------------------------------------------------------*/
#include "fatfs_opt.h"
#include "ff.h"
/** Private typedef ----------------------------------------------------------*/

/** Private macros -----------------------------------------------------------*/

/** Private constants --------------------------------------------------------*/
/** Public variables ---------------------------------------------------------*/
/** Private variables --------------------------------------------------------*/
static BYTE work[FF_MAX_SS];/**< 挂载工作内存,不可放入线程,占用内存太大*/
static FATFS fsobject;/**< 磁盘挂载对象,不可放入线程,占用内存太大*/
static FIL fp;/**< 文件对象,不可放入线程,占用内存太大*/
/** Private function prototypes ----------------------------------------------*/

/** Private user code --------------------------------------------------------*/

/** Private application code -------------------------------------------------*/
/*******************************************************************************
*
*       Static code
*
********************************************************************************
*/

/** Public application code --------------------------------------------------*/
/*******************************************************************************
*
*       Public code
*
********************************************************************************
*/
/**
  ******************************************************************
  * @brief   测试fatfs
  * @param   [in]None
  * @return  None
  * @author  aron566
  * @version V1.0
  * @date    2020-01-05
  ******************************************************************
  */
void fs_test(void)
{

//	MKFS_PARM parm;
//  parm.fmt = FM_FAT32;
//  parm.n_fat = 0;/*逻辑驱动器号*/
//  parm.align = 512; /*分配扇区大小*/
//  parm.n_root = 0;
//  parm.au_size = 0;
//	printf("fatfs test start.\n");
//	/* 格式化文件系统 */
//	res = f_mkfs("3:", &parm, work, sizeof(work));//"3:"是卷标,来自于 #define SPI_FLASH		0
//	if (res)
//	{
//		printf("format faild.\n");
//		return ;
//	}
//	else
//	{
//		printf("format ok.\n");
//	}

  /*挂载*/
	FRESULT res;
	res = f_mount(&fsobject,  "3:",  1);  /**< 挂载文件系统, "3:"就是挂载的设备号为3的设备,1立即执行挂载*/

	if(res == FR_NO_FILESYSTEM)  /**< FR_NO_FILESYSTEM值为13,表示没有有效的设备*/
	{
		printf("res = %d\r\n", res);
		res = f_mkfs("3:", 0, work, sizeof(work));
		printf("f_mkfs  is  over\r\n");
		printf("res = %d\r\n", res);
		res = f_mount(NULL, "3:", 1);/**< 取消文件系统*/
		res = f_mount(&fsobject, "3:", 1);/**< 挂载文件系统*/
 	}
	 printf("res = %d\r\n", res);
  
	/*创建文件*/
	res = f_open(&fp, "3:/test.txt", FA_CREATE_NEW|FA_WRITE|FA_READ);
	if(res)
	{
		printf("open file faild.\r\n");
    if(res == FR_EXIST)
    {
      printf("the file is existed.\r\n");
      f_open(&fp, "3:/test.txt", FA_WRITE|FA_READ);
    }
	}
	else
	{
		printf("open file ok.\r\n");
	}
	/* write a message */
  UINT write_size;
	res = f_write(&fp, "Hello,World!", 12, &write_size);
	//printf("res write:%d\r\n",res);
	if (write_size == 12)
	{
		printf("write ok!\r\n");
	}
	else
	{
		printf("write faild!\r\n");
	}
  FSIZE_t fsize;
	fsize = f_size(&fp);
	printf("file size:%d Bytes.\r\n",fsize);
  BYTE buf[50];
	memset(buf, 0, 50);
	f_lseek(&fp, 0);
  UINT read_size;
	res = f_read(&fp, buf, 12, &read_size);
	if (res == FR_OK)
	{
		printf("read file ok!\r\n");
		printf("read size:%d Bytes.\r\n",read_size);
	}
	else
	{
		printf("read file faild!\r\n");
	}
	printf("read data:\r\n");
  for(int index = 0;index < 12;index++)
  {
    printf("0x%02X ",buf[index]);
  }
	printf("\n%s\n", buf);
  
	/*关闭文件*/
	f_close(&fp);
}

#include "sfud.h"
/**
 * SFUD demo for the first flash device test.
 *
 * @param addr flash start address
 * @param size test flash size
 * @param size test flash data buffer
 */
void sfud_demo(uint32_t addr, size_t size, uint8_t *data)
{
    sfud_err result = SFUD_SUCCESS;
    extern sfud_flash *sfud_dev;
    const sfud_flash *flash = sfud_get_device(SFUD_W25Q16BV_DEVICE_INDEX);
    size_t i;
    /* prepare write data */
    for (i = 0; i < size; i++)
    {
        data[i] = i;
    }
    /* erase test */
    result = sfud_erase(flash, addr, size);
    if (result == SFUD_SUCCESS)
    {
        printf("Erase the %s flash data finish. Start from 0x%08X, size is %zu.\r\n", flash->name, addr, size);
    }
    else
    {
        printf("Erase the %s flash data failed.\r\n", flash->name);
        return;
    }
    /* write test */
    result = sfud_write(flash, addr, size, data);
    if (result == SFUD_SUCCESS)
    {
        printf("Write the %s flash data finish. Start from 0x%08X, size is %zu.\r\n", flash->name, addr, size);
    }
    else
    {
        printf("Write the %s flash data failed.\r\n", flash->name);
        return;
    }
    /* read test */
    result = sfud_read(flash, addr, size, data);
    if (result == SFUD_SUCCESS)
    {
        printf("Read the %s flash data success. Start from 0x%08X, size is %zu. The data is:\r\n", flash->name, addr, size);
        printf("Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\r\n");
        for (i = 0; i < size; i++)
        {
            if (i % 16 == 0)
            {
                printf("[%08X] ", addr + i);
            }
            printf("%02X ", data[i]);
            if (((i + 1) % 16 == 0) || i == size - 1)
            {
                printf("\r\n");
            }
        }
        printf("\r\n");
    }
    else
    {
        printf("Read the %s flash data failed.\r\n", flash->name);
    }
    /* data check */
    for (i = 0; i < size; i++)
    {
        if (data[i] != i % 256)
        {
            printf("Read and check write data has an error. Write the %s flash data failed.\r\n", flash->name);
            break;
        }
    }
    if (i == size)
    {
        printf("The %s flash test is success.\r\n", flash->name);
    }
}

#ifdef __cplusplus ///<end extern c
}
#endif
/******************************** End of file *********************************/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ARM单片机FATFS文件系统的移植 的相关文章

  • 在没有 IDE 的情况下如何使用 CMSIS?

    我正在使用 STM32F103C8T6 并想使用 CMSIS 这本质上只是寄存器定义 没有代码 让我的生活更轻松 同时仍保持在较低水平 问题是我不知道如何安装该库以便在命令行上使用 Makefile 使用 所有文档似乎都与特定于供应商的 I
  • GCC - 如何停止链接 malloc?

    我正在努力将我的代码缩减到最小的骨架大小 我使用的是只有 32k 闪存的 STM32F0 需要很大一部分闪存用于数据存储 我的代码已经有大约 20k 闪存大小 其中一些是由于使用了 STM32 HAL 函数 我可以在以后需要时对其进行解释和
  • HAL库STM32常用外设教程(二)—— GPIO输入\输出

    HAL库STM32常用外设教程 二 GPIO输入 输出 文章目录 HAL库STM32常用外设教程 二 GPIO输入 输出 前言 一 GPIO功能概述 二 GPIO的HAl库驱动 三 GPIO使用示例 1 示例功能 四 代码讲解 五 总结
  • rt-thread studio中新建5.02版本报错

    先吐槽一下 rt thread studio出现BUG真多 好多时间都是在找BUG 但里面用好多控件还是挺好用的 真是又爱又恨 所以一般使用功能不多的话还是用keil多一点 创建5 02版本工程之后直接进行编译 直接会报下面这个错误 资源
  • STM32F4 通过软复位跳转到引导加载程序,无需 BOOT0 和 BOOT1 引脚

    我问这个问题是因为可以在这里找到类似问题的答案 通过应用程序跳转到 STM32 中的引导加载程序 即从用户闪存在引导模式下使用引导 0 和引导 1 引脚 用户 JF002 JF002回答 当我想跳转到引导加载程序时 我在其中一个备份寄存器中
  • 匹配 STM32F0 和 zlib 中的 CRC32

    我正在研究运行 Linux 的计算机和 STM32F0 之间的通信链路 我想对我的数据包使用某种错误检测 并且由于 STM32F0 有 CRC32 硬件 并且我在 Linux 上有带有 CRC32 的 zlib 所以我认为在我的项目中使用
  • 物联网网关

    物联网网关是 连接物联网设备和互联网的重要桥梁 它负责将物联网设备采集到的数据进行处理 存储和转发 使其能够与云端或其它设备进行通信 物联网网关的作用是实现物联网设备与云端的无缝连接和数据交互 物联网网关功能 数据采集 物联网网关可以从物联
  • 毕业设计 江科大STM32的智能温室控制蓝牙声光报警APP系统设计

    基于STM32的智能温室控制蓝牙声光报警APP系统设计 1 项目简介 1 1 系统构成 1 2 系统功能 2 部分电路设计 2 1 stm32f103c8t6单片机最小系统电路设计 2 2 LCD1602液晶显示电路设计 2 2 风
  • 1.69寸SPI接口240*280TFT液晶显示模块使用中碰到的问题

    1 69寸SPI接口240 280TFT液晶显示模块使用中碰到的问题说明并记录一下 在网上买了1 69寸液晶显示模块 使用spi接口 分辨率240 280 给的参考程序是GPIO模拟的SPI接口 打算先移植到FreeRtos测试 再慢慢使用
  • 串口通讯第一次发送数据多了一字节

    先初始化IO再初始化串口 导致第一次发送时 多出一个字节数据 优化方案 先初始化串口再初始化IO 即可正常通讯
  • 毕设开题分享 单片机智能教室系统(智能照明+人数统计)

    1 简介 Hi 大家好 今天向大家介绍一个学长做的单片机项目 单片机智能教室系统 智能照明 人数统计 大家可用于 课程设计 或 毕业设计 项目分享 https gitee com feifei1122 simulation project
  • 库函数点亮Led

    提示 文章写完后 目录可以自动生成 如何生成可参考右边的帮助文档 文章目录 前言 一 pandas是什么 二 使用步骤 1 引入库 2 读入数据 总结 前言 提示 这里可以添加本文要记录的大概内容 例如 随着人工智能的不断发展 机器学习这门
  • 核心耦合内存在 STM32F4xx 上可执行吗?

    尝试从 STM32F429s CCM 运行代码 但每当我命中 CCM 中的第一条指令时 我总是会遇到硬故障 并且 IBUSERR 标志被设置 该指令有效且一致 STM32F4xx 是否可能不允许从 CCM 执行 数据访问效果良好 alios
  • 是否有 FAT FS 驱动程序希望引导扇区的字节 508 和 509 为零?

    在实施的同时我自己的引导扇区加载程序从 2012 年开始 https hg ulukai org ecm ldosboot rev 17884e6352e6 l1 255我确保将偏移量 508 和 509 处的字节清零 这些是标准 512
  • 嵌入式 C++11 代码 — 我需要 volatile 吗?

    采用 Cortex M3 MCU STM32F1 的嵌入式设备 它具有嵌入式闪存 64K MCU固件可以在运行时重新编程闪存扇区 这是由闪存控制器 FMC 寄存器完成的 所以它不像a b那么简单 FMC 获取缓冲区指针并将数据刻录到某个闪存
  • STM32内部时钟

    我对 STM32F7 设备 意法半导体的 Cortex M7 微控制器 上的时钟系统感到困惑 参考手册没有充分阐明这些时钟之间的差异 SYSCLK HCLK FCLK 参考手册中阅读章节 gt RCC 为 Cortex 系统定时器 SysT
  • PWM DMA 到整个 GPIO

    我有一个 STM32F4 我想对一个已与掩码进行 或 运算的 GPIO 端口进行 PWM 处理 所以 也许我们想要 PWM0b00100010一段时间为 200khz 但随后 10khz 后 我们现在想要 PWM0b00010001 然后
  • 在 Contiki 程序中使用 malloc

    考虑以下 Contiki 程序 include
  • HAL_Delay() 陷入无限循环

    我被 HAL Delay 函数困住了 当我调用此函数 HAL Delay 时 控制陷入无限循环 在寻找问题的过程中 我发现了这个 http www openstm32 org forumthread2145 threadId2146 htt
  • 移动数组中的元素

    我需要一点帮助 我想将数组中的元素向上移动一个元素 以便新位置 1 包含位置 1 中的旧值 new 2 包含 old 1 依此类推 旧的最后一个值被丢弃 第一个位置的新值是我每秒给出的新值 我使用大小为 10 的数组 uint32 t TE

随机推荐

  • 学习Javascript闭包(Closure)[非常棒的文章]

    作者 阮一峰 日期 2009年8月30日 闭包 closure 是Javascript语言的一个难点 也是它的特色 很多高级应用都要依靠闭包实现 下面就是我的学习笔记 对于Javascript初学者应该是很有用的 一 变量的作用域 要理解闭
  • 关于论青少年尽早学少儿编程之说

    关于论青少年尽早学少儿编程之说 正如一本书中所描述的一句话 尽早学习编程 是孩子为未来做好准备必不可少的一步 看完这句话之后 给我们的直观印象可能就是 不教孩子学习编程在某种程度上等于不教他们读书写字 这种说法明显是片面的 编程 读书写字
  • 若依系统注册功能

    加油 三步实现注册 前端 后端 分配角色 总结 前端 login vue中打开注册开关 后端 打开数据库sys config表 开启注册功能 分配角色 在SysUserMapper中添加方法 实现方法 在SysUserServiceImpl
  • dialog中二维码显示问题

    由于dialog加载过程会耗费一定时间 因此在dialog中直接调用会导致在一次打开的dialog无法加载二维码 在dialog标签中加入 opened ShowQRCode 属性 opened是dialog动画打开完毕之后的回调 当页面加
  • 计算机网络层提供的面向连接服务还是无连接服务讨论与思考

    概要 在计算机网络领域 网络层应该向运输层提供怎样的服务 面向连接 还是 无连接 曾引起了长期的争论 争论焦点的实质就是 在计算机通信中 可靠交付应当由谁来负责 是网络还是端系统 介绍 有些人认为应当借助于电信网的成功经验 让网络负责可靠交
  • 计算机主机名与用户名区别

    一 主机名概念 主机名就是计算机的名字 计算机名 网上邻居就是根据主机名来识别的 这个名字可以随时更改 从我的电脑属性的计算机名就可更改 用户登陆时候用的是操作系统的个人用户帐号 这个也可以更改 从控制面板的用户界面里改就可以了 这个用户名
  • 1. Inna and Pink Pony

    1 Inna and Pink Pony 首先找出四个边界点 但要注意当横纵坐标等于边界横纵坐标时 需考虑是否会出界 满足以上条件时 考虑横纵坐标移动次数其和为偶数时便可以完成移动 因为正负抵消原则 话不多说 直接上Python代码 n m
  • 解决 CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate’问题

    针对使用conda进入虚拟环境时遇到的问题 CommandNotFoundError Your shell has not been properly configured to use conda activate 解决方法 win r
  • 解决Android中使用RecyclerView滑动时底部item显示不全的问题

    感觉这个bug是不是因人而异啊 找了很多文章都没能解决我的问题 包括在RecyclerView上在嵌套上一层RelativeLayout 添加属性android descendantFocusability blocksDescendant
  • 解决“L6200E Symbol xx defined (by xx.o and xx.o)”重复定义问题

    今天来分享一个关于自己之前遇到的一个问题 就是关于重复定义会造成的一个错误 错误提示为 OBJ LCD axf Error L6200E Symbol ascii 1206 multiply defined by lcd user o an
  • C语言每日一题:7.寻找数组中心下标。

    思路一 暴力求解 1 定义一个ps作为中间下标去记录下标值 2 循环下标ps从头到位 定义四个变量分别是left sum left right sum right 3 初始化left ps 1和right ps 1 当ps0 gt 就让su
  • etcd学习和实战:4、Java使用etcd实现服务发现和管理

    etcd学习和实战 4 Java使用etcd实现服务发现和管理 文章目录 etcd学习和实战 4 Java使用etcd实现服务发现和管理 1 前言 2 代码 2 1 服务注册 2 2 服务发现 2 3 运行结果 2 4 问题 3 最后 1
  • 关于SVM的一点笔记

    关于SVM的一点笔记 一 简单了解 1 感知机 perceptron 感知机是一种类似于生物中神经细胞功能的人工神经元 它可以把一个或者多个输入 x 1 x 1 x1 x
  • flask最基础的增删改查实现步骤及代码

    分类序列化器 写入要序列化的字段 user info id fields Integer name fields String 商品序列化器 写入要序列化的字段 goods info id fields Integer name field
  • Spring系列面试题(Spring、SpringMvc、SpringBoot)

    一 springboot自动配置原理 自动装配 简单来说就是自动把第三方组件的Bean装载到Spring IOC器里面 不需要开发人员再去写Bean的配置 在Spring Boot应用里面 只需要在启动类加上 SpringBootAppli
  • 五张图带你理解 RocketMQ 顺序消息实现机制

    大家好 我是君哥 今天聊一聊 RocketMQ 的顺序消息实现机制 在有些场景下 使用 MQ 需要保证消息的顺序性 比如在电商系统中 用户提交订单 支付订单 订单出库这 3 个消息应该保证顺序性 如下图 对于 RocketMQ 来说 主要是
  • Electron桌面开发入门

    1 初始化工作 midir electron demo cd electron demo npm init 到package json 文件下将入口文件修改为main js main main js 并且创建main js文件 electr
  • Java猫和狗(继承,多态,抽象,接口版)上

    Java的继承 抽象 多态 接口的简单应用 我们利用 猫和狗都是动物类 然后猫会抓鱼 狗会看门的这些方法来简单应用一下继承 抽象 多态 接口 简单思路就是 1 定义动物类 2 定义猫 狗类 让他们成为动物的子类 3 编写测试类 继承 使子类
  • PTA L1-016:查验身份证 (python)

    一 题目要求 二 参考代码 sheet 0 1 1 0 2 X 3 9 4 8 5 7 6 6 7 5 8 4 9 3 10 2 w 7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 n int input c 0 f
  • ARM单片机FATFS文件系统的移植

    ARM单片机FATFS文件系统的移植 测试效果 前提条件 下载所需源码 FATFS 文件系统 SFUD万能驱动 加入工程 接口驱动 测试代码 FreeRTOS10 0 1 FATFS FF14A SFUD V1 1 0 STM32F103Z