Using SDcard hangs waiting for OSAevent

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using SDcard hangs waiting for OSAevent

1,432 Views
CktDesigner
Contributor IV

I'm using MCUXpresso version v11.7.0 with SDK version 2.13.0

I'm attempting to use the SDcard peripheral.    I compiled/executed the SDK SDcard demo/example and it operates properly.

Now I'm trying to add this functionality to my application.  

I used the MCUXpresso config tool to add the appropriate driver, then modified it to add the functions that were in the demo/example but not in the code that was added by the MCUXpresso.

I made sure that the pinMux and pinConfig calls matched those in the demo.   I believe the clocks are set the same.

When I attempt to run the code, it hangs waiting for an OSA event (a mutex being cleared?)

Is it waiting for an SDcard command to complete?     Is there something else I need to set up or initialize?

Thanks!

0 Kudos
Reply
6 Replies

1,272 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello
I hope you are well.

It will be helpful to check the device you are trying to connect. Yes, it is waiting for a command to complete, timeout can be configured to avoid the hang on that part.
Which type of card are you trying to interface?

Best regards,
Omar

0 Kudos
Reply

744 Views
akhil__
Contributor II

akhil___0-1720002965244.png

@Omar_Anguiano 
@CktDesigner 

@kerryzhou 

I am also facing the same issue. (RT 1170 custom board)

SDK version: 2.14

How can I resolve this?

"Timeout can be configured to avoid the hang on that part."
How do I configure the timeout?

Which type of card are you trying to interface?
SDHC (32 GB)


Similar issue -Infinite wait when initialising SD card with FatFS and FreeRTOS on RT1176 

"Does the SDK unmodified example work correctly? It can be helpful to restart the host before initializing the Sdcard."

Same issue for example projects "evkmimxrt1170_sdcard_fatfs_cm7" and "evkmimxrt1170_sdcard_fatfs_freertos_cm7"

 

Thanks,

AKHIL

0 Kudos
Reply

735 Views
CktDesigner
Contributor IV

I am using RT1062 on a custom board.    I couldn't find any detailed documentation that describes the SD card interface, so I had to walk through the code to determine what features, etc. needed to be enabled.

To allow the SD card to be mounted, there are a number of conditions that need to be met.   Some of them are:

1. SD card must be powered.   On the NXP evaluation board, there is a control bit that turns power on.

2. The SD card voltage must be correct.   On the NXP evaluation board, there is a control bit that selects one of two voltages.   In my design, it is always 3.3V

3. The SD card detect must be active.   Most card sockets have a switch that detects if the card is present.   This must be wired to the correct pin.

In my case, the code "hung" in an infinite loop waiting for all of the conditions to be met, then eventually timed out.   Putting breakpoints in was somewhat tricky because the timer would sometimes time out,  so debugging was a long process!

Perhaps the place to start is to look through "sdmcc_config.h" and "sdmcc_config.c" to make sure you have set everything up correctly for your custom board.    For example, in the header file, I had to comment out:

#define BOARD_SDMMC_SD_IO_VOLTAGE_CONTROL_TYPE kSD_IOVoltageCtrlByHost

and replace it with

#define BOARD_SDMMC_SD_IO_VOLTAGE_CONTROL_TYPE kSD_IOVoltageCtrlNotSupport

The .c file does some pin assignments, etc.

 

Hope this helps!

0 Kudos
Reply

719 Views
akhil__
Contributor II

Thanks for the reply


I am using an RT1170 custom board.

1) In my case there is no card detect pin
2) The voltage is always 3.3v

I tried using the example code(evkmimxrt1170_sdcard_fatfs_cm7), but it gets stuck in SDMMC_OSAEventwait()

Tried this also

#define BOARD_SDMMC_SD_IO_VOLTAGE_CONTROL_TYPE kSD_IOVoltageCtrlByHost

replaced with 

#define BOARD_SDMMC_SD_IO_VOLTAGE_CONTROL_TYPE kSD_IOVoltageCtrlNotSupport

 

Thanks

0 Kudos
Reply

711 Views
CktDesigner
Contributor IV

As I mentioned, you must check all of the conditions needed by the SDcard software.

From the stack trace you included, while the code waits in SDMMC_OSAEventWait, it is waiting due to the transfer that was initiated from SDMMCHOST_TransferFunction, which was called from SD_SendInterfaceCondition, which was called from SD_ProbeBusVoltage....

SD_ProbeBusVoltage is called from sdcard_init...     If BOARD_SDMMC_SD_IO_VOLTAGE_CONTROL_TYPE is set to kSD_IOVoltageCtrlNotSupport , this code should be skipped over.  

Even though your card socket doesn't have a card detect pin, the code checks for the status of the pin assigned in sdmmc_config.h      Make sure you have set these up appropriately...

 

0 Kudos
Reply

707 Views
akhil__
Contributor II

Thanks for the reply.

The issue was resolved by switching from a Class 4 to a Class 6 SD card.

Now, I'm facing an issue while creating a new project. The SDK example works fine, and modified SDK examples also work fine. However, in the new project, when I call the function f_mkdir it gets stuck in a loop, as shown in the attached image.

akhil___0-1720104067779.png

After this,

 

akhil___1-1720104158527.png

Am I missing any settings? How can I resolve this?

@CktDesigner 
@Omar_Anguiano 
@kerryzhou 

Thanks,
Akhil

0 Kudos
Reply