Invalid parameter error with IOCTL_DISK_READ on Nand Flash RRS feed

  • Question

  • I'm using the IOCTL_DISK_READ DeviceIOControl() to directly access sectors of NAND Flash of my device (CE6.0).
    This is needed in my case for specific testing purpose.

    The DeviceIOControl() fails, I get an Invalid parameter error, but the same code returns successfully on other media devices (i.e.SD-Card or iNAND).

    Anyone knows the reason of this?


    Here is the code:

    HANDLE hStore;
    STOREINFO StoreInfo;
    DWORD BytesRead;
    SG_REQ InStruct;
    BYTE* pData;
    DWORD DataBytes;

    hStore = OpenStore(TEXT("DSK1:"));

    StoreInfo.cbSize = sizeof(StoreInfo);
    GetStoreInfo( hStore, &StoreInfo ) ;

    StoreBytes = StoreInfo.snNumSectors * StoreInfo.dwBytesPerSector;

    DataBytes = StoreInfo.dwBytesPerSector;
    pData = (BYTE*)malloc( DataBytes );

    InStruct.sr_start = 0;                        //Physical sector to read.
    InStruct.sr_num_sec = 1;                    //Number of sectors to read.
    InStruct.sr_num_sg = 1;                        //Number of output buffers.
    InStruct.sr_status = ERROR_SUCCESS;
    InStruct.sr_callback = NULL;
    InStruct.sr_sglist[0].sb_buf = pData;        //Pointer to output data buffer for read data.
    InStruct.sr_sglist[0].sb_len = DataBytes;    //Output data buffer size.

    if ( !DeviceIoControl(hStore,            // Handle to the device
                        IOCTL_DISK_READ,        // IOCTL for the operation
                        &InStruct,                // Pointer to input data buffer.
                        sizeof(InStruct),        // Size of input data buffer.
                        NULL,                    // Pointer to output data buffer.
                        0,                        // Size of output data buffer.
                        &BytesRead,                // Pointer to variable (bytes read in output buffer).
                        NULL) )
            OUTPUT(TEXT("ERROR: sector %d read failure...error %d!\n"), InStruct.sr_start, GetLastError() );

    Friday, March 16, 2012 9:12 AM

All replies

  • Check if the handle "hStore" is valid or not. That is you are able to open the SDK1 partition.

    --- Misbah

    Senior Design Engineer T.E.S Electroni Solutions (Bangalore-India)

    Friday, March 16, 2012 11:33 AM
  • Hi Misbah,

    hStore is valid and I'm able to get the store info, but IOCTL_DISK_READ fails.

    Thank you for helping!

    Friday, March 16, 2012 11:46 AM
  • Are you able to call these IOCTL's "IOCTL_DISK_GETINFO", "IOCTL_DISK_WRITE" ?

    Try calling "DISK_IOCTL_READ" if it supports and compiles for you

    --- Misbah

    Senior Design Engineer T.E.S Electroni Solutions (Bangalore-India)

    Friday, March 16, 2012 1:06 PM
  • Try calling the IOCTL on the partition handle rather than the store handle.
    Friday, March 16, 2012 4:27 PM