/*********************************************************************
*
*       _FSTask
*/
static void _FSTask(void) {
    FS_FILE * pFile;

    if (FS_IsLLFormatted("") == 0) {
        printf("Low level formatting");
        FS_FormatLow("");  /* Erase & Low-level  format the flash */
    }
    if (FS_IsHLFormatted("") == 0) {
        printf("High level formatting\n");
        FS_Format("", NULL);       /* High-level format the flash */
    }
    FS_SetAutoMount("", 0);
    FS_Mount("");
    while (1) {

        while (1) {
            char ac[30];

            if (FS_IsVolumeMounted("")) {
                pFile = FS_FOpen("Log.txt", "a+");
                sprintf(ac, "OS_Time = %.8d\r\n", OS_GetTime());
                FS_Write(pFile, ac, 20);
                FS_FClose(pFile);
            }
            OS_Delay(1000);
        }
    }

}
Example #2
0
/*********************************************************************
*
*       _InitIfRequired
*/
static void _InitIfRequired(void) {
  if (_IsInited == 0) {
    FS_Init();
    FS_FormatLLIfRequired(_sVolumeName);
    //
    // Check if volume needs to be high level formatted.
    //
    if (FS_IsHLFormatted(_sVolumeName) == 0) {
      printf("High level formatting: %s\n", _sVolumeName);
      FS_Format(_sVolumeName, NULL);
    }
    //
    // Enable long file name support if LFN package is available.
    // LFN is an optional emFile package!
    //
//    FS_FAT_SupportLFN();
    _IsInited = 1;
  }
}
void MainTask(void) {
  unsigned i;
  U32 Space;
  U32 NumLoops;
  U32 NumBytes;
  U32 NumBytesAtOnce;
  FS_FILE * pFile;
  I32 t;

  FS_Init();
  _TestNo = -1;
  //
  // Check if we need to low-level format the volume
  //
  if (FS_IsLLFormatted(VOLUME_NAME) == 0) {
    FS_X_Log("Low level formatting\n");
    FS_FormatLow(VOLUME_NAME);  /* Erase & Low-level  format the flash */
  }
  //
  // Volume is always high level formatted
  // before doing any performance tests.
  //
  FS_X_Log("High level formatting\n");
#if FS_SUPPORT_FAT
  if (FS_FormatSD(VOLUME_NAME) == 0) {
#else
  if (FS_Format(VOLUME_NAME, NULL) == 0) {
#endif
    //
    // Disable that the directory entry is every time
    // updated after a write operation
    //
    FS_ConfigUpdateDirOnWrite(0);
    //
    // Fill the buffer with data
    //
    FS_MEMSET((void*)_aBuffer, 'a', sizeof(_aBuffer));
    //
    // Get some general info
    //
    Space          = FS_GetVolumeFreeSpace(VOLUME_NAME);
    Space          = MIN(Space, FILE_SIZE);
    NumBytes       = BLOCK_SIZE * NUM_BLOCKS_MEASURE;
    NumBytesAtOnce = BLOCK_SIZE;
    NumLoops       = Space / NumBytes;

    //
    // Create file of full size
    //
    _StartTest("W", NumBytes);
    pFile = FS_FOpen(FILE_NAME, "w");
    //
    // Preallocate the file, setting the file pointer to the highest position
    // and declare it as the end of the file.
    //
    FS_SetFilePos(pFile, Space, FS_FILE_BEGIN);
    FS_SetEndOfFile(pFile);
    //
    // Set file position to the beginning
    //
    FS_SetFilePos(pFile, 0, FS_FILE_BEGIN);
    //
    // Check write performance with clusters/file size preallocated
    //
    sprintf(_ac, "Writing %lu chunks of %lu Bytes: ", NumLoops, NumBytes);
    FS_X_Log(_ac);
    for (i = 0; i < NumLoops ; i++) {
      t = _WriteFile(pFile, &_aBuffer[0], NumBytesAtOnce);
      _StoreResult(t);
      FS_X_Log(".");
    }
    FS_X_Log("OK\n");
    FS_FClose(pFile);
    //
    // Check read performance
    //
    _StartTest("R", NumBytes);
    sprintf(_ac, "Reading %lu chunks of %lu Bytes: " , NumLoops, NumBytes);
    FS_X_Log(_ac);
    pFile = FS_FOpen(FILE_NAME, "r");
    for (i = 0; i < NumLoops; i++) {
      t = _ReadFile(pFile, _aBuffer, NumBytesAtOnce);
      _StoreResult(t);
      FS_X_Log(".");
    }
    FS_X_Log("OK\n\n");
    FS_FClose(pFile);
    //
    // Show results for performance list
    //
    for (i = 0; i <= (unsigned)_TestNo; i++) {
      sprintf(_ac, "%s Speed: %f kByte/s\n", _aResult[i].sName, _GetAverage(i));
      FS_X_Log(_ac);
    }
    FS_X_Log("Finished\n");
    FS_Unmount(VOLUME_NAME);
  } else {
    FS_X_Log("Volume could not be formatted!\n");
  }
  while (1) {
    ;
  }
}
Example #4
0
BOOL BAL_TaskInit()
{
    UINT8 i = 0;
    INT32 err_code = 0x00;
    UINT32 fs_dev_count = 0;
    FS_DEV_INFO* fs_dev_info = NULL;
    UINT32 fs_root_dev_count = 0;

    
#if ( CHIP_ASIC_ID != CHIP_ASIC_ID_JADE)
    csw_RegisterYourself();
#else
    DM_CheckPowerOnCause();
#endif

  // hal_fastOSTimInit();

  BAL_DevHandlerInit();
  TS_Init_Inner();

  // TS_SetOutputMask(CSW_TS_ID, 1);           
  // TS_SetOutputMask(CFW_SIM_TS_ID, 1);    
  // TS_SetOutputMask(CFW_NW_TS_ID, 1);    
  // TS_SetOutputMask(CFW_SMS_TS_ID, 1);  
  // TS_SetOutputMask(CFW_CC_TS_ID, 1);   
  // TS_SetOutputMask(CFW_SS_TS_ID, 1);    
  // TS_SetOutputMask(CFW_PM_TS_ID, 1);    
  // TS_SetOutputMask(BASE_FFS_TS_ID, 1);    
  // TS_SetOutputMask(BASE_TM_TS_ID, 1);    
  // TS_SetOutputMask(CFW_SHELL_TS_ID, 1);    
  // TS_SetOutputMask(CFW_AOM_TS_ID, 1);   

// open 1,2,3,4
  // sxs_IoCtx.TraceBitMap [TGET_ID(_CSW)] =  1|(1 << 1) | (1 << 2)|(1<<3);

  // open shell trace
  sxs_IoCtx.TraceBitMap[TGET_ID(_CSW)] = (1 << 1);

  // 
  // sxs_IoCtx.TraceBitMap [TGET_ID(_MMI)] = 0;
  // sxs_IoCtx.TraceBitMap [TGET_ID(_MM)] = 0;

  BAL_SetMMIDefaultValue();

// CSW_CheckMMIDefaultValue() ;
  CSW_CheckMMIDefaultValue(); // add wys 2007-06-20

  csw_MemIint();
  PM_CheckValidPowerOnVoltage(3000);

/*
    if(0x00 ==  CFW_GetValidMarker())//0x00 表示非生产模式
    {
        	CSW_TRACE(100, TSTXT("norm modle"));

        if(!PM_CheckValidPowerOnVoltage(g_MMI_Default_Value.nMinVol))
        {
            hal_ShutDown();
        }
    }
    else
    {
                	CSW_TRACE(100, TSTXT("e modle"));

    }

  //deleted by mabo to power on at low power voltage,20070829
  //add wys 2007-06-20
    if(0x00 ==  CFW_GetValidMarker())//0x00 表示非生产模式
    {
        	CSW_TRACE(BASE_BAL_TS_ID, TSTXT("BAL_TaskInit norm modle"));

        if(!PM_CheckValidPowerOnVoltage(g_MMI_Default_Value.nMinVol))
        {
            hal_ShutDown();
        }
    }
    else
    {
           CSW_TRACE(BASE_BAL_TS_ID, TSTXT("BAL_TaskInit e modle"));

    }
//add end
*/
	
    CSW_TRACE(BASE_BAL_TS_ID, TSTXT("\nBAL_TaskInit Start. \n"));

    DRV_FlashPowerUp();
    //mabo deleted,20070813
    //DRV_FlashInit(CSW_DVR_FLASH_INIT_PARA) ;
    //romuald added 20080425
#if (CHIP_ASIC_ID != CHIP_ASIC_ID_JADE)
    DRV_FlashInit();
#endif
    //Modify for memory overflow bug at 20090724
    //for(i = 0; i< SIZEOF(g_BalTasks); i++) 
    for(i = 0; i< MAX_BAL_TASK_NUM; i++) 
        g_BalTasks[i] = HNULL;
    
    g_BalTasks[BAL_TASK_NUM(BAL_SYS_TASK_PRIORITY)] = COS_CreateTask_Prv(BAL_SysTask, NULL, NULL, 
        BAL_SYS_TASK_STACK_SIZE, BAL_SYS_TASK_PRIORITY, COS_CREATE_DEFAULT, 0, "BAL_SysTask");
#ifdef CFW_TCPIP_SUPPORT

    g_BalTasks[BAL_TASK_NUM(BAL_CFW_ADV_TASK_PRIORITY)] = COS_CreateTask_Prv(BAL_CFWApsTask, NULL, NULL, 
        BAL_CFW_ADV_TASK_STACK_SIZE, BAL_CFW_ADV_TASK_PRIORITY, COS_CREATE_DEFAULT, 0, "BAL_CFWApsTask");
#endif    
    g_BalTasks[BAL_TASK_NUM(BAL_DEV_MONITOR_TASK_PRIORITY)] = COS_CreateTask_Prv(BAL_DevMonitorTask, NULL, NULL, 
        BAL_DEV_MONITOR_TASK_STACK_SIZE, BAL_DEV_MONITOR_TASK_PRIORITY, COS_CREATE_DEFAULT, 0, "BAL_DevMonitorTask");
    
    g_BalTasks[3] = COS_CreateTask_Prv(BAL_BackgroundTask, NULL, NULL, 
        BAL_BG_TASK_STACK_SIZE, COS_BK_TASK_PRI, COS_CREATE_DEFAULT, 0, "BAL_BackgroundTask");
    

//Add by lixp at 20080201
//
#ifdef ML_SUPPORT
    ML_Init();
    ML_SetCodePage(ML_ISO8859_1);
#elif defined(NEW_ML_SUPPORT)
#endif	
    BAL_ApplicationInit();

    err_code = VDS_Init();   // Initialize VDS. added bye nie. 20070322
    if(ERR_SUCCESS == err_code)
    {
        CSW_TRACE(BASE_BAL_TS_ID,"VDS_Init() OK.\n");        
    }
    else
    {
        CSW_TRACE(BASE_BAL_TS_ID,"VDS_Init() ERROR, Error code: %d.\n", err_code);
    }
     err_code = DSM_DevInit();
    if(ERR_SUCCESS == err_code)
    {
        CSW_TRACE(BASE_BAL_TS_ID,"DSM_DevInit OK.\n");
    }
    else
    {
        CSW_TRACE(BASE_BAL_TS_ID,"DSM_DevInit ERROR, Error code: %d. \n",err_code);
    }

    err_code = REG_Init();
    if(ERR_SUCCESS == err_code)
    {
        CSW_TRACE(BASE_BAL_TS_ID, TSTXT("REG_Init() OK.\n"));
    }
    else
    {
        CSW_TRACE(BASE_BAL_TS_ID, TSTXT("REG_Init() Fail!Error code:%d.\n"),err_code);
    }
        
	
    err_code = CFW_CfgInit();
    if(ERR_SUCCESS == err_code)
    {
        CSW_TRACE(BASE_BAL_TS_ID, TSTXT("CFW_CfgInit OK.\n"));
    }
    else
    {
        CSW_TRACE(BASE_BAL_TS_ID, TSTXT("CFW_CfgInit ERROR, Error code: 0x%08x \n"), err_code);
    }

    err_code = SMS_DM_Init();
    if(ERR_SUCCESS == err_code)
    {
        CSW_TRACE(BASE_BAL_TS_ID, TSTXT("SMS_DM_Init OK.\n"));
    }
    else
    {
        CSW_TRACE(BASE_BAL_TS_ID, TSTXT("SMS_DM_Init ERROR, Error code: %d.\n"), err_code);
    }

   

    err_code = FS_PowerOn();
    if(ERR_SUCCESS == err_code)
    {
        CSW_TRACE(BASE_BAL_TS_ID,"FS Power On Check OK.\n");
    }
    else
    {
        CSW_TRACE(BASE_BAL_TS_ID,"FS Power On Check ERROR, Error code: %d. \n",err_code);
    }

   // Get FS device table.
   err_code = FS_GetDeviceInfo(&fs_dev_count, &fs_dev_info);
   if(err_code != ERR_SUCCESS)
   {
        CSW_TRACE(BASE_BAL_TS_ID,"Device not register.\n");
        fs_dev_count = 0;
    }

    // Check the state of root device ,if not format, format it.
    // Mount root device.
    for(i = 0; i < fs_dev_count; i++)
    {
        // format the flash device.
        if(fs_dev_info[i].dev_type == FS_DEV_TYPE_FLASH && fs_dev_info[i].is_root == TRUE)
        {
            err_code = FS_HasFormatted(fs_dev_info[i].dev_name,FS_TYPE_FAT);

            if(ERR_FS_HAS_FORMATED == err_code)
            {
                CSW_TRACE(BASE_BAL_TS_ID,"The flash device %s has formated.\n",fs_dev_info[i].dev_name);
            }
            else if(ERR_FS_NOT_FORMAT == err_code)
            {        

                CSW_TRACE(BASE_BAL_TS_ID,"The flash device %s not format.\n",fs_dev_info[i].dev_name);
                err_code = FS_Format(fs_dev_info[i].dev_name,FS_TYPE_FAT,0);
                if(ERR_SUCCESS == err_code)
                {
                    CSW_TRACE(BASE_BAL_TS_ID,"The flash device %s format ok.\n",fs_dev_info[i].dev_name);
                }
                else if(ERR_FS_NOT_FORMAT == err_code)
                {
                    CSW_TRACE(BASE_BAL_TS_ID,"The flash device %s format error.Error code:%d.\n",fs_dev_info[i].dev_name,err_code);            
                }    
            }
            else 
            {
                CSW_TRACE(BASE_BAL_TS_ID,"The flash device %s has formated error.Error code:%d.\n",fs_dev_info[i].dev_name,err_code);
                
            }
             
            // Mount root device.
            if(fs_root_dev_count > 0)
            {
              CSW_TRACE(BASE_BAL_TS_ID,"The FS root device too more:%d.\n",fs_root_dev_count);
            }
            else
            {
                err_code = FS_MountRoot(NULL);
                if(ERR_SUCCESS == err_code)
                {
                    CSW_TRACE(BASE_BAL_TS_ID,"FS MountRoot(%s) OK.\n",fs_dev_info[i].dev_name);
                }
                else
                {
                    CSW_TRACE(BASE_BAL_TS_ID,"FS MountRoot(%s) ERROR, Error code: %d. \n",fs_dev_info[i].dev_name,err_code);
                }
            }
            fs_root_dev_count ++;
                       
        }
    }


//#ifdef SIM_SWITCH_ENABLE
#if 0
    //
    //Add by lixp at 070407
    //SimSwitch(UINT8 SimNum)
    //#define SIM_1 1 //simcard 1
    //#define SIM_2 2 //simcard 2
    //
    UINT8 nSIMCARD_INDEX = 0x00;
    err_code = CFW_CfgGetSimSwitch(&nSIMCARD_INDEX);
    if(ERR_SUCCESS == err_code)
    {
        CSW_TRACE(BASE_BAL_TS_ID, TSTXT("CFW_CfgGetSimSwitch OK.\n"));
    }
    else
    {
        CSW_TRACE(BASE_BAL_TS_ID, TSTXT("CFW_CfgGetSimSwitch ERROR, Error code: 0x%08x \n"), err_code);
    }
    
    SimSwitch(nSIMCARD_INDEX);
    CSW_TRACE(BASE_BAL_TS_ID, TSTXT("nSIMCARD_INDEX is %d\n"),nSIMCARD_INDEX);
#endif
#ifdef FSTRACE_SUPPORT
    fsTace_task_create();
#endif
    #if defined(USER_DATA_CACHE_SUPPORT) && !defined(_T_UPGRADE_PROGRAMMER) 
    err_code = VDS_InitCache();   // Initialize VDS Cache.
    if(ERR_SUCCESS == err_code)
    {
        CSW_TRACE(BASE_BAL_TS_ID,"VDS_InitCache() OK.\n");        
    }
    else
    {
        CSW_TRACE(BASE_BAL_TS_ID,"VDS_InitCache() ERROR, Error code: %d.\n", err_code);
    }    
    #endif
    return TRUE;
}