Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bsp/stm32/stm32l496-ali-developer/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions bsp/stm32/stm32l496-ali-developer/board/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
52 changes: 52 additions & 0 deletions bsp/stm32/stm32l496-ali-developer/board/mnt.c
Original file line number Diff line number Diff line change
@@ -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>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define DBG_TAG "mnt"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>

#include "fal.h"
#include <dfs_fs.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)
{
rt_kprintf("Failed to create device.\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rt_kprintf("Failed to create device.\n");
LOG_E("Failed to create device.");

}
#ifdef BSP_USING_ON_CHIP_FLASH_FATFS
if (dfs_mount(FS_PARTITION_NAME, "/", "elm", 0, 0) == 0)
{
rt_kprintf("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!");
}
}
#endif

#endif
return 0;
}
INIT_ENV_EXPORT(mnt_init);
#endif

4 changes: 2 additions & 2 deletions bsp/stm32/stm32l496-ali-developer/board/ports/fal_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
9 changes: 7 additions & 2 deletions bsp/stm32/stm32l496-st-nucleo/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion bsp/stm32/stm32l496-st-nucleo/board/mnt_onchip.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define DBG_TAG "mnt"
#define DBG_LVL DBG_INFO
#include <rtdbg.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)
{
rt_kprintf("Failed to create device.\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rt_kprintf("Failed to create device.\n");
LOG_E("Failed to create device.");

}
#ifdef BSP_USING_ON_CHIP_FLASH_FATFS
if (dfs_mount(FS_PARTITION_NAME, "/", "elm", 0, 0) == 0)
{
rt_kprintf("Filesystem initialized!");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rt_kprintf("Filesystem initialized!");
LOG_I("Filesystem initialized!");

Expand All @@ -35,7 +41,8 @@ int mnt_init(void)
rt_kprintf("Failed to initialize filesystem!");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rt_kprintf("Failed to initialize filesystem!");
LOG_E("Failed to initialize filesystem!");

}
}

#endif
#endif
return 0;
}
INIT_ENV_EXPORT(mnt_init);
Expand Down