AnsweredAssumed Answered

How use to nandflash on usbdevice?

Question asked by Kwon YM on May 8, 2018
Latest reply on May 8, 2018 by Clive One

I use STM32F429IG, MT29F4G08ABADAWP that have been tested nandflash alright.

 

I want nandflash as usb device on WINDOWS10.

 

So, I setting USB_DEVICE and mass Storage Class and use example "STM32_USB-FS-Device_Lib_V4.1.0".

 

Finally, I can see USB device on WINDOWS10, but it can't express anymore information. ex) volume.

 

I heard, for ues this, It needs "format" to nand flash. right?

 

So, how can I use it?

 

or What I need?

 

[usbd_storage_if.c]------------------------------------

int8_t STORAGE_Init_FS (uint8_t lun)
{
/* USER CODE BEGIN 2 */
return (USBD_OK);
/* USER CODE END 2 */
}


int8_t STORAGE_GetCapacity_FS (uint8_t lun, uint32_t *block_num, uint16_t *block_size)
{
/* USER CODE BEGIN 3 */
*block_num = STORAGE_BLK_NBR;
*block_size = STORAGE_BLK_SIZ;
return (USBD_OK);
/* USER CODE END 3 */
}


int8_t STORAGE_IsReady_FS (uint8_t lun)
{
/* USER CODE BEGIN 4 */
if(HAL_NAND_Read_Status(&hnand1) == NAND_READY)
return (USBD_OK);
else
return (USBD_FAIL);
/* USER CODE END 4 */
}


int8_t STORAGE_IsWriteProtected_FS (uint8_t lun)
{
/* USER CODE BEGIN 5 */
return (USBD_OK);
/* USER CODE END 5 */
}


int8_t STORAGE_Read_FS (uint8_t lun,
uint8_t *buf,
uint32_t blk_addr,
uint16_t blk_len)
{
/* USER CODE BEGIN 6 */
NAND_AddressTypeDef Address;

Address.Plane = 0x00;
Address.Block = blk_addr >> 6;
Address.Page = blk_addr & 0x3F;

HAL_NAND_Read_Page(&hnand1, &Address, buf, 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 */
NAND_AddressTypeDef Address;

Address.Plane = 0x00;
Address.Block = blk_addr >> 6;
Address.Page = blk_addr & 0x3F;
HAL_NAND_Write_Page(&hnand1, &Address, buf, blk_len);

return (USBD_OK);
/* USER CODE END 7 */
}


int8_t STORAGE_GetMaxLun_FS (void)
{
/* USER CODE BEGIN 8 */
return (STORAGE_LUN_NBR - 1);
/* USER CODE END 8 */
}

-----------------------------------------------

Outcomes