mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-27 23:57:06 +08:00
[bsp/stm32l496_ali] add the on-chip flash (#6061)
* [bsp/stm32l496_ali] add the on-chip flash * [bsp/stm32l496_ali]add Kconfig Co-authored-by: Meco Man <920369182@qq.com>
This commit is contained in:
parent
33be34d8ec
commit
c16eaf55de
@ -63,6 +63,14 @@ menu "On-chip Peripheral Drivers"
|
||||
|
||||
config BSP_USING_ON_CHIP_FLASH
|
||||
bool "Enable on-chip FLASH"
|
||||
select RT_USING_FAL
|
||||
default n
|
||||
|
||||
config BSP_USING_ON_CHIP_FLASH_FATFS
|
||||
bool "Enable onchip flash with FatFS"
|
||||
depends on BSP_USING_ON_CHIP_FLASH
|
||||
select RT_USING_DFS
|
||||
select RT_USING_DFS_ELMFAT
|
||||
default n
|
||||
|
||||
menuconfig BSP_USING_SPI
|
||||
|
@ -18,6 +18,9 @@ if GetDepend(['BSP_USING_SPI_LCD']):
|
||||
if GetDepend(['BSP_USING_SDCARD']):
|
||||
src += Glob('ports/sdcard_port.c')
|
||||
|
||||
if GetDepend(['BSP_USING_ON_CHIP_FLASH']):
|
||||
src += Glob('mnt.c')
|
||||
|
||||
path = [cwd]
|
||||
path += [cwd + '/CubeMX_Config/Inc']
|
||||
path += [cwd + '/ports']
|
||||
|
@ -14,30 +14,40 @@
|
||||
#include "fal.h"
|
||||
#include <dfs_fs.h>
|
||||
|
||||
#define DBG_TAG "mnt"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_fs.h>
|
||||
|
||||
int mnt_init(void)
|
||||
{
|
||||
#ifdef BSP_USING_ON_CHIP_FLASH
|
||||
fal_init();
|
||||
#define FS_PARTITION_NAME "flash"
|
||||
struct rt_device *mtd_dev;
|
||||
mtd_dev = fal_blk_device_create(FS_PARTITION_NAME);
|
||||
if (!mtd_dev)
|
||||
{
|
||||
LOG_E("Failed to create device.\n");
|
||||
}
|
||||
#ifdef BSP_USING_ON_CHIP_FLASH_FATFS
|
||||
if (dfs_mount(FS_PARTITION_NAME, "/", "elm", 0, 0) == 0)
|
||||
{
|
||||
rt_kprintf("Filesystem initialized!");
|
||||
LOG_I("Filesystem initialized!");
|
||||
}
|
||||
else
|
||||
{
|
||||
dfs_mkfs("elm", FS_PARTITION_NAME);
|
||||
if (dfs_mount(FS_PARTITION_NAME, "/", "elm", 0, 0) != 0)
|
||||
{
|
||||
rt_kprintf("Failed to initialize filesystem!");
|
||||
LOG_I("Failed to initialize filesystem!");
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BSP_USING_ON_CHIP_FLASH_FATFS */
|
||||
#endif /* BSP_USING_ON_CHIP_FLASH */
|
||||
return 0;
|
||||
}
|
||||
INIT_ENV_EXPORT(mnt_init);
|
||||
#endif
|
||||
|
||||
#endif /* RT_USING_DFS */
|
@ -27,8 +27,8 @@ extern const struct fal_flash_dev stm32_onchip_flash;
|
||||
/* partition table */
|
||||
#define FAL_PART_TABLE \
|
||||
{ \
|
||||
{FAL_PART_MAGIC_WROD, "app", "onchip_flash", 0, 496 * 1024, 0}, \
|
||||
{FAL_PART_MAGIC_WROD, "param", "onchip_flash", 496* 1024, 16 * 1024, 0}, \
|
||||
{FAL_PART_MAGIC_WROD, "app", "onchip_flash", 0, 512 * 1024, 0}, \
|
||||
{FAL_PART_MAGIC_WROD, "flash", "onchip_flash", 512* 1024, 512 * 1024, 0}, \
|
||||
}
|
||||
#endif /* FAL_PART_HAS_TABLE_CFG */
|
||||
#endif /* _FAL_CFG_H_ */
|
||||
|
@ -96,10 +96,15 @@ menu "On-chip Peripheral Drivers"
|
||||
endif
|
||||
|
||||
config BSP_USING_ON_CHIP_FLASH
|
||||
bool "Enable on-chip FLASH"
|
||||
select RT_USING_FAL
|
||||
default n
|
||||
|
||||
config BSP_USING_ON_CHIP_FLASH_FATFS
|
||||
bool "Enable onchip flash with FatFS"
|
||||
depends on BSP_USING_ON_CHIP_FLASH
|
||||
select RT_USING_DFS
|
||||
select RT_USING_DFS_ELMFAT
|
||||
select RT_USING_FAL
|
||||
bool "Enable on-chip FLASH"
|
||||
default n
|
||||
|
||||
config BSP_USING_USBD
|
||||
|
@ -13,8 +13,7 @@ CubeMX_Config/Src/stm32l4xx_hal_msp.c
|
||||
''')
|
||||
|
||||
if GetDepend(['BSP_USING_ON_CHIP_FLASH']):
|
||||
src += Glob('mnt_onchip.c')
|
||||
|
||||
src += Glob('mnt.c')
|
||||
|
||||
path = [cwd]
|
||||
path += [cwd + '/CubeMX_Config/Inc']
|
||||
|
52
bsp/stm32/stm32l496-st-nucleo/board/mnt.c
Normal file
52
bsp/stm32/stm32l496-st-nucleo/board/mnt.c
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-06-08 supperthomas first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include "fal.h"
|
||||
|
||||
#define DBG_TAG "mnt"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_fs.h>
|
||||
|
||||
int mnt_init(void)
|
||||
{
|
||||
#ifdef BSP_USING_ON_CHIP_FLASH
|
||||
fal_init();
|
||||
#define FS_PARTITION_NAME "flash"
|
||||
struct rt_device *mtd_dev;
|
||||
mtd_dev = fal_blk_device_create(FS_PARTITION_NAME);
|
||||
if (!mtd_dev)
|
||||
{
|
||||
LOG_E("Failed to create device.\n");
|
||||
}
|
||||
#ifdef BSP_USING_ON_CHIP_FLASH_FATFS
|
||||
if (dfs_mount(FS_PARTITION_NAME, "/", "elm", 0, 0) == 0)
|
||||
{
|
||||
LOG_I("Filesystem initialized!");
|
||||
}
|
||||
else
|
||||
{
|
||||
dfs_mkfs("elm", FS_PARTITION_NAME);
|
||||
if (dfs_mount(FS_PARTITION_NAME, "/", "elm", 0, 0) != 0)
|
||||
{
|
||||
LOG_E("Failed to initialize filesystem!");
|
||||
}
|
||||
}
|
||||
#endif /* BSP_USING_ON_CHIP_FLASH_FATFS */
|
||||
#endif /* BSP_USING_ON_CHIP_FLASH */
|
||||
return 0;
|
||||
}
|
||||
INIT_ENV_EXPORT(mnt_init);
|
||||
#endif /* RT_USING_DFS */
|
Loading…
x
Reference in New Issue
Block a user