Author Topic: USB Device reset  (Read 5136 times)

Harish

  • Member
  • ***
  • Posts: 8
USB Device reset
« on: April 14, 2017, 12:41:43 am »
Hi Jan,

I need a help again with below two points.
1. I have a case where the files are written to flash in a Microcontroller using file system and host cannot write anything to device flash as write command is disabled in SCSI states. In flash I can see files are updated but its not visible in Host drive.
When I remove and reconnect the USB stick manually, I can see the updated files.
Please provide a solution to see when a file is updated internally from flash then I should be able to see files in host drive as well.

2. I have to make USB device as write protected. For that I have removed SCSI write in the device so that host cannot write anything.
But in host side, whenever it tries to write something SCSI state doesn't respond and it simply breaks so host hangs the computer. Is there any way to inform host that device is write protected may be by file system or SCSI write response?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB Device reset
« Reply #1 on: April 14, 2017, 09:36:58 am »
1. From my book USB Mass Storage:

A device that accesses files on its own (not via the USB host) should inform the USB host when firmware has written to a file or made other changes to a volume’s contents. A device can do so via the UNIT ATTENTION condition.

2. The device needs to report that it is write protected by using the UNIT ATTENTION condition and response to REQUEST SENSE. See:

https://en.wikipedia.org/wiki/Key_Code_Qualifier

Harish

  • Member
  • ***
  • Posts: 8
Re: USB Device reset
« Reply #2 on: June 22, 2017, 06:36:04 am »
Hi Jan,

In TEST Unit ready, if a new file is written then I send bCSWStatus as 1 it means failed.
Then host sends REQUEST SENSE command,
It is replied with
Sense->errCode       =   0x70;
Sense->senseKey      =    0x06;
Sense->addSenseLength    =    10;
Sense->addSenseCode    =    0x28;
Sense->addSenseCode   =    0;

After this is sent, bCSWStatus=0 is sent to acknowledge

Here are the observations
1. files needs a refreshing
2. it takes more time in windows
3. very slow and sometimes hangs or nothing is changing in Linux.
4. medium removal command is executed

Is anything missing above or not correct, please let me know.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research