Skip to content

Commit 3f1653b

Browse files
unicornxRbb666
authored andcommitted
bsp: k230: support sdio
Support sdio work for 01Studio board. 01Studio connect TF socket with sdio0, which is different from standard canmv v1.0/v1.1 board (which uses sdio1). Updated configuration menu, - SDIO devices are now a choice of two. - Root file system types are also a choice of multiple. Currently only cromfs and elmFAT are supported. - Modified the default mount partition of the root file system to sd0p1 Deleted the configuration BSP_SD_SDIO_DEV, and now directly set mmcsd_change according to the selection of the SDIO device. Eliminated the warning of the drv_sdhci.c and egularized the code format. The logic of this file has not been essentially modified. Sync and update the .config/rtconfig.h to the latest. Signed-off-by: Chen Wang <[email protected]>
1 parent d1628a1 commit 3f1653b

File tree

6 files changed

+210
-106
lines changed

6 files changed

+210
-106
lines changed

bsp/k230/.config

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ CONFIG_RT_USING_LDSO=y
562562
# CONFIG_ELF_LOAD_RANDOMIZE is not set
563563
CONFIG_LWP_USING_TERMINAL=y
564564
CONFIG_LWP_PTY_MAX_PARIS_LIMIT=64
565+
CONFIG_RT_USING_VDSO=y
565566

566567
#
567568
# Using USB legacy version
@@ -1490,9 +1491,15 @@ CONFIG_PKG_ZLIB_VER="latest"
14901491
# Drivers Configuration
14911492
#
14921493
CONFIG_BSP_USING_HARDLOCK=y
1493-
# CONFIG_BSP_USING_SDIO is not set
1494+
CONFIG_BSP_USING_SDIO=y
1495+
CONFIG_BSP_USING_SDIO0=y
1496+
# CONFIG_BSP_SDIO0_EMMC is not set
1497+
# CONFIG_BSP_SDIO0_1V8 is not set
1498+
# CONFIG_BSP_USING_SDIO1 is not set
1499+
CONFIG_BSP_SD_MNT_DEVNAME="sd0p1"
14941500
# end of Drivers Configuration
14951501

14961502
CONFIG_BOARD_fpgac908=y
14971503
CONFIG___STACKSIZE__=65536
1498-
CONFIG_BSP_ROOTFS_TYPE_CROMFS=y
1504+
CONFIG_BSP_ROOTFS_TYPE_ELMFAT=y
1505+
# CONFIG_BSP_ROOTFS_TYPE_CROMFS is not set

bsp/k230/Kconfig

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,17 @@ config __STACKSIZE__
2525
int "stack size for interrupt"
2626
default 4096
2727

28-
config BSP_ROOTFS_TYPE_CROMFS
29-
bool "Use CROMFS as ROOTFS"
30-
select RT_USING_DFS_CROMFS
31-
select PKG_USING_ZLIB
32-
default y
28+
choice BSP_ROOTFS_TYPE
29+
prompt "Root File-System type"
30+
default BSP_ROOTFS_TYPE_ELMFAT
31+
32+
config BSP_ROOTFS_TYPE_ELMFAT
33+
bool "Use Elm-chan FAT File-System"
34+
select RT_USING_DFS_ELMFAT
35+
36+
config BSP_ROOTFS_TYPE_CROMFS
37+
bool "Use Compressed ROM File-System (ReadOnly)"
38+
select RT_USING_DFS_CROMFS
39+
select PKG_USING_ZLIB
40+
select PKG_USING_ZLIB_LATEST_VERSION
41+
endchoice

bsp/k230/applications/mnt.c

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#ifdef RT_USING_DFS
44
#include <dfs_fs.h>
55

6+
#ifdef BSP_ROOTFS_TYPE_CROMFS
67
rt_weak uint8_t *cromfs_get_partition_data(uint32_t *len)
78
{
89
return RT_NULL;
@@ -21,9 +22,32 @@ static int mnt_cromfs(void)
2122

2223
return ret;
2324
}
25+
#endif
2426

2527
int mnt_init(void)
2628
{
29+
#if defined(BSP_USING_SDIO) && defined(BSP_ROOTFS_TYPE_ELMFAT)
30+
int timeout = 50; // Timeout after 50 iterations (5 seconds if each iteration waits 100ms)
31+
while (mmcsd_wait_cd_changed(100) != MMCSD_HOST_PLUGED)
32+
{
33+
if (--timeout <= 0)
34+
{
35+
rt_kprintf("Timeout waiting for MMCSD host to be plugged!\n");
36+
return -1; // Return an error code to indicate failure
37+
}
38+
rt_thread_mdelay(100); // Yield to the scheduler
39+
}
40+
41+
if (dfs_mount(BSP_SD_MNT_DEVNAME, "/", "elm", 0, 0) != 0)
42+
{
43+
rt_kprintf("%s mounted on / failed!\n", BSP_SD_MNT_DEVNAME);
44+
}
45+
else {
46+
rt_kprintf("%s mounted on / success!\n", BSP_SD_MNT_DEVNAME);
47+
}
48+
#endif
49+
50+
#ifdef BSP_ROOTFS_TYPE_CROMFS
2751
rt_err_t ret;
2852

2953
ret = mnt_cromfs();
@@ -32,27 +56,26 @@ int mnt_init(void)
3256
rt_kprintf("CromFS mount failed!\n");
3357
return ret;
3458
}
59+
else
60+
{
61+
rt_kprintf("CromFS mount success!\n");
62+
}
63+
#endif
3564

3665
mkdir("/dev/shm", 0x777);
3766

3867
if (dfs_mount(RT_NULL, "/dev/shm", "tmp", 0, 0) != 0)
3968
{
40-
rt_kprintf("Dir /dev/shm mount failed!\n");
69+
rt_kprintf("tmpfs mounted on /dev/shm failed!\n");
4170
}
42-
43-
#ifdef BSP_SD_SDIO_DEV
44-
while (mmcsd_wait_cd_changed(100) != MMCSD_HOST_PLUGED)
45-
;
46-
47-
if (dfs_mount(BSP_SD_MNT_DEVNAME, "/mnt", "elm", 0, 0) != 0)
48-
{
49-
rt_kprintf("Dir /mnt mount failed!\n");
71+
else {
72+
rt_kprintf("tmpfs mounted on /dev/shm success!\n");
5073
}
51-
#endif
5274

5375
rt_kprintf("file system initialization done!\n");
5476

5577
return 0;
5678
}
5779
INIT_ENV_EXPORT(mnt_init);
58-
#endif
80+
81+
#endif /* RT_USING_DFS */

bsp/k230/board/Kconfig

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,38 @@ menu "Drivers Configuration"
77
menuconfig BSP_USING_SDIO
88
bool "Enable SDIO"
99
select RT_USING_SDIO
10-
default n
10+
default y
1111

1212
if BSP_USING_SDIO
13-
config BSP_USING_SDIO0
14-
bool "Enable SDIO0"
15-
default n
1613

17-
if BSP_USING_SDIO0
18-
config BSP_SDIO0_EMMC
19-
bool "Enable eMMC"
20-
default y
14+
choice BSP_SDIO_DEV
15+
prompt "Select SDIO device"
16+
default BSP_USING_SDIO0
17+
help
18+
Select the SDIO device to be used.
2119

22-
config BSP_SDIO0_1V8
23-
bool "Enable 1.8V"
20+
config BSP_USING_SDIO0
21+
bool "Enable SDIO0"
2422
default y
25-
endif
2623

27-
config BSP_USING_SDIO1
28-
bool "Enable SDIO1"
29-
default y
24+
if BSP_USING_SDIO0
25+
config BSP_SDIO0_EMMC
26+
bool "Enable eMMC"
27+
default n
3028

31-
config BSP_SD_SDIO_DEV
32-
int "SDIO device SdCard on"
33-
range 0 1
34-
default 1
29+
config BSP_SDIO0_1V8
30+
bool "Enable 1.8V"
31+
default n
32+
endif
33+
34+
config BSP_USING_SDIO1
35+
bool "Enable SDIO1"
36+
default n
37+
endchoice
3538

3639
config BSP_SD_MNT_DEVNAME
3740
string "The name of the SD-BlkDev to be mounted"
38-
default "sd13"
41+
default "sd0p1"
3942
endif
4043

41-
4244
endmenu

0 commit comments

Comments
 (0)