From de32f35016f6ae5f2b02848a934c638be3499cc0 Mon Sep 17 00:00:00 2001 From: zhangyan <103986797+messigogogo@users.noreply.github.com> Date: Fri, 19 Apr 2024 08:52:09 +0800 Subject: [PATCH] =?UTF-8?q?[bsp/phytium]=E9=83=A8=E5=88=86=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E9=A9=B1=E5=8A=A8=E4=BF=AE=E6=94=B9=20(#8794)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * update * 修改 SDIF 驱动,支持同时使用 TF 卡和 eMMC,更换飞腾派自启动镜像 * drivers debug * update * update * update config * update * modify format --------- Co-authored-by: 朱耿宇 --- bsp/phytium/README.md | 1 + bsp/phytium/aarch32/.config | 22 +- bsp/phytium/aarch32/applications/mnt.c | 140 --- .../aarch32/configs/e2000d_demo_rtsmart | 50 +- .../aarch32/configs/e2000d_demo_rtsmart.h | 23 +- .../aarch32/configs/e2000d_demo_rtthread | 43 +- .../aarch32/configs/e2000d_demo_rtthread.h | 19 +- .../aarch32/configs/e2000q_demo_rtsmart | 29 +- .../aarch32/configs/e2000q_demo_rtsmart.h | 16 +- .../aarch32/configs/e2000q_demo_rtthread | 25 +- .../aarch32/configs/e2000q_demo_rtthread.h | 11 + .../aarch32/configs/phytium_pi_rtsmart | 28 +- .../aarch32/configs/phytium_pi_rtsmart.h | 14 +- .../aarch32/configs/phytium_pi_rtthread | 25 +- .../aarch32/configs/phytium_pi_rtthread.h | 9 + bsp/phytium/aarch32/rtconfig.h | 9 + bsp/phytium/aarch64/.config | 9 +- bsp/phytium/aarch64/applications/mnt.c | 142 --- .../aarch64/configs/e2000d_demo_rtsmart | 55 +- .../aarch64/configs/e2000d_demo_rtsmart.h | 16 +- .../aarch64/configs/e2000d_demo_rtthread | 13 +- .../aarch64/configs/e2000d_demo_rtthread.h | 7 +- .../aarch64/configs/e2000q_demo_rtsmart | 20 +- .../aarch64/configs/e2000q_demo_rtsmart.h | 10 +- .../aarch64/configs/e2000q_demo_rtthread | 50 +- .../aarch64/configs/e2000q_demo_rtthread.h | 11 +- .../aarch64/configs/phytium_pi_rtsmart | 21 +- .../aarch64/configs/phytium_pi_rtsmart.h | 11 +- .../aarch64/configs/phytium_pi_rtthread | 11 +- .../aarch64/configs/phytium_pi_rtthread.h | 4 + bsp/phytium/aarch64/rtconfig.h | 4 + bsp/phytium/doc/how_to_use_file_system.md | 59 ++ bsp/phytium/doc/use_phytium_pi_sd_image.md | 147 ++- bsp/phytium/libraries/SConscript | 23 +- bsp/phytium/libraries/drivers/Kconfig | 41 +- bsp/phytium/libraries/drivers/drv_can.c | 4 +- bsp/phytium/libraries/drivers/drv_gpio.c | 11 +- bsp/phytium/libraries/drivers/drv_i2c.c | 5 +- bsp/phytium/libraries/drivers/drv_log.h | 2 +- bsp/phytium/libraries/drivers/drv_sdif.c | 910 +++++++++++------- bsp/phytium/libraries/drivers/drv_spi.c | 6 +- .../phytium_standalone_sdk_install.py | 2 +- .../port/fboard_port/e2000d_demo/mnt_sdcard.c | 133 +++ .../port/fboard_port/e2000q_demo/mnt_sdcard.c | 133 +++ .../port/fboard_port/firefly/mnt_sdcard.c | 118 +++ .../libraries/port/fboard_port/mnt_ramdisk.c | 50 + 46 files changed, 1546 insertions(+), 946 deletions(-) delete mode 100644 bsp/phytium/aarch32/applications/mnt.c delete mode 100644 bsp/phytium/aarch64/applications/mnt.c create mode 100644 bsp/phytium/doc/how_to_use_file_system.md create mode 100644 bsp/phytium/libraries/port/fboard_port/e2000d_demo/mnt_sdcard.c create mode 100644 bsp/phytium/libraries/port/fboard_port/e2000q_demo/mnt_sdcard.c create mode 100644 bsp/phytium/libraries/port/fboard_port/firefly/mnt_sdcard.c create mode 100644 bsp/phytium/libraries/port/fboard_port/mnt_ramdisk.c diff --git a/bsp/phytium/README.md b/bsp/phytium/README.md index 7c853915e8..65245dfd2d 100644 --- a/bsp/phytium/README.md +++ b/bsp/phytium/README.md @@ -58,6 +58,7 @@ 2. 启动 RT-Thread env 应用程序,在交互界面可以使用`cd`指令进入`aarch32`或`aarch64`目录 3. 按照指导安装 [aarch32](./aarch32/README.md)或[aarch64](./aarch64/README.md)编译链,并进行相关配置 4. 按照指导[启动镜像程序](./doc/how_to_flashed_binary.md) +5. 参考[使用文件系统](./doc/how_to_use_file_system.md)制作和使用文件系统 ### RT-Thread Studio 环境 diff --git a/bsp/phytium/aarch32/.config b/bsp/phytium/aarch32/.config index 5a4ca4888b..8c9456d6a0 100644 --- a/bsp/phytium/aarch32/.config +++ b/bsp/phytium/aarch32/.config @@ -1219,9 +1219,16 @@ CONFIG_RT_USING_SPIM0=y # CONFIG_RT_USING_SPIM1 is not set # CONFIG_RT_USING_SPIM2 is not set # CONFIG_RT_USING_SPIM3 is not set -# CONFIG_BSP_USING_CAN is not set +CONFIG_BSP_USING_CAN=y +# CONFIG_RT_USING_CANFD is not set +# CONFIG_RT_USING_FILTER is not set +# CONFIG_RT_USING_CAN0 is not set +# CONFIG_RT_USING_CAN1 is not set CONFIG_BSP_USING_GPIO=y -# CONFIG_BSP_USING_QSPI is not set +CONFIG_BSP_USING_QSPI=y +CONFIG_RT_USING_QSPI0=y +CONFIG_USING_QSPI_CHANNEL0=y +# CONFIG_USING_QSPI_CHANNEL1 is not set CONFIG_BSP_USING_ETH=y CONFIG_RT_LWIP_PBUF_POOL_BUFSIZE=1700 CONFIG_BSP_USING_PWM=y @@ -1252,10 +1259,15 @@ CONFIG_RT_USING_MIO1=y # CONFIG_RT_USING_MIO14 is not set # CONFIG_RT_USING_MIO15 is not set # CONFIG_I2C_USE_CONTROLLER is not set -# CONFIG_BSP_USING_SDIF is not set +CONFIG_BSP_USING_SDIF=y +CONFIG_BSP_USING_SDCARD_FATFS=y +# CONFIG_USING_SDIF0 is not set +CONFIG_USING_SDIF1=y +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set CONFIG_BSP_USING_DC=y CONFIG_RT_USING_DC_CHANNEL0=y -# CONFIG_RT_USING_DC_CHANNEL1 is not set +CONFIG_RT_USING_DC_CHANNEL1=y # CONFIG_BSP_USING_XHCI is not set # CONFIG_BSP_USING_PUSB2 is not set @@ -1279,6 +1291,7 @@ CONFIG_TARGET_PHYTIUMPI=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="phytiumpi" CONFIG_SOC_CORE_NUM=4 CONFIG_F32BIT_MEMORY_ADDRESS=0x80000000 @@ -1286,7 +1299,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set diff --git a/bsp/phytium/aarch32/applications/mnt.c b/bsp/phytium/aarch32/applications/mnt.c deleted file mode 100644 index e052a3e812..0000000000 --- a/bsp/phytium/aarch32/applications/mnt.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2006-2023, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Email: opensource_embedded@phytium.com.cn - * - * Change Logs: - * Date Author Notes - * 2023-04-27 huanghe first version - * 2023-07-14 liqiaozhong add SD file sys mount func - * - */ -#include -#if defined(RT_USING_DFS) -#include - -#include -#include - -static int ram_disk_mount(const char *mount_point) -{ -#ifdef RT_USING_DFS_RAMFS - extern struct dfs_ramfs *dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size); - - rt_uint8_t *pool = RT_NULL; - rt_size_t size = 8 * 1024 * 1024; - - pool = rt_malloc(size); - if (pool == RT_NULL) - { - LOG_E("Malloc fail!"); - } - - if (dfs_mount(RT_NULL, mount_point, "ram", 0, (const void *)dfs_ramfs_create(pool, size)) == 0) - { - LOG_I("RAM file system initializated!"); - } - else - { - LOG_E("RAM file system initializate failed!"); - } -#endif - - return RT_EOK; -} - -#ifdef BSP_USING_SDCARD_FATFS -extern void fsdif_change(void); -static int sd_disk_try_mount(char *device_name, char *mount_point, char *fs_type_name, int mkfs_count) -{ - struct statfs fs_stat; - int rc = 0; - - LOG_I("mount(\"%s\",\"%s\",\"%s\");", device_name, mount_point, fs_type_name); - - if (rt_device_find(device_name) == NULL) - { - LOG_I("%s not find!!!", device_name); - return -RT_EIO; - } - - mkdir(mount_point, 0); -_remount: - rc = dfs_mount(device_name, mount_point, fs_type_name, 0, 0); - if (rc == 0) - { - LOG_I("mounted %s on %s", device_name, mount_point); - if (dfs_statfs(mount_point, &fs_stat) >= 0) - { - LOG_I("%s size:%d, total: %d, free: %d", mount_point, - fs_stat.f_bsize, fs_stat.f_blocks, fs_stat.f_bfree); - } - } - else - { - if (mkfs_count > 0) - { - /* LOG_I("[%s]try mkfs -t %s %s ", mkfs_count, fs_type_name, device_name); - dfs_mkfs(fs_type_name, device_name); */ - mkfs_count--; - LOG_E("%s is not in %s, please format first !!!", device_name, fs_type_name); - goto _remount; - } - - LOG_I("mount failed :%d ", rc); - return -RT_EIO; - } - - return RT_EOK; -} - -static void sd_filesytem_task_entry(void *parameter) -{ - int result; - LOG_D("sdio host change: %d", change); - mmcsd_wait_cd_changed(0); /* clear */ - fsdif_change(); /* send cd change to host */ - - /* block until plug/unplug event happens */ - result = mmcsd_wait_cd_changed(RT_WAITING_FOREVER); - if (result == MMCSD_HOST_PLUGED) - { - rt_kprintf("mmcsd change pluged \n"); - /* mount sdcard partition as / */ - if (RT_EOK == sd_disk_try_mount(BSP_USING_SDCARD_PARTITION, "/", "elm", 0)) - { - ram_disk_mount("/ram"); /* mount ramdisk if configured */ - } - } -} - -int filesystem_mount(void) -{ - rt_thread_t tid; - tid = rt_thread_create("sd_filesytem", sd_filesytem_task_entry, - RT_NULL, - 4096, - RT_THREAD_PRIORITY_MAX - 2, 20); - if (tid != RT_NULL) - { - rt_thread_startup(tid); - } - else - { - LOG_E("create sd mount task error!"); - } - - return RT_EOK; -} -INIT_APP_EXPORT(filesystem_mount); - -#else -static int filesystem_mount(void) -{ - return ram_disk_mount("/"); /* mount ramdisk as / */ -} -INIT_APP_EXPORT(filesystem_mount); -#endif // #ifdef BSP_USING_SDCARD_FATFS -#endif // #if defined(RT_USING_DFS) \ No newline at end of file diff --git a/bsp/phytium/aarch32/configs/e2000d_demo_rtsmart b/bsp/phytium/aarch32/configs/e2000d_demo_rtsmart index 50307b51e0..7a28d9a0c6 100644 --- a/bsp/phytium/aarch32/configs/e2000d_demo_rtsmart +++ b/bsp/phytium/aarch32/configs/e2000d_demo_rtsmart @@ -78,7 +78,7 @@ CONFIG_RT_USING_HEAP=y CONFIG_RT_USING_DEVICE=y CONFIG_RT_USING_DEVICE_OPS=y # CONFIG_RT_USING_INTERRUPT_INFO is not set -# CONFIG_RT_USING_THREADSAFE_PRINTF is not set +CONFIG_RT_USING_THREADSAFE_PRINTF=y CONFIG_RT_USING_SCHED_THREAD_CTX=y CONFIG_RT_USING_CONSOLE=y CONFIG_RT_CONSOLEBUF_SIZE=256 @@ -135,7 +135,6 @@ CONFIG_RT_USING_DFS=y CONFIG_DFS_USING_POSIX=y CONFIG_DFS_USING_WORKDIR=y CONFIG_DFS_FD_MAX=16 -# CONFIG_RT_USING_DFS_V1 is not set CONFIG_RT_USING_DFS_V2=y CONFIG_RT_USING_DFS_ELMFAT=y @@ -163,6 +162,7 @@ CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000 # CONFIG_RT_DFS_ELM_USE_EXFAT is not set CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DFS_ROMFS is not set +CONFIG_RT_USING_DFS_PTYFS=y # CONFIG_RT_USING_DFS_CROMFS is not set # CONFIG_RT_USING_DFS_TMPFS is not set CONFIG_RT_USING_DFS_MQUEUE=y @@ -193,10 +193,8 @@ CONFIG_RT_USING_SERIAL_V1=y # CONFIG_RT_USING_SERIAL_V2 is not set CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_SERIAL_RB_BUFSZ=1024 -CONFIG_RT_USING_TTY=y -# CONFIG_RT_TTY_DEBUG is not set CONFIG_RT_USING_CAN=y -CONFIG_RT_CAN_USING_HDR=y +# CONFIG_RT_CAN_USING_HDR is not set CONFIG_RT_CAN_USING_CANFD=y # CONFIG_RT_USING_CPUTIME is not set CONFIG_RT_USING_I2C=y @@ -421,10 +419,11 @@ CONFIG_LWP_CONSOLE_INPUT_BUFFER_SIZE=1024 CONFIG_LWP_TID_MAX_NR=64 CONFIG_LWP_ENABLE_ASID=y CONFIG_RT_LWP_SHM_MAX_NR=64 -# CONFIG_LWP_UNIX98_PTY is not set CONFIG_RT_USING_LDSO=y # CONFIG_ELF_DEBUG_ENABLE is not set # CONFIG_ELF_LOAD_RANDOMIZE is not set +CONFIG_LWP_USING_TERMINAL=y +CONFIG_LWP_PTY_MAX_PARIS_LIMIT=64 # # Memory management @@ -1246,13 +1245,13 @@ CONFIG_RT_USING_UART1=y # CONFIG_RT_USING_UART2 is not set # CONFIG_RT_USING_UART3 is not set CONFIG_BSP_USING_SPI=y -# CONFIG_RT_USING_SPIM0 is not set +CONFIG_RT_USING_SPIM0=y # CONFIG_RT_USING_SPIM1 is not set -CONFIG_RT_USING_SPIM2=y +# CONFIG_RT_USING_SPIM2 is not set # CONFIG_RT_USING_SPIM3 is not set CONFIG_BSP_USING_CAN=y -CONFIG_RT_USING_CANFD=y -CONFIG_RT_USING_FILTER=y +# CONFIG_RT_USING_CANFD is not set +# CONFIG_RT_USING_FILTER is not set CONFIG_RT_USING_CAN0=y CONFIG_RT_USING_CAN1=y CONFIG_BSP_USING_GPIO=y @@ -1265,16 +1264,16 @@ CONFIG_RT_LWIP_PBUF_POOL_BUFSIZE=1700 CONFIG_BSP_USING_PWM=y # CONFIG_RT_USING_PWM0 is not set # CONFIG_RT_USING_PWM1 is not set -# CONFIG_RT_USING_PWM2 is not set +CONFIG_RT_USING_PWM2=y # CONFIG_RT_USING_PWM3 is not set # CONFIG_RT_USING_PWM4 is not set # CONFIG_RT_USING_PWM5 is not set -CONFIG_RT_USING_PWM6=y +# CONFIG_RT_USING_PWM6 is not set # CONFIG_RT_USING_PWM7 is not set CONFIG_BSP_USING_I2C=y CONFIG_I2C_USE_MIO=y -# CONFIG_RT_USING_MIO0 is not set -# CONFIG_RT_USING_MIO1 is not set +CONFIG_RT_USING_MIO0=y +CONFIG_RT_USING_MIO1=y # CONFIG_RT_USING_MIO2 is not set # CONFIG_RT_USING_MIO3 is not set # CONFIG_RT_USING_MIO4 is not set @@ -1288,21 +1287,19 @@ CONFIG_I2C_USE_MIO=y # CONFIG_RT_USING_MIO12 is not set # CONFIG_RT_USING_MIO13 is not set # CONFIG_RT_USING_MIO14 is not set -CONFIG_RT_USING_MIO15=y -CONFIG_I2C_USE_CONTROLLER=y -CONFIG_RT_USING_I2C0=y -# CONFIG_RT_USING_I2C1 is not set -# CONFIG_RT_USING_I2C2 is not set -# CONFIG_RT_USING_I2C3 is not set +# CONFIG_RT_USING_MIO15 is not set +# CONFIG_I2C_USE_CONTROLLER is not set CONFIG_BSP_USING_SDIF=y CONFIG_BSP_USING_SDCARD_FATFS=y -CONFIG_BSP_USING_SDCARD_PARTITION="sd0" -# CONFIG_USING_SDIF0 is not set +CONFIG_USING_SDIF0=y +# CONFIG_USE_SDIF0_TF is not set +CONFIG_USE_SDIF0_EMMC=y CONFIG_USING_SDIF1=y -# CONFIG_USING_EMMC is not set +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set CONFIG_BSP_USING_DC=y -# CONFIG_RT_USING_DC_CHANNEL0 is not set -CONFIG_RT_USING_DC_CHANNEL1=y +CONFIG_RT_USING_DC_CHANNEL0=y +# CONFIG_RT_USING_DC_CHANNEL1 is not set # CONFIG_BSP_USING_XHCI is not set # CONFIG_BSP_USING_PUSB2 is not set @@ -1326,6 +1323,7 @@ CONFIG_TARGET_E2000D=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="e2000" CONFIG_TARGET_TYPE_NAME="d" CONFIG_SOC_CORE_NUM=2 @@ -1334,7 +1332,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set @@ -1358,6 +1355,7 @@ CONFIG_BOARD_NAME="demo" # CONFIG_USE_TACHO_IOPAD is not set # CONFIG_USE_UART_IOPAD is not set # CONFIG_USE_THIRD_PARTY_IOPAD is not set +# CONFIG_FIREFLY_DEMO_BOARD is not set # CONFIG_CUS_DEMO_BOARD is not set # diff --git a/bsp/phytium/aarch32/configs/e2000d_demo_rtsmart.h b/bsp/phytium/aarch32/configs/e2000d_demo_rtsmart.h index 8cd62cc435..24f9866092 100644 --- a/bsp/phytium/aarch32/configs/e2000d_demo_rtsmart.h +++ b/bsp/phytium/aarch32/configs/e2000d_demo_rtsmart.h @@ -53,6 +53,7 @@ #define RT_USING_HEAP #define RT_USING_DEVICE #define RT_USING_DEVICE_OPS +#define RT_USING_THREADSAFE_PRINTF #define RT_USING_SCHED_THREAD_CTX #define RT_USING_CONSOLE #define RT_CONSOLEBUF_SIZE 256 @@ -114,6 +115,7 @@ #define RT_DFS_ELM_REENTRANT #define RT_DFS_ELM_MUTEX_TIMEOUT 3000 #define RT_USING_DFS_DEVFS +#define RT_USING_DFS_PTYFS #define RT_USING_DFS_MQUEUE #define RT_USING_PAGECACHE @@ -137,9 +139,7 @@ #define RT_USING_SERIAL_V1 #define RT_SERIAL_USING_DMA #define RT_SERIAL_RB_BUFSZ 1024 -#define RT_USING_TTY #define RT_USING_CAN -#define RT_CAN_USING_HDR #define RT_CAN_USING_CANFD #define RT_USING_I2C #define RT_USING_I2C_BITOPS @@ -282,6 +282,8 @@ #define LWP_ENABLE_ASID #define RT_LWP_SHM_MAX_NR 64 #define RT_USING_LDSO +#define LWP_USING_TERMINAL +#define LWP_PTY_MAX_PARIS_LIMIT 64 /* Memory management */ @@ -421,10 +423,8 @@ #define RT_USING_UART0 #define RT_USING_UART1 #define BSP_USING_SPI -#define RT_USING_SPIM2 +#define RT_USING_SPIM0 #define BSP_USING_CAN -#define RT_USING_CANFD -#define RT_USING_FILTER #define RT_USING_CAN0 #define RT_USING_CAN1 #define BSP_USING_GPIO @@ -434,18 +434,19 @@ #define BSP_USING_ETH #define RT_LWIP_PBUF_POOL_BUFSIZE 1700 #define BSP_USING_PWM -#define RT_USING_PWM6 +#define RT_USING_PWM2 #define BSP_USING_I2C #define I2C_USE_MIO -#define RT_USING_MIO15 -#define I2C_USE_CONTROLLER -#define RT_USING_I2C0 +#define RT_USING_MIO0 +#define RT_USING_MIO1 #define BSP_USING_SDIF #define BSP_USING_SDCARD_FATFS -#define BSP_USING_SDCARD_PARTITION "sd0" +#define USING_SDIF0 +#define USE_SDIF0_EMMC #define USING_SDIF1 +#define USE_SDIF1_TF #define BSP_USING_DC -#define RT_USING_DC_CHANNEL1 +#define RT_USING_DC_CHANNEL0 /* Board extended module Drivers */ diff --git a/bsp/phytium/aarch32/configs/e2000d_demo_rtthread b/bsp/phytium/aarch32/configs/e2000d_demo_rtthread index c7b8fea0d8..ddda850c8a 100644 --- a/bsp/phytium/aarch32/configs/e2000d_demo_rtthread +++ b/bsp/phytium/aarch32/configs/e2000d_demo_rtthread @@ -186,7 +186,7 @@ CONFIG_RT_USING_SERIAL_V1=y CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_SERIAL_RB_BUFSZ=1024 CONFIG_RT_USING_CAN=y -CONFIG_RT_CAN_USING_HDR=y +# CONFIG_RT_CAN_USING_HDR is not set CONFIG_RT_CAN_USING_CANFD=y # CONFIG_RT_USING_CPUTIME is not set CONFIG_RT_USING_I2C=y @@ -1215,15 +1215,15 @@ CONFIG_RT_USING_UART1=y # CONFIG_RT_USING_UART2 is not set # CONFIG_RT_USING_UART3 is not set CONFIG_BSP_USING_SPI=y -# CONFIG_RT_USING_SPIM0 is not set +CONFIG_RT_USING_SPIM0=y # CONFIG_RT_USING_SPIM1 is not set -CONFIG_RT_USING_SPIM2=y +# CONFIG_RT_USING_SPIM2 is not set # CONFIG_RT_USING_SPIM3 is not set CONFIG_BSP_USING_CAN=y -CONFIG_RT_USING_CANFD=y -CONFIG_RT_USING_FILTER=y -CONFIG_RT_USING_CAN0=y -CONFIG_RT_USING_CAN1=y +# CONFIG_RT_USING_CANFD is not set +# CONFIG_RT_USING_FILTER is not set +# CONFIG_RT_USING_CAN0 is not set +# CONFIG_RT_USING_CAN1 is not set CONFIG_BSP_USING_GPIO=y CONFIG_BSP_USING_QSPI=y CONFIG_RT_USING_QSPI0=y @@ -1234,16 +1234,16 @@ CONFIG_RT_LWIP_PBUF_POOL_BUFSIZE=1700 CONFIG_BSP_USING_PWM=y # CONFIG_RT_USING_PWM0 is not set # CONFIG_RT_USING_PWM1 is not set -# CONFIG_RT_USING_PWM2 is not set +CONFIG_RT_USING_PWM2=y # CONFIG_RT_USING_PWM3 is not set # CONFIG_RT_USING_PWM4 is not set # CONFIG_RT_USING_PWM5 is not set -CONFIG_RT_USING_PWM6=y +# CONFIG_RT_USING_PWM6 is not set # CONFIG_RT_USING_PWM7 is not set CONFIG_BSP_USING_I2C=y CONFIG_I2C_USE_MIO=y -# CONFIG_RT_USING_MIO0 is not set -# CONFIG_RT_USING_MIO1 is not set +CONFIG_RT_USING_MIO0=y +CONFIG_RT_USING_MIO1=y # CONFIG_RT_USING_MIO2 is not set # CONFIG_RT_USING_MIO3 is not set # CONFIG_RT_USING_MIO4 is not set @@ -1257,20 +1257,18 @@ CONFIG_I2C_USE_MIO=y # CONFIG_RT_USING_MIO12 is not set # CONFIG_RT_USING_MIO13 is not set # CONFIG_RT_USING_MIO14 is not set -CONFIG_RT_USING_MIO15=y -CONFIG_I2C_USE_CONTROLLER=y -CONFIG_RT_USING_I2C0=y -# CONFIG_RT_USING_I2C1 is not set -# CONFIG_RT_USING_I2C2 is not set -# CONFIG_RT_USING_I2C3 is not set +# CONFIG_RT_USING_MIO15 is not set +# CONFIG_I2C_USE_CONTROLLER is not set CONFIG_BSP_USING_SDIF=y CONFIG_BSP_USING_SDCARD_FATFS=y -CONFIG_BSP_USING_SDCARD_PARTITION="sd0" -# CONFIG_USING_SDIF0 is not set +CONFIG_USING_SDIF0=y +# CONFIG_USE_SDIF0_TF is not set +CONFIG_USE_SDIF0_EMMC=y CONFIG_USING_SDIF1=y -# CONFIG_USING_EMMC is not set +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set CONFIG_BSP_USING_DC=y -# CONFIG_RT_USING_DC_CHANNEL0 is not set +CONFIG_RT_USING_DC_CHANNEL0=y CONFIG_RT_USING_DC_CHANNEL1=y # CONFIG_BSP_USING_XHCI is not set # CONFIG_BSP_USING_PUSB2 is not set @@ -1295,6 +1293,7 @@ CONFIG_TARGET_E2000D=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="e2000" CONFIG_TARGET_TYPE_NAME="d" CONFIG_SOC_CORE_NUM=2 @@ -1303,7 +1302,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set @@ -1327,6 +1325,7 @@ CONFIG_BOARD_NAME="demo" # CONFIG_USE_TACHO_IOPAD is not set # CONFIG_USE_UART_IOPAD is not set # CONFIG_USE_THIRD_PARTY_IOPAD is not set +# CONFIG_E2000Q_DEMO_BOARD is not set # CONFIG_CUS_DEMO_BOARD is not set # diff --git a/bsp/phytium/aarch32/configs/e2000d_demo_rtthread.h b/bsp/phytium/aarch32/configs/e2000d_demo_rtthread.h index 4cbca1aaf2..7db829a50d 100644 --- a/bsp/phytium/aarch32/configs/e2000d_demo_rtthread.h +++ b/bsp/phytium/aarch32/configs/e2000d_demo_rtthread.h @@ -127,7 +127,6 @@ #define RT_SERIAL_USING_DMA #define RT_SERIAL_RB_BUFSZ 1024 #define RT_USING_CAN -#define RT_CAN_USING_HDR #define RT_CAN_USING_CANFD #define RT_USING_I2C #define RT_USING_I2C_BITOPS @@ -394,12 +393,8 @@ #define RT_USING_UART0 #define RT_USING_UART1 #define BSP_USING_SPI -#define RT_USING_SPIM2 +#define RT_USING_SPIM0 #define BSP_USING_CAN -#define RT_USING_CANFD -#define RT_USING_FILTER -#define RT_USING_CAN0 -#define RT_USING_CAN1 #define BSP_USING_GPIO #define BSP_USING_QSPI #define RT_USING_QSPI0 @@ -407,17 +402,19 @@ #define BSP_USING_ETH #define RT_LWIP_PBUF_POOL_BUFSIZE 1700 #define BSP_USING_PWM -#define RT_USING_PWM6 +#define RT_USING_PWM2 #define BSP_USING_I2C #define I2C_USE_MIO -#define RT_USING_MIO15 -#define I2C_USE_CONTROLLER -#define RT_USING_I2C0 +#define RT_USING_MIO0 +#define RT_USING_MIO1 #define BSP_USING_SDIF #define BSP_USING_SDCARD_FATFS -#define BSP_USING_SDCARD_PARTITION "sd0" +#define USING_SDIF0 +#define USE_SDIF0_EMMC #define USING_SDIF1 +#define USE_SDIF1_TF #define BSP_USING_DC +#define RT_USING_DC_CHANNEL0 #define RT_USING_DC_CHANNEL1 /* Board extended module Drivers */ diff --git a/bsp/phytium/aarch32/configs/e2000q_demo_rtsmart b/bsp/phytium/aarch32/configs/e2000q_demo_rtsmart index 3383732ae9..c9208e8d0e 100644 --- a/bsp/phytium/aarch32/configs/e2000q_demo_rtsmart +++ b/bsp/phytium/aarch32/configs/e2000q_demo_rtsmart @@ -162,6 +162,7 @@ CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000 # CONFIG_RT_DFS_ELM_USE_EXFAT is not set CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DFS_ROMFS is not set +CONFIG_RT_USING_DFS_PTYFS=y # CONFIG_RT_USING_DFS_CROMFS is not set # CONFIG_RT_USING_DFS_TMPFS is not set CONFIG_RT_USING_DFS_MQUEUE=y @@ -192,8 +193,6 @@ CONFIG_RT_USING_SERIAL_V1=y # CONFIG_RT_USING_SERIAL_V2 is not set CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_SERIAL_RB_BUFSZ=1024 -CONFIG_RT_USING_TTY=y -# CONFIG_RT_TTY_DEBUG is not set CONFIG_RT_USING_CAN=y # CONFIG_RT_CAN_USING_HDR is not set CONFIG_RT_CAN_USING_CANFD=y @@ -420,10 +419,11 @@ CONFIG_LWP_CONSOLE_INPUT_BUFFER_SIZE=1024 CONFIG_LWP_TID_MAX_NR=64 CONFIG_LWP_ENABLE_ASID=y CONFIG_RT_LWP_SHM_MAX_NR=64 -# CONFIG_LWP_UNIX98_PTY is not set CONFIG_RT_USING_LDSO=y # CONFIG_ELF_DEBUG_ENABLE is not set # CONFIG_ELF_LOAD_RANDOMIZE is not set +CONFIG_LWP_USING_TERMINAL=y +CONFIG_LWP_PTY_MAX_PARIS_LIMIT=64 # # Memory management @@ -1249,9 +1249,16 @@ CONFIG_RT_USING_SPIM0=y # CONFIG_RT_USING_SPIM1 is not set # CONFIG_RT_USING_SPIM2 is not set # CONFIG_RT_USING_SPIM3 is not set -# CONFIG_BSP_USING_CAN is not set +CONFIG_BSP_USING_CAN=y +# CONFIG_RT_USING_CANFD is not set +# CONFIG_RT_USING_FILTER is not set +CONFIG_RT_USING_CAN0=y +CONFIG_RT_USING_CAN1=y CONFIG_BSP_USING_GPIO=y -# CONFIG_BSP_USING_QSPI is not set +CONFIG_BSP_USING_QSPI=y +CONFIG_RT_USING_QSPI0=y +CONFIG_USING_QSPI_CHANNEL0=y +# CONFIG_USING_QSPI_CHANNEL1 is not set CONFIG_BSP_USING_ETH=y CONFIG_RT_LWIP_PBUF_POOL_BUFSIZE=1700 CONFIG_BSP_USING_PWM=y @@ -1282,7 +1289,14 @@ CONFIG_RT_USING_MIO1=y # CONFIG_RT_USING_MIO14 is not set # CONFIG_RT_USING_MIO15 is not set # CONFIG_I2C_USE_CONTROLLER is not set -# CONFIG_BSP_USING_SDIF is not set +CONFIG_BSP_USING_SDIF=y +CONFIG_BSP_USING_SDCARD_FATFS=y +CONFIG_USING_SDIF0=y +# CONFIG_USE_SDIF0_TF is not set +CONFIG_USE_SDIF0_EMMC=y +CONFIG_USING_SDIF1=y +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set CONFIG_BSP_USING_DC=y CONFIG_RT_USING_DC_CHANNEL0=y # CONFIG_RT_USING_DC_CHANNEL1 is not set @@ -1309,6 +1323,7 @@ CONFIG_TARGET_E2000Q=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="e2000" CONFIG_TARGET_TYPE_NAME="q" CONFIG_SOC_CORE_NUM=4 @@ -1317,7 +1332,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set @@ -1340,7 +1354,6 @@ CONFIG_E2000Q_DEMO_BOARD=y # # IO mux configuration when board start up # -# CONFIG_FIREFLY_DEMO_BOARD is not set # CONFIG_CUS_DEMO_BOARD is not set # diff --git a/bsp/phytium/aarch32/configs/e2000q_demo_rtsmart.h b/bsp/phytium/aarch32/configs/e2000q_demo_rtsmart.h index 560db767e0..56c5402ba1 100644 --- a/bsp/phytium/aarch32/configs/e2000q_demo_rtsmart.h +++ b/bsp/phytium/aarch32/configs/e2000q_demo_rtsmart.h @@ -115,6 +115,7 @@ #define RT_DFS_ELM_REENTRANT #define RT_DFS_ELM_MUTEX_TIMEOUT 3000 #define RT_USING_DFS_DEVFS +#define RT_USING_DFS_PTYFS #define RT_USING_DFS_MQUEUE #define RT_USING_PAGECACHE @@ -138,7 +139,6 @@ #define RT_USING_SERIAL_V1 #define RT_SERIAL_USING_DMA #define RT_SERIAL_RB_BUFSZ 1024 -#define RT_USING_TTY #define RT_USING_CAN #define RT_CAN_USING_CANFD #define RT_USING_I2C @@ -282,6 +282,8 @@ #define LWP_ENABLE_ASID #define RT_LWP_SHM_MAX_NR 64 #define RT_USING_LDSO +#define LWP_USING_TERMINAL +#define LWP_PTY_MAX_PARIS_LIMIT 64 /* Memory management */ @@ -422,7 +424,13 @@ #define RT_USING_UART1 #define BSP_USING_SPI #define RT_USING_SPIM0 +#define BSP_USING_CAN +#define RT_USING_CAN0 +#define RT_USING_CAN1 #define BSP_USING_GPIO +#define BSP_USING_QSPI +#define RT_USING_QSPI0 +#define USING_QSPI_CHANNEL0 #define BSP_USING_ETH #define RT_LWIP_PBUF_POOL_BUFSIZE 1700 #define BSP_USING_PWM @@ -431,6 +439,12 @@ #define I2C_USE_MIO #define RT_USING_MIO0 #define RT_USING_MIO1 +#define BSP_USING_SDIF +#define BSP_USING_SDCARD_FATFS +#define USING_SDIF0 +#define USE_SDIF0_EMMC +#define USING_SDIF1 +#define USE_SDIF1_TF #define BSP_USING_DC #define RT_USING_DC_CHANNEL0 diff --git a/bsp/phytium/aarch32/configs/e2000q_demo_rtthread b/bsp/phytium/aarch32/configs/e2000q_demo_rtthread index 6fa95ea3e8..1e8a6d0c2b 100644 --- a/bsp/phytium/aarch32/configs/e2000q_demo_rtthread +++ b/bsp/phytium/aarch32/configs/e2000q_demo_rtthread @@ -1219,9 +1219,16 @@ CONFIG_RT_USING_SPIM0=y # CONFIG_RT_USING_SPIM1 is not set # CONFIG_RT_USING_SPIM2 is not set # CONFIG_RT_USING_SPIM3 is not set -# CONFIG_BSP_USING_CAN is not set +CONFIG_BSP_USING_CAN=y +# CONFIG_RT_USING_CANFD is not set +# CONFIG_RT_USING_FILTER is not set +# CONFIG_RT_USING_CAN0 is not set +# CONFIG_RT_USING_CAN1 is not set CONFIG_BSP_USING_GPIO=y -# CONFIG_BSP_USING_QSPI is not set +CONFIG_BSP_USING_QSPI=y +CONFIG_RT_USING_QSPI0=y +CONFIG_USING_QSPI_CHANNEL0=y +# CONFIG_USING_QSPI_CHANNEL1 is not set CONFIG_BSP_USING_ETH=y CONFIG_RT_LWIP_PBUF_POOL_BUFSIZE=1700 CONFIG_BSP_USING_PWM=y @@ -1252,10 +1259,17 @@ CONFIG_RT_USING_MIO1=y # CONFIG_RT_USING_MIO14 is not set # CONFIG_RT_USING_MIO15 is not set # CONFIG_I2C_USE_CONTROLLER is not set -# CONFIG_BSP_USING_SDIF is not set +CONFIG_BSP_USING_SDIF=y +CONFIG_BSP_USING_SDCARD_FATFS=y +CONFIG_USING_SDIF0=y +# CONFIG_USE_SDIF0_TF is not set +CONFIG_USE_SDIF0_EMMC=y +CONFIG_USING_SDIF1=y +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set CONFIG_BSP_USING_DC=y CONFIG_RT_USING_DC_CHANNEL0=y -# CONFIG_RT_USING_DC_CHANNEL1 is not set +CONFIG_RT_USING_DC_CHANNEL1=y # CONFIG_BSP_USING_XHCI is not set # CONFIG_BSP_USING_PUSB2 is not set @@ -1279,6 +1293,7 @@ CONFIG_TARGET_E2000Q=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="e2000" CONFIG_TARGET_TYPE_NAME="q" CONFIG_SOC_CORE_NUM=4 @@ -1287,7 +1302,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set @@ -1310,7 +1324,6 @@ CONFIG_E2000Q_DEMO_BOARD=y # # IO mux configuration when board start up # -# CONFIG_FIREFLY_DEMO_BOARD is not set # CONFIG_CUS_DEMO_BOARD is not set # diff --git a/bsp/phytium/aarch32/configs/e2000q_demo_rtthread.h b/bsp/phytium/aarch32/configs/e2000q_demo_rtthread.h index 17213c998f..3952381102 100644 --- a/bsp/phytium/aarch32/configs/e2000q_demo_rtthread.h +++ b/bsp/phytium/aarch32/configs/e2000q_demo_rtthread.h @@ -394,7 +394,11 @@ #define RT_USING_UART1 #define BSP_USING_SPI #define RT_USING_SPIM0 +#define BSP_USING_CAN #define BSP_USING_GPIO +#define BSP_USING_QSPI +#define RT_USING_QSPI0 +#define USING_QSPI_CHANNEL0 #define BSP_USING_ETH #define RT_LWIP_PBUF_POOL_BUFSIZE 1700 #define BSP_USING_PWM @@ -403,8 +407,15 @@ #define I2C_USE_MIO #define RT_USING_MIO0 #define RT_USING_MIO1 +#define BSP_USING_SDIF +#define BSP_USING_SDCARD_FATFS +#define USING_SDIF0 +#define USE_SDIF0_EMMC +#define USING_SDIF1 +#define USE_SDIF1_TF #define BSP_USING_DC #define RT_USING_DC_CHANNEL0 +#define RT_USING_DC_CHANNEL1 /* Board extended module Drivers */ diff --git a/bsp/phytium/aarch32/configs/phytium_pi_rtsmart b/bsp/phytium/aarch32/configs/phytium_pi_rtsmart index 6d97a19f49..a1e4572046 100644 --- a/bsp/phytium/aarch32/configs/phytium_pi_rtsmart +++ b/bsp/phytium/aarch32/configs/phytium_pi_rtsmart @@ -162,6 +162,7 @@ CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000 # CONFIG_RT_DFS_ELM_USE_EXFAT is not set CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DFS_ROMFS is not set +CONFIG_RT_USING_DFS_PTYFS=y # CONFIG_RT_USING_DFS_CROMFS is not set # CONFIG_RT_USING_DFS_TMPFS is not set CONFIG_RT_USING_DFS_MQUEUE=y @@ -192,8 +193,6 @@ CONFIG_RT_USING_SERIAL_V1=y # CONFIG_RT_USING_SERIAL_V2 is not set CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_SERIAL_RB_BUFSZ=1024 -CONFIG_RT_USING_TTY=y -# CONFIG_RT_TTY_DEBUG is not set CONFIG_RT_USING_CAN=y # CONFIG_RT_CAN_USING_HDR is not set CONFIG_RT_CAN_USING_CANFD=y @@ -420,10 +419,11 @@ CONFIG_LWP_CONSOLE_INPUT_BUFFER_SIZE=1024 CONFIG_LWP_TID_MAX_NR=64 CONFIG_LWP_ENABLE_ASID=y CONFIG_RT_LWP_SHM_MAX_NR=64 -# CONFIG_LWP_UNIX98_PTY is not set CONFIG_RT_USING_LDSO=y # CONFIG_ELF_DEBUG_ENABLE is not set # CONFIG_ELF_LOAD_RANDOMIZE is not set +CONFIG_LWP_USING_TERMINAL=y +CONFIG_LWP_PTY_MAX_PARIS_LIMIT=64 # # Memory management @@ -1249,9 +1249,16 @@ CONFIG_RT_USING_SPIM0=y # CONFIG_RT_USING_SPIM1 is not set # CONFIG_RT_USING_SPIM2 is not set # CONFIG_RT_USING_SPIM3 is not set -# CONFIG_BSP_USING_CAN is not set +CONFIG_BSP_USING_CAN=y +# CONFIG_RT_USING_CANFD is not set +# CONFIG_RT_USING_FILTER is not set +CONFIG_RT_USING_CAN0=y +CONFIG_RT_USING_CAN1=y CONFIG_BSP_USING_GPIO=y -# CONFIG_BSP_USING_QSPI is not set +CONFIG_BSP_USING_QSPI=y +CONFIG_RT_USING_QSPI0=y +CONFIG_USING_QSPI_CHANNEL0=y +# CONFIG_USING_QSPI_CHANNEL1 is not set CONFIG_BSP_USING_ETH=y CONFIG_RT_LWIP_PBUF_POOL_BUFSIZE=1700 CONFIG_BSP_USING_PWM=y @@ -1282,7 +1289,14 @@ CONFIG_RT_USING_MIO1=y # CONFIG_RT_USING_MIO14 is not set # CONFIG_RT_USING_MIO15 is not set # CONFIG_I2C_USE_CONTROLLER is not set -# CONFIG_BSP_USING_SDIF is not set +CONFIG_BSP_USING_SDIF=y +CONFIG_BSP_USING_SDCARD_FATFS=y +# CONFIG_USING_SDIF0 is not set +# CONFIG_USE_SDIF0_TF is not set +# CONFIG_USE_SDIF0_EMMC is not set +CONFIG_USING_SDIF1=y +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set CONFIG_BSP_USING_DC=y CONFIG_RT_USING_DC_CHANNEL0=y # CONFIG_RT_USING_DC_CHANNEL1 is not set @@ -1309,6 +1323,7 @@ CONFIG_TARGET_PHYTIUMPI=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="phytiumpi" CONFIG_SOC_CORE_NUM=4 CONFIG_F32BIT_MEMORY_ADDRESS=0x80000000 @@ -1316,7 +1331,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set diff --git a/bsp/phytium/aarch32/configs/phytium_pi_rtsmart.h b/bsp/phytium/aarch32/configs/phytium_pi_rtsmart.h index 37466dda60..487404da67 100644 --- a/bsp/phytium/aarch32/configs/phytium_pi_rtsmart.h +++ b/bsp/phytium/aarch32/configs/phytium_pi_rtsmart.h @@ -115,6 +115,7 @@ #define RT_DFS_ELM_REENTRANT #define RT_DFS_ELM_MUTEX_TIMEOUT 3000 #define RT_USING_DFS_DEVFS +#define RT_USING_DFS_PTYFS #define RT_USING_DFS_MQUEUE #define RT_USING_PAGECACHE @@ -138,7 +139,6 @@ #define RT_USING_SERIAL_V1 #define RT_SERIAL_USING_DMA #define RT_SERIAL_RB_BUFSZ 1024 -#define RT_USING_TTY #define RT_USING_CAN #define RT_CAN_USING_CANFD #define RT_USING_I2C @@ -282,6 +282,8 @@ #define LWP_ENABLE_ASID #define RT_LWP_SHM_MAX_NR 64 #define RT_USING_LDSO +#define LWP_USING_TERMINAL +#define LWP_PTY_MAX_PARIS_LIMIT 64 /* Memory management */ @@ -422,7 +424,13 @@ #define RT_USING_UART1 #define BSP_USING_SPI #define RT_USING_SPIM0 +#define BSP_USING_CAN +#define RT_USING_CAN0 +#define RT_USING_CAN1 #define BSP_USING_GPIO +#define BSP_USING_QSPI +#define RT_USING_QSPI0 +#define USING_QSPI_CHANNEL0 #define BSP_USING_ETH #define RT_LWIP_PBUF_POOL_BUFSIZE 1700 #define BSP_USING_PWM @@ -431,6 +439,10 @@ #define I2C_USE_MIO #define RT_USING_MIO0 #define RT_USING_MIO1 +#define BSP_USING_SDIF +#define BSP_USING_SDCARD_FATFS +#define USING_SDIF1 +#define USE_SDIF1_TF #define BSP_USING_DC #define RT_USING_DC_CHANNEL0 diff --git a/bsp/phytium/aarch32/configs/phytium_pi_rtthread b/bsp/phytium/aarch32/configs/phytium_pi_rtthread index 5a4ca4888b..a3f2877cdc 100644 --- a/bsp/phytium/aarch32/configs/phytium_pi_rtthread +++ b/bsp/phytium/aarch32/configs/phytium_pi_rtthread @@ -1219,9 +1219,16 @@ CONFIG_RT_USING_SPIM0=y # CONFIG_RT_USING_SPIM1 is not set # CONFIG_RT_USING_SPIM2 is not set # CONFIG_RT_USING_SPIM3 is not set -# CONFIG_BSP_USING_CAN is not set +CONFIG_BSP_USING_CAN=y +# CONFIG_RT_USING_CANFD is not set +# CONFIG_RT_USING_FILTER is not set +# CONFIG_RT_USING_CAN0 is not set +# CONFIG_RT_USING_CAN1 is not set CONFIG_BSP_USING_GPIO=y -# CONFIG_BSP_USING_QSPI is not set +CONFIG_BSP_USING_QSPI=y +CONFIG_RT_USING_QSPI0=y +CONFIG_USING_QSPI_CHANNEL0=y +# CONFIG_USING_QSPI_CHANNEL1 is not set CONFIG_BSP_USING_ETH=y CONFIG_RT_LWIP_PBUF_POOL_BUFSIZE=1700 CONFIG_BSP_USING_PWM=y @@ -1252,10 +1259,17 @@ CONFIG_RT_USING_MIO1=y # CONFIG_RT_USING_MIO14 is not set # CONFIG_RT_USING_MIO15 is not set # CONFIG_I2C_USE_CONTROLLER is not set -# CONFIG_BSP_USING_SDIF is not set +CONFIG_BSP_USING_SDIF=y +CONFIG_BSP_USING_SDCARD_FATFS=y +# CONFIG_USING_SDIF0 is not set +# CONFIG_USE_SDIF0_TF is not set +# CONFIG_USE_SDIF0_EMMC is not set +CONFIG_USING_SDIF1=y +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set CONFIG_BSP_USING_DC=y CONFIG_RT_USING_DC_CHANNEL0=y -# CONFIG_RT_USING_DC_CHANNEL1 is not set +CONFIG_RT_USING_DC_CHANNEL1=y # CONFIG_BSP_USING_XHCI is not set # CONFIG_BSP_USING_PUSB2 is not set @@ -1279,6 +1293,7 @@ CONFIG_TARGET_PHYTIUMPI=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="phytiumpi" CONFIG_SOC_CORE_NUM=4 CONFIG_F32BIT_MEMORY_ADDRESS=0x80000000 @@ -1286,7 +1301,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set @@ -1294,6 +1308,7 @@ CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # # Board Configuration # +# CONFIG_E2000D_DEMO_BOARD is not set CONFIG_BOARD_NAME="firefly" # CONFIG_USE_SPI_IOPAD is not set # CONFIG_USE_GPIO_IOPAD is not set diff --git a/bsp/phytium/aarch32/configs/phytium_pi_rtthread.h b/bsp/phytium/aarch32/configs/phytium_pi_rtthread.h index 137ebf33c2..986c3bb5c8 100644 --- a/bsp/phytium/aarch32/configs/phytium_pi_rtthread.h +++ b/bsp/phytium/aarch32/configs/phytium_pi_rtthread.h @@ -394,7 +394,11 @@ #define RT_USING_UART1 #define BSP_USING_SPI #define RT_USING_SPIM0 +#define BSP_USING_CAN #define BSP_USING_GPIO +#define BSP_USING_QSPI +#define RT_USING_QSPI0 +#define USING_QSPI_CHANNEL0 #define BSP_USING_ETH #define RT_LWIP_PBUF_POOL_BUFSIZE 1700 #define BSP_USING_PWM @@ -403,8 +407,13 @@ #define I2C_USE_MIO #define RT_USING_MIO0 #define RT_USING_MIO1 +#define BSP_USING_SDIF +#define BSP_USING_SDCARD_FATFS +#define USING_SDIF1 +#define USE_SDIF1_TF #define BSP_USING_DC #define RT_USING_DC_CHANNEL0 +#define RT_USING_DC_CHANNEL1 /* Board extended module Drivers */ diff --git a/bsp/phytium/aarch32/rtconfig.h b/bsp/phytium/aarch32/rtconfig.h index 137ebf33c2..986c3bb5c8 100644 --- a/bsp/phytium/aarch32/rtconfig.h +++ b/bsp/phytium/aarch32/rtconfig.h @@ -394,7 +394,11 @@ #define RT_USING_UART1 #define BSP_USING_SPI #define RT_USING_SPIM0 +#define BSP_USING_CAN #define BSP_USING_GPIO +#define BSP_USING_QSPI +#define RT_USING_QSPI0 +#define USING_QSPI_CHANNEL0 #define BSP_USING_ETH #define RT_LWIP_PBUF_POOL_BUFSIZE 1700 #define BSP_USING_PWM @@ -403,8 +407,13 @@ #define I2C_USE_MIO #define RT_USING_MIO0 #define RT_USING_MIO1 +#define BSP_USING_SDIF +#define BSP_USING_SDCARD_FATFS +#define USING_SDIF1 +#define USE_SDIF1_TF #define BSP_USING_DC #define RT_USING_DC_CHANNEL0 +#define RT_USING_DC_CHANNEL1 /* Board extended module Drivers */ diff --git a/bsp/phytium/aarch64/.config b/bsp/phytium/aarch64/.config index 60c3f9756e..a4eb4a3fec 100644 --- a/bsp/phytium/aarch64/.config +++ b/bsp/phytium/aarch64/.config @@ -1279,7 +1279,12 @@ CONFIG_RT_USING_MIO10=y # CONFIG_RT_USING_MIO14 is not set # CONFIG_RT_USING_MIO15 is not set # CONFIG_I2C_USE_CONTROLLER is not set -# CONFIG_BSP_USING_SDIF is not set +CONFIG_BSP_USING_SDIF=y +CONFIG_BSP_USING_SDCARD_FATFS=y +# CONFIG_USING_SDIF0 is not set +CONFIG_USING_SDIF1=y +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set CONFIG_BSP_USING_DC=y # CONFIG_RT_USING_DC_CHANNEL0 is not set # CONFIG_RT_USING_DC_CHANNEL1 is not set @@ -1308,6 +1313,7 @@ CONFIG_TARGET_PHYTIUMPI=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="phytiumpi" CONFIG_SOC_CORE_NUM=4 CONFIG_F32BIT_MEMORY_ADDRESS=0x80000000 @@ -1315,7 +1321,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set diff --git a/bsp/phytium/aarch64/applications/mnt.c b/bsp/phytium/aarch64/applications/mnt.c deleted file mode 100644 index 202f29ed89..0000000000 --- a/bsp/phytium/aarch64/applications/mnt.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2006-2023, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Email: opensource_embedded@phytium.com.cn - * - * Change Logs: - * Date Author Notes - * 2023-04-27 huanghe first version - * 2023-07-14 liqiaozhong add SD file sys mount func - * - */ -#include -#if defined(RT_USING_DFS) -#include - -#include -#include - -static int ram_disk_mount(const char *mount_point) -{ -#ifdef RT_USING_DFS_RAMFS - extern struct dfs_ramfs *dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size); - - rt_uint8_t *pool = RT_NULL; - rt_size_t size = 8 * 1024 * 1024; - rt_err_t err = RT_EOK; - - pool = rt_malloc(size); - if (pool == RT_NULL) - { - LOG_E("Malloc fail!"); - } - - err = dfs_mount(RT_NULL, mount_point, "ram", 0, (const void *)dfs_ramfs_create(pool, size)); - if (err == RT_EOK) - { - LOG_I("RAM file system initializated!"); - } - else - { - LOG_E("RAM file system initializate failed!, err = %d", err); - } -#endif - - return RT_EOK; -} - -#ifdef BSP_USING_SDCARD_FATFS -extern void fsdif_change(void); -static int sd_disk_try_mount(char *device_name, char *mount_point, char *fs_type_name, int mkfs_count) -{ - struct statfs fs_stat; - int rc = 0; - - LOG_I("mount(\"%s\",\"%s\",\"%s\");", device_name, mount_point, fs_type_name); - - if (rt_device_find(device_name) == NULL) - { - LOG_I("%s not find!!!", device_name); - return -RT_EIO; - } - - mkdir(mount_point, 0); -_remount: - rc = dfs_mount(device_name, mount_point, fs_type_name, 0, 0); - if (rc == 0) - { - LOG_I("mounted %s on %s", device_name, mount_point); - if (dfs_statfs(mount_point, &fs_stat) >= 0) - { - LOG_I("%s size:%d, total: %d, free: %d", mount_point, - fs_stat.f_bsize, fs_stat.f_blocks, fs_stat.f_bfree); - } - } - else - { - if (mkfs_count > 0) - { - /* LOG_I("[%s]try mkfs -t %s %s ", mkfs_count, fs_type_name, device_name); - dfs_mkfs(fs_type_name, device_name); */ - mkfs_count--; - LOG_E("%s is not in %s, please format first !!!", device_name, fs_type_name); - goto _remount; - } - - LOG_I("mount failed :%d ", rc); - return -RT_EIO; - } - - return RT_EOK; -} - -static void sd_filesytem_task_entry(void *parameter) -{ - int result; - LOG_D("sdio host change: %d", change); - mmcsd_wait_cd_changed(0); /* clear */ - fsdif_change(); /* send cd change to host */ - - /* block until plug/unplug event happens */ - result = mmcsd_wait_cd_changed(RT_WAITING_FOREVER); - if (result == MMCSD_HOST_PLUGED) - { - rt_kprintf("mmcsd change pluged \n"); - /* mount sdcard partition as / */ - if (RT_EOK == sd_disk_try_mount(BSP_USING_SDCARD_PARTITION, "/", "elm", 0)) - { - ram_disk_mount("/ram"); /* mount ramdisk if configured */ - } - } -} - -int filesystem_mount(void) -{ - rt_thread_t tid; - tid = rt_thread_create("sd_filesytem", sd_filesytem_task_entry, - RT_NULL, - 4096, - RT_THREAD_PRIORITY_MAX - 2, 20); - if (tid != RT_NULL) - { - rt_thread_startup(tid); - } - else - { - LOG_E("create sd mount task error!"); - } - - return RT_EOK; -} -INIT_APP_EXPORT(filesystem_mount); - -#else -static int filesystem_mount(void) -{ - return ram_disk_mount("/"); /* mount ramdisk as / */ -} -INIT_ENV_EXPORT(filesystem_mount); -#endif // #ifdef BSP_USING_SDCARD_FATFS -#endif // #if defined(RT_USING_DFS) \ No newline at end of file diff --git a/bsp/phytium/aarch64/configs/e2000d_demo_rtsmart b/bsp/phytium/aarch64/configs/e2000d_demo_rtsmart index 41262aded0..8f31850ed9 100644 --- a/bsp/phytium/aarch64/configs/e2000d_demo_rtsmart +++ b/bsp/phytium/aarch64/configs/e2000d_demo_rtsmart @@ -165,6 +165,7 @@ CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000 # CONFIG_RT_DFS_ELM_USE_EXFAT is not set CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DFS_ROMFS is not set +CONFIG_RT_USING_DFS_PTYFS=y # CONFIG_RT_USING_DFS_CROMFS is not set # CONFIG_RT_USING_DFS_TMPFS is not set # CONFIG_RT_USING_DFS_MQUEUE is not set @@ -195,8 +196,6 @@ CONFIG_RT_USING_SERIAL_V1=y # CONFIG_RT_USING_SERIAL_V2 is not set CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_SERIAL_RB_BUFSZ=64 -CONFIG_RT_USING_TTY=y -# CONFIG_RT_TTY_DEBUG is not set CONFIG_RT_USING_CAN=y CONFIG_RT_CAN_USING_HDR=y CONFIG_RT_CAN_USING_CANFD=y @@ -385,7 +384,35 @@ CONFIG_LWIP_NETIF_LOOPBACK=0 # CONFIG_RT_LWIP_USING_HW_CHECKSUM is not set CONFIG_RT_LWIP_USING_PING=y # CONFIG_LWIP_USING_DHCPD is not set -# CONFIG_RT_LWIP_DEBUG is not set +CONFIG_RT_LWIP_DEBUG=y +# CONFIG_RT_LWIP_SYS_DEBUG is not set +# CONFIG_RT_LWIP_ETHARP_DEBUG is not set +# CONFIG_RT_LWIP_PPP_DEBUG is not set +# CONFIG_RT_LWIP_MEM_DEBUG is not set +# CONFIG_RT_LWIP_MEMP_DEBUG is not set +# CONFIG_RT_LWIP_PBUF_DEBUG is not set +# CONFIG_RT_LWIP_API_LIB_DEBUG is not set +# CONFIG_RT_LWIP_API_MSG_DEBUG is not set +# CONFIG_RT_LWIP_TCPIP_DEBUG is not set +CONFIG_RT_LWIP_NETIF_DEBUG=y +# CONFIG_RT_LWIP_SOCKETS_DEBUG is not set +# CONFIG_RT_LWIP_DNS_DEBUG is not set +# CONFIG_RT_LWIP_AUTOIP_DEBUG is not set +# CONFIG_RT_LWIP_DHCP_DEBUG is not set +# CONFIG_RT_LWIP_IP_DEBUG is not set +# CONFIG_RT_LWIP_IP_REASS_DEBUG is not set +# CONFIG_RT_LWIP_ICMP_DEBUG is not set +# CONFIG_RT_LWIP_IGMP_DEBUG is not set +# CONFIG_RT_LWIP_UDP_DEBUG is not set +# CONFIG_RT_LWIP_TCP_DEBUG is not set +# CONFIG_RT_LWIP_TCP_INPUT_DEBUG is not set +# CONFIG_RT_LWIP_TCP_OUTPUT_DEBUG is not set +# CONFIG_RT_LWIP_TCP_RTO_DEBUG is not set +# CONFIG_RT_LWIP_TCP_CWND_DEBUG is not set +# CONFIG_RT_LWIP_TCP_WND_DEBUG is not set +# CONFIG_RT_LWIP_TCP_FR_DEBUG is not set +# CONFIG_RT_LWIP_TCP_QLEN_DEBUG is not set +# CONFIG_RT_LWIP_TCP_RST_DEBUG is not set # CONFIG_RT_USING_AT is not set # @@ -419,10 +446,11 @@ CONFIG_RT_CH_MSG_MAX_NR=1024 CONFIG_LWP_CONSOLE_INPUT_BUFFER_SIZE=1024 CONFIG_LWP_TID_MAX_NR=64 CONFIG_RT_LWP_SHM_MAX_NR=64 -# CONFIG_LWP_UNIX98_PTY is not set CONFIG_RT_USING_LDSO=y # CONFIG_ELF_DEBUG_ENABLE is not set # CONFIG_ELF_LOAD_RANDOMIZE is not set +CONFIG_LWP_USING_TERMINAL=y +CONFIG_LWP_PTY_MAX_PARIS_LIMIT=64 # # Memory management @@ -1273,9 +1301,9 @@ CONFIG_RT_USING_SPIM2=y CONFIG_RT_USING_SPIM3=y CONFIG_BSP_USING_CAN=y CONFIG_RT_USING_CANFD=y -# CONFIG_RT_USING_FILTER is not set +CONFIG_RT_USING_FILTER=y CONFIG_RT_USING_CAN0=y -# CONFIG_RT_USING_CAN1 is not set +CONFIG_RT_USING_CAN1=y CONFIG_BSP_USING_GPIO=y CONFIG_BSP_USING_QSPI=y CONFIG_RT_USING_QSPI0=y @@ -1311,8 +1339,17 @@ CONFIG_I2C_USE_MIO=y # CONFIG_RT_USING_MIO14 is not set CONFIG_RT_USING_MIO15=y # CONFIG_I2C_USE_CONTROLLER is not set -# CONFIG_BSP_USING_SDIF is not set -# CONFIG_BSP_USING_DC is not set +CONFIG_BSP_USING_SDIF=y +CONFIG_BSP_USING_SDCARD_FATFS=y +CONFIG_USING_SDIF0=y +# CONFIG_USE_SDIF0_TF is not set +CONFIG_USE_SDIF0_EMMC=y +CONFIG_USING_SDIF1=y +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set +CONFIG_BSP_USING_DC=y +# CONFIG_RT_USING_DC_CHANNEL0 is not set +CONFIG_RT_USING_DC_CHANNEL1=y # CONFIG_BSP_USING_XHCI is not set # CONFIG_BSP_USING_PUSB2 is not set @@ -1338,6 +1375,7 @@ CONFIG_TARGET_E2000D=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="e2000" CONFIG_TARGET_TYPE_NAME="d" CONFIG_SOC_CORE_NUM=2 @@ -1346,7 +1384,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set diff --git a/bsp/phytium/aarch64/configs/e2000d_demo_rtsmart.h b/bsp/phytium/aarch64/configs/e2000d_demo_rtsmart.h index d3d78bf47a..6fbe114007 100644 --- a/bsp/phytium/aarch64/configs/e2000d_demo_rtsmart.h +++ b/bsp/phytium/aarch64/configs/e2000d_demo_rtsmart.h @@ -122,6 +122,7 @@ #define RT_DFS_ELM_REENTRANT #define RT_DFS_ELM_MUTEX_TIMEOUT 3000 #define RT_USING_DFS_DEVFS +#define RT_USING_DFS_PTYFS #define RT_USING_PAGECACHE /* page cache config */ @@ -144,7 +145,6 @@ #define RT_USING_SERIAL_V1 #define RT_SERIAL_USING_DMA #define RT_SERIAL_RB_BUFSZ 64 -#define RT_USING_TTY #define RT_USING_CAN #define RT_CAN_USING_HDR #define RT_CAN_USING_CANFD @@ -257,6 +257,8 @@ #define LWIP_SO_LINGER 0 #define LWIP_NETIF_LOOPBACK 0 #define RT_LWIP_USING_PING +#define RT_LWIP_DEBUG +#define RT_LWIP_NETIF_DEBUG /* Memory protection */ @@ -279,6 +281,8 @@ #define LWP_TID_MAX_NR 64 #define RT_LWP_SHM_MAX_NR 64 #define RT_USING_LDSO +#define LWP_USING_TERMINAL +#define LWP_PTY_MAX_PARIS_LIMIT 64 /* Memory management */ @@ -427,7 +431,9 @@ #define RT_USING_SPIM3 #define BSP_USING_CAN #define RT_USING_CANFD +#define RT_USING_FILTER #define RT_USING_CAN0 +#define RT_USING_CAN1 #define BSP_USING_GPIO #define BSP_USING_QSPI #define RT_USING_QSPI0 @@ -439,6 +445,14 @@ #define BSP_USING_I2C #define I2C_USE_MIO #define RT_USING_MIO15 +#define BSP_USING_SDIF +#define BSP_USING_SDCARD_FATFS +#define USING_SDIF0 +#define USE_SDIF0_EMMC +#define USING_SDIF1 +#define USE_SDIF1_TF +#define BSP_USING_DC +#define RT_USING_DC_CHANNEL1 /* Board extended module Drivers */ diff --git a/bsp/phytium/aarch64/configs/e2000d_demo_rtthread b/bsp/phytium/aarch64/configs/e2000d_demo_rtthread index a2e42a4dab..933708b82a 100644 --- a/bsp/phytium/aarch64/configs/e2000d_demo_rtthread +++ b/bsp/phytium/aarch64/configs/e2000d_demo_rtthread @@ -41,7 +41,7 @@ CONFIG_RT_KSERVICE_USING_STDLIB=y CONFIG_RT_KPRINTF_USING_LONGLONG=y CONFIG_RT_USING_DEBUG=y CONFIG_RT_DEBUGING_COLOR=y -CONFIG_RT_DEBUGING_CONTEXT=y +# CONFIG_RT_DEBUGING_CONTEXT is not set # CONFIG_RT_DEBUGING_AUTO_INIT is not set # CONFIG_RT_DEBUGING_PAGE_LEAK is not set # CONFIG_RT_DEBUGING_SPINLOCK is not set @@ -1283,7 +1283,14 @@ CONFIG_I2C_USE_MIO=y # CONFIG_RT_USING_MIO14 is not set CONFIG_RT_USING_MIO15=y # CONFIG_I2C_USE_CONTROLLER is not set -# CONFIG_BSP_USING_SDIF is not set +CONFIG_BSP_USING_SDIF=y +CONFIG_BSP_USING_SDCARD_FATFS=y +CONFIG_USING_SDIF0=y +# CONFIG_USE_SDIF0_TF is not set +CONFIG_USE_SDIF0_EMMC=y +CONFIG_USING_SDIF1=y +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set CONFIG_BSP_USING_DC=y # CONFIG_RT_USING_DC_CHANNEL0 is not set CONFIG_RT_USING_DC_CHANNEL1=y @@ -1312,6 +1319,7 @@ CONFIG_TARGET_E2000D=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="e2000" CONFIG_TARGET_TYPE_NAME="d" CONFIG_SOC_CORE_NUM=2 @@ -1320,7 +1328,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set diff --git a/bsp/phytium/aarch64/configs/e2000d_demo_rtthread.h b/bsp/phytium/aarch64/configs/e2000d_demo_rtthread.h index 28e4797cf6..18021fbfc5 100644 --- a/bsp/phytium/aarch64/configs/e2000d_demo_rtthread.h +++ b/bsp/phytium/aarch64/configs/e2000d_demo_rtthread.h @@ -30,7 +30,6 @@ #define RT_KPRINTF_USING_LONGLONG #define RT_USING_DEBUG #define RT_DEBUGING_COLOR -#define RT_DEBUGING_CONTEXT /* Inter-Thread communication */ @@ -411,6 +410,12 @@ #define BSP_USING_I2C #define I2C_USE_MIO #define RT_USING_MIO15 +#define BSP_USING_SDIF +#define BSP_USING_SDCARD_FATFS +#define USING_SDIF0 +#define USE_SDIF0_EMMC +#define USING_SDIF1 +#define USE_SDIF1_TF #define BSP_USING_DC #define RT_USING_DC_CHANNEL1 diff --git a/bsp/phytium/aarch64/configs/e2000q_demo_rtsmart b/bsp/phytium/aarch64/configs/e2000q_demo_rtsmart index 5ab396ebda..2365473cbe 100644 --- a/bsp/phytium/aarch64/configs/e2000q_demo_rtsmart +++ b/bsp/phytium/aarch64/configs/e2000q_demo_rtsmart @@ -165,6 +165,7 @@ CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000 # CONFIG_RT_DFS_ELM_USE_EXFAT is not set CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DFS_ROMFS is not set +CONFIG_RT_USING_DFS_PTYFS=y # CONFIG_RT_USING_DFS_CROMFS is not set # CONFIG_RT_USING_DFS_TMPFS is not set # CONFIG_RT_USING_DFS_MQUEUE is not set @@ -195,8 +196,6 @@ CONFIG_RT_USING_SERIAL_V1=y # CONFIG_RT_USING_SERIAL_V2 is not set CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_SERIAL_RB_BUFSZ=64 -CONFIG_RT_USING_TTY=y -# CONFIG_RT_TTY_DEBUG is not set CONFIG_RT_USING_CAN=y CONFIG_RT_CAN_USING_HDR=y CONFIG_RT_CAN_USING_CANFD=y @@ -447,10 +446,11 @@ CONFIG_RT_CH_MSG_MAX_NR=1024 CONFIG_LWP_CONSOLE_INPUT_BUFFER_SIZE=1024 CONFIG_LWP_TID_MAX_NR=64 CONFIG_RT_LWP_SHM_MAX_NR=64 -# CONFIG_LWP_UNIX98_PTY is not set CONFIG_RT_USING_LDSO=y # CONFIG_ELF_DEBUG_ENABLE is not set # CONFIG_ELF_LOAD_RANDOMIZE is not set +CONFIG_LWP_USING_TERMINAL=y +CONFIG_LWP_PTY_MAX_PARIS_LIMIT=64 # # Memory management @@ -1341,11 +1341,15 @@ CONFIG_RT_USING_MIO15=y # CONFIG_I2C_USE_CONTROLLER is not set CONFIG_BSP_USING_SDIF=y CONFIG_BSP_USING_SDCARD_FATFS=y -CONFIG_BSP_USING_SDCARD_PARTITION="sd0" -# CONFIG_USING_SDIF0 is not set +CONFIG_USING_SDIF0=y +# CONFIG_USE_SDIF0_TF is not set +CONFIG_USE_SDIF0_EMMC=y CONFIG_USING_SDIF1=y -# CONFIG_USING_EMMC is not set -# CONFIG_BSP_USING_DC is not set +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set +CONFIG_BSP_USING_DC=y +# CONFIG_RT_USING_DC_CHANNEL0 is not set +CONFIG_RT_USING_DC_CHANNEL1=y # CONFIG_BSP_USING_XHCI is not set # CONFIG_BSP_USING_PUSB2 is not set @@ -1371,6 +1375,7 @@ CONFIG_TARGET_E2000Q=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="e2000" CONFIG_TARGET_TYPE_NAME="q" CONFIG_SOC_CORE_NUM=4 @@ -1379,7 +1384,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set diff --git a/bsp/phytium/aarch64/configs/e2000q_demo_rtsmart.h b/bsp/phytium/aarch64/configs/e2000q_demo_rtsmart.h index f7e611a018..fd88a047a8 100644 --- a/bsp/phytium/aarch64/configs/e2000q_demo_rtsmart.h +++ b/bsp/phytium/aarch64/configs/e2000q_demo_rtsmart.h @@ -122,6 +122,7 @@ #define RT_DFS_ELM_REENTRANT #define RT_DFS_ELM_MUTEX_TIMEOUT 3000 #define RT_USING_DFS_DEVFS +#define RT_USING_DFS_PTYFS #define RT_USING_PAGECACHE /* page cache config */ @@ -144,7 +145,6 @@ #define RT_USING_SERIAL_V1 #define RT_SERIAL_USING_DMA #define RT_SERIAL_RB_BUFSZ 64 -#define RT_USING_TTY #define RT_USING_CAN #define RT_CAN_USING_HDR #define RT_CAN_USING_CANFD @@ -281,6 +281,8 @@ #define LWP_TID_MAX_NR 64 #define RT_LWP_SHM_MAX_NR 64 #define RT_USING_LDSO +#define LWP_USING_TERMINAL +#define LWP_PTY_MAX_PARIS_LIMIT 64 /* Memory management */ @@ -445,8 +447,12 @@ #define RT_USING_MIO15 #define BSP_USING_SDIF #define BSP_USING_SDCARD_FATFS -#define BSP_USING_SDCARD_PARTITION "sd0" +#define USING_SDIF0 +#define USE_SDIF0_EMMC #define USING_SDIF1 +#define USE_SDIF1_TF +#define BSP_USING_DC +#define RT_USING_DC_CHANNEL1 /* Board extended module Drivers */ diff --git a/bsp/phytium/aarch64/configs/e2000q_demo_rtthread b/bsp/phytium/aarch64/configs/e2000q_demo_rtthread index 88cc33eca6..df12663363 100644 --- a/bsp/phytium/aarch64/configs/e2000q_demo_rtthread +++ b/bsp/phytium/aarch64/configs/e2000q_demo_rtthread @@ -41,7 +41,7 @@ CONFIG_RT_KSERVICE_USING_STDLIB=y CONFIG_RT_KPRINTF_USING_LONGLONG=y CONFIG_RT_USING_DEBUG=y CONFIG_RT_DEBUGING_COLOR=y -CONFIG_RT_DEBUGING_CONTEXT=y +# CONFIG_RT_DEBUGING_CONTEXT is not set # CONFIG_RT_DEBUGING_AUTO_INIT is not set # CONFIG_RT_DEBUGING_PAGE_LEAK is not set # CONFIG_RT_DEBUGING_SPINLOCK is not set @@ -374,35 +374,7 @@ CONFIG_LWIP_NETIF_LOOPBACK=0 # CONFIG_RT_LWIP_USING_HW_CHECKSUM is not set CONFIG_RT_LWIP_USING_PING=y # CONFIG_LWIP_USING_DHCPD is not set -CONFIG_RT_LWIP_DEBUG=y -# CONFIG_RT_LWIP_SYS_DEBUG is not set -# CONFIG_RT_LWIP_ETHARP_DEBUG is not set -# CONFIG_RT_LWIP_PPP_DEBUG is not set -# CONFIG_RT_LWIP_MEM_DEBUG is not set -# CONFIG_RT_LWIP_MEMP_DEBUG is not set -# CONFIG_RT_LWIP_PBUF_DEBUG is not set -# CONFIG_RT_LWIP_API_LIB_DEBUG is not set -# CONFIG_RT_LWIP_API_MSG_DEBUG is not set -# CONFIG_RT_LWIP_TCPIP_DEBUG is not set -CONFIG_RT_LWIP_NETIF_DEBUG=y -# CONFIG_RT_LWIP_SOCKETS_DEBUG is not set -# CONFIG_RT_LWIP_DNS_DEBUG is not set -# CONFIG_RT_LWIP_AUTOIP_DEBUG is not set -# CONFIG_RT_LWIP_DHCP_DEBUG is not set -# CONFIG_RT_LWIP_IP_DEBUG is not set -# CONFIG_RT_LWIP_IP_REASS_DEBUG is not set -# CONFIG_RT_LWIP_ICMP_DEBUG is not set -# CONFIG_RT_LWIP_IGMP_DEBUG is not set -# CONFIG_RT_LWIP_UDP_DEBUG is not set -# CONFIG_RT_LWIP_TCP_DEBUG is not set -# CONFIG_RT_LWIP_TCP_INPUT_DEBUG is not set -# CONFIG_RT_LWIP_TCP_OUTPUT_DEBUG is not set -# CONFIG_RT_LWIP_TCP_RTO_DEBUG is not set -# CONFIG_RT_LWIP_TCP_CWND_DEBUG is not set -# CONFIG_RT_LWIP_TCP_WND_DEBUG is not set -# CONFIG_RT_LWIP_TCP_FR_DEBUG is not set -# CONFIG_RT_LWIP_TCP_QLEN_DEBUG is not set -# CONFIG_RT_LWIP_TCP_RST_DEBUG is not set +# CONFIG_RT_LWIP_DEBUG is not set # CONFIG_RT_USING_AT is not set # @@ -1273,9 +1245,9 @@ CONFIG_RT_USING_SPIM2=y CONFIG_RT_USING_SPIM3=y CONFIG_BSP_USING_CAN=y CONFIG_RT_USING_CANFD=y -CONFIG_RT_USING_FILTER=y +# CONFIG_RT_USING_FILTER is not set CONFIG_RT_USING_CAN0=y -CONFIG_RT_USING_CAN1=y +# CONFIG_RT_USING_CAN1 is not set CONFIG_BSP_USING_GPIO=y CONFIG_BSP_USING_QSPI=y CONFIG_RT_USING_QSPI0=y @@ -1313,13 +1285,15 @@ CONFIG_RT_USING_MIO15=y # CONFIG_I2C_USE_CONTROLLER is not set CONFIG_BSP_USING_SDIF=y CONFIG_BSP_USING_SDCARD_FATFS=y -CONFIG_BSP_USING_SDCARD_PARTITION="sd0" -# CONFIG_USING_SDIF0 is not set +CONFIG_USING_SDIF0=y +# CONFIG_USE_SDIF0_TF is not set +CONFIG_USE_SDIF0_EMMC=y CONFIG_USING_SDIF1=y -# CONFIG_USING_EMMC is not set +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set CONFIG_BSP_USING_DC=y -CONFIG_RT_USING_DC_CHANNEL0=y -# CONFIG_RT_USING_DC_CHANNEL1 is not set +# CONFIG_RT_USING_DC_CHANNEL0 is not set +CONFIG_RT_USING_DC_CHANNEL1=y # CONFIG_BSP_USING_XHCI is not set # CONFIG_BSP_USING_PUSB2 is not set @@ -1345,6 +1319,7 @@ CONFIG_TARGET_E2000Q=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="e2000" CONFIG_TARGET_TYPE_NAME="q" CONFIG_SOC_CORE_NUM=4 @@ -1353,7 +1328,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set diff --git a/bsp/phytium/aarch64/configs/e2000q_demo_rtthread.h b/bsp/phytium/aarch64/configs/e2000q_demo_rtthread.h index 8b384d856c..fdce69de6c 100644 --- a/bsp/phytium/aarch64/configs/e2000q_demo_rtthread.h +++ b/bsp/phytium/aarch64/configs/e2000q_demo_rtthread.h @@ -30,7 +30,6 @@ #define RT_KPRINTF_USING_LONGLONG #define RT_USING_DEBUG #define RT_DEBUGING_COLOR -#define RT_DEBUGING_CONTEXT /* Inter-Thread communication */ @@ -240,8 +239,6 @@ #define LWIP_SO_LINGER 0 #define LWIP_NETIF_LOOPBACK 0 #define RT_LWIP_USING_PING -#define RT_LWIP_DEBUG -#define RT_LWIP_NETIF_DEBUG /* Memory protection */ @@ -401,9 +398,7 @@ #define RT_USING_SPIM3 #define BSP_USING_CAN #define RT_USING_CANFD -#define RT_USING_FILTER #define RT_USING_CAN0 -#define RT_USING_CAN1 #define BSP_USING_GPIO #define BSP_USING_QSPI #define RT_USING_QSPI0 @@ -417,10 +412,12 @@ #define RT_USING_MIO15 #define BSP_USING_SDIF #define BSP_USING_SDCARD_FATFS -#define BSP_USING_SDCARD_PARTITION "sd0" +#define USING_SDIF0 +#define USE_SDIF0_EMMC #define USING_SDIF1 +#define USE_SDIF1_TF #define BSP_USING_DC -#define RT_USING_DC_CHANNEL0 +#define RT_USING_DC_CHANNEL1 /* Board extended module Drivers */ diff --git a/bsp/phytium/aarch64/configs/phytium_pi_rtsmart b/bsp/phytium/aarch64/configs/phytium_pi_rtsmart index fb8c15b393..a7ac979bcc 100644 --- a/bsp/phytium/aarch64/configs/phytium_pi_rtsmart +++ b/bsp/phytium/aarch64/configs/phytium_pi_rtsmart @@ -165,6 +165,7 @@ CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000 # CONFIG_RT_DFS_ELM_USE_EXFAT is not set CONFIG_RT_USING_DFS_DEVFS=y # CONFIG_RT_USING_DFS_ROMFS is not set +CONFIG_RT_USING_DFS_PTYFS=y # CONFIG_RT_USING_DFS_CROMFS is not set # CONFIG_RT_USING_DFS_TMPFS is not set # CONFIG_RT_USING_DFS_MQUEUE is not set @@ -195,8 +196,6 @@ CONFIG_RT_USING_SERIAL_V1=y # CONFIG_RT_USING_SERIAL_V2 is not set CONFIG_RT_SERIAL_USING_DMA=y CONFIG_RT_SERIAL_RB_BUFSZ=64 -CONFIG_RT_USING_TTY=y -# CONFIG_RT_TTY_DEBUG is not set CONFIG_RT_USING_CAN=y # CONFIG_RT_CAN_USING_HDR is not set CONFIG_RT_CAN_USING_CANFD=y @@ -419,10 +418,11 @@ CONFIG_RT_CH_MSG_MAX_NR=1024 CONFIG_LWP_CONSOLE_INPUT_BUFFER_SIZE=1024 CONFIG_LWP_TID_MAX_NR=64 CONFIG_RT_LWP_SHM_MAX_NR=64 -# CONFIG_LWP_UNIX98_PTY is not set CONFIG_RT_USING_LDSO=y # CONFIG_ELF_DEBUG_ENABLE is not set # CONFIG_ELF_LOAD_RANDOMIZE is not set +CONFIG_LWP_USING_TERMINAL=y +CONFIG_LWP_PTY_MAX_PARIS_LIMIT=64 # # Memory management @@ -1307,8 +1307,17 @@ CONFIG_RT_USING_MIO10=y # CONFIG_RT_USING_MIO14 is not set # CONFIG_RT_USING_MIO15 is not set # CONFIG_I2C_USE_CONTROLLER is not set -# CONFIG_BSP_USING_SDIF is not set -# CONFIG_BSP_USING_DC is not set +CONFIG_BSP_USING_SDIF=y +CONFIG_BSP_USING_SDCARD_FATFS=y +# CONFIG_USING_SDIF0 is not set +# CONFIG_USE_SDIF0_TF is not set +# CONFIG_USE_SDIF0_EMMC is not set +CONFIG_USING_SDIF1=y +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set +CONFIG_BSP_USING_DC=y +CONFIG_RT_USING_DC_CHANNEL0=y +CONFIG_RT_USING_DC_CHANNEL1=y # CONFIG_BSP_USING_XHCI is not set # CONFIG_BSP_USING_PUSB2 is not set @@ -1334,6 +1343,7 @@ CONFIG_TARGET_PHYTIUMPI=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="phytiumpi" CONFIG_SOC_CORE_NUM=4 CONFIG_F32BIT_MEMORY_ADDRESS=0x80000000 @@ -1341,7 +1351,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set diff --git a/bsp/phytium/aarch64/configs/phytium_pi_rtsmart.h b/bsp/phytium/aarch64/configs/phytium_pi_rtsmart.h index c9dd1d6418..cfdbf6208d 100644 --- a/bsp/phytium/aarch64/configs/phytium_pi_rtsmart.h +++ b/bsp/phytium/aarch64/configs/phytium_pi_rtsmart.h @@ -122,6 +122,7 @@ #define RT_DFS_ELM_REENTRANT #define RT_DFS_ELM_MUTEX_TIMEOUT 3000 #define RT_USING_DFS_DEVFS +#define RT_USING_DFS_PTYFS #define RT_USING_PAGECACHE /* page cache config */ @@ -144,7 +145,6 @@ #define RT_USING_SERIAL_V1 #define RT_SERIAL_USING_DMA #define RT_SERIAL_RB_BUFSZ 64 -#define RT_USING_TTY #define RT_USING_CAN #define RT_CAN_USING_CANFD #define RT_USING_I2C @@ -278,6 +278,8 @@ #define LWP_TID_MAX_NR 64 #define RT_LWP_SHM_MAX_NR 64 #define RT_USING_LDSO +#define LWP_USING_TERMINAL +#define LWP_PTY_MAX_PARIS_LIMIT 64 /* Memory management */ @@ -438,6 +440,13 @@ #define RT_USING_MIO1 #define RT_USING_MIO2 #define RT_USING_MIO10 +#define BSP_USING_SDIF +#define BSP_USING_SDCARD_FATFS +#define USING_SDIF1 +#define USE_SDIF1_TF +#define BSP_USING_DC +#define RT_USING_DC_CHANNEL0 +#define RT_USING_DC_CHANNEL1 /* Board extended module Drivers */ diff --git a/bsp/phytium/aarch64/configs/phytium_pi_rtthread b/bsp/phytium/aarch64/configs/phytium_pi_rtthread index 60c3f9756e..7e13aa1df4 100644 --- a/bsp/phytium/aarch64/configs/phytium_pi_rtthread +++ b/bsp/phytium/aarch64/configs/phytium_pi_rtthread @@ -1279,7 +1279,14 @@ CONFIG_RT_USING_MIO10=y # CONFIG_RT_USING_MIO14 is not set # CONFIG_RT_USING_MIO15 is not set # CONFIG_I2C_USE_CONTROLLER is not set -# CONFIG_BSP_USING_SDIF is not set +CONFIG_BSP_USING_SDIF=y +CONFIG_BSP_USING_SDCARD_FATFS=y +# CONFIG_USING_SDIF0 is not set +# CONFIG_USE_SDIF0_TF is not set +# CONFIG_USE_SDIF0_EMMC is not set +CONFIG_USING_SDIF1=y +CONFIG_USE_SDIF1_TF=y +# CONFIG_USE_SDIF1_EMMC is not set CONFIG_BSP_USING_DC=y # CONFIG_RT_USING_DC_CHANNEL0 is not set # CONFIG_RT_USING_DC_CHANNEL1 is not set @@ -1308,6 +1315,7 @@ CONFIG_TARGET_PHYTIUMPI=y # CONFIG_TARGET_E2000S is not set # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_PD2308 is not set CONFIG_SOC_NAME="phytiumpi" CONFIG_SOC_CORE_NUM=4 CONFIG_F32BIT_MEMORY_ADDRESS=0x80000000 @@ -1315,7 +1323,6 @@ CONFIG_F32BIT_MEMORY_LENGTH=0x80000000 CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000 CONFIG_F64BIT_MEMORY_LENGTH=0x800000000 CONFIG_TARGET_E2000=y -# CONFIG_USE_SPINLOCK is not set CONFIG_DEFAULT_DEBUG_PRINT_UART1=y # CONFIG_DEFAULT_DEBUG_PRINT_UART0 is not set # CONFIG_DEFAULT_DEBUG_PRINT_UART2 is not set diff --git a/bsp/phytium/aarch64/configs/phytium_pi_rtthread.h b/bsp/phytium/aarch64/configs/phytium_pi_rtthread.h index f53549b165..90c33ed22b 100644 --- a/bsp/phytium/aarch64/configs/phytium_pi_rtthread.h +++ b/bsp/phytium/aarch64/configs/phytium_pi_rtthread.h @@ -410,6 +410,10 @@ #define RT_USING_MIO1 #define RT_USING_MIO2 #define RT_USING_MIO10 +#define BSP_USING_SDIF +#define BSP_USING_SDCARD_FATFS +#define USING_SDIF1 +#define USE_SDIF1_TF #define BSP_USING_DC /* Board extended module Drivers */ diff --git a/bsp/phytium/aarch64/rtconfig.h b/bsp/phytium/aarch64/rtconfig.h index f53549b165..90c33ed22b 100644 --- a/bsp/phytium/aarch64/rtconfig.h +++ b/bsp/phytium/aarch64/rtconfig.h @@ -410,6 +410,10 @@ #define RT_USING_MIO1 #define RT_USING_MIO2 #define RT_USING_MIO10 +#define BSP_USING_SDIF +#define BSP_USING_SDCARD_FATFS +#define USING_SDIF1 +#define USE_SDIF1_TF #define BSP_USING_DC /* Board extended module Drivers */ diff --git a/bsp/phytium/doc/how_to_use_file_system.md b/bsp/phytium/doc/how_to_use_file_system.md new file mode 100644 index 0000000000..2590a520dc --- /dev/null +++ b/bsp/phytium/doc/how_to_use_file_system.md @@ -0,0 +1,59 @@ +# 如何使用 RT-Thread 文件系统 + +- 文件系统是开发者最常用的操作系统功能之一,RT-Thread 中很多功能也依赖文件系统完成,后面以 SD 卡作为文件系统介质,介绍一下 RT-Thread 中文件系统的制作和使用 + +- 飞腾派如果固件在 SD 卡中,不适用于本文档,可以参考[飞腾派SD文件系统](./use_phytium_pi_sd_image.md) + +## 配置 SD 驱动 + +- 打开配置 BSP_USING_SDIF,使能 SD 驱动 +- 打开配置 BSP_USING_SDCARD_FATFS,使能 SD 文件系统 +- 根据板子的实际情况选择 SD 控制器,SD0 打开 USING_SDIF0,SD1 打开 USING_SDIF1 +- 根据 SD 控制器连接的介质选择,TF 卡或者 eMMC,例如 USE_SDIF1_TF +- 在 mnt_sdcard.c 中指定根目录和 SD 设备 +- 进行编译生成镜像 + +## 识别 SD 设备 + +- 启动镜像后,输入 list devices,查看 SD 设备是否识别成功 + +``` +msh />list device +device type ref count +---------------- -------------------- ---------- +sd10 Block Device 0 --> SD1 的第一个分区 +sd1 Block Device 1 --> SD1 +sd0 Block Device 1 +zero Miscellaneous Device 0 +urandom Miscellaneous Device 0 +random Miscellaneous Device 0 +null Miscellaneous Device 0 +e0 Network Interface 1 +SPI3 SPI Bus 0 +SPI2 SPI Bus 0 +SPI1 SPI Bus 0 +SPI0 SPI Bus 0 +PWM6 PWM Device 0 +MIO15 I2C Bus 0 +DC1 Graphic Device 0 +uart1 Character Device 2 +uart0 Character Device 0 +QSPI0 SPI Bus 0 +CAN0 CAN Device 0 +``` + +## 制作 SD 文件系统 + +- 如果之前 SD 卡里没有 FAT32 文件系统,自动挂载可能不会成功,需要启动 RT-Thread 后格式化一个 SD 设备,然后 mount + +``` +msh />mkfs sd1 / elm +msh />mount sd1 / elm +mount device sd1(elm) onto / ... succeed! +``` + +- 文件系统制作好后,下次启动会自动挂载成根目录 + +## 使用 SD 文件系统 + +- 参考[RT-Thread 的文件系统使用说明](https://www.rt-thread.org/document/api/group___d_f_s.html) \ No newline at end of file diff --git a/bsp/phytium/doc/use_phytium_pi_sd_image.md b/bsp/phytium/doc/use_phytium_pi_sd_image.md index c323322146..0f8ca8db06 100644 --- a/bsp/phytium/doc/use_phytium_pi_sd_image.md +++ b/bsp/phytium/doc/use_phytium_pi_sd_image.md @@ -3,7 +3,6 @@ > 本文主要介绍如何在飞腾派中进行 RT-Thread 程序的开发和固化 - 飞腾派开发板是一款面向广大工程师和爱好者的开源硬件。主板处理器采用飞腾四核处理器,兼容 ARM v8 指令集,主频最高可达 1.8GHz -- 由于默认系统需要 16G 的空间,推荐使用 32G 的 SD 卡开发 RT-Thread 程序 ## 开发和调试程序 @@ -13,19 +12,19 @@ - 如果需要固化 RT-Thread 程序镜像在 SD 卡中,并实现开机自启动,可以使用下列的镜像,镜像中包含飞腾派的启动固件、飞腾派OS和一个 RT-Thread 的启动分区 -- [镜像下载链接](https://pan.baidu.com/s/1eL2ElKeVBU5GOyvzn2kl-A),提取码:PIIM +- [镜像下载链接](https://pan.baidu.com/s/1asc3MdcIh71-fkjS6Rptvw),提取码:PHYT - 下载之后解压,使用 sdcard-rtthread.img ``` - ----------------------------------------------------------------------------------- - | | | | - | 64MB (系统镜像) | 16G (Phytium Pi OS 根文件系统) | 4G (RT-Thread文件系统) | - | (无格式) | (ext4格式) | (fat32格式) | - ---------------------------------------------------------------------------------- + ------------------------------------------------------ + | | | + | 64MB (系统镜像) | 2G (RT-Thread文件系统) | + | (无格式) | (fat32格式) | + ----------------------------------------------------- ``` -- Windows 上使用 balenaEtcher 工具烧入一张 SD 卡(>= 32G),镜像的格式如下图所示,由3个分区组成,前 64MB 是二进制无格式的启动镜像,然后 16G 是 Phytium Pi OS 的根文件系统,格式为 ext4,最后 4G 是 RT-Thread 文件系统,格式为 fat32, +- Windows 上使用 balenaEtcher 工具烧入一张 SD 卡,镜像的格式如下图所示,由1个分区组成,前 64MB 是二进制无格式的启动镜像,后面 2G 是 RT-Thread 文件系统,格式为 fat32, - 在 linux 系统上,可以使用 dd 命令将镜像写入 SD 卡 (/dev/sdd) @@ -36,6 +35,7 @@ - SD 卡烧入完成之后插入飞腾派 SD 卡槽,重启飞腾派就会自动进入 RT-Thread 系统, ``` + PHYTIUM MCI: 0, PHYTIUM MCI: 1 Loading Environment from MMC... OK In: uart@2800d000 Out: uart@2800d000 @@ -44,95 +44,72 @@ scanning bus for devices... SATA link 0 timeout. AHCI 0001.0301 32 slots 1 ports 6 Gbps 0x1 impl SATA mode - flags: 64bit ncq stag pm led clo only pmp pio slum part ccc apst + flags: 64bit ncq stag pm led clo only pmp pio slum part ccc apst SATA link 0 timeout. AHCI 0001.0301 32 slots 1 ports 6 Gbps 0x1 impl SATA mode - flags: 64bit ncq stag pm led clo only pmp pio slum part ccc apst - Hit any key to stop autoboot: 0 - 739360 bytes read in 206 ms (3.4 MiB/s) + flags: 64bit ncq stag pm led clo only pmp pio slum part ccc apst + Hit any key to stop autoboot: 0 + 2740352 bytes read in 578 ms (4.5 MiB/s) ## Starting application at 0x80080000 ... \ | / - RT - Thread Operating System - / | \ 5.1.0 build Nov 9 2023 09:13:25 - 2006 - 2022 Copyright by RT-Thread team - do components initialization. - initialize rti_board_end:0 done - initialize dfs_init:0 done - initialize rt_work_sys_workqueue_init:0 done - initialize rt_mmcsd_core_init:0 done + / | \ 5.1.0 build Apr 9 2024 09:17:05 + 2006 - 2024 Copyright by RT-Thread team + lwIP-2.1.2 initialized! + [I/I2C] I2C bus [MIO15] registered + FXMAC OS Init Success! + Xmac e0 Initiailized! + Set netif e0 ip addr! + [E/drv] Auto negotiation is error. + FXMAC OS Init Success! + Xmac e1 Initiailized! + Set Xmac e1 ip addr! + Start Xmac NUM0 + Start Xmac NUM1 + [I/sal.skt] Socket Abstraction Layer initialize success. + msh />rt_device_find 0 + [I/SDIO] SD card capacity 31178752 KB. + found part[0], begin: 67108864, size: 2.0GB + [I/mnt.filesystem] sd00 mount to '/' + + msh />ls / + Directory /: + System Volume Inform + rtthread_a64.bin 2740352 + msh />df + disk free: 1.9 GB [ 4180704 block, 512 bytes per block ] + msh /> ``` -## 更新飞腾派 RT-Thread 镜像 - -- 有两种方式可以更新 SD 卡第三个分区中的 RT-Thread 镜像 -- 1. 将 SD 卡插入一台能识别第三个分区的电脑 (Ubuntu 系统能识别,Windows 可能不能识别),直接将 RT-Thread 镜像复制入 SD 卡 -- 2. 可以通过 u-boot 上传 RT-Thread 镜像,然后保存在 SD 卡第三个分区中,注意保存文件的大小 (0xc0000),要超过 tftpboot 加载的文件大小 - - ``` - Phytium-Pi#setenv ipaddr 192.168.4.20;setenv serverip 192.168.4.50;setenv gatewayip 192.168.4.1; - Phytium-Pi#tftpboot 0x90100000 rtthread_a64.bin - ethernet@3200c000: PHY present at 0 - ethernet@3200c000: Starting autonegotiation... - ethernet@3200c000: Autonegotiation complete - ethernet@3200c000: link up, 1000Mbps full-duplex (lpa: 0x2800) - ft sgmii speed 1000M! - Using ethernet@3200c000 device - TFTP from server 192.168.4.50; our IP address is 192.168.4.20 - Filename 'rtthread_a64.bin'. - Load address: 0x90100000 - Loading: ################################################################# - ################################################################# - ############### - 133.8 KiB/s - done - Bytes transferred = 739840 (b4a00 hex) - Phytium-Pi#fatls mmc 0:2 - rtthread-images/ - .Trash-1000/ - ram/ - System Volume Information/ - - 0 file(s), 4 dir(s) - - Phytium-Pi#fatwrite mmc 0:2 0x90100000 rtthread-images/rtthread_a64.bin 0xc0000 - 786432 bytes written in 398 ms (1.9 MiB/s) - Phytium-Pi#fatls mmc 0:2 rtthread-images - ./ - ../ - 786432 rtthread_a64.bin - 944384 rtsmart_a64.bin - 950828 rtsmart_a32.bin - 722580 rtthread_a32.bin - - 4 file(s), 2 dir(s) - - Phytium-Pi# - ``` ## 修改自启动的 RT-Thread 镜像 -- 通过在 u-boot 控制台修改 bootcmd,可以指定不同的 RT-Thread 镜像自启动,如下所示,指定启动 RT-Smart 镜像 `rtsmart_a64.bin` +- 通过在 u-boot 控制台修改 bootcmd,可以指定不同的 RT-Thread 镜像自启动,如下所示,指定启动 RT-Smart 镜像 `rtthread_a64.bin` - ``` - Phytium-Pi#printenv bootcmd - bootcmd=mw 0x32b301a8 0x275;mmc dev 0;mmc read 0x90000000 0x2000 0x10000;bootm 0x90000000#phytium - Phytium-Pi#setenv bootcmd "fatload mmc 0:2 0x80080000 rtthread-images/rtthread_a64.bin;dcache flush;go 0x80080000;" - Phytium-Pi#saveenv - ``` - - -## 切换成 linux 开发模式 - -- 本文提供的 RT-Thread 开发镜像中,有一个 linux 系统,需要的时候可以修改 bootcmd,切换成自启动 linux 系统 - - ``` - Phytium-Pi#setenv bootcmd "mw 0x32b301a8 0x275;mmc dev 0;mmc read 0x90000000 0x2000 0x10000;bootm 0x90000000#phytium" - Phytium-Pi#saveenv - Saving Environment to MMC... Writing to MMC(0)... OK - ``` +``` +Phytium-Pi#printenv bootcmd +bootcmd=mw 0x32b301a8 0x275;mmc dev 0;mmc read 0x90000000 0x2000 0x10000;bootm 0x90000000#phytium +Phytium-Pi#setenv bootcmd "fatload mmc 0:1 0x80080000 rtthread_a64.bin;dcache flush;go 0x80080000;" +Phytium-Pi#saveenv +``` ## 在 RT-Thread 应用中访问 SD 卡分区 -- 如前面介绍的,RT-Thread 应用可以使用第二个分区,分区文件系统格式为 FAT32 -- 打开配置 BSP_USING_SDCARD_FATFS 后, RT-Thread / RT-Smart 启动过程中会将 SD 卡挂载为根目录,将配置 BSP_USING_SDCARD_PARTITION 设置为 `sd1`,指定第二个分区为 RT-Thread 根目录,启动后创建的文件都会使用这个 SD 分区 \ No newline at end of file +- 如前面介绍的,参考 libraries/port/fboard_port/firefly/mnt_sdcard.c,启动后会将 SD 卡的第一个分区(2GB 大小)自动挂载到根目录下 + +``` +[I/SDIO] SD card capacity 31178752 KB. +found part[0], begin: 67108864, size: 2.0GB +[I/mnt.filesystem] sd00 mount to '/' + +msh /> +msh />ls +Directory /: +rtthread_a64.bin 2740352 +msh />df +disk free: 1.9 GB [ 4180704 block, 512 bytes per block ] +msh /> +``` + +- 如果需要替换 SD 卡中的 RT-Thread 镜像,直接取下 SD 卡插入 Windows/Ubuntu PC 中进行替换即可 \ No newline at end of file diff --git a/bsp/phytium/libraries/SConscript b/bsp/phytium/libraries/SConscript index 63e8a1766e..38576ed343 100644 --- a/bsp/phytium/libraries/SConscript +++ b/bsp/phytium/libraries/SConscript @@ -49,6 +49,28 @@ if GetDepend(['TARGET_D2000']): src += Glob(cwd+'/port/soc_port/d2000/*.c') path += [PHYTIUM_SDK_DIR + '/soc/d2000'] +# board port +if GetDepend(['E2000D_DEMO_BOARD']): + path += cwd + '/fboard_port/e2000d_demo' + +if GetDepend(['E2000D_DEMO_BOARD']): + path += cwd + '/fboard_port/e2000q_demo' + +if GetDepend(['FIREFLY_DEMO_BOARD']): + path += cwd + '/fboard_port/firefly' + +if GetDepend(['BSP_USING_SDCARD_FATFS']): + if GetDepend(['E2000D_DEMO_BOARD']): + src += Glob(cwd + '/port/fboard_port/e2000d_demo/mnt_sdcard.c') + + if GetDepend(['E2000Q_DEMO_BOARD']): + src += Glob(cwd + '/port/fboard_port/e2000q_demo/mnt_sdcard.c') + + if GetDepend(['FIREFLY_DEMO_BOARD']): + src += Glob(cwd + '/port/fboard_port/firefly/mnt_sdcard.c') +else: + src += Glob(cwd + '/port/fboard_port/mnt_ramdisk.c') + # driver path += [PORT_DRV_DIR] @@ -148,7 +170,6 @@ src += Glob(cwd+'/port/fdriver_port/*.c') path += [cwd + '/port/fdriver_port'] ## fboard port -src += Glob(cwd+'/port/fboard_port/*.c') path += [cwd + '/port/fboard_port'] ## lwip port diff --git a/bsp/phytium/libraries/drivers/Kconfig b/bsp/phytium/libraries/drivers/Kconfig index 361413c6b5..b49f464e53 100644 --- a/bsp/phytium/libraries/drivers/Kconfig +++ b/bsp/phytium/libraries/drivers/Kconfig @@ -228,25 +228,36 @@ menu "On-chip Peripheral Drivers" select RT_USING_DFS_ELMFAT default n - if BSP_USING_SDCARD_FATFS - config BSP_USING_SDCARD_PARTITION - string "Set SDCARD (FATFS) partition index" - default "sd0" + config USING_SDIF0 + bool "Use SDIF0" + + if USING_SDIF0 + choice + prompt "Select SD0 Usage" + default USE_SDIF0_TF + config USE_SDIF0_TF + bool "SD0(TF)" + + config USE_SDIF0_EMMC + bool "SD0(eMMC)" + + endchoice endif - choice - prompt "Choose a card to mount" - default USING_SDIF1 + config USING_SDIF1 + bool "Use SDIF1" - config USING_SDIF0 - bool "Use SDIF0" + if USING_SDIF1 + choice + prompt "Select SD1 Usage" + default USE_SDIF1_TF + config USE_SDIF1_TF + bool "SD1(TF)" - config USING_SDIF1 - bool "Use SDIF1" - - config USING_EMMC - bool "Use EMMC" - endchoice + config USE_SDIF1_EMMC + bool "SD1(eMMC)" + endchoice + endif endif diff --git a/bsp/phytium/libraries/drivers/drv_can.c b/bsp/phytium/libraries/drivers/drv_can.c index f03f5214be..f531bcc0fd 100644 --- a/bsp/phytium/libraries/drivers/drv_can.c +++ b/bsp/phytium/libraries/drivers/drv_can.c @@ -328,7 +328,7 @@ static rt_err_t _can_control(struct rt_can_device *can, int cmd, void *arg) return RT_EOK; } -static int _can_sendmsg(struct rt_can_device *can, const void *buf, rt_uint32_t box_num) +static rt_ssize_t _can_sendmsg(struct rt_can_device *can, const void *buf, rt_uint32_t box_num) { RT_ASSERT(can); RT_ASSERT(buf); @@ -365,7 +365,7 @@ static int _can_sendmsg(struct rt_can_device *can, const void *buf, rt_uint32_t return (FCanSend(&drv_can->can_handle, &can_frame) == RT_EOK) ? RT_EOK : -RT_ERROR; } -static int _can_recvmsg(struct rt_can_device *can, void *buf, rt_uint32_t fifo) +static rt_ssize_t _can_recvmsg(struct rt_can_device *can, void *buf, rt_uint32_t fifo) { RT_ASSERT(can); RT_ASSERT(buf); diff --git a/bsp/phytium/libraries/drivers/drv_gpio.c b/bsp/phytium/libraries/drivers/drv_gpio.c index 8798485891..ae5ed5762d 100644 --- a/bsp/phytium/libraries/drivers/drv_gpio.c +++ b/bsp/phytium/libraries/drivers/drv_gpio.c @@ -223,19 +223,12 @@ rt_err_t drv_pin_attach_irq(struct rt_device *device, rt_base_t pin, if (pin_config->en_irq) { FGpioSetInterruptMask(pin_instance, FALSE); - FGpioPinId pin_of_ctrl = - { - .ctrl = ctrl_id, - .port = FGPIO_PORT_A, - .pin = FGPIO_PIN_0 - }; - - if (FGPIO_IRQ_BY_CONTROLLER == FGpioGetPinIrqSourceType(pin_of_ctrl)) /* setup for ctrl report interrupt */ + if (FGPIO_IRQ_BY_CONTROLLER == FGpioGetPinIrqSourceType(*pin_instance)) /* setup for ctrl report interrupt */ { FGpioOpsSetupCtrlIRQ(instance); LOG_I("GPIO-%d report irq by controller", ctrl_id); } - else if (FGPIO_IRQ_BY_PIN == FGpioGetPinIrqSourceType(pin_of_ctrl)) + else if (FGPIO_IRQ_BY_PIN == FGpioGetPinIrqSourceType(*pin_instance)) { FGpioOpsSetupPinIRQ(instance, pin_instance, pin_config); LOG_I("GPIO-%d report irq by pin", ctrl_id); diff --git a/bsp/phytium/libraries/drivers/drv_i2c.c b/bsp/phytium/libraries/drivers/drv_i2c.c index 6ed2ff04c6..0ad7832700 100644 --- a/bsp/phytium/libraries/drivers/drv_i2c.c +++ b/bsp/phytium/libraries/drivers/drv_i2c.c @@ -169,11 +169,12 @@ static rt_ssize_t i2c_master_xfer(struct rt_i2c_bus_device *device, struct rt_i2 RT_ASSERT(device); u32 ret; struct rt_i2c_msg *pmsg; + rt_ssize_t i; struct phytium_i2c_bus *i2c_bus; i2c_bus = (struct phytium_i2c_bus *)(device); u32 mem_addr; - for (int i = 0; i < num; i++) + for (i = 0; i < num; i++) { pmsg = &msgs[i]; for (u32 j = 0; j diff --git a/bsp/phytium/libraries/drivers/drv_sdif.c b/bsp/phytium/libraries/drivers/drv_sdif.c index 8292d6230b..aef5119458 100644 --- a/bsp/phytium/libraries/drivers/drv_sdif.c +++ b/bsp/phytium/libraries/drivers/drv_sdif.c @@ -9,10 +9,11 @@ * Date Author Notes * 2023/7/11 liqiaozhong init SD card and mount file system * 2023/11/8 zhugengyu add interrupt handling for dma waiting, unify function naming + * 2024/4/7 zhugengyu support use two sdif device */ /***************************** Include Files *********************************/ -#include"rtconfig.h" +#include "rtconfig.h" #ifdef BSP_USING_SDIF #include @@ -23,12 +24,12 @@ #include #ifdef RT_USING_SMART - #include "ioremap.h" +#include "ioremap.h" #endif #include "mm_aspace.h" #include "interrupt.h" -#define LOG_TAG "sdif_drv" +#define LOG_TAG "sdif_drv" #include "drv_log.h" #include "ftypes.h" @@ -42,184 +43,292 @@ #include "drv_sdif.h" /************************** Constant Definitions *****************************/ -#ifdef USING_SDIF0 - #define SDIF_CONTROLLER_ID FSDIF0_ID -#elif defined (USING_SDIF1) - #define SDIF_CONTROLLER_ID FSDIF1_ID -#endif -#define SDIF_MALLOC_CAP_DESC 256U -#define SDIF_DMA_ALIGN 512U -#define SDIF_DMA_BLK_SZ 512U -#define SDIF_VALID_OCR 0x00FFFF80 /* supported voltage range is 1.65v-3.6v (VDD_165_195-VDD_35_36) */ -#define SDIF_MAX_BLK_TRANS 20U +#define SDIF_CARD_TYPE_MICRO_SD 1 +#define SDIF_CARD_TYPE_EMMC 2 +#define SDIF_CARD_TYPE_SDIO 3 -#ifndef CONFIG_SDCARD_OFFSET - #define CONFIG_SDCARD_OFFSET 0x0U -#endif +#define SDIF_DMA_BLK_SZ 512U +#define SDIF_MAX_BLK_TRANS 20U +#define SDIF_DMA_ALIGN SDIF_DMA_BLK_SZ /* preserve pointer to host instance */ static struct rt_mmcsd_host *mmc_host[FSDIF_NUM] = {RT_NULL}; /**************************** Type Definitions *******************************/ + typedef struct { - FSdif *mmcsd_instance; + FSdif sdif; + rt_int32_t sd_type; FSdifIDmaDesc *rw_desc; - rt_err_t (*transfer)(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req, FSdifCmdData *cmd_data_p); + uintptr_t rw_desc_dma; + rt_size_t rw_desc_num; struct rt_event event; -#define SDIF_EVENT_CARD_DETECTED (1 << 0) -#define SDIF_EVENT_COMMAND_DONE (1 << 1) -#define SDIF_EVENT_DATA_DONE (1 << 2) -#define SDIF_EVENT_ERROR_OCCUR (1 << 3) -#define SDIF_EVENT_SDIO_IRQ (1 << 4) -} fsdif_info_t; +#define SDIF_EVENT_CARD_DETECTED (1 << 0) +#define SDIF_EVENT_COMMAND_DONE (1 << 1) +#define SDIF_EVENT_DATA_DONE (1 << 2) +#define SDIF_EVENT_ERROR_OCCUR (1 << 3) +#define SDIF_EVENT_SDIO_IRQ (1 << 4) + void *aligned_buffer; + uintptr_t aligned_buffer_dma; + rt_size_t aligned_buffer_size; + FSdifCmdData req_cmd; + FSdifCmdData req_stop; + FSdifData req_data; +} sdif_info_t; /************************** Variable Definitions *****************************/ /***************** Macros (Inline Functions) Definitions *********************/ -void fsdif_change(void); -/*******************************Api Functions*********************************/ -static void fsdif_host_relax(void) +/******************************* Functions *********************************/ +static void sdif_host_relax(void) { rt_thread_mdelay(1); } -static void fsdif_card_detect_callback(FSdif *const mmcsd_instance, void *args, u32 status, u32 dmac_status) +void sdif_change(rt_uint32_t id) { - struct rt_mmcsd_host *host = (struct rt_mmcsd_host *)args; - fsdif_info_t *private_data = (fsdif_info_t *)host->private_data; - - rt_event_send(&private_data->event, SDIF_EVENT_CARD_DETECTED); - fsdif_change(); -} - -static void fsdif_command_done_callback(FSdif *const mmcsd_instance, void *args, u32 status, u32 dmac_status) -{ - struct rt_mmcsd_host *host = (struct rt_mmcsd_host *)args; - fsdif_info_t *private_data = (fsdif_info_t *)host->private_data; - - rt_event_send(&private_data->event, SDIF_EVENT_COMMAND_DONE); -} - -static void fsdif_data_done_callback(FSdif *const mmcsd_instance, void *args, u32 status, u32 dmac_status) -{ - struct rt_mmcsd_host *host = (struct rt_mmcsd_host *)args; - fsdif_info_t *private_data = (fsdif_info_t *)host->private_data; - - rt_event_send(&private_data->event, SDIF_EVENT_DATA_DONE); -} - -static void fsdif_sdio_irq_callback(FSdif *const mmcsd_instance, void *args, u32 status, u32 dmac_status) -{ - struct rt_mmcsd_host *host = (struct rt_mmcsd_host *)args; - fsdif_info_t *private_data = (fsdif_info_t *)host->private_data; - - rt_event_send(&private_data->event, SDIF_EVENT_SDIO_IRQ); -} - -static void fsdif_error_occur_callback(FSdif *const mmcsd_instance, void *args, u32 status, u32 dmac_status) -{ - struct rt_mmcsd_host *host = (struct rt_mmcsd_host *)args; - fsdif_info_t *private_data = (fsdif_info_t *)host->private_data; - - rt_event_send(&private_data->event, SDIF_EVENT_ERROR_OCCUR); -} - -static void fsdif_ctrl_setup_interrupt(struct rt_mmcsd_host *host) -{ - fsdif_info_t *private_data = (fsdif_info_t *)host->private_data; - FSdif *mmcsd_instance = private_data->mmcsd_instance; - FSdifConfig *config_p = &mmcsd_instance->config; - rt_uint32_t cpu_id = rt_hw_cpu_id(); - - rt_hw_interrupt_set_target_cpus(config_p->irq_num, cpu_id); - rt_hw_interrupt_set_priority(config_p->irq_num, 0xd0); - - /* register intr callback */ - rt_hw_interrupt_install(config_p->irq_num, - FSdifInterruptHandler, - mmcsd_instance, - NULL); - - /* enable irq */ - rt_hw_interrupt_umask(config_p->irq_num); - - FSdifRegisterEvtHandler(mmcsd_instance, FSDIF_EVT_CARD_DETECTED, fsdif_card_detect_callback, host); - FSdifRegisterEvtHandler(mmcsd_instance, FSDIF_EVT_ERR_OCCURE, fsdif_error_occur_callback, host); - FSdifRegisterEvtHandler(mmcsd_instance, FSDIF_EVT_CMD_DONE, fsdif_command_done_callback, host); - FSdifRegisterEvtHandler(mmcsd_instance, FSDIF_EVT_DATA_DONE, fsdif_data_done_callback, host); - FSdifRegisterEvtHandler(mmcsd_instance, FSDIF_EVT_SDIO_IRQ, fsdif_sdio_irq_callback, host); - - return; -} - -static rt_err_t fsdif_ctrl_init(struct rt_mmcsd_host *host) -{ - fsdif_info_t *private_data = (fsdif_info_t *)host->private_data; - FSdif *mmcsd_instance = RT_NULL; - const FSdifConfig *default_mmcsd_config = RT_NULL; - FSdifConfig mmcsd_config; - FSdifIDmaDesc *rw_desc = RT_NULL; - - mmcsd_instance = rt_malloc(sizeof(FSdif)); - if (!mmcsd_instance) + RT_ASSERT(id < FSDIF_NUM); + if (mmc_host[id]) { - LOG_E("Malloc mmcsd_instance failed"); - return -RT_ERROR; + mmcsd_change(mmc_host[id]); + } +} + +rt_int32_t sdif_card_inserted(rt_uint32_t id) +{ + RT_ASSERT(id < FSDIF_NUM); + if (mmc_host[id]) + { + return mmc_host[id]->ops->get_card_status(mmc_host[id]); } - rw_desc = rt_malloc_align(SDIF_MAX_BLK_TRANS * sizeof(FSdifIDmaDesc), SDIF_MALLOC_CAP_DESC); - if (!rw_desc) - { - LOG_E("Malloc rw_desc failed"); - return -RT_ERROR; - } - - rt_memset(mmcsd_instance, 0, sizeof(FSdif)); - rt_memset(rw_desc, 0, SDIF_MAX_BLK_TRANS * sizeof(FSdifIDmaDesc)); - - /* SDIF controller init */ - RT_ASSERT((default_mmcsd_config = FSdifLookupConfig(SDIF_CONTROLLER_ID)) != RT_NULL); - mmcsd_config = *default_mmcsd_config; /* load default config */ -#ifdef RT_USING_SMART - mmcsd_config.base_addr = (uintptr)rt_ioremap((void *)mmcsd_config.base_addr, 0x1000); -#endif - mmcsd_config.trans_mode = FSDIF_IDMA_TRANS_MODE; -#ifdef USING_EMMC - mmcsd_config.non_removable = TRUE; /* eMMC is unremovable on board */ -#else - mmcsd_config.non_removable = FALSE; /* TF card is removable on board */ -#endif - mmcsd_config.get_tuning = FSdifGetTimingSetting; - - if (FSDIF_SUCCESS != FSdifCfgInitialize(mmcsd_instance, &mmcsd_config)) - { - LOG_E("SDIF controller init failed."); - return -RT_ERROR; - } - - if (FSDIF_SUCCESS != FSdifSetIDMAList(mmcsd_instance, rw_desc, (uintptr)rw_desc + PV_OFFSET, SDIF_MAX_BLK_TRANS)) - { - LOG_E("SDIF controller setup DMA failed."); - return -RT_ERROR; - } - mmcsd_instance->desc_list.first_desc_dma = (uintptr)rw_desc + PV_OFFSET; - - FSdifRegisterRelaxHandler(mmcsd_instance, fsdif_host_relax); /* SDIF delay for a while */ - - private_data->mmcsd_instance = mmcsd_instance; - private_data->rw_desc = rw_desc; - - fsdif_ctrl_setup_interrupt(host); - return RT_EOK; + return 0; } -rt_inline rt_err_t fsdif_dma_transfer(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req, FSdifCmdData *req_cmd) +static void sdif_card_detect_callback(FSdif *const sdif, void *args, u32 status, u32 dmac_status) +{ + struct rt_mmcsd_host *host = (struct rt_mmcsd_host *)args; + sdif_info_t *host_info = (sdif_info_t *)host->private_data; + + rt_event_send(&host_info->event, SDIF_EVENT_CARD_DETECTED); + sdif_change(host_info->sdif.config.instance_id); +} + +static void sdif_command_done_callback(FSdif *const sdif, void *args, u32 status, u32 dmac_status) +{ + struct rt_mmcsd_host *host = (struct rt_mmcsd_host *)args; + sdif_info_t *host_info = (sdif_info_t *)host->private_data; + + rt_event_send(&host_info->event, SDIF_EVENT_COMMAND_DONE); +} + +static void sdif_data_done_callback(FSdif *const sdif, void *args, u32 status, u32 dmac_status) +{ + struct rt_mmcsd_host *host = (struct rt_mmcsd_host *)args; + sdif_info_t *host_info = (sdif_info_t *)host->private_data; + + rt_event_send(&host_info->event, SDIF_EVENT_DATA_DONE); +} + +static void sdif_sdio_irq_callback(FSdif *const sdif, void *args, u32 status, u32 dmac_status) +{ + struct rt_mmcsd_host *host = (struct rt_mmcsd_host *)args; + sdif_info_t *host_info = (sdif_info_t *)host->private_data; + + rt_event_send(&host_info->event, SDIF_EVENT_SDIO_IRQ); +} + +static void sdif_error_occur_callback(FSdif *const sdif, void *args, u32 status, u32 dmac_status) +{ + struct rt_mmcsd_host *host = (struct rt_mmcsd_host *)args; + sdif_info_t *host_info = (sdif_info_t *)host->private_data; + LOG_E("Error occur !!!"); + LOG_E("Status: 0x%x, dmac status: 0x%x.", status, dmac_status); + + if (status & FSDIF_INT_RE_BIT) + LOG_E("Response err. 0x%x", FSDIF_INT_RE_BIT); + + if (status & FSDIF_INT_RTO_BIT) + LOG_E("Response timeout. 0x%x", FSDIF_INT_RTO_BIT); + + if (dmac_status & FSDIF_DMAC_STATUS_DU) + LOG_E("Descriptor un-readable. 0x%x", FSDIF_DMAC_STATUS_DU); + + if (status & FSDIF_INT_DCRC_BIT) + LOG_E("Data CRC error. 0x%x", FSDIF_INT_DCRC_BIT); + + if (status & FSDIF_INT_RCRC_BIT) + LOG_E("Data CRC error. 0x%x", FSDIF_INT_RCRC_BIT); + + rt_event_send(&host_info->event, SDIF_EVENT_ERROR_OCCUR); +} + +static rt_err_t sdif_pre_request(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req) +{ + rt_err_t err = RT_EOK; + sdif_info_t *host_info = (sdif_info_t *)host->private_data; + + if (host_info->sd_type != SDIF_CARD_TYPE_SDIO) + { + /* ignore SDIO detect command */ + if ((req->cmd->cmd_code == SD_IO_SEND_OP_COND) || + (req->cmd->cmd_code == SD_IO_RW_DIRECT)) + { + req->cmd->err = -1; + mmcsd_req_complete(host); + err = RT_EEMPTY; + } + } + + if (host_info->sd_type == SDIF_CARD_TYPE_EMMC) + { + /* ignore micro SD detect command, not in eMMC spec. */ + if ((req->cmd->cmd_code == SD_APP_OP_COND) || + (req->cmd->cmd_code == APP_CMD)) + { + req->cmd->err = -1; + mmcsd_req_complete(host); + err = RT_EEMPTY; + } + + /* ignore mmcsd_send_if_cond(CMD-8) which will failed for eMMC + but check cmd arg to let SEND_EXT_CSD (CMD-8) run */ + if ((req->cmd->cmd_code == SD_SEND_IF_COND) && + (req->cmd->arg == 0x1AA)) /* 0x1AA is the send_if_cond pattern, use it by care */ + { + req->cmd->err = -1; + mmcsd_req_complete(host); + err = RT_EEMPTY; + } + } + + if ((req->cmd->cmd_code == READ_MULTIPLE_BLOCK) || + (req->cmd->cmd_code == WRITE_MULTIPLE_BLOCK)) /* set block count */ + { + struct rt_mmcsd_req sbc; + struct rt_mmcsd_cmd sbc_cmd; + + rt_memset(&sbc, 0, sizeof(sbc)); + rt_memset(&sbc_cmd, 0, sizeof(sbc_cmd)); + + sbc_cmd.cmd_code = SET_BLOCK_COUNT; + RT_ASSERT(req->data); + sbc_cmd.arg = req->data->blks; + sbc_cmd.flags = RESP_R1; + + LOG_I("set block_count = %d", req->data->blks); + + sbc.data = RT_NULL; + sbc.cmd = &sbc_cmd; + sbc.stop = RT_NULL; + sbc.sbc = RT_NULL; + mmcsd_send_request(host, &sbc); + + err = sbc_cmd.err; + if (req->cmd->busy_timeout < 1000) /* in case rt-thread do not give wait timeout */ + { + req->cmd->busy_timeout = 5000; + } + } + + return err; +} + +static void sdif_convert_command_info(struct rt_mmcsd_host *host, struct rt_mmcsd_cmd *in_cmd, struct rt_mmcsd_data *in_data, FSdifCmdData *out_req) +{ + FSdifCmdData *out_cmd = out_req; + FSdifData *out_data = out_req->data_p; + sdif_info_t *host_info = (sdif_info_t *)host->private_data; + + out_cmd->flag = 0U; + + if (in_cmd->cmd_code == GO_IDLE_STATE) + { + out_cmd->flag |= FSDIF_CMD_FLAG_NEED_INIT; + } + + if (in_cmd->cmd_code == GO_INACTIVE_STATE) + { + out_cmd->flag |= FSDIF_CMD_FLAG_NEED_AUTO_STOP | FSDIF_CMD_FLAG_ABORT; + } + + if (resp_type(in_cmd) != RESP_NONE) + { + out_cmd->flag |= FSDIF_CMD_FLAG_EXP_RESP; + + if (resp_type(in_cmd) == RESP_R2) + { + /* need 136 bits long response */ + out_cmd->flag |= FSDIF_CMD_FLAG_EXP_LONG_RESP; + } + + if ((resp_type(in_cmd) != RESP_R3) && + (resp_type(in_cmd) != RESP_R4)) + { + /* most cmds need CRC */ + out_cmd->flag |= FSDIF_CMD_FLAG_NEED_RESP_CRC; + } + } + + if (in_data) + { + RT_ASSERT(out_data); + out_cmd->flag |= FSDIF_CMD_FLAG_EXP_DATA; + + if (in_data->flags & DATA_DIR_READ) + { + out_cmd->flag |= FSDIF_CMD_FLAG_READ_DATA; + out_data->buf = (void *)in_data->buf; + out_data->buf_dma = (uintptr_t)in_data->buf + PV_OFFSET; + } + else if (in_data->flags & DATA_DIR_WRITE) + { + out_cmd->flag |= FSDIF_CMD_FLAG_WRITE_DATA; + out_data->buf = (void *)in_data->buf; + out_data->buf_dma = (uintptr_t)in_data->buf + PV_OFFSET; + } + else + { + RT_ASSERT(0); + } + + out_data->blksz = in_data->blksize; + out_data->blkcnt = in_data->blks; + out_data->datalen = in_data->blksize * in_data->blks; + + /* handle unaligned input buffer */ + if (out_data->buf_dma % SDIF_DMA_ALIGN) + { + RT_ASSERT(out_data->datalen <= host_info->aligned_buffer_size); + out_data->buf = host_info->aligned_buffer; + out_data->buf_dma = (uintptr_t)host_info->aligned_buffer + PV_OFFSET; + + if (in_data->flags & DATA_DIR_WRITE) + { + /* copy the data need to write to sd card */ + memcpy(out_data->buf, in_data->buf, out_data->datalen); + } + } + + LOG_D("buf@%p, blksz: %d, datalen: %ld", + out_data->buf, + out_data->blksz, + out_data->datalen); + } + + out_cmd->cmdidx = in_cmd->cmd_code; + out_cmd->cmdarg = in_cmd->arg; + LOG_D("cmdarg: 0x%x", out_cmd->cmdarg); +} + +static rt_err_t sdif_do_transfer(struct rt_mmcsd_host *host, FSdifCmdData *req_cmd, rt_int32_t timeout_ms) { FError ret = FT_SUCCESS; + sdif_info_t *host_info = (sdif_info_t *)host->private_data; rt_uint32_t event = 0U; rt_uint32_t wait_event = 0U; - fsdif_info_t *private_data = (fsdif_info_t *)host->private_data; - FSdif *mmcsd_instance = private_data->mmcsd_instance; + + LOG_I("cmd-%d sending", req_cmd->cmdidx); if (req_cmd->data_p == RT_NULL) { @@ -230,7 +339,7 @@ rt_inline rt_err_t fsdif_dma_transfer(struct rt_mmcsd_host *host, struct rt_mmcs wait_event = SDIF_EVENT_COMMAND_DONE | SDIF_EVENT_DATA_DONE; } - ret = FSdifDMATransfer(mmcsd_instance, req_cmd); + ret = FSdifDMATransfer(&host_info->sdif, req_cmd); if (ret != FT_SUCCESS) { LOG_E("FSdifDMATransfer() fail."); @@ -239,31 +348,72 @@ rt_inline rt_err_t fsdif_dma_transfer(struct rt_mmcsd_host *host, struct rt_mmcs while (TRUE) { - if (rt_event_recv(&private_data->event, + /* + * transfer without data: wait COMMAND_DONE event + * transfer with data: wait COMMAND_DONE and DATA_DONE event + */ + if (rt_event_recv(&host_info->event, (wait_event), - (RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR | RT_WAITING_NO), - rt_tick_from_millisecond(5000), + (RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR), + rt_tick_from_millisecond(1000), &event) == RT_EOK) { - (void)FSdifGetCmdResponse(mmcsd_instance, req_cmd); + (void)FSdifGetCmdResponse(&host_info->sdif, req_cmd); break; } - else + + /* + * transfer with error: check if ERROR_OCCUR event exists, no wait + */ + if (rt_event_recv(&host_info->event, + (SDIF_EVENT_ERROR_OCCUR), + (RT_EVENT_FLAG_AND | RT_WAITING_NO), + 0, + &event) == RT_EOK) { - if (rt_event_recv(&private_data->event, - (SDIF_EVENT_ERROR_OCCUR), - (RT_EVENT_FLAG_CLEAR | RT_WAITING_NO), - rt_tick_from_millisecond(5000), - &event) == RT_EOK) - { - LOG_E("Sdif DMA transfer endup with error !!!"); - return -RT_EIO; - } + LOG_E("Sdif DMA transfer endup with error !!!"); + return -RT_EIO; } - fsdif_host_relax(); + timeout_ms -= 1000; + if (timeout_ms <= 0) + { + LOG_E("Sdif DMA transfer endup with timeout !!!"); + return -RT_EIO; + } } + return RT_EOK; +} + +static void sdif_send_request(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req) +{ + sdif_info_t *host_info = (sdif_info_t *)host->private_data; + FSdifCmdData *req_cmd = &host_info->req_cmd; + FSdifData *req_data = &host_info->req_data; + + rt_err_t err = sdif_pre_request(host, req); + if (err != RT_EOK) + { + return; + } + + memset(req_cmd, 0, sizeof(*req_cmd)); + + if (req->data) + { + memset(req_data, 0, sizeof(*req_data)); + req_cmd->data_p = req_data; + } + else + { + req_cmd->data_p = RT_NULL; + } + + sdif_convert_command_info(host, req->cmd, req->data, req_cmd); + + req->cmd->err = sdif_do_transfer(host, req_cmd, req->cmd->busy_timeout); + if (resp_type(req->cmd) & RESP_MASK) { if (resp_type(req->cmd) == RESP_R2) @@ -279,149 +429,30 @@ rt_inline rt_err_t fsdif_dma_transfer(struct rt_mmcsd_host *host, struct rt_mmcs } } - return RT_EOK; -} - -static void fsdif_request_send(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req) -{ - /* ignore some SDIF-ONIY cmd */ - if ((req->cmd->cmd_code == SD_IO_SEND_OP_COND) || (req->cmd->cmd_code == SD_IO_RW_DIRECT)) - { - req->cmd->err = -1; - goto skip_cmd; - } - - fsdif_info_t *private_data = (fsdif_info_t *)host->private_data; - FSdifCmdData req_cmd; - FSdifCmdData req_stop; - FSdifData req_data; - rt_uint32_t *data_buf_aligned = RT_NULL; - rt_uint32_t cmd_flag = resp_type(req->cmd); - - rt_memset(&req_cmd, 0, sizeof(FSdifCmdData)); - rt_memset(&req_stop, 0, sizeof(FSdifCmdData)); - rt_memset(&req_data, 0, sizeof(FSdifData)); - - /* convert req into ft driver type */ - if (req->cmd->cmd_code == GO_IDLE_STATE) - { - req_cmd.flag |= FSDIF_CMD_FLAG_NEED_INIT; - } - - if (req->cmd->cmd_code == GO_INACTIVE_STATE) - { - req_cmd.flag |= FSDIF_CMD_FLAG_NEED_AUTO_STOP; - } - - if ((cmd_flag != RESP_R3) && (cmd_flag != RESP_R4) && (cmd_flag != RESP_NONE)) - { - req_cmd.flag |= FSDIF_CMD_FLAG_NEED_RESP_CRC; - } - - if (cmd_flag & RESP_MASK) - { - req_cmd.flag |= FSDIF_CMD_FLAG_EXP_RESP; - - if (cmd_flag == RESP_R2) - { - req_cmd.flag |= FSDIF_CMD_FLAG_EXP_LONG_RESP; - } - } - - if (req->data) /* transfer command with data */ - { - data_buf_aligned = rt_malloc_align(SDIF_DMA_BLK_SZ * req->data->blks, SDIF_DMA_ALIGN); - if (!data_buf_aligned) - { - LOG_E("Malloc data_buf_aligned failed"); - return; - } - rt_memset(data_buf_aligned, 0, SDIF_DMA_BLK_SZ * req->data->blks); - - req_cmd.flag |= FSDIF_CMD_FLAG_EXP_DATA; - - req_data.blksz = req->data->blksize; - req_data.blkcnt = req->data->blks + CONFIG_SDCARD_OFFSET; - req_data.datalen = req->data->blksize * req->data->blks; - if ((uintptr)req->data->buf % SDIF_DMA_ALIGN) /* data buffer should be 512-aligned */ - { - if (req->data->flags & DATA_DIR_WRITE) - { - rt_memcpy((void *)data_buf_aligned, (void *)req->data->buf, req_data.datalen); - } - req_data.buf = (rt_uint8_t *)data_buf_aligned; - req_data.buf_dma = (uintptr)data_buf_aligned + PV_OFFSET; - } - else - { - req_data.buf = (rt_uint8_t *)req->data->buf; - req_data.buf_dma = (uintptr)req->data->buf + PV_OFFSET; - } - req_cmd.data_p = &req_data; - - if (req->data->flags & DATA_DIR_READ) - { - req_cmd.flag |= FSDIF_CMD_FLAG_READ_DATA; - } - else if (req->data->flags & DATA_DIR_WRITE) - { - req_cmd.flag |= FSDIF_CMD_FLAG_WRITE_DATA; - } - } - - req_cmd.cmdidx = req->cmd->cmd_code; - req_cmd.cmdarg = req->cmd->arg; - - /* do cmd and data transfer */ - req->cmd->err = (private_data->transfer)(host, req, &req_cmd); - if (req->cmd->err != RT_EOK) - { - LOG_E("transfer failed in %s", __func__); - } - if (req->data && (req->data->flags & DATA_DIR_READ)) { - if ((uintptr)req->data->buf % SDIF_DMA_ALIGN) /* data buffer should be 512-aligned */ + /* if it is read sd card, copy data to unaligned buffer and return */ + if ((uintptr)req->data->buf % SDIF_DMA_ALIGN) { - rt_memcpy((void *)req->data->buf, (void *)data_buf_aligned, req_data.datalen); + rt_memcpy((void *)req->data->buf, + (void *)host_info->aligned_buffer, + req_cmd->data_p->datalen); } } - /* stop cmd */ - if (req->stop) - { - req_stop.cmdidx = req->stop->cmd_code; - req_stop.cmdarg = req->stop->arg; - if (req->stop->flags & RESP_MASK) - { - req_stop.flag |= FSDIF_CMD_FLAG_READ_DATA; - if (resp_type(req->stop) == RESP_R2) - { - req_stop.flag |= FSDIF_CMD_FLAG_EXP_LONG_RESP; - } - } - req->stop->err = (private_data->transfer)(host, req, &req_stop); - } - - if (data_buf_aligned) - { - rt_free_align(data_buf_aligned); - } - -skip_cmd: mmcsd_req_complete(host); } -static void fsdif_set_iocfg(struct rt_mmcsd_host *host, struct rt_mmcsd_io_cfg *io_cfg) +static void sdif_set_iocfg(struct rt_mmcsd_host *host, struct rt_mmcsd_io_cfg *io_cfg) { FError ret = FT_SUCCESS; - fsdif_info_t *private_data = (fsdif_info_t *)host->private_data; - FSdif *mmcsd_instance = private_data->mmcsd_instance; - uintptr base_addr = mmcsd_instance->config.base_addr; + sdif_info_t *host_info = (sdif_info_t *)host->private_data; + FSdif *sdif = &host_info->sdif; + uintptr base_addr = sdif->config.base_addr; if (0 != io_cfg->clock) { - ret = FSdifSetClkFreq(mmcsd_instance, io_cfg->clock); + ret = FSdifSetClkFreq(sdif, io_cfg->clock); if (ret != FT_SUCCESS) { LOG_E("FSdifSetClkFreq fail."); @@ -430,102 +461,257 @@ static void fsdif_set_iocfg(struct rt_mmcsd_host *host, struct rt_mmcsd_io_cfg * switch (io_cfg->bus_width) { - case MMCSD_BUS_WIDTH_1: - FSdifSetBusWidth(base_addr, 1U); - break; - case MMCSD_BUS_WIDTH_4: - FSdifSetBusWidth(base_addr, 4U); - break; - case MMCSD_BUS_WIDTH_8: - FSdifSetBusWidth(base_addr, 8U); - break; - default: - LOG_E("Invalid bus width %d", io_cfg->bus_width); - break; + case MMCSD_BUS_WIDTH_1: + FSdifSetBusWidth(base_addr, 1U); + break; + case MMCSD_BUS_WIDTH_4: + FSdifSetBusWidth(base_addr, 4U); + break; + case MMCSD_BUS_WIDTH_8: + FSdifSetBusWidth(base_addr, 8U); + break; + default: + LOG_E("Invalid bus width %d", io_cfg->bus_width); + break; } } -static const struct rt_mmcsd_host_ops ops = +static rt_int32_t sdif_card_status(struct rt_mmcsd_host *host) { - fsdif_request_send, - fsdif_set_iocfg, - RT_NULL, - RT_NULL, - RT_NULL, -}; + sdif_info_t *host_info = (sdif_info_t *)host->private_data; + FSdif *sdif = &host_info->sdif; + uintptr base_addr = sdif->config.base_addr; -void fsdif_change(void) -{ - mmcsd_change(mmc_host[SDIF_CONTROLLER_ID]); + return FSdifCheckIfCardExists(base_addr) ? 1 : 0; } -int rt_hw_fsdif_init(void) +static const struct rt_mmcsd_host_ops ops = + { + .request = sdif_send_request, + .set_iocfg = sdif_set_iocfg, + .get_card_status = sdif_card_status, + .enable_sdio_irq = RT_NULL, + .execute_tuning = RT_NULL, +}; + +static void sdif_ctrl_setup_interrupt(struct rt_mmcsd_host *host) +{ + sdif_info_t *host_info = (sdif_info_t *)host->private_data; + FSdif *sdif = &(host_info->sdif); + FSdifConfig *config_p = &sdif->config; + rt_uint32_t cpu_id = rt_hw_cpu_id(); + + rt_hw_interrupt_set_target_cpus(config_p->irq_num, cpu_id); + rt_hw_interrupt_set_priority(config_p->irq_num, 0xd0); + + /* register intr callback */ + rt_hw_interrupt_install(config_p->irq_num, + FSdifInterruptHandler, + sdif, + NULL); + + /* enable irq */ + rt_hw_interrupt_umask(config_p->irq_num); + + FSdifRegisterEvtHandler(sdif, FSDIF_EVT_CARD_DETECTED, sdif_card_detect_callback, host); + FSdifRegisterEvtHandler(sdif, FSDIF_EVT_ERR_OCCURE, sdif_error_occur_callback, host); + FSdifRegisterEvtHandler(sdif, FSDIF_EVT_CMD_DONE, sdif_command_done_callback, host); + FSdifRegisterEvtHandler(sdif, FSDIF_EVT_DATA_DONE, sdif_data_done_callback, host); + FSdifRegisterEvtHandler(sdif, FSDIF_EVT_SDIO_IRQ, sdif_sdio_irq_callback, host); + + return; +} + +static rt_err_t sdif_host_init(rt_uint32_t id, rt_uint32_t type) { - /* variables init */ struct rt_mmcsd_host *host = RT_NULL; - fsdif_info_t *private_data = RT_NULL; + sdif_info_t *host_info = RT_NULL; + const FSdifConfig *default_sdif_config = RT_NULL; + FSdifConfig sdif_config; rt_err_t result = RT_EOK; host = mmcsd_alloc_host(); if (!host) { LOG_E("Alloc host failed"); + result = RT_ENOMEM; goto err_free; } - private_data = rt_malloc(sizeof(fsdif_info_t)); - if (!private_data) + host_info = rt_malloc(sizeof(sdif_info_t)); + if (!host_info) { - LOG_E("Malloc private_data failed"); + LOG_E("Malloc host_info failed"); + result = RT_ENOMEM; + goto err_free; + } + rt_memset(host_info, 0, sizeof(*host_info)); + + result = rt_event_init(&host_info->event, "sdif_event", RT_IPC_FLAG_FIFO); + RT_ASSERT(RT_EOK == result); + + host_info->aligned_buffer_size = SDIF_DMA_BLK_SZ * SDIF_MAX_BLK_TRANS; + host_info->aligned_buffer = rt_malloc_align(host_info->aligned_buffer_size, + SDIF_DMA_ALIGN); + if (!host_info->aligned_buffer) + { + LOG_E("Malloc aligned buffer failed"); + result = RT_ENOMEM; goto err_free; } - rt_memset(private_data, 0, sizeof(fsdif_info_t)); - private_data->transfer = fsdif_dma_transfer; - result = rt_event_init(&private_data->event, "sdif_event", RT_IPC_FLAG_FIFO); - RT_ASSERT(RT_EOK == result); + host_info->aligned_buffer_dma = (uintptr_t)host_info->aligned_buffer + PV_OFFSET; + rt_memset(host_info->aligned_buffer, 0, host_info->aligned_buffer_size); + + host_info->rw_desc_num = (SDIF_DMA_BLK_SZ * SDIF_MAX_BLK_TRANS) / FSDIF_IDMAC_MAX_BUF_SIZE + 1; + host_info->rw_desc = rt_malloc_align(host_info->rw_desc_num * sizeof(FSdifIDmaDesc), + SDIF_DMA_ALIGN); + if (!host_info->rw_desc) + { + LOG_E("Malloc rw_desc failed"); + result = RT_ENOMEM; + goto err_free; + } + + host_info->rw_desc_dma = (uintptr_t)host_info->rw_desc + PV_OFFSET; + rt_memset(host_info->rw_desc, 0, host_info->rw_desc_num * sizeof(FSdifIDmaDesc)); /* host data init */ host->ops = &ops; - host->freq_min = 400000; - host->freq_max = 50000000; - host->valid_ocr = SDIF_VALID_OCR; /* the voltage range supported is 1.65v-3.6v */ - host->flags = MMCSD_MUTBLKWRITE | MMCSD_BUSWIDTH_4; - host->max_seg_size = SDIF_DMA_BLK_SZ; /* used in block_dev.c */ - host->max_dma_segs = SDIF_MAX_BLK_TRANS; /* physical segment number */ - host->max_blk_size = SDIF_DMA_BLK_SZ; /* all the 4 para limits size of one blk tran */ - host->max_blk_count = SDIF_MAX_BLK_TRANS; - host->private_data = private_data; - - mmc_host[SDIF_CONTROLLER_ID] = host; - - if (RT_EOK != fsdif_ctrl_init(host)) + host->freq_min = FSDIF_CLK_SPEED_400KHZ; + if (type == SDIF_CARD_TYPE_MICRO_SD) { - LOG_E("fsdif_ctrl_init() failed"); + host->freq_max = FSDIF_CLK_SPEED_50_MHZ; + } + else + { + host->freq_max = FSDIF_CLK_SPEED_52_MHZ; + } + + host->valid_ocr = VDD_32_33 | VDD_33_34; /* voltage 3.3v */ + host->flags = MMCSD_MUTBLKWRITE | MMCSD_BUSWIDTH_4; + host->max_seg_size = SDIF_DMA_BLK_SZ; /* used in block_dev.c */ + host->max_dma_segs = SDIF_MAX_BLK_TRANS; /* physical segment number */ + host->max_blk_size = SDIF_DMA_BLK_SZ; /* all the 4 para limits size of one blk tran */ + host->max_blk_count = SDIF_MAX_BLK_TRANS; + host->private_data = host_info; + host->name[0] = 's'; + host->name[1] = 'd'; + host->name[2] = '0' + id; + host->name[3] = '\0'; + + mmc_host[id] = host; + + RT_ASSERT((default_sdif_config = FSdifLookupConfig(id)) != RT_NULL); + sdif_config = *default_sdif_config; +#ifdef RT_USING_SMART + sdif_config.base_addr = (uintptr)rt_ioremap((void *)sdif_config.base_addr, 0x1000); +#endif + sdif_config.trans_mode = FSDIF_IDMA_TRANS_MODE; + + if (type == SDIF_CARD_TYPE_MICRO_SD) + { + sdif_config.non_removable = FALSE; /* TF card is removable on board */ + } + else if (type == SDIF_CARD_TYPE_EMMC) + { + sdif_config.non_removable = TRUE; /* eMMC is unremovable on board */ + } + + sdif_config.get_tuning = FSdifGetTimingSetting; + + if (FSDIF_SUCCESS != FSdifCfgInitialize(&host_info->sdif, &sdif_config)) + { + LOG_E("SDIF controller init failed."); + result = RT_EIO; goto err_free; } - return RT_EOK; + if (FSDIF_SUCCESS != FSdifSetIDMAList(&host_info->sdif, + host_info->rw_desc, + host_info->rw_desc_dma, + host_info->rw_desc_num)) + { + LOG_E("SDIF controller setup DMA failed."); + result = RT_EIO; + goto err_free; + } + + FSdifRegisterRelaxHandler(&host_info->sdif, sdif_host_relax); /* SDIF delay for a while */ + + host_info->sd_type = type; + LOG_I("Init sdif-%d as %d", id, type); + + /* setup interrupt */ + sdif_ctrl_setup_interrupt(host); + return result; err_free: if (host) { - rt_free(host); - } - if (private_data->mmcsd_instance) - { - rt_free(private_data->mmcsd_instance); - } - if (private_data->rw_desc) - { - rt_free_align(private_data->rw_desc); - } - if (private_data) - { - rt_free(private_data); + mmcsd_free_host(host); } - return -RT_EOK; + if (host_info) + { + if (host_info->aligned_buffer) + { + rt_free(host_info->aligned_buffer); + host_info->aligned_buffer = RT_NULL; + host_info->aligned_buffer_size = 0U; + } + + if (host_info->rw_desc) + { + rt_free(host_info->rw_desc); + host_info->rw_desc = RT_NULL; + host_info->rw_desc_num = 0; + } + + rt_free(host_info); + } + + return result; } -INIT_DEVICE_EXPORT(rt_hw_fsdif_init); -#endif // #ifdef RT_USING_SDIO + +int rt_hw_sdif_init(void) +{ + int status = RT_EOK; + rt_uint32_t sd_type; + + FSdifTimingInit(); + +#ifdef USING_SDIF0 +#if defined(USE_SDIF0_TF) + sd_type = SDIF_CARD_TYPE_MICRO_SD; +#elif defined(USE_SDIF0_EMMC) + sd_type = SDIF_CARD_TYPE_EMMC; +#endif + status = sdif_host_init(FSDIF0_ID, sd_type); + + if (status != RT_EOK) + { + LOG_E("SDIF0 init failed, status = %d", status); + return status; + } +#endif + +#ifdef USING_SDIF1 +#if defined(USE_SDIF1_TF) + sd_type = SDIF_CARD_TYPE_MICRO_SD; +#elif defined(USE_SDIF1_EMMC) + sd_type = SDIF_CARD_TYPE_EMMC; +#endif + status = sdif_host_init(FSDIF1_ID, sd_type); + + if (status != RT_EOK) + { + LOG_E("SDIF0 init failed, status = %d", status); + return status; + } +#endif + + return status; +} +INIT_DEVICE_EXPORT(rt_hw_sdif_init); +#endif // #ifdef BSP_USING_SDIF \ No newline at end of file diff --git a/bsp/phytium/libraries/drivers/drv_spi.c b/bsp/phytium/libraries/drivers/drv_spi.c index 5c59358a3f..e1648f2b2d 100644 --- a/bsp/phytium/libraries/drivers/drv_spi.c +++ b/bsp/phytium/libraries/drivers/drv_spi.c @@ -47,7 +47,7 @@ static struct rt_event rx_done_event; #define EVENT_RX_DONE (1 << 1) /*******************************Api Functions*********************************/ static rt_err_t spim_configure(struct rt_spi_device *device, struct rt_spi_configuration *configuration); -static rt_uint32_t spim_xfer(struct rt_spi_device *device, struct rt_spi_message *message); +static rt_ssize_t spim_xfer(struct rt_spi_device *device, struct rt_spi_message *message); static FError FSpimSetupInterrupt(FSpim *instance_p) { @@ -147,12 +147,12 @@ static rt_err_t spim_configure(struct rt_spi_device *device, return ret; } -static rt_uint32_t spim_xfer(struct rt_spi_device *device, struct rt_spi_message *message) +static rt_ssize_t spim_xfer(struct rt_spi_device *device, struct rt_spi_message *message) { RT_ASSERT(device != RT_NULL); RT_ASSERT(device->parent.user_data != RT_NULL); RT_ASSERT(message != RT_NULL); - rt_size_t message_length; + rt_ssize_t message_length; rt_uint8_t *recv_buf; const rt_uint8_t *send_buf; diff --git a/bsp/phytium/libraries/phytium_standalone_sdk_install.py b/bsp/phytium/libraries/phytium_standalone_sdk_install.py index ced6db85a9..d660f702ac 100644 --- a/bsp/phytium/libraries/phytium_standalone_sdk_install.py +++ b/bsp/phytium/libraries/phytium_standalone_sdk_install.py @@ -19,6 +19,6 @@ def clone_repository(branch, commit_hash): if __name__ == "__main__": branch_to_clone = "master" - commit_to_clone = "13657081faf9f2d504592f7110159c4e63dc6f29" + commit_to_clone = "cd15b23000d0c52968dc322b6d99025195bbf446" clone_repository(branch_to_clone, commit_to_clone) \ No newline at end of file diff --git a/bsp/phytium/libraries/port/fboard_port/e2000d_demo/mnt_sdcard.c b/bsp/phytium/libraries/port/fboard_port/e2000d_demo/mnt_sdcard.c new file mode 100644 index 0000000000..e19d613c8a --- /dev/null +++ b/bsp/phytium/libraries/port/fboard_port/e2000d_demo/mnt_sdcard.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2006-2023, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Email: opensource_embedded@phytium.com.cn + * + * Change Logs: + * Date Author Notes + * 2023-04-27 huanghe first version + * 2023-07-14 liqiaozhong add SD file sys mount func + * 2024-04-08 zhugengyu define mount table by board + */ +#include +#include + +#define DBG_TAG "mnt.filesystem" +#define DBG_LVL DBG_INFO +#include + +#define FS_SD_MOUNT_POINT "/" +#define FS_SD_DEVICE_NAME "sd1" +#define FS_SD_DEVICE_INDEX 1 + +#define FS_EMMC_MOUNT_POINT "/sd0" +#define FS_EMMC_DEVICE_NAME "sd0" +#define FS_EMMC_DEVICE_INDEX 0 + +extern void sdif_change(rt_uint32_t id); +extern rt_int32_t sdif_card_inserted(rt_uint32_t id); + +static rt_int32_t card_inserted = 0; + +static void _sdcard_mount(void) +{ + rt_device_t device; + + device = rt_device_find(FS_SD_DEVICE_NAME); + rt_kprintf("rt_device_find %x \r\n", device); + if (device == NULL) + { + mmcsd_wait_cd_changed(0); + sdif_change(FS_SD_DEVICE_INDEX); + mmcsd_wait_cd_changed(RT_WAITING_FOREVER); + device = rt_device_find(FS_SD_DEVICE_NAME); + } + + if (device != RT_NULL) + { + if (dfs_mount(FS_SD_DEVICE_NAME, FS_SD_MOUNT_POINT, "elm", 0, 0) == RT_EOK) + { + LOG_I("%s mount to '%s'", FS_SD_DEVICE_NAME, FS_SD_MOUNT_POINT); + mkdir(FS_EMMC_MOUNT_POINT, 0); + if (dfs_mount(FS_EMMC_DEVICE_NAME, FS_EMMC_MOUNT_POINT, "elm", 0, 0) == RT_EOK) + { + LOG_I("%s mount to '%s'", FS_EMMC_DEVICE_NAME, FS_EMMC_MOUNT_POINT); + } + + card_inserted = 1; + } + else + { + LOG_W("%s mount to '%s' failed!", FS_SD_DEVICE_NAME, FS_SD_MOUNT_POINT); + } + } +} + +static void _sdcard_unmount(void) +{ + rt_thread_mdelay(200); + dfs_unmount(FS_SD_MOUNT_POINT); + LOG_I("Unmount %s", FS_SD_MOUNT_POINT); + + mmcsd_wait_cd_changed(0); + sdif_change(FS_SD_DEVICE_INDEX); + mmcsd_wait_cd_changed(RT_WAITING_FOREVER); + + card_inserted = 0; +} + +static void sd_auto_mount(void *parameter) +{ + rt_thread_mdelay(20); + + /* detect eMMC */ + mmcsd_wait_cd_changed(0); + sdif_change(FS_EMMC_DEVICE_INDEX); + mmcsd_wait_cd_changed(RT_WAITING_FOREVER); + + if ((card_inserted == 0) && (sdif_card_inserted(FS_SD_DEVICE_INDEX) == 1)) + { + _sdcard_mount(); + } + + while (RT_TRUE) + { + rt_thread_mdelay(200); + + if ((card_inserted == 0) && (sdif_card_inserted(FS_SD_DEVICE_INDEX) == 1)) + { + _sdcard_mount(); + } + + if ((card_inserted == 1) && (sdif_card_inserted(FS_SD_DEVICE_INDEX) == 0)) + { + _sdcard_unmount(); + } + } +} + +static void sd_mount(void) +{ + rt_thread_t tid; + + tid = rt_thread_create("sd_mount", sd_auto_mount, RT_NULL, + 4096, RT_THREAD_PRIORITY_MAX - 2, 20); + if (tid != RT_NULL) + { + rt_thread_startup(tid); + } + else + { + LOG_E("create sd_mount thread err!"); + return; + } +} + +int filesystem_mount(void) +{ + sd_mount(); + return RT_EOK; +} +INIT_APP_EXPORT(filesystem_mount); diff --git a/bsp/phytium/libraries/port/fboard_port/e2000q_demo/mnt_sdcard.c b/bsp/phytium/libraries/port/fboard_port/e2000q_demo/mnt_sdcard.c new file mode 100644 index 0000000000..e19d613c8a --- /dev/null +++ b/bsp/phytium/libraries/port/fboard_port/e2000q_demo/mnt_sdcard.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2006-2023, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Email: opensource_embedded@phytium.com.cn + * + * Change Logs: + * Date Author Notes + * 2023-04-27 huanghe first version + * 2023-07-14 liqiaozhong add SD file sys mount func + * 2024-04-08 zhugengyu define mount table by board + */ +#include +#include + +#define DBG_TAG "mnt.filesystem" +#define DBG_LVL DBG_INFO +#include + +#define FS_SD_MOUNT_POINT "/" +#define FS_SD_DEVICE_NAME "sd1" +#define FS_SD_DEVICE_INDEX 1 + +#define FS_EMMC_MOUNT_POINT "/sd0" +#define FS_EMMC_DEVICE_NAME "sd0" +#define FS_EMMC_DEVICE_INDEX 0 + +extern void sdif_change(rt_uint32_t id); +extern rt_int32_t sdif_card_inserted(rt_uint32_t id); + +static rt_int32_t card_inserted = 0; + +static void _sdcard_mount(void) +{ + rt_device_t device; + + device = rt_device_find(FS_SD_DEVICE_NAME); + rt_kprintf("rt_device_find %x \r\n", device); + if (device == NULL) + { + mmcsd_wait_cd_changed(0); + sdif_change(FS_SD_DEVICE_INDEX); + mmcsd_wait_cd_changed(RT_WAITING_FOREVER); + device = rt_device_find(FS_SD_DEVICE_NAME); + } + + if (device != RT_NULL) + { + if (dfs_mount(FS_SD_DEVICE_NAME, FS_SD_MOUNT_POINT, "elm", 0, 0) == RT_EOK) + { + LOG_I("%s mount to '%s'", FS_SD_DEVICE_NAME, FS_SD_MOUNT_POINT); + mkdir(FS_EMMC_MOUNT_POINT, 0); + if (dfs_mount(FS_EMMC_DEVICE_NAME, FS_EMMC_MOUNT_POINT, "elm", 0, 0) == RT_EOK) + { + LOG_I("%s mount to '%s'", FS_EMMC_DEVICE_NAME, FS_EMMC_MOUNT_POINT); + } + + card_inserted = 1; + } + else + { + LOG_W("%s mount to '%s' failed!", FS_SD_DEVICE_NAME, FS_SD_MOUNT_POINT); + } + } +} + +static void _sdcard_unmount(void) +{ + rt_thread_mdelay(200); + dfs_unmount(FS_SD_MOUNT_POINT); + LOG_I("Unmount %s", FS_SD_MOUNT_POINT); + + mmcsd_wait_cd_changed(0); + sdif_change(FS_SD_DEVICE_INDEX); + mmcsd_wait_cd_changed(RT_WAITING_FOREVER); + + card_inserted = 0; +} + +static void sd_auto_mount(void *parameter) +{ + rt_thread_mdelay(20); + + /* detect eMMC */ + mmcsd_wait_cd_changed(0); + sdif_change(FS_EMMC_DEVICE_INDEX); + mmcsd_wait_cd_changed(RT_WAITING_FOREVER); + + if ((card_inserted == 0) && (sdif_card_inserted(FS_SD_DEVICE_INDEX) == 1)) + { + _sdcard_mount(); + } + + while (RT_TRUE) + { + rt_thread_mdelay(200); + + if ((card_inserted == 0) && (sdif_card_inserted(FS_SD_DEVICE_INDEX) == 1)) + { + _sdcard_mount(); + } + + if ((card_inserted == 1) && (sdif_card_inserted(FS_SD_DEVICE_INDEX) == 0)) + { + _sdcard_unmount(); + } + } +} + +static void sd_mount(void) +{ + rt_thread_t tid; + + tid = rt_thread_create("sd_mount", sd_auto_mount, RT_NULL, + 4096, RT_THREAD_PRIORITY_MAX - 2, 20); + if (tid != RT_NULL) + { + rt_thread_startup(tid); + } + else + { + LOG_E("create sd_mount thread err!"); + return; + } +} + +int filesystem_mount(void) +{ + sd_mount(); + return RT_EOK; +} +INIT_APP_EXPORT(filesystem_mount); diff --git a/bsp/phytium/libraries/port/fboard_port/firefly/mnt_sdcard.c b/bsp/phytium/libraries/port/fboard_port/firefly/mnt_sdcard.c new file mode 100644 index 0000000000..1d40e824aa --- /dev/null +++ b/bsp/phytium/libraries/port/fboard_port/firefly/mnt_sdcard.c @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2006-2023, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Email: opensource_embedded@phytium.com.cn + * + * Change Logs: + * Date Author Notes + * 2023-04-27 huanghe first version + * 2023-07-14 liqiaozhong add SD file sys mount func + * 2024-04-08 zhugengyu define mount table by board + */ +#include +#include + +#define DBG_TAG "mnt.filesystem" +#define DBG_LVL DBG_INFO +#include + +#define FS_SD_MOUNT_POINT "/" +#define FS_SD_DEVICE_NAME "sd00" /* first partition of SD0 */ +#define FS_SD_DEVICE_INDEX 0 + +extern void sdif_change(rt_uint32_t id); +extern rt_int32_t sdif_card_inserted(rt_uint32_t id); + +static rt_int32_t card_inserted = 0; + +static void _sdcard_mount(void) +{ + rt_device_t device; + + device = rt_device_find(FS_SD_DEVICE_NAME); + rt_kprintf("rt_device_find %x \r\n", device); + if (device == NULL) + { + mmcsd_wait_cd_changed(0); + sdif_change(FS_SD_DEVICE_INDEX); + mmcsd_wait_cd_changed(RT_WAITING_FOREVER); + device = rt_device_find(FS_SD_DEVICE_NAME); + } + + if (device != RT_NULL) + { + if (dfs_mount(FS_SD_DEVICE_NAME, FS_SD_MOUNT_POINT, "elm", 0, 0) == RT_EOK) + { + LOG_I("%s mount to '%s'", FS_SD_DEVICE_NAME, FS_SD_MOUNT_POINT); + card_inserted = 1; + } + else + { + LOG_W("%s mount to '%s' failed!", FS_SD_DEVICE_NAME, FS_SD_MOUNT_POINT); + } + } +} + +static void _sdcard_unmount(void) +{ + rt_thread_mdelay(200); + dfs_unmount(FS_SD_MOUNT_POINT); + LOG_I("Unmount %s", FS_SD_MOUNT_POINT); + + mmcsd_wait_cd_changed(0); + sdif_change(FS_SD_DEVICE_INDEX); + mmcsd_wait_cd_changed(RT_WAITING_FOREVER); + + card_inserted = 0; +} + +static void sd_auto_mount(void *parameter) +{ + rt_thread_mdelay(20); + + if ((card_inserted == 0) && (sdif_card_inserted(FS_SD_DEVICE_INDEX) == 1)) + { + _sdcard_mount(); + } + + while (RT_TRUE) + { + rt_thread_mdelay(200); + + if ((card_inserted == 0) && (sdif_card_inserted(FS_SD_DEVICE_INDEX) == 1)) + { + _sdcard_mount(); + } + + if ((card_inserted == 1) && (sdif_card_inserted(FS_SD_DEVICE_INDEX) == 0)) + { + _sdcard_unmount(); + } + } +} + +static void sd_mount(void) +{ + rt_thread_t tid; + + tid = rt_thread_create("sd_mount", sd_auto_mount, RT_NULL, + 4096, RT_THREAD_PRIORITY_MAX - 2, 20); + if (tid != RT_NULL) + { + rt_thread_startup(tid); + } + else + { + LOG_E("create sd_mount thread err!"); + return; + } +} + +int filesystem_mount(void) +{ + sd_mount(); + return RT_EOK; +} +INIT_APP_EXPORT(filesystem_mount); diff --git a/bsp/phytium/libraries/port/fboard_port/mnt_ramdisk.c b/bsp/phytium/libraries/port/fboard_port/mnt_ramdisk.c new file mode 100644 index 0000000000..bf05816e07 --- /dev/null +++ b/bsp/phytium/libraries/port/fboard_port/mnt_ramdisk.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2006-2023, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Email: opensource_embedded@phytium.com.cn + * + * Change Logs: + * Date Author Notes + * 2023-04-27 huanghe first version + * 2023-07-14 liqiaozhong add SD file sys mount func + * + */ +#include +#include +#ifndef RT_USING_SMART +#include +#include + +static int ram_disk_mount(const char *mount_point) +{ + extern struct dfs_ramfs *dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size); + + rt_uint8_t *pool = RT_NULL; + rt_size_t size = 8 * 1024 * 1024; + + pool = rt_malloc(size); + if (pool == RT_NULL) + { + LOG_E("Malloc fail!"); + } + + if (dfs_mount(RT_NULL, mount_point, "ram", 0, (const void *)dfs_ramfs_create(pool, size)) == 0) + { + LOG_I("RAM file system initializated!"); + } + else + { + LOG_E("RAM file system initializate failed!"); + } + + return RT_EOK; +} + +static int filesystem_mount(void) +{ + return ram_disk_mount("/"); /* mount ramdisk as / */ +} +INIT_APP_EXPORT(filesystem_mount); +#endif \ No newline at end of file