Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 9 additions & 1 deletion bsp/stm32/stm32l496-ali-developer/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,16 @@ menu "On-chip Peripheral Drivers"
default n
endif

config BSP_USING_ON_CHIP_FLASH
config BSP_USING_ONCHIP_FLASH
bool "Enable on-chip FLASH"
select RT_USING_FAL
default n

config BSP_USING_ONCHIP_FLASH_FATFS
bool "Enable onchip flash with FatFS"
depends on BSP_USING_ONCHIP_FLASH
select RT_USING_DFS
select RT_USING_DFS_ELMFAT
Comment thread
supperthomas marked this conversation as resolved.
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_ONCHIP_FLASH']):
src += Glob('mnt.c')

path = [cwd]
path += [cwd + '/CubeMX_Config/Inc']
path += [cwd + '/ports']
Expand Down
44 changes: 44 additions & 0 deletions bsp/stm32/stm32l496-ali-developer/board/mnt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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
Copy Markdown
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_ONCHIP_FLASH
fal_init();
#define FS_PARTITION_NAME "flash"
struct rt_device *mtd_dev;
mtd_dev = fal_blk_device_create(FS_PARTITION_NAME);
if (dfs_mount(FS_PARTITION_NAME, "/", "elm", 0, 0) == 0)
Comment thread
supperthomas marked this conversation as resolved.
{
rt_kprintf("Filesystem initialized!");
Comment thread
supperthomas marked this conversation as resolved.
Outdated
}
else
{
dfs_mkfs("elm", FS_PARTITION_NAME);
if (dfs_mount(FS_PARTITION_NAME, "/", "elm", 0, 0) != 0)
{
rt_kprintf("Failed to initialize filesystem!");
Comment thread
supperthomas marked this conversation as resolved.
Outdated
}
}
#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_ */
11 changes: 8 additions & 3 deletions bsp/stm32/stm32l496-st-nucleo/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,16 @@ menu "On-chip Peripheral Drivers"
endif
endif

config BSP_USING_ON_CHIP_FLASH
config BSP_USING_ONCHIP_FLASH
bool "Enable on-chip FLASH"
select RT_USING_FAL
default n

config BSP_USING_ONCHIP_FLASH_FATFS
bool "Enable onchip flash with FatFS"
depends on BSP_USING_ONCHIP_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