Skip to content

Commit a0b76a2

Browse files
authored
Merge pull request #106 from whj4674672/master
【完善】使能 spi flash 挂载文件系统
2 parents b543531 + c91b7e8 commit a0b76a2

File tree

25 files changed

+978
-2531
lines changed

25 files changed

+978
-2531
lines changed

libraries/Kconfig

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,20 @@ menu "Onboard Peripheral"
9191
select BSP_USING_UART4
9292
default n
9393

94+
config BSP_USING_SPI_FLASH
95+
bool "Enable SPI FLASH (spi1)"
96+
select BSP_USING_SPI
97+
select BSP_USING_SPI1
98+
select PKG_USING_FAL
99+
select FAL_USING_SFUD_PORT
100+
select RT_USING_SFUD
101+
default n
102+
94103
config BSP_USING_WIFI
95104
bool "Enable wifi (AP6212)"
96105
select ART_PI_USING_WIFI_6212_LIB
97106
select ART_PI_USING_OTA_LIB
98-
select BSP_USING_SPI
99-
select BSP_USING_SPI1
107+
select BSP_USING_SPI_FLASH
100108
select RT_USING_WIFI
101109
select RT_USING_SAL
102110
default n
@@ -122,11 +130,9 @@ menu "Onboard Peripheral"
122130
default n
123131
config BSP_USING_SPI_FLASH_FS
124132
bool "Enable SPI FLASH filesystem"
125-
select BSP_USING_SPI
126-
select BSP_USING_SPI1
127-
select PKG_USING_FAL
128-
select FAL_USING_SFUD_PORT
129-
select RT_USING_SFUD
133+
select BSP_USING_SPI_FLASH
134+
select RT_USING_MTD_NOR
135+
select PKG_USING_LITTLEFS
130136
default n
131137
endif
132138

libraries/drivers/SConscript

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ if GetDepend(['BSP_USING_USBH']):
4949
if GetDepend(['RT_USING_CAN']):
5050
src += ['drv_fdcan.c']
5151

52+
if GetDepend(['BSP_USING_SPI_FLASH']):
53+
src += ['drv_spi_flash.c']
54+
5255
path = [cwd]
5356
path += [cwd + '/include']
5457
path += [cwd + '/include/config']

libraries/drivers/drv_spi_flash.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2020-11-07 wanghaijing the first version
9+
*/
10+
11+
#include <rtthread.h>
12+
#include <rtdevice.h>
13+
#include <spi_flash.h>
14+
#include <drv_spi.h>
15+
16+
static int rt_flash_init(void)
17+
{
18+
extern rt_spi_flash_device_t rt_sfud_flash_probe(const char *spi_flash_dev_name, const char *spi_dev_name);
19+
extern int fal_init(void);
20+
21+
rt_hw_spi_device_attach("spi1", "spi10", GPIOA, GPIO_PIN_4);
22+
23+
/* initialize SPI Flash device */
24+
rt_sfud_flash_probe("norflash0", "spi10");
25+
26+
fal_init();
27+
28+
return 0;
29+
}
30+
INIT_ENV_EXPORT(rt_flash_init);

libraries/rt_ota_lib/src/rtota_update.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Date Author Notes
88
* 2018-01-30 armink the first version
99
* 2018-08-27 Murphy update log
10+
* 2020-11-07 wanghaijing remove initialize SPI Flash
1011
*/
1112

1213
#include <rtthread.h>
@@ -35,24 +36,6 @@
3536

3637
char *partition_name;
3738

38-
static int rt_flash_init(void)
39-
{
40-
#include <spi_flash.h>
41-
#include <drv_spi.h>
42-
extern rt_spi_flash_device_t rt_sfud_flash_probe(const char *spi_flash_dev_name, const char *spi_dev_name);
43-
extern int fal_init(void);
44-
45-
rt_hw_spi_device_attach("spi1", "spi10", GPIOA, GPIO_PIN_4);
46-
47-
/* initialize SPI Flash device */
48-
rt_sfud_flash_probe("norflash0", "spi10");
49-
50-
fal_init();
51-
52-
return 0;
53-
}
54-
INIT_ENV_EXPORT(rt_flash_init);
55-
5639
static size_t update_file_total_size, update_file_cur_size;
5740
static const struct fal_partition * dl_part = RT_NULL;
5841
static enum rym_code ymodem_on_begin(struct rym_ctx *ctx, rt_uint8_t *buf, rt_size_t len)

projects/art_pi_blink_led/.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ CONFIG_FINSH_ARG_MAX=10
114114
#
115115
CONFIG_RT_USING_DFS=y
116116
CONFIG_DFS_USING_WORKDIR=y
117-
CONFIG_DFS_FILESYSTEMS_MAX=2
118-
CONFIG_DFS_FILESYSTEM_TYPES_MAX=2
119-
CONFIG_DFS_FD_MAX=16
117+
CONFIG_DFS_FILESYSTEMS_MAX=6
118+
CONFIG_DFS_FILESYSTEM_TYPES_MAX=6
119+
CONFIG_DFS_FD_MAX=32
120120
# CONFIG_RT_USING_DFS_MNTTABLE is not set
121121
# CONFIG_RT_USING_DFS_ELMFAT is not set
122122
CONFIG_RT_USING_DFS_DEVFS=y

projects/art_pi_blink_led/board/port/filesystem.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
#include <rtthread.h>
1313

1414
#ifdef BSP_USING_FS
15-
16-
#if RT_DFS_ELM_MAX_SECTOR_SIZE < 4096
17-
#error "Please define RT_DFS_ELM_MAX_SECTOR_SIZE more than 4096"
18-
#endif
1915
#if DFS_FILESYSTEMS_MAX < 4
2016
#error "Please define DFS_FILESYSTEMS_MAX more than 4"
2117
#endif
@@ -158,8 +154,8 @@ int mount_init(void)
158154
{
159155
LOG_E("create sd_mount thread err!");
160156
}
161-
return RT_EOK;
162157
#endif
158+
return RT_EOK;
163159
}
164160
INIT_APP_EXPORT(mount_init);
165161

0 commit comments

Comments
 (0)