[求助]用CH375读取U盘的0扇区错误

hcn老大,

请问我用CH375读取U盘的0扇区时为什么给我返回错误的信息呢,以下为返回的0扇区的信息:

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 3C 8C E8 00 00 00 01 01 00 06 3F 20 7D 20 00 00 00 E0 E7 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

好像就是最后2个字节是正确的,而其它的都不对,这是为什么?

以下为我用来读扇区的部分程序,是根据《USB 芯片CH375 的评估板说明及应用参考》中的例子程序修改的:

unsigned char ReadSector(unsigned long iLbaStart) { unsigned char mIntStatus; unsigned char *mBufferPoint; unsigned int mBlockCount; unsigned char mLength,tmp; unsigned char temp[] = "Sector0:";

Write_COM_Sentence(temp);

CH375A_CMD_Write( CMD_DISK_READ ); //send disk read request CH375A_DATA_Write( (unsigned char)iLbaStart ); //send the lowest 8 bits of the sector address CH375A_DATA_Write( (unsigned char)( iLbaStart >> 8 ) ); //send the second low 8 bits of the sector address CH375A_DATA_Write( (unsigned char)( iLbaStart >> 16 ) ); //send the second high 8 bits of the sector address CH375A_DATA_Write( (unsigned char)( iLbaStart >> 24 ) ); //send the highest 8 bits of the sector address CH375A_DATA_Write( 1 ); //sends the number of sectors mBufferPoint = dataBuffer; //points to the data buffer // for ( mBlockCount = iSectorCount * 8; mBlockCount != 0; mBlockCount -- )

for ( mBlockCount = 8; mBlockCount != 0; mBlockCount -- ) { mIntStatus = WaitInt(); //waits for the interrupts if ( mIntStatus == USB_INT_DISK_READ ) //if the data is available from CH375A { CH375A_CMD_Write(CMD_RD_USB_DATA ); //reads the data from CH375A mLength = CH375A_DATA_Read(); //first reads the length of the data while (mLength) { tmp = CH375A_DATA_Read(); Write_COM_Byte1(tmp); *mBufferPoint = tmp; //reads the data and save it the databuffer mBufferPoint ++; mLength --; } CH375A_CMD_Write( CMD_DISK_RD_GO ); //continue reading the data } else break; // break from the loop if there is error } if ( mBlockCount == 0 ) { mIntStatus = WaitInt( ); if ( mIntStatus == USB_INT_SUCCESS ) return( 0 ); //read success } return( mIntStatus ); //read fails and return the reason }

hcn老大,

请问我用CH375读取U盘的0扇区时为什么给我返回错误的信息呢,以下为返回的0扇区的信息:

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 3C 8C E8 00 00 00 01 01 00 06 3F 20 7D 20 00 00 00 E0 E7 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

好像就是最后2个字节是正确的,而其它的都不对,这是为什么?

以下为我用来读扇区的部分程序,是根据《USB 芯片CH375 的评估板说明及应用参考》中的例子程序修改的:

unsigned char ReadSector(unsigned long iLbaStart) { unsigned char mIntStatus; unsigned char *mBufferPoint; unsigned int mBlockCount; unsigned char mLength,tmp; unsigned char temp[] = "Sector0:";

Write_COM_Sentence(temp);

CH375A_CMD_Write( CMD_DISK_READ ); //send disk read request CH375A_DATA_Write( (unsigned char)iLbaStart ); //send the lowest 8 bits of the sector address CH375A_DATA_Write( (unsigned char)( iLbaStart >> 8 ) ); //send the second low 8 bits of the sector address CH375A_DATA_Write( (unsigned char)( iLbaStart >> 16 ) ); //send the second high 8 bits of the sector address CH375A_DATA_Write( (unsigned char)( iLbaStart >> 24 ) ); //send the highest 8 bits of the sector address CH375A_DATA_Write( 1 ); //sends the number of sectors mBufferPoint = dataBuffer; //points to the data buffer // for ( mBlockCount = iSectorCount * 8; mBlockCount != 0; mBlockCount -- )

for ( mBlockCount = 8; mBlockCount != 0; mBlockCount -- ) { mIntStatus = WaitInt(); //waits for the interrupts if ( mIntStatus == USB_INT_DISK_READ ) //if the data is available from CH375A { CH375A_CMD_Write(CMD_RD_USB_DATA ); //reads the data from CH375A mLength = CH375A_DATA_Read(); //first reads the length of the data while (mLength) { tmp = CH375A_DATA_Read(); Write_COM_Byte1(tmp); *mBufferPoint = tmp; //reads the data and save it the databuffer mBufferPoint ++; mLength --; } CH375A_CMD_Write( CMD_DISK_RD_GO ); //continue reading the data } else break; // break from the loop if there is error } if ( mBlockCount == 0 ) { mIntStatus = WaitInt( ); if ( mIntStatus == USB_INT_SUCCESS ) return( 0 ); //read success } return( mIntStatus ); //read fails and return the reason }

不好意思,刚才发完帖才发现忘了在数据中间加回车了,不好看,现在我给修改一过来。


那你用工具看下你的U盘的第0扇区是不是这个数据,你这个数据好象是第1扇区的数据,不像第0扇区的数据


没有错,你读第32扇区试试看。


谢谢啦,我试试


嗯,第32扇区果然是扇区0,但是为什么扇区0跑到扇区32了呢?那我读的扇区0是什么?


哈哈,跟我一样困扰


物理上面的第0扇区实际上相当于硬盘的主引导扇区(MBR),只是针对有的U盘,而有些U盘则没有这个


哦,原来如此


只有登录才能回复,可以选择微信账号登录