cancel
Showing results for 
Search instead for 
Did you mean: 

how to read or write multi-sectors after send one cmd? (STM32 105 host)

wuhaibin011
Associate II
Posted on March 27, 2011 at 17:53

how to read or write multi-sectors after send one cmd? (STM32 105 host)

3 REPLIES 3
Posted on May 17, 2011 at 14:29

The SCSI READ10 command itself takes a block count, other parts of your transfer chain might need to know the total size of the transfer. You'd have to review how the subroutine converts the size back to blocks.

The blocks are typically 512 bytes for hard-drives, 2048 for CD/DVD drives. You should use a READ CAPACITY command to get the parameters the drive is working from.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
wuhaibin011
Associate II
Posted on May 17, 2011 at 14:29

thanks a lot for clive1's reply.

i still don't understand the question.  the follow file is the FATFS 0.8.

if i take like this , is it right?

thanks a lot!

////////////////////////////////////

DRESULT disk_read (

 

 BYTE drv,  /* Physical drive nmuber (0..) */

 

 BYTE *buff,  /* Data buffer to store read data */

 

 DWORD sector, /* Sector address (LBA) */

 

 BYTE count  /* Number of sectors to read (1..255) */

 

)

 

{

  uint8_t status = RES_ERROR;

  if( !count )

 

  {   

 

    return RES_PARERR;  

 

  }

  switch (drv)

 

  {

 

    case 0: 

 

 if(HCD_IsDeviceConnected(&USB_OTG_FS_dev))

 

 {

 

       if(count==1)            /* one sector */     

 

       {           

 

          do

 

          {               

 

            status = USBH_MSC_Read10( (uint8_t *)(&buff[0]) ,sector,USBH_MSC_Param.MSPageLength);

 

            USBH_MSC_HandleBOTXfer();

 

          }

 

          while((status == USBH_MSC_BUSY ) && (HCD_IsDeviceConnected(&USB_OTG_FS_dev)));

 

       }

 

       else                    /* multi-sector */    

 

       {

 

       do

 

          {

 

            status = USBH_MSC_Read10( (uint8_t *)(&buff[0]) ,sector,count*512);

 

            USBH_MSC_HandleBOTXfer();

 

          }

 

          while((status == USBH_MSC_BUSY ) && (HCD_IsDeviceConnected(&USB_OTG_FS_dev)));

 

    }

 

 }                                                                                     

 

   

 

 if(status == USBH_MSC_OK)

 

    {

 

      return RES_OK;

 

    }

 

    else

 

    {

 

      return RES_ERROR;

 

    }

 case 1: 

 

   break;

    case 2: 

 

   break;

    default:

 

      break;

  }

 

 

 

  return RES_ERROR;

 

}//////////////////////////////

 

From: clive1

 

Posted: Sunday, March 27, 2011 6:14 PM

 

Subject: how to read or write multi-sectors after send one cmd? (STM32 105 host)

 

clive1Sunday, March 27, 2011 6:14 PMhow to read or write multi-sectors after send one cmd? (STM32 105 host)

The SCSI READ10 command itself takes a block count, other parts of your transfer chain might need to know the total size of the transfer. You'd have to review how the subroutine converts the size back to blocks.

The blocks are typically 512 bytes for hard-drives, 2048 for CD/DVD drives. You should use a READ CAPACITY command to get the parameters the drive is working from.

wuhaibin011
Associate II
Posted on May 17, 2011 at 14:29

Up!