[update] add fal component. (#5662)

* [update] add fal component.

* [update] format code.

* [update] change PKG_USING_FAL to RT_USING_FAL

* [update] format code.

* [update] fal

* [update] delete FAL_SW_VERSION
This commit is contained in:
LiuKang
2022-03-15 09:48:05 +08:00
committed by GitHub
parent 3b1445d49c
commit 75a7cb6929
67 changed files with 2775 additions and 93 deletions

View File

@@ -14,7 +14,7 @@
#ifdef BSP_USING_ON_CHIP_FLASH
#include "drv_flash.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -171,7 +171,7 @@ __exit:
return size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size);

View File

@@ -13,7 +13,7 @@
#ifdef BSP_USING_ON_CHIP_FLASH
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -21,7 +21,7 @@
#define LOG_TAG "drv.flash"
#include <drv_log.h>
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#define AB32_FLASH_START_ADDRESS 0x00000000
#define AB32_FLASH_SIZE (1024 * 1024)

View File

@@ -63,7 +63,7 @@ menu "On-chip Peripheral Drivers"
endif
endif
config BSP_USING_ON_CHIP_FLASH
select PKG_USING_FAL
select RT_USING_FAL
bool "Enable on-chip FLASH"
default n
config BSP_USING_I2C

View File

@@ -25,7 +25,7 @@ menu "Hardware Drivers Config"
config OCFLASH_USE_FAL
bool "Enable On Chip Flash FAL Driver"
depends on BSP_USING_OCFLASH
select PKG_USING_FAL
select RT_USING_FAL
default n
config OCFLASH_USE_LFS
bool "Enable On Chip Flash DFS Driver"

View File

@@ -15,7 +15,7 @@
#ifdef BSP_USING_ON_CHIP_FLASH
#include "drv_flash.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -172,7 +172,7 @@ __exit:
return size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size);

View File

@@ -14,7 +14,7 @@
#ifdef BSP_USING_ON_CHIP_FLASH
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -155,7 +155,7 @@ int mcu_flash_erase(rt_uint32_t addr, size_t size)
return size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size);

View File

@@ -11,7 +11,7 @@
#include <stdint.h>
#include "board.h"
#include "nrfx_qspi.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include <fal.h>
//log

View File

@@ -14,7 +14,7 @@
#ifdef BSP_USING_ON_CHIP_FS
#ifndef PKG_USING_FAL
#ifndef RT_USING_FAL
#error "if you want to use on chip filesystem, you need to enable FAL package()"
#endif

View File

@@ -338,7 +338,7 @@ menu "On-chip Peripheral Drivers"
endif
config BSP_USING_ON_CHIP_FLASH
select PKG_USING_FAL
select RT_USING_FAL
bool "Enable on-chip FLASH"
default n

View File

@@ -37,7 +37,7 @@ menu "Onboard Peripheral Drivers"
menuconfig BSP_USING_QSPI_FLASH
select PKG_USING_FAL
select RT_USING_FAL
bool "Enable QSPI FLASH(MX25R64 8MB)"
default n
depends on BSP_BOARD_PCA_10056
@@ -378,7 +378,7 @@ menu "On-chip Peripheral Drivers"
config BSP_USING_ON_CHIP_FLASH
select PKG_USING_FAL
select RT_USING_FAL
bool "Enable on-chip FLASH"
default n

View File

@@ -28,7 +28,7 @@ config SOC_SERIES_M032
config BSP_USING_FMC
bool "Enable Flash Memory Controller(FMC)"
select PKG_USING_FAL
select RT_USING_FAL
default n
config BSP_USING_GPIO

View File

@@ -16,7 +16,7 @@
#include <rtdevice.h>
#include "NuMicro.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include <fal.h>
#endif
@@ -31,7 +31,7 @@
/* Private functions ------------------------------------------------------------*/
static int nu_fmc_init(void);
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int aprom_read(long offset, uint8_t *buf, size_t size);
static int aprom_write(long offset, const uint8_t *buf, size_t size);
static int aprom_erase(long offset, size_t size);
@@ -39,7 +39,7 @@ static int nu_fmc_init(void);
static int ldrom_read(long offset, uint8_t *buf, size_t size);
static int ldrom_write(long offset, const uint8_t *buf, size_t size);
static int ldrom_erase(long offset, size_t size);
#endif /* PKG_USING_FAL */
#endif /* RT_USING_FAL */
/* Public functions -------------------------------------------------------------*/
int nu_fmc_read(long offset, uint8_t *buf, size_t size);
@@ -50,10 +50,10 @@ int nu_fmc_erase(long offset, size_t size);
static rt_mutex_t g_mutex_fmc = RT_NULL;
/* Public variables -------------------------------------------------------------*/
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
const struct fal_flash_dev Onchip_aprom_flash = { "OnChip_APROM", FMC_APROM_BASE, FMC_APROM_END, FMC_FLASH_PAGE_SIZE, {NULL, aprom_read, aprom_write, aprom_erase} };
const struct fal_flash_dev Onchip_ldrom_flash = { "OnChip_LDROM", FMC_LDROM_BASE, FMC_LDROM_END, FMC_FLASH_PAGE_SIZE, {NULL, ldrom_read, ldrom_write, ldrom_erase} };
#endif /* PKG_USING_FAL */
#endif /* RT_USING_FAL */
int nu_fmc_read(long addr, uint8_t *buf, size_t size)
{
@@ -277,7 +277,7 @@ Exit3:
return erased_size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int aprom_read(long offset, uint8_t *buf, size_t size)
{
@@ -309,7 +309,7 @@ static int ldrom_erase(long offset, size_t size)
return nu_fmc_erase(Onchip_ldrom_flash.addr + offset, size);
}
#endif /* PKG_USING_FAL */
#endif /* RT_USING_FAL */
static int nu_fmc_init(void)
{
@@ -319,8 +319,8 @@ static int nu_fmc_init(void)
g_mutex_fmc = rt_mutex_create("nu_fmc_lock", RT_IPC_FLAG_PRIO);
/* PKG_USING_FAL */
#if defined(PKG_USING_FAL)
/* RT_USING_FAL */
#if defined(RT_USING_FAL)
fal_init();
#endif

View File

@@ -28,7 +28,7 @@ config SOC_SERIES_M2354
config BSP_USING_FMC
bool "Enable Flash Memory Controller(FMC)"
select PKG_USING_FAL
select RT_USING_FAL
default n
config BSP_USING_GPIO

View File

@@ -16,7 +16,7 @@
#include <rtdevice.h>
#include "NuMicro.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include <fal.h>
#endif
@@ -28,7 +28,7 @@
/* Private functions ------------------------------------------------------------*/
static int nu_fmc_init(void);
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int aprom_read(long offset, uint8_t *buf, size_t size);
static int aprom_write(long offset, const uint8_t *buf, size_t size);
static int aprom_erase(long offset, size_t size);
@@ -36,7 +36,7 @@ static int nu_fmc_init(void);
static int ldrom_read(long offset, uint8_t *buf, size_t size);
static int ldrom_write(long offset, const uint8_t *buf, size_t size);
static int ldrom_erase(long offset, size_t size);
#endif /* PKG_USING_FAL */
#endif /* RT_USING_FAL */
/* Public functions -------------------------------------------------------------*/
int nu_fmc_read(long offset, uint8_t *buf, size_t size);
@@ -47,10 +47,10 @@ int nu_fmc_erase(long offset, size_t size);
static rt_mutex_t g_mutex_fmc = RT_NULL;
/* Public variables -------------------------------------------------------------*/
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
const struct fal_flash_dev Onchip_aprom_flash = { "OnChip_APROM", FMC_APROM_BASE, FMC_APROM_END, FMC_FLASH_PAGE_SIZE, {NULL, aprom_read, aprom_write, aprom_erase} };
const struct fal_flash_dev Onchip_ldrom_flash = { "OnChip_LDROM", FMC_LDROM_BASE, FMC_LDROM_END, FMC_FLASH_PAGE_SIZE, {NULL, ldrom_read, ldrom_write, ldrom_erase} };
#endif /* PKG_USING_FAL */
#endif /* RT_USING_FAL */
int nu_fmc_read(long addr, uint8_t *buf, size_t size)
{
@@ -274,7 +274,7 @@ Exit3:
return erased_size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int aprom_read(long offset, uint8_t *buf, size_t size)
{
@@ -306,7 +306,7 @@ static int ldrom_erase(long offset, size_t size)
return nu_fmc_erase(Onchip_ldrom_flash.addr + offset, size);
}
#endif /* PKG_USING_FAL */
#endif /* RT_USING_FAL */
static int nu_fmc_init(void)
{
@@ -316,8 +316,8 @@ static int nu_fmc_init(void)
g_mutex_fmc = rt_mutex_create("nu_fmc_lock", RT_IPC_FLAG_PRIO);
/* PKG_USING_FAL */
#if defined(PKG_USING_FAL)
/* RT_USING_FAL */
#if defined(RT_USING_FAL)
fal_init();
#endif

View File

@@ -28,7 +28,7 @@ config SOC_SERIES_M480
config BSP_USING_FMC
bool "Enable Flash Memory Controller(FMC)"
select PKG_USING_FAL
select RT_USING_FAL
default n
config BSP_USING_GPIO

View File

@@ -16,7 +16,7 @@
#include <rtdevice.h>
#include "NuMicro.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include <fal.h>
#endif
@@ -28,7 +28,7 @@
/* Private functions ------------------------------------------------------------*/
static int nu_fmc_init(void);
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int aprom_read(long offset, uint8_t *buf, size_t size);
static int aprom_write(long offset, const uint8_t *buf, size_t size);
static int aprom_erase(long offset, size_t size);
@@ -36,7 +36,7 @@ static int nu_fmc_init(void);
static int ldrom_read(long offset, uint8_t *buf, size_t size);
static int ldrom_write(long offset, const uint8_t *buf, size_t size);
static int ldrom_erase(long offset, size_t size);
#endif /* PKG_USING_FAL */
#endif /* RT_USING_FAL */
/* Public functions -------------------------------------------------------------*/
int nu_fmc_read(long offset, uint8_t *buf, size_t size);
@@ -47,10 +47,10 @@ int nu_fmc_erase(long offset, size_t size);
static rt_mutex_t g_mutex_fmc = RT_NULL;
/* Public variables -------------------------------------------------------------*/
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
const struct fal_flash_dev Onchip_aprom_flash = { "OnChip_APROM", FMC_APROM_BASE, FMC_APROM_END, FMC_FLASH_PAGE_SIZE, {NULL, aprom_read, aprom_write, aprom_erase} };
const struct fal_flash_dev Onchip_ldrom_flash = { "OnChip_LDROM", FMC_LDROM_BASE, FMC_LDROM_END, FMC_FLASH_PAGE_SIZE, {NULL, ldrom_read, ldrom_write, ldrom_erase} };
#endif /* PKG_USING_FAL */
#endif /* RT_USING_FAL */
int nu_fmc_read(long addr, uint8_t *buf, size_t size)
{
@@ -291,7 +291,7 @@ Exit3:
return erased_size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int aprom_read(long offset, uint8_t *buf, size_t size)
{
@@ -323,7 +323,7 @@ static int ldrom_erase(long offset, size_t size)
return nu_fmc_erase(Onchip_ldrom_flash.addr + offset, size);
}
#endif /* PKG_USING_FAL */
#endif /* RT_USING_FAL */
static int nu_fmc_init(void)
{
@@ -334,8 +334,8 @@ static int nu_fmc_init(void)
g_mutex_fmc = rt_mutex_create("nu_fmc_lock", RT_IPC_FLAG_PRIO);
RT_ASSERT(g_mutex_fmc != RT_NULL);
/* PKG_USING_FAL */
#if defined(PKG_USING_FAL)
/* RT_USING_FAL */
#if defined(RT_USING_FAL)
fal_init();
#endif

View File

@@ -28,7 +28,7 @@
#include <sys/stat.h>
#include <sys/statfs.h>
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include <fal.h>
#endif
@@ -214,7 +214,7 @@ INIT_ENV_EXPORT(filesystem_init);
#if defined(BOARD_USING_STORAGE_SPIFLASH)
int mnt_init_spiflash0(void)
{
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
extern int fal_init_check(void);
if (!fal_init_check())
fal_init();

View File

@@ -28,7 +28,7 @@
#include <sys/stat.h>
#include <sys/statfs.h>
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include <fal.h>
#endif
@@ -212,7 +212,7 @@ INIT_ENV_EXPORT(filesystem_init);
#if defined(BOARD_USING_STORAGE_SPIFLASH)
int mnt_init_spiflash0(void)
{
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
extern int fal_init_check(void);
if (!fal_init_check())
fal_init();

View File

@@ -315,13 +315,13 @@
/* Micrium: Micrium software products porting for RT-Thread */
#define PKG_USING_FAL
#define RT_USING_FAL
#define FAL_DEBUG_CONFIG
#define FAL_DEBUG 1
#define FAL_PART_HAS_TABLE_CFG
#define FAL_USING_SFUD_PORT
#define FAL_USING_NOR_FLASH_DEV_NAME "norflash0"
#define PKG_USING_FAL_LATEST_VERSION
#define RT_USING_FAL_LATEST_VERSION
#define PKG_FAL_VER_NUM 0x99999
#define PKG_USING_RAMDISK
#define PKG_USING_RAMDISK_LATEST_VERSION

View File

@@ -28,7 +28,7 @@
#include <sys/stat.h>
#include <sys/statfs.h>
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include <fal.h>
#endif
@@ -211,7 +211,7 @@ INIT_ENV_EXPORT(filesystem_init);
#if defined(BOARD_USING_STORAGE_SPIFLASH)
int mnt_init_spiflash0(void)
{
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
extern int fal_init_check(void);
if (!fal_init_check())
fal_init();

View File

@@ -334,13 +334,13 @@
/* Micrium: Micrium software products porting for RT-Thread */
#define PKG_USING_FAL
#define RT_USING_FAL
#define FAL_DEBUG_CONFIG
#define FAL_DEBUG 1
#define FAL_PART_HAS_TABLE_CFG
#define FAL_USING_SFUD_PORT
#define FAL_USING_NOR_FLASH_DEV_NAME "norflash0"
#define PKG_USING_FAL_LATEST_VERSION
#define RT_USING_FAL_LATEST_VERSION
#define PKG_FAL_VER_NUM 0x99999
#define PKG_USING_RAMDISK
#define PKG_USING_RAMDISK_LATEST_VERSION

View File

@@ -19,7 +19,7 @@
#include <sys/stat.h>
#include <sys/statfs.h>
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include <fal.h>
#endif

View File

@@ -19,7 +19,7 @@
#include <sys/stat.h>
#include <sys/statfs.h>
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include <fal.h>
#endif

View File

@@ -296,11 +296,11 @@
/* Micrium: Micrium software products porting for RT-Thread */
#define PKG_USING_FAL
#define RT_USING_FAL
#define FAL_DEBUG_CONFIG
#define FAL_DEBUG 1
#define FAL_PART_HAS_TABLE_CFG
#define PKG_USING_FAL_LATEST_VERSION
#define RT_USING_FAL_LATEST_VERSION
#define PKG_FAL_VER_NUM 0x99999
/* peripheral libraries and drivers */

View File

@@ -19,7 +19,7 @@
#include <sys/stat.h>
#include <sys/statfs.h>
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include <fal.h>
#endif

View File

@@ -323,11 +323,11 @@
/* Micrium: Micrium software products porting for RT-Thread */
#define PKG_USING_FAL
#define RT_USING_FAL
#define FAL_DEBUG_CONFIG
#define FAL_DEBUG 1
#define FAL_PART_HAS_TABLE_CFG
#define PKG_USING_FAL_LATEST_VERSION
#define RT_USING_FAL_LATEST_VERSION
#define PKG_FAL_VER_NUM 0x99999
/* peripheral libraries and drivers */

View File

@@ -18,7 +18,7 @@
#include <rtthread.h>
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -190,7 +190,7 @@ int _flash_erase_32k(rt_uint32_t addr, size_t size)
return size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read_8k(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_read_32k(long offset, rt_uint8_t *buf, size_t size);

View File

@@ -14,7 +14,7 @@
#include "drv_config.h"
#include "drv_flash.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -170,7 +170,7 @@ __exit:
return size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size);

View File

@@ -16,7 +16,7 @@
#include "drv_config.h"
#include "drv_flash.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -246,7 +246,7 @@ __exit:
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size);

View File

@@ -14,7 +14,7 @@
#include "drv_config.h"
#include "drv_flash.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -251,7 +251,7 @@ __exit:
return result;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read_16k(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_read_64k(long offset, rt_uint8_t *buf, size_t size);

View File

@@ -14,7 +14,7 @@
#include "drv_config.h"
#include "drv_flash.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -359,7 +359,7 @@ __exit:
return size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read_16k(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_read_64k(long offset, rt_uint8_t *buf, size_t size);

View File

@@ -17,7 +17,7 @@
#include "drv_config.h"
#include "drv_flash.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -307,7 +307,7 @@ __exit:
return size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#define FLASH_SIZE_GRANULARITY_32K (4 * 32 * 1024)
#define FLASH_SIZE_GRANULARITY_128K (128 * 1024)
#define FLASH_SIZE_GRANULARITY_256K (7 * 256 *1024)

View File

@@ -14,7 +14,7 @@
#include "drv_config.h"
#include "drv_flash.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -203,7 +203,7 @@ __exit:
return size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size);

View File

@@ -18,7 +18,7 @@
#include "drv_config.h"
#include "drv_flash.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -227,7 +227,7 @@ __exit:
return size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read_128k(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_write_128k(long offset, const rt_uint8_t *buf, size_t size);
static int fal_flash_erase_128k(long offset, size_t size);

View File

@@ -14,7 +14,7 @@
#include "drv_config.h"
#include "drv_flash.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -264,7 +264,7 @@ __exit:
return size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size);

View File

@@ -14,7 +14,7 @@
#include "drv_config.h"
#include "drv_flash.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -204,7 +204,7 @@ __exit:
return size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size);

View File

@@ -129,7 +129,7 @@ menu "Onboard Peripheral Drivers"
select RT_USING_MTD_NOR
select BSP_USING_SPI_FLASH
select BSP_USING_FS
select PKG_USING_FAL
select RT_USING_FAL
select FAL_USING_AUTO_INIT
select FAL_PART_HAS_TABLE_CFG
select PKG_USING_LITTLEFS

View File

@@ -15,7 +15,7 @@ CubeMX_Config/Src/stm32f4xx_hal_msp.c
if GetDepend(['BSP_USING_QSPI_FLASH']):
src += ['ports/drv_qspi_flash.c']
if GetDepend(['PKG_USING_FAL']):
if GetDepend(['RT_USING_FAL']):
src += ['ports/qspi_mnt.c']
if GetDepend(['BSP_USING_TOUCH']):

View File

@@ -38,7 +38,7 @@ menu "Onboard Peripheral Drivers"
select BSP_USING_QSPI
select RT_USING_SFUD
select RT_SFUD_USING_QSPI
select PKG_USING_FAL
select RT_USING_FAL
select FAL_USING_SFUD_PORT
default n

View File

@@ -15,7 +15,7 @@ CubeMX_Config/Src/stm32f4xx_hal_msp.c
if GetDepend(['BSP_USING_QSPI_FLASH']):
src += ['ports/drv_qspi_flash.c']
if GetDepend(['PKG_USING_FAL']):
if GetDepend(['RT_USING_FAL']):
src += ['ports/qspi_mnt.c']
if GetDepend(['BSP_USING_LCD_OTM8009A']):

View File

@@ -8,7 +8,7 @@
* 2019-04-11 ZYH first version
*/
#include <rtthread.h>
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include <fal.h>
#include <dfs_fs.h>

View File

@@ -91,7 +91,7 @@ menu "Onboard Peripheral Drivers"
bool "Enable SPI FLASH (spi1)"
select BSP_USING_SPI
select BSP_USING_SPI1
select PKG_USING_FAL
select RT_USING_FAL
select FAL_USING_SFUD_PORT
select RT_USING_SFUD
default n

View File

@@ -156,7 +156,7 @@ menu "Onboard Peripheral Drivers"
select RT_USING_LWIP
select RT_USING_DFS
select DFS_USING_POSIX
select PKG_USING_FAL
select RT_USING_FAL
select PKG_USING_EASYFLASH
select RT_USING_WIFI_6181_LIB
select RT_USING_OTA_LIB

View File

@@ -17,6 +17,6 @@ elif rtconfig.PLATFORM == 'armcc':
elif rtconfig.PLATFORM == 'armclang':
LOCAL_CFLAGS += ' -std=c99'
group = DefineGroup('FAL', src, depend = ['PKG_USING_FAL'], CPPPATH = CPPPATH, LOCAL_CFLAGS = LOCAL_CFLAGS)
group = DefineGroup('FAL', src, depend = ['RT_USING_FAL'], CPPPATH = CPPPATH, LOCAL_CFLAGS = LOCAL_CFLAGS)
Return('group')

View File

@@ -15,7 +15,7 @@
#include "drv_flash.h"
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
#include "fal.h"
#endif
@@ -172,7 +172,7 @@ __exit:
return size;
}
#if defined(PKG_USING_FAL)
#if defined(RT_USING_FAL)
static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size);
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size);
@@ -208,6 +208,6 @@ static int fal_flash_erase(long offset, size_t size)
return ch32_flash_erase(ch32_onchip_flash.addr + offset, size);
}
#endif /* PKG_USING_FAL */
#endif /* RT_USING_FAL */
#endif /* BSP_USING_ON_CHIP_FLASH */

View File

@@ -25,6 +25,8 @@ config RT_USING_LEGACY
source "$RTT_DIR/components/cplusplus/Kconfig"
source "$RTT_DIR/components/fal/Kconfig"
source "$RTT_DIR/components/finsh/Kconfig"
source "$RTT_DIR/components/dfs/Kconfig"

55
components/fal/Kconfig Normal file
View File

@@ -0,0 +1,55 @@
# Kconfig file for package fal
menuconfig RT_USING_FAL
bool "fal: Flash Abstraction Layer implement. Manage flash device and partition."
default n
if RT_USING_FAL
config FAL_DEBUG_CONFIG
bool "Enable debug log output"
default y
config FAL_DEBUG
int
default 1 if FAL_DEBUG_CONFIG
default 0
config FAL_PART_HAS_TABLE_CFG
bool "FAL partition table config has defined on 'fal_cfg.h'"
default y
help
If defined partition table on 'fal_cfg.h' please enable this option.
When this option is disable, it will auto find and load the partition table
on a specified location in flash partition.
if !FAL_PART_HAS_TABLE_CFG
config FAL_PART_TABLE_FLASH_DEV_NAME
string "The flash device which saving partition table"
default "onchip"
help
It will auto find the partition table on this flash device.
config FAL_PART_TABLE_END_OFFSET
int "The patition table end address relative to flash device offset."
default 65536
help
The auto find and load the partition table process is forward from this
offset address on flash.
endif
config FAL_USING_SFUD_PORT
bool "FAL uses SFUD drivers"
default n
help
The fal_flash_sfud_port.c in the samples\porting directory will be used.
if FAL_USING_SFUD_PORT
config FAL_USING_NOR_FLASH_DEV_NAME
string "The name of the device used by FAL"
default "norflash0"
endif
endif

14
components/fal/SConscript Normal file
View File

@@ -0,0 +1,14 @@
from building import *
import rtconfig
cwd = GetCurrentDir()
src = Glob('src/*.c')
CPPPATH = [cwd + '/inc']
if GetDepend(['FAL_USING_SFUD_PORT']):
src += Glob('samples/porting/fal_flash_sfud_port.c')
group = DefineGroup('Fal', src, depend = ['RT_USING_FAL'], CPPPATH = CPPPATH)
Return('group')

View File

@@ -0,0 +1,145 @@
# FAL API
## 查找 Flash 设备
```C
const struct fal_flash_dev *fal_flash_device_find(const char *name)
```
| 参数 | 描述 |
| :----- | :----------------------- |
| name | Flash 设备名称 |
| return | 如果查找成功,将返回 Flash 设备对象,查找失败返回 NULL |
## 查找 Flash 分区
```C
const struct fal_partition *fal_partition_find(const char *name)
```
| 参数 | 描述 |
| :----- | :----------------------- |
| name | Flash 分区名称 |
| return | 如果查找成功,将返回 Flash 分区对象,查找失败返回 NULL |
## 获取分区表
```C
const struct fal_partition *fal_get_partition_table(size_t *len)
```
| 参数 | 描述 |
| :----- | :----------------------- |
| len | 分区表的长度 |
| return | 分区表 |
## 临时设置分区表
FAL 初始化时会自动装载默认分区表。使用该设置将临时修改分区表,重启后会 **丢失** 该设置
```C
void fal_set_partition_table_temp(struct fal_partition *table, size_t len)
```
| 参数 | 描述 |
| :----- | :----------------------- |
| table | 分区表 |
| len | 分区表的长度 |
## 从分区读取数据
```C
int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t *buf, size_t size)
```
| 参数 | 描述 |
| :----- | :----------------------- |
| part | 分区对象 |
| addr | 相对分区的偏移地址 |
| buf | 存放待读取数据的缓冲区 |
| size | 待读取数据的大小 |
| return | 返回实际读取的数据大小 |
## 往分区写入数据
```C
int fal_partition_write(const struct fal_partition *part, uint32_t addr, const uint8_t *buf, size_t size)
```
| 参数 | 描述 |
| :----- | :----------------------- |
| part | 分区对象 |
| addr | 相对分区的偏移地址 |
| buf | 存放待写入数据的缓冲区 |
| size | 待写入数据的大小 |
| return | 返回实际写入的数据大小 |
## 擦除分区数据
```C
int fal_partition_erase(const struct fal_partition *part, uint32_t addr, size_t size)
```
| 参数 | 描述 |
| :----- | :----------------------- |
| part | 分区对象 |
| addr | 相对分区的偏移地址 |
| size | 擦除区域的大小 |
| return | 返回实际擦除的区域大小 |
## 擦除整个分区数据
```C
int fal_partition_erase_all(const struct fal_partition *part)
```
| 参数 | 描述 |
| :----- | :----------------------- |
| part | 分区对象 |
| return | 返回实际擦除的区域大小 |
## 打印分区表
```c
void fal_show_part_table(void)
```
## 创建块设备
该函数可以根据指定的分区名称,创建对应的块设备,以便于在指定的分区上挂载文件系统
```C
struct rt_device *fal_blk_device_create(const char *parition_name)
```
| 参数 | 描述 |
| :----- | :----------------------- |
| parition_name | 分区名称 |
| return | 创建成功,则返回对应的块设备,失败返回空 |
## 创建 MTD Nor Flash 设备
该函数可以根据指定的分区名称,创建对应的 MTD Nor Flash 设备,以便于在指定的分区上挂载文件系统
```C
struct rt_device *fal_mtd_nor_device_create(const char *parition_name)
```
| 参数 | 描述 |
| :------------ | :---------------------------------------------------- |
| parition_name | 分区名称 |
| return | 创建成功,则返回对应的 MTD Nor Flash 设备,失败返回空 |
## 创建字符设备
该函数可以根据指定的分区名称,创建对应的字符设备,以便于通过 deivice 接口或 devfs 接口操作分区,开启了 POSIX 后,还可以通过 open/read/write 函数操作分区。
```C
struct rt_device *fal_char_device_create(const char *parition_name)
```
| 参数 | 描述 |
| :------------ | :----------------------------------------- |
| parition_name | 分区名称 |
| return | 创建成功,则返回对应的字符设备,失败返回空 |

View File

@@ -0,0 +1,144 @@
# FAL API
## Find Flash device
```C
const struct fal_flash_dev *fal_flash_device_find(const char *name)
```
| Parameters | Description |
| :----- | :----------------------- |
| name | Flash device name |
| return | If the search is successful, the Flash device object will be returned, and if the search fails, it will return NULL |
## Find Flash Partition
```C
const struct fal_partition *fal_partition_find(const char *name)
```
| Parameters | Description |
| :----- | :----------------------- |
| name | Flash partition name |
| return | If the search is successful, the Flash partition object will be returned, and if the search fails, it will return NULL |
## Get the partition table
```C
const struct fal_partition *fal_get_partition_table(size_t *len)
```
| Parameters | Description |
| :----- | :----------------------- |
| len | The length of the partition table |
| return | Partition table |
## Temporarily set the partition table
The default partition table will be automatically loaded when FAL is initialized. Using this setting will temporarily modify the partition table and will **lost** this setting after restarting
```C
void fal_set_partition_table_temp(struct fal_partition *table, size_t len)
```
| Parameters | Description |
| :----- | :----------------------- |
| table | Partition table |
| len | Length of the partition table |
## Read data from partition
```C
int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t *buf, size_t size)
```
| Parameters | Description |
| :----- | :----------------------- |
| part | Partition object |
| addr | Relative partition offset address |
| buf | Buffer to store the data to be read |
| size | The size of the data to be read |
| return | Return the actual read data size |
## Write data to partition
```C
int fal_partition_write(const struct fal_partition *part, uint32_t addr, const uint8_t *buf, size_t size)
```
| Parameters | Description |
| :----- | :----------------------- |
| part | Partition object |
| addr | Relative partition offset address |
| buf | Buffer to store data to be written |
| size | The size of the data to be written |
| return | Return the actual written data size |
## Erase partition data
```C
int fal_partition_erase(const struct fal_partition *part, uint32_t addr, size_t size)
```
| Parameters | Description |
| :----- | :----------------------- |
| part | Partition object |
| addr | Relative partition offset address |
| size | The size of the erased area |
| return | Return the actual erased area size |
## Erase the entire partition data
```C
int fal_partition_erase_all(const struct fal_partition *part)
```
| Parameters | Description |
| :----- | :----------------------- |
| part | Partition object |
| return | Return the actual erased area size |
## Print partition table
```c
void fal_show_part_table(void)
```
## Create block device
This function can create the corresponding block device according to the specified partition name, so as to mount the file system on the specified partition
```C
struct rt_device *fal_blk_device_create(const char *parition_name)
```
| Parameters | Description |
| :----- | :----------------------- |
| parition_name | partition name |
| return | If the creation is successful, the corresponding block device will be returned, and if it fails, empty |
## Create MTD Nor Flash device
This function can create the corresponding MTD Nor Flash device according to the specified partition name, so as to mount the file system on the specified partition
```C
struct rt_device *fal_mtd_nor_device_create(const char *parition_name)
```
| Parameters | Description |
| :------------ | :---------------------------------- ------------------ |
| parition_name | Partition name |
| return | If the creation is successful, the corresponding MTD Nor Flash device will be returned, otherwise empty |
## Create a character device
This function can create the corresponding character device according to the specified partition name to facilitate the operation of the partition through the deivice interface or the devfs interface. After POSIX is turned on, the partition can also be operated through the open/read/write function.
```C
struct rt_device *fal_char_device_create(const char *parition_name)
```
| Parameters | Description |
| :------------ | :---------------------------------- ------- |
| parition_name | partition name |
| return | If the creation is successful, the corresponding character device will be returned, otherwise empty |

Some files were not shown because too many files have changed in this diff Show More