cancel
Showing results for 
Search instead for 
Did you mean: 

How use to nandflash on usbdevice?

Kwon YM
Associate
Posted on May 08, 2018 at 21:03

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 */

}

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

1 REPLY 1
Posted on May 08, 2018 at 23:43

You'd need to manage the NAND at a block level, both erase, and writing partial blocks. You might need to address the read/write of multiple sectors that span the NAND block boundaries. Other thing to address would likely be ECC data, correction and wear leveling.

Windows would need to format a file system on to a blank NAND device. ie structures for FAT32, etc.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..