cancel
Showing results for 
Search instead for 
Did you mean: 

USB host MSC read sector count

hamidrezanayeri
Associate III

Hello everyone.

I am working on a project which needs low level access to USB mass storage class such as reading sector size/count of an attached storage device but thus far I could not get anything out of my board which is nucleo-f446re.

I have initialized my board as a USB host mass storage class and I am abled to write on specific sectors such as sector number 10 and it DOES write it down using msc_scsi.c functions but I can't find any solution to determine sector count of attached device. I just can't find the appropriate function/data structure for it,

Can anyone please help me with it?

11 REPLIES 11

SCSI command READ CAPACITY doesn't work as it always returns 0.

Should I initialize something first? And if yes, how to do so?

I'm not using fatfs middleware so I guess lots of data structures are not initialized automatically.

hamidrezanayeri
Associate III

Also it might be worth noting that phost->pActiveClass->pData is equal to 0 which means null pointer and when I make a call to any function that uses this particular data, the micro hangs completely. That's why I think I'm missing some initialization steps.

However phost->pData is set and can be referenced, but it doesn't contain the valid data I'm looking for.