cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, trying to read and write files into spi flash 1megaByte through msc configured usb. I keep getting , unable to complete format when plugging usb to pc.

svii
Associate III

spi flash driver is tested and working fine.

///////////////////////////usbd_stoarge_if.c////////////////////////////////

#define STORAGE_LUN_NBR         1

#define STORAGE_BLK_NBR         0x200    

#define STORAGE_BLK_SIZ         256

int8_t STORAGE_Read_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)

{

 /* USER CODE BEGIN 6 */

 uint32_t add_blk = blk_addr*0x1000;  

 SST80B_ReadSector(buf,0,add_blk,blk_len);

return (USBD_OK);

 /* USER CODE END 6 */

}

int8_t STORAGE_Write_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)

{

 /* USER CODE BEGIN 7 */

 uint32_t add_blk = blk_addr*0x1000 ;  

 chipsector_erase_call(add_blk);

 SST25Write(add_blk,(uint8_t *)buf,blk_len);

 return (USBD_OK);

/* USER CODE END 7 */

}

above is the code ,kindly let me know what could be the problem.

The spi flash has a minimum 4096 erase so i have tried this

out add_blk =blk_addr*0x1000.

I have tried :

#define STORAGE_LUN_NBR         1

#define STORAGE_BLK_NBR         0x100    

#define STORAGE_BLK_SIZ          0x200

again while formatting it fails

when i try

I have tried :

#define STORAGE_LUN_NBR         1

#define STORAGE_BLK_NBR         0x100    

#define STORAGE_BLK_SIZ          0x1000

formatting does not even start the code gets hanged.

let me know any suggestions ,thanks in advance.

0 REPLIES 0