Esempio n. 1
0
GSN_STATUS
App_FsInit(APP_FS_T *pFsCtx)
{
	UINT32 memsize, memsize1;
	INT32 rc;
	UINT8 *pFsBuff, *pFsBuff1;
	
	pPartn_0_Info = &pFsCtx->partn[APP_FS_PARTN_CONFIG];
	pPartn_1_Info = &pFsCtx->partn[APP_FS_PARTN_WEB_PAGES];

	f_init();
	f_enterFS();
    App_ConfigPartnInfoSet(pFsCtx);
	/*Initialise Partition 0 (used cof storing configuration)*/
	memsize = fs_getmem_flashdrive(fs_phy_nor_n25q_32mb_3v_65nm_0);
	pFsBuff = gsn_malloc(memsize);
    if(pFsBuff != NULL)
    {
		rc = f_mountdrive(0, pFsBuff, memsize, (void *)fs_mount_flashdrive,
							fs_phy_nor_n25q_32mb_3v_65nm_0);
		if(rc == F_ERR_NOTFORMATTED)
		{
			f_format(0);
		}
	}
	else
	{
		while(1);
	}
	
#ifdef ADK_PROV_ENABLE/* Initialise Appropriate Web Pages Partition */

	App_WebPagesPartnInfoSet(pFsCtx);

	memsize1 = fs_getmem_flashdrive(fs_phy_nor_n25q_32mb_3v_65nm_1);
	pFsBuff1 = gsn_malloc(memsize1);
	if(pFsBuff != NULL)
	{
		rc = f_mountdrive(1, pFsBuff1, memsize1, (void *)fs_mount_flashdrive,
				fs_phy_nor_n25q_32mb_3v_65nm_1);
        if(rc == F_ERR_NOTFORMATTED)
		{
			return GSN_FAILURE;
		}
	}
	else
	{
		while(1);
	}

#endif	
    return GSN_SUCCESS;
}
Esempio n. 2
0
PUBLIC INT32
S2wCert_FlashFileLoad(char *fileName)
{
	INT32 fileLen,index;
	F_FILE *fd; 
	char name[64]={0};
	if(fileName == NULL)
		return -1;
    if(!s2wappMainTaskCtxt->fsInit)
    {
		App_FsInit();
		s2wappMainTaskCtxt->fsInit = TRUE;
        f_enterFS();
	}
	index=sprintf(name,"A:/certs/");	
	index=sprintf(name+index,fileName);	
	fileLen = f_filelength(name);
	if(fileLen == -1)
	{
		name[0]='B';
		fileLen = f_filelength(name);
		if(fileLen == -1)
		{					
			index = -1;		
			goto FlashFileLoadExit;
	}
	}	
	index = S2wCert_MemAlloc (fileLen);
	if(index != -1)
	{
	s2w_ssl_cert_table[index].name = gsn_malloc(strlen(fileName) + 1);
	if(s2w_ssl_cert_table[index].name == NULL)
	{
			S2wCert_MemFree(s2w_ssl_cert_table[index].certAddress);
			index = -1; 	
			goto FlashFileLoadExit;
	}
	strcpy((char*)s2w_ssl_cert_table[index].name, fileName);
	s2w_ssl_cert_table[index].location = CERT_IN_FLASH;
		fd = f_open(name, "r");
		if(fd == NULL)
	{
			S2wCert_MemFree(s2w_ssl_cert_table[index].certAddress);
			gsn_free(s2w_ssl_cert_table[index].name);
			index = -1; 	
			goto FlashFileLoadExit;
		}
		f_read(s2w_ssl_cert_table[index].certAddress+2, 1, fileLen, fd);
		s2w_ssl_cert_table[index].certAddress[0] = (fileLen & 0xff);
		s2w_ssl_cert_table[index].certAddress[1] = ((fileLen >> 8) & 0xff);
		f_close(fd);
	}
Esempio n. 3
0
static void setUpFlash()
{
    f_enterFS();
#ifdef MOD5441X
    int drv = OpenOffBoardFlash();
    int rv = f_chdrive( drv );
    if (rv == F_NO_ERROR)
    {
        printf("External Flash opened.\r\n");
        extFlashOpened = true;
    }
    else
    {
        printf("FAILED TO OPEN EXTERNAL FLASH.\r\n");
    }
#elif defined NANO54415
    InitExtFlash();
    extFlashOpened = true;
#else
#error Platform type unknown for filesytem setup.
#endif
}
int *initOnBoardSD(int drv) {

	static int card_status[2] = { 0, 0 };
	f_enterFS();
	int rv = f_chdrive(drv);

	if (rv == F_NO_ERROR) {
		iprintf("drive change successful\r\n");
		//iprintf("No of Files Found = %d\n",DumpDir());
		card_status[0] = 1;
		card_status[1] = DumpDir();
		return card_status;

	}

	else {
		iprintf("drive change failed: ");
		DisplayEffsErrorCode(rv);
		card_status[0] = -1;
		card_status[1] = 0;
		return card_status;
	}
}
Esempio n. 5
0
/**
 ******************************************************************
 * @ingroup S2w-Application
 * @brief Process delete SSL certificate. 
 *   This function delete the certificate.
 * @param certName        pointer to to certificate name to delete
 * @param 0   Operation success.
 * @return  1  Operation failed.
 ******************************************************************/
PUBLIC UINT8  
AppS2w_CertDelete(UINT8 *certName)
{
    UINT8 fileName[42]={0};
    INT32 retVal =0;
    UINT32 len;
    if(!s2wappMainTaskCtxt->fsInit)
    {
		App_FsInit();
		s2wappMainTaskCtxt->fsInit = TRUE;
        f_enterFS();
	}
	S2wCert_MemFree(certName);
	len = sprintf((char*)fileName,"A:/certs/");	
	memcpy(fileName+len,certName,strlen((const char *)certName));
	retVal = f_delete((char*)fileName);
	if(retVal == F_NO_ERROR)
	{
		return S2W_SUCCESS; 
	}
	else
		return S2W_FAILURE;			
}
Esempio n. 6
0
INT32
S2wCert_SearchFlash(char *ptr)
{
	F_FILE *fd;
    if(!s2wappMainTaskCtxt->fsInit)
    {
		App_FsInit();
		s2wappMainTaskCtxt->fsInit = TRUE;
        f_enterFS();
	}
	f_chdir("certs");
	fd = f_open(ptr, "r");
	f_chdir("..");

	if(fd)
	{
		f_close(fd);
		return -1;
	}
	else
	{
		return 0;
	}
}