This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

the time delay question in ATA_SubmitIdentify() function when initing ATA deriver

Other Parts Discussed in Thread: OMAP-L138

Hi, everyone:

I use the RTFS system to read and write SATA on the OMAP-L138 board. And I use bios_5_41_13_42, rtfs_1_10_02_32, pspdrivers_01_30_01.

 My code stuck in ATA_DrvInit() function while it is working fine with RTFS example. After debugging I found that it is stuck in ATA_SubmitIdentify() function.

In the ATA_SubmitIdentify() function, there are a section of codes:

       pReq -> Retry   = 10u;

       ATA_SubmitReq (pDevice, pReq);

       while (pReq -> Retry != 0)

       {

          //PAL_osWaitMsecs (1u);

              m_delay(1u);

              //pReq -> Retry--;

       }

And the m_delay function:

void m_delay( Uint32 msecDelay)

{

    volatile Uint32 i,j;

//  TSK_sleep(msecDelay);

    for(i=0; i<msecDelay; ++i)

           for(j=0; j<0x1fff; ++j); //TODO ???

}

If I run straightly, the program will enter infinite loop in the m_delay function. But if I abandoned the “//” before “pReq -> Retry--;”, and set a breakpoint before “while (pReq -> Retry != 0)”, the ATA_SubmitIdentify() function could go successfully and then ATA_driver could be Initialized successfully.

So how does the variable pReq -> Retry be changed? Could you please tell me why it is like this here and how I should configure here? 

Please help me. Thanks a lot!

Best wishes

Samantha

  • We are working on your post.
  • Dear Samantha,
    Yes, your observation seems to be right.
    That line (//pReq -> Retry--;) should be uncommented and never comes out of the loop since its not decremented.
  • Dear Titus,

    Yes. But if I make it  uncommented, the ATA driver initialization could not be successful either. Actually, it stuck in the ATA_SubmitReq() function, which submits an IO request on the device. And there is an error in this sentence:

    retVal = pDevice -> pIdeInt -> pIdeOps -> SubmitReq (pDevice -> pIdeInt -> pIntHndl, pReq);

    Unfortunately,  pIdeOps -> SubmitReq is a library function and I could not check it.

    So where is the wrong? What should I do or configure?

    Please help me, Titus. Thanks a lot!

    Regards

    Samantha

  • Can you try to increase the retry timing and "m_delay" timing ?
    Ex:
    pReq -> Retry = 50u;
    m_delay(50u);
  • Dear Titus,

    After the debug tonight, it does not work. And althought I set the breakpoint it can not run successfully.  That is it could not work now, and I did not change anything.

    Maybe there something wrong with the configure of DSPBIOS, that is, the .tcf file. I really have no idea.

    .So coiuld share an example on the rtfs to sata, or just a .tcf file of the example?

    I am almos confused fort 3 months. Please help me. Thanks a lot!

    Best wishes!

    Samantha

  • Dear Titus S,

    Now, I cancled the “//” before “pReq -> Retry--;”, and set a breakpoint before “while (pReq -> Retry != 0)”, the ATA_SubmitIdentify() function could go successfully. But if I did not set the breakpoint, it filed and the ATA_MED_Register() returned error.

    You  said that line (//pReq -> Retry--;) should be uncommented. But it has alike sentence in other functions, like the following. How it happened? Is it wrong either?

    I will appreciate it if you reply me another time. Thank  you very much, Titus!

    Best wishes!

    static Int32 ATA_MaxLba (ATA_Drive_t *pDevice)
    {
      ATA_Dev_Req_t *pReq = NULL;
      ATA_Dev_Stat_t Status;
      Int32 retVal = ATA_ERR_GEN;
    
      if(NULL != pDevice)
      {
    		retVal = ATA_NO_ERR;
    	  pReq = ATA_AllocReq (pDevice, False);
    	  if (pReq != NULL)
    	  {
    	    pReq -> MediaHandle = NULL;
    	    pReq -> IsInternal  = True;
    	    pReq -> Command . Device = pDevice -> Dev;
    	    pReq -> Command . Cmd = ATA_READ_MAX_SECT;
    	    pReq -> Buffer = NULL;
    	    pReq -> Mode = TASKFILE;
    	    pReq -> Res . IsEvent = False;
    	    pReq -> Handler = &ATA_IdentHndlr;
    	    pReq -> ToHndlr = &ATA_IdentHndlr;
    	    pReq -> Timeout = ATA_ONESEC_TO;
    	    pReq -> Retry   = 10u;
    
    	    ATA_SubmitReq (pDevice, pReq);
    
    	    while (pReq -> Retry != 0)
    	    {
    		  m_delay(1u);
    	    }
    
    		Status = pReq->Status;
    

    Regards

    Samantha