Skip to main content
MVV.1
Associate II
June 3, 2021
Solved

problem mapping NAND flash to PC through USB_MSC

  • June 3, 2021
  • 9 replies
  • 2585 views

I just made a FS_USB_MSC project and I wanted to access the flash from my windows computer.

when I use RAM space for the STORAGE_Read_FS and STORAGE_Write_FS I can Access the RAM without any problem. and also I can format the space in windows to be able to access it.

but when I use HAL_NAND functions the windows says "windows was unable to complete the format". the fucntions that I wrote to access the flash memory are :

*************************************************************************

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

{

 /* USER CODE BEGIN 6 */

pAddressz = (NAND_AddressTypeDef){blk_addr%64,0,blk_addr/64}; //page,plane,block

if(HAL_NAND_Read_Page_8b(&hnand1, &pAddressz, buf, blk_len) != HAL_OK){

return USBD_FAIL;

}

 return (USBD_OK);

 /* USER CODE END 6 */

}

/**

 * @brief .

 * @param lun: .

 * @retval USBD_OK if all operations are OK else USBD_FAIL

 */

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

{

 /* USER CODE BEGIN 7 */

pAddressz = (NAND_AddressTypeDef){blk_addr%64,0,blk_addr/64}; //page,plane,block

if(HAL_NAND_Write_Page_8b(&hnand1, &pAddressz, buf, blk_len) != HAL_OK){

return USBD_FAIL;

}

 return (USBD_OK);

 /* USER CODE END 7 */

}

**********************************************************************

pls help find the problem.

This topic has been closed for replies.
Best answer by Tesla DeLorean

For the write you'll need to manage the erase and larger erase block size

9 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
June 3, 2021

For the write you'll need to manage the erase and larger erase block size

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
MVV.1
MVV.1Author
Associate II
June 3, 2021

what do you mean by "manage the erase"?

and what do you mean by "larger erase block size"?

Tesla DeLorean
Guru
June 3, 2021

You have to erase data in flash before you can re-write over it.

The erase size is likely 128KB, or more, you're writing 512 byte blocks into the middle of that, the mass storage device expects the other data to be kept safe, not disappear.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
MVV.1
MVV.1Author
Associate II
June 7, 2021

Thanks for helping me Tesla DeLorean!