Author Topic: MSC Host: How do I clear UNIT ATTENTION?  (Read 13282 times)

MartinJK

  • Member
  • ***
  • Posts: 5
MSC Host: How do I clear UNIT ATTENTION?
« on: March 19, 2011, 06:07:59 am »
I am currently debugging my USB MSC host class implementation (on Blackfin development board) that connects to an SD Card reader. I am using TEST UNIT READY and this works fine for detecting media in the card reader, however if I remove the card and reinsert it the SENSE data always shows UNIT_ATTENTION with ASC = 28h (not ready to ready change) and never clears.
 
If, on startup of my application, no card is present all is OK: I can insert a card and send TEST UNIT READY a few times and the above UNIT_ATTENTION clears. However, once inserted, subsequent re-insertions fail to clear UNIT_ATTENTION.
 
Does anyone know of a way to clear the UNIT_ATTENTION and get the SENSE data back to Key=00h, ASC = 00h?

Thanks
Martin

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: MSC Host: How do I clear UNIT ATTENTION?
« Reply #1 on: March 21, 2011, 02:53:11 pm »
Because so many mass-storage devices don't comply with the spec but instead are designed just well enough to work with major OSes, a way to debug is to attach the device to a Windows host, use a protocol analyzer to record the traffic, and program your host to do whatever Windows does.

Jan

MartinJK

  • Member
  • ***
  • Posts: 5
Re: MSC Host: How do I clear UNIT ATTENTION?
« Reply #2 on: March 21, 2011, 04:37:24 pm »
Hi Jan

Thanks for the reply. The only thing I could see from the trace was a READ CAPACITY attempt after getting a NOT READY response: the device stalls - as it should - and the host clears - as it should. I tried this today and it worked....

Then I tried again without the READ CAPACITY and it also worked. A case of the Friday afternoon blues I think!!

Thanks
Martin