From ad888c0db2a165711a700f2779ad995e1eae613a Mon Sep 17 00:00:00 2001 From: "sober.song" Date: Fri, 5 Jan 2024 11:04:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8B=94=E6=8F=92SD=E5=8D=A1?= =?UTF-8?q?=E5=90=8E=E5=9B=9E=E6=94=BE=E8=AF=BB=E5=8F=96SD=E5=8D=A1?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cardv/SrcCode/System/SF_SysStrgMng.c | 8 +-- .../source/cardv/SrcCode/System/SysStrg_Exe.c | 67 +++++++++++++++++++ .../source/sf_app/code/source/app/sf_common.c | 4 +- 3 files changed, 70 insertions(+), 9 deletions(-) diff --git a/code/application/source/cardv/SrcCode/System/SF_SysStrgMng.c b/code/application/source/cardv/SrcCode/System/SF_SysStrgMng.c index 93fcb4dc1..2be1cab1f 100755 --- a/code/application/source/cardv/SrcCode/System/SF_SysStrgMng.c +++ b/code/application/source/cardv/SrcCode/System/SF_SysStrgMng.c @@ -326,11 +326,6 @@ SF_ST_MMC_DEV *SF_StrgCheckWorkableDev(void) } } - for(int i = 0; i < 2; i++) - { - sf_mmc_dev[i]->dev_type = workable_dev; - } - if(workable_dev == MMC_DEV_NO) { //MLOGD("Strg Check, No dev can use\n"); @@ -338,13 +333,13 @@ SF_ST_MMC_DEV *SF_StrgCheckWorkableDev(void) } else { + sf_mmc_dev[workable_dev]->dev_type = workable_dev; //MLOGD("Strg Check, workable_dev = %d\n", workable_dev); SF_SetMMCDev(sf_mmc_dev[workable_dev]); return sf_mmc_dev[workable_dev]; } } -#if 1 static int sfStrgOnActionSendCurrentDev(SF_ST_MMC_DEV *pMMCDev) { SF_MESSAGE_BUF_S stMessageBuf = {0}; @@ -356,7 +351,6 @@ static int sfStrgOnActionSendCurrentDev(SF_ST_MMC_DEV *pMMCDev) MLOGD("sf sys strg update current dev!\n"); return 0; } -#endif static void* mmc_monitoring_thread(void *arg) { diff --git a/code/application/source/cardv/SrcCode/System/SysStrg_Exe.c b/code/application/source/cardv/SrcCode/System/SysStrg_Exe.c index bc5c59a50..1291047c4 100644 --- a/code/application/source/cardv/SrcCode/System/SysStrg_Exe.c +++ b/code/application/source/cardv/SrcCode/System/SysStrg_Exe.c @@ -807,6 +807,48 @@ INT32 System_OnStrgSetActDrive(VControl *pCtrl, UINT32 paramNum, UINT32 *paramAr return NVTEVT_CONSUME; } +int search_str_in_file(char *path, char *str) +{ + FILE *fp = NULL; + UINT32 u32ize = 0; + int found = 0; + char *pStrSrc = NULL; + + fp = fopen(path, "r"); + if (fp) { + fseek(fp, 0, SEEK_END); + u32ize = ftell(fp); // take file size + fseek(fp, 0, SEEK_SET); // move to position zero + pStrSrc = (char *)malloc(u32ize * sizeof(char)); + + if (pStrSrc) { + fread(pStrSrc, 1, u32ize, fp); + if (strstr(pStrSrc, str)) { + found = 1; + } + free(pStrSrc); + } + + fclose(fp); + fp = NULL; + pStrSrc = NULL; + u32ize = 0; + } + + return found; +} + +int System_check_mmcblk0p1(void) +{ + SysMain_system("ls /dev/mmcblk0p1 > /tmp/lsdev.txt"); + vos_util_delay_ms(100); + if (search_str_in_file("/tmp/lsdev.txt", "/dev/mmcblk0p1")) { + return 1; + } else { + return 0; + } +} + INT32 System_OnStrgInsert(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray) { UINT32 strg_id = paramArray[0]; @@ -853,6 +895,31 @@ INT32 System_OnStrgInsert(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray) //SysMain_system("df"); //only for debug, the "/mnt/sd" path must be existed. #endif + /* wait mmcblk */ + if(strg_id == STRG_ID_SD){ + + UINT32 count = 0 , delay = 50, timeout = 60; + + while(count++ < timeout) + { + if (System_check_mmcblk0p1()){ + break; + } + else{ + vos_util_delay_ms(delay); + } + } + + if(System_check_mmcblk0p1()){ + /* hotplug */ + if(count != 1) + vos_util_delay_ms(50); + } + else{ + DBG_ERR("mmcblk0p1 not found!\n"); + } + } + if(strg_id == STRG_ID_SD){ DX_HANDLE pStrgDev = (DX_HANDLE)sdio_getStorageObject(STRG_OBJ_FAT1); if (GxStrg_OpenDevice(strg_id, pStrgDev) != TRUE) { diff --git a/code/application/source/sf_app/code/source/app/sf_common.c b/code/application/source/sf_app/code/source/app/sf_common.c index 9c8ef5579..e9d91bad8 100755 --- a/code/application/source/sf_app/code/source/app/sf_common.c +++ b/code/application/source/sf_app/code/source/app/sf_common.c @@ -712,9 +712,9 @@ static SINT32 sf_app_process_cmd_SD(SF_MESSAGE_BUF_S *pMessageBuf) { sfStrgDevSdHandler(pMessageBuf->arg1, pMessageBuf->arg2, pMessageBuf->arg3); } - //else if(pMessageBuf->arg2 == MMC_DEV_EMMC) + else if(pMessageBuf->arg2 == MMC_DEV_EMMC) { - //sfStrgDevEmmcHandler(pMessageBuf->arg1, pMessageBuf->arg2, pMessageBuf->arg3); + sfStrgDevEmmcHandler(pMessageBuf->arg1, pMessageBuf->arg2, pMessageBuf->arg3); } switch(pMessageBuf->arg1)