none
SDHC: SdBus driver RRS feed

  • Question

  • Hello,
    I have a problem with the SDHC driver. The SdBus driver is getting hanged while I transfer data to the SD card.
    The driver is stuck in:
    ..\WinCE8\WinCE8\public\common\oak\drivers\sdcard\sdbus\sddevice.cpp
    SD_API_STATUS CSDDevice::SDReadWriteRegistersDirect_I(SD_IO_TRANSFER_TYPE ReadWrite, DWORD Address, BOOLEAN ReadAfterWrite,PUCHAR pBuffer,ULONG BufferLength)
    ->    line 2731

    It looks like this problem:
    https://social.msdn.microsoft.com/Forums/en-US/434c782f-06ee-42c4-a56f-6611aca72a64/sd-bus?forum=winembplatdev

    https://community.nxp.com/message/320021

    It seems that the SdBus driver is not SMP capable. You can see that in the following procedure:

        ...

        PID:00400002 TID:03F80026 --    CSDBusReqAsyncQueue::QueueBusRequest: (line 129) SubmitRequestToHC: pRequ=0xdd69a860 cmd=25

        PID:00400002 TID:03F80026 ++ -> CESDHCBase::BusRequestHandler: pRequ=0xdd69a864 cmd=25 m_pCurRequ=0x00000000

        PID:00400002 TID:03F80026 ++ <- CESDHCBase::BusRequestHandler: pRequ=0xdd69a864 status=1

        PID:00400002 TID:03F80026 --    CSDBusReqAsyncQueue::QueueBusRequest: (line 109) m_pQueueListLast->SetAsyncQueueNext: pRequ=0xcc8e74b0 cmd=12

     

        PID:00400003 TID:010C000E ++    DMA_COMPLETE: pRequ=0xdd69a864

        PID:00400003 TID:010C000E ++ -> HndlTxCmplt: sIrqStat=0x0000000b

        PID:00400003 TID:010C000E ++ -> IndicateBusRequCmplt: pRequ=0xdd69a864 status=0

        PID:00400003 TID:010C000E --    CSDBusReqAsyncQueue::CompleteRequest: (line 184) pRequest->CompleteBusRequest

        PID:00400003 TID:010C000E --    CSDBusReqAsyncQueue::CompleteRequest: (line 200) SbmtRqustToHC pRequ=0xcc8e74b0

        PID:00400003 TID:04050002 --    CSDBusReqAsyncQueue::QueueBusRequest: (line 109) m_pQueueListLast->SetAsyncQueueNext: pRequ=0xc445e3f0 cmd=18

        PID:00400002 TID:010C000E ++ -> BusRequHndlr: pRequ=0xcc8e74b4 cmd=12 m_pCurRequ=0x00000000

        PID:00400003 TID:04050002 --    CSDBusReqAsyncQueue::QueueBusRequest: (line 109) m_pQueueListLast->SetAsyncQueueNext: pRequ=0xc445e4a0 cmd=12

        PID:00400002 TID:010C000E ++ -> IndicateBusRequCmplt: pRequ=0xcc8e74b4 status=0

        PID:00400003 TID:010C000E --    CSDBusReqAsyncQueue::CompleteRequest: (line 184) pRequest->CompleteBusRequest

        PID:00400003 TID:010C000E --    CSDBusReqAsyncQueue::CompleteRequest: (line 200) SbmtRqustToHC pRequ=0xc445e3f0

        PID:00400003 TID:010C000E ++ -> BusRequHndlr: pRequ=0xc445e3f4 cmd=18 m_pCurRequ=0x00000000

        PID:00400003 TID:010C000E ++    SndCmd: XferTyp=0x123a0037

        PID:00400003 TID:010C000E ++ <- BusRequHndlr: pRequ=0xc445e3f4 status=1

        PID:00400003 TID:010C000E ++ <- IndicateBusRequCmplt: status=0  pReq=0xcc8e74b4  cmd=12

        PID:00400003 TID:010C000E ++    BusRequHndlr: m_pCurRqu=0xc445e3f4 m_fCurRquFPath=1

        PID:00400003 TID:010C000E ++ -> IndicateBusRequCmplt: pRequ=0xcc8e74b4 status=0

        PID:00400003 TID:010C000E ++ <- IndicateBusRequCmplt: status=2  m_FastPathStatus=2

        PID:00400003 TID:010C000E ++ <- BusRequHndlr: pRequ=0xcc8e74b4 status=0

        PID:00400003 TID:010C000E ++ <- IndicateBusRequCmplt: status=0  pReq=0xdd69a864  cmd=18

                                    

        PID:00400002 TID:010C000E ++    DMA_COMPLETE: pRequ=0xc445e3f4

        PID:00400003 TID:010C000E ++ -> HndlTxCmplt: sIrqStat=0x0000000b

        PID:00400003 TID:010C000E ++ -> IndicateBusRequCmplt: pRequ=0xc445e3f4 status=0

        PID:00400003 TID:010C000E --    CSDBusReqAsyncQueue::CompleteRequest: (line 184) pRequest->CompleteBusRequest

        PID:00400003 TID:010C000E --    CSDBusReqAsyncQueue::CompleteRequest: (line 200) SbmtRqustToHC pRequ=0xc445e4a0

        PID:00400003 TID:010C000E ++ -> BusRequHndlr: pRequ=0xc445e4a4 cmd=12 m_pCurRequ=0x00000000

        PID:00400003 TID:010C000E ++ -> IndicateBusRequCmplt: pRequ=0xc445e4a4 status=0

        PID:00400003 TID:010C000E --    CSDBusReqAsyncQueue::CompleteRequest: (line 184) pRequest->CompleteBusRequest

    1)  PID:00400002 TID:00D50012 --    CSDBusReqAsyncQueue::QueueBusRequest: (line 129) SubmitRequestToHC: pRequ=0xcc8e74b0 cmd=18

    2)  PID:00400002 TID:010C000E --    CSDBusReqAsyncQueue::CompleteRequest: (line 200) SbmtRqustToHC pRequ=0xcc8e74b0

    3)  PID:00400003 TID:010C000E ++ -> BusRequHndlr: pRequ=0xcc8e74b4 cmd=18 m_pCurRequ=0x00000000

    4)  PID:00400003 TID:010C000E ++    SndCmd: XferTyp=0x123a0037

    5)  PID:00400003 TID:010C000E ++ <- BusRequHndlr: pRequ=0xcc8e74b4 status=1

        PID:00400003 TID:010C000E ++ <- IndicateBusRequCmplt: status=0  pReq=0xc445e4a4  cmd=12

        PID:00400003 TID:010C000E ++    BusRequHndlr: m_pCurRqu=0xcc8e74b4 m_fCurRquFPath=1

        PID:00400003 TID:010C000E ++ -> IndicateBusRequCmplt: pRequ=0xc445e4a4 status=0

        PID:00400003 TID:010C000E ++ <- IndicateBusRequCmplt: status=2  m_FastPathStatus=2

        PID:00400003 TID:010C000E ++ <- BusRequHndlr: pRequ=0xc445e4a4 status=0

        PID:00400003 TID:010C000E ++ <- IndicateBusRequCmplt: status=0  pReq=0xc445e3f4  cmd=18

    6)  PID:00400003 TID:00D50012 -- -> CSDSlot::SubmitRequestToHC: (line 389) pRequest->CompleteBusRequest: fAttchd=1  crHCOwnd=0xcc8e74b0  pRqust=0xcc8e74b0  SltRdy=1  IsAtt=1

    7)  PID:00400003 TID:00D50012 --    CSDBusReqAsyncQueue::QueueBusRequest: (line 133) CompleteRequest: pRequ=0xcc8e74b0 cmd=-1073741821  status=18

                                    

        PID:00400002 TID:010C000E ++    DMA_ASSERT: pRequ=0x00000000

        PID:00400002 TID:00D50012 --    CSDBusReqAsyncQueue::CompleteRequest: (line 184) pRequest->CompleteBusRequest

        PID:00400002 TID:010C000E ++ -> HndlTxCmplt: sIrqStat=0x0000000b

        PID:00400002 TID:00D50012 --    CSDDevice::SDSynchronousBusRequest_I: pCur failed  pCur=0xcc8e74b0

        PID:00400002 TID:010C000E ++    HndlTxCmplt: pRequest==NULL sIrqStat=0x0000000b nIrqStat=0x00000008

        PID:00400002 TID:00D50012 --    CSDDevice::SDSynchronousBusRequest_I: pCur failed  pCur=0xdd69a860

    1)    A new request is inserted to the queue (TID:00D50012).
    2)    The old request continues with the content of the new request (TID:010C000E).        ->  Error: wrong stack context
    3)    The new request triggers the hardware in the wrong stack context (TID:010C000E).

    6)    The new request will continue in his proper stack context (TID:00D50012).
    7)    Submit the new request is failed. Therefore it is terminated with the function CompleteRequest (TID:00D50012).


    Is the SdBus driver thread safe?
    How can it be fixed?

    My configuration:
    -    Visual Studio (Update 3)
    -    Platform Builder WEC 2013 (Update 34)
    -    Nxp - LS1021a (DualCore Cortex A7)


    Best regards
    AchillC

    Friday, July 21, 2017 8:40 AM

All replies

  • Hi AchillC,

    Can you give me a reproducible scenario? So what test are you performing and for example do you use HIVE-Based registry (if so how is it configured).

    How many USDHC instances do you have (USDHC1/USDHC2 or more)?


    Good Luck,

    Erwin Zwart, eMVP
    Check out my blog: http://guruce.com/blog
    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Tuesday, August 15, 2017 7:58 AM
  • Hi Erwin,

    Here is Gerhard, I set an Alarm on this thread cause it is also interested for me and my Project, sorry to Interrupt your conversation with AchillC.

    I currently use an evaluation board and here only one SD card interface is available.

    I need a fast mass storage, cause my app produces some GB of data.

    Currently I use the USB host interface with 32GB USB stick.

    As my SOM offers two SD card interfaces I came up with the idea to use one SD card interface for booting my device and the second SD interface for mass storage.

    I am pretty new to WEC2013, so I don’t understand some of your statements. What do you mean with HIVE the registry?

    Currently I develop my app (mostly managed code) and have to start it from VS2015. I don’t have a version running without degugger. Maybe this is  the reason, why I am not in troubles with permanent stored registry (I guess HIVE .. hibernate ??).

    Now it is time to build the final PCB board and use it instead of  the eval board. I still have a USB host socket and can use an USB stick for mass storage but the next step is  to use the second SD card and use the USB stick only for data transfer or other future use.

    The final step is  to run my system (and my app) after power up without VS2015 and debugger.

    Maybe you can point me to some articles dealing with all that stuff.

    Thanks a lot.

    With best regards

    Gerhard

    Gerhard

    Tuesday, August 15, 2017 8:46 AM
  • No problem Gerhard,

    I do think that it is best to start a new thread with your question(s) in order to allow other people to  respond as well.

    Hive == indeed permanent registry (stored on eg. SD card) (http://geekswithblogs.net/BruceEitman/archive/2009/08/11/windows-ce-what-is-hive-registry.aspx)

    Ti[s for your new thread:

    Dealing with all that stuff is quite generic. What do you mean by this? Getting your PCB up and running? configure HIVE-based registry? starting your application at boot?


    Good Luck,

    Erwin Zwart, eMVP
    Check out my blog: http://guruce.com/blog
    GuruCE
    Microsoft Embedded Partner
    http://guruce.com
    Consultancy, training and development services.

    Tuesday, August 15, 2017 9:00 AM
  • Hi Erwin,
    thanks for your reply.
    I don’t use Hive-Based and I have only one instance (..\WinCE8\public\common\oak\files\common.bib  ->  sdhc.dll $(_FLATRELEASEDIR)\sdhc.dll).

    The error always comes when the thread priority value from the controller-IST (SDHC) is changed to 97 (or higher  ->  lower priority).

    Scenario:
    Thread A) sends a command for write.
    CSDDevice::SDSynchronousBusRequest_I()                     (sddevice.cpp)
      CSDBusReqAsyncQueue::QueueBusRequest()                   (sdslot.cpp)

    Wait…

    Thread B) (the SDHC-IST) indicates that the request is complete (DMA done). So we are done for the request (Parent), remove it from the queue and complete bus request.
    CSDBusReqAsyncQueue::CompleteRequest()                      (sdslot.cpp)
        CSDBusRequest::CompleteBusRequest()                       (sdbusreq.hpp)
            CSDBusRequest::CheckForCompletion()                     (sdbusreq.cpp)
            // Nothing to do. Go back.
        CSDBusRequest::DeRef()                                    (sdbusreq.hpp)
        // DeRef-Parent.
        CSDSlot::SubmitRequestToHC()                              (sdslot.cpp)
        // There is still a request (Child) in the queue. Send it.


        The SDHC indicates that the request (Child) is complete.
        CSDSlot::CompleteRequestFromHC()                        (sdslot.cpp)
            CSDBusReqAsyncQueue::CompleteRequest()                (sdslot.cpp)
                CSDBusRequest::CompleteBusRequest()                 (sdbusreq.hpp)
                    CSDBusRequest::CheckForCompletion()               (sdbusreq.cpp)
                    // Set the event to complete. => False
                    // The event is signaled. Thread A) continues and delete the requests (Child and Parent).
                    // CSDDevice::SDSynchronousBusRequest_I() is now finished.
                CSDBusRequest::DeRef()                                    (sdbusreq.hpp)
                // DeRef-Child.  => ERROR -> Child and Parent are NULL.



    Thanks a lot.

    AchillC

                    
    Monday, August 28, 2017 4:27 PM