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

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

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

748 Views
JonMcLeanSMC
Contributor II

Hi,

I am currently trying to add SD card and FatFS functionality to an existing project however I am having some difficulty getting the SD card to initialize correctly. My code is based off the SDK example for using FreeRTOS, FatFS, and SDMMC.

When trying to initialize the SD card using SD_CardInit the project will get stuck waiting when trying to read the SCR from the SD card. Specifically it gets stuck while executing the SDMMCHOST_TransferFunction during the data transfer event, see screenshot attached. Upon executing the SDMMC_OSA_EventWait (as shown in screenshot) FreeRTOS will proceed to return to an idle task and remain there until the program is stopped.

 

Any ideas on how to resolve this issue?

 

Thanks,

Jon McLean

 

Code Screenshot:

Screen Shot 2022-11-15 at 2.56.46 pm.png

 

Debug Thread Screenshot:

Screen Shot 2022-11-15 at 2.57.28 pm.png

 

FreeRTOS Task Screenshot:

Screen Shot 2022-11-15 at 2.59.11 pm.png

 

Card Detect Task Code:

static void CardDetectTask(void *pvParameters) {
	cardDetectSemaphore = xSemaphoreCreateBinary();

	BOARD_SD_Config(&g_sd, SDCARD_DetectCallback, BOARD_SDMMC_SD_HOST_IRQ_PRIORITY, NULL);

	if(SD_HostInit(&g_sd) == kStatus_Success) {
		while(true) {
			if(xSemaphoreTake(cardDetectSemaphore, portMAX_DELAY) == pdTRUE) {
				if(cardInserted != cardInsertedStatus) {
					cardInserted = cardInsertedStatus;

					if(cardInserted) {
						PRINTF("Card Inserted\r\n");

						SD_SetCardPower(&g_sd, false);
						SD_SetCardPower(&g_sd, true);

						PRINTF("\r\n\Initialising SD Card \r\n");
						SD_CardInit(&g_sd);
						PRINTF("\r\nFinished Card Init\r\n");

						if(DEMO_MakeFileSystem() != kStatus_Success) {
							continue;
						}

						// Notify Tasks
					}
				}

				if(!cardInserted) {
					PRINTF("\r\n No SD card, please insert \r\n");
				}
			}
		}
	}else {
		PRINTF("\r\nSD Host Init Failed\r\n");
	}

	vTaskSuspend(NULL);
}
0 Kudos
3 Replies

730 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello
Hope you are well.

Are you using the EVK? Which SDK version are you using?
Is this issue persistent on all the available SD cards?

Please let me know so we can find the root cause of this issue.
Best regards,
Omar

727 Views
JonMcLeanSMC
Contributor II

Hi @Omar_Anguiano ,

Thanks for the response. This issue occurs across all SD cards I have available (all SDHC). I am not using an EVK board and am instead using a custom development board. I am using SDK version 2.12.1.

Also I have done some further investigation since my last post and have managed to use a logic analyzer to get the following output which shows the SCR is sent and a response is given by the card (which as far as I can tell is then ignored by the host, hence causing the program to hang).

Screen Shot 2022-11-18 at 11.07.12 am.png

 

Additionally I have contacted the manufacturer of the board I am using to confirm the pin configurations are correct. I've attached the full output from the logic analyzer below (produced using pulseview). Let me know if you have any ideas as to what could be causing this.

Thanks,

Jon McLean

 

EDIT: I've also attached a better screenshot of the logic analyzer that contains the channel names for each of the traces

0 Kudos

708 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

 

Thank you for your additional information. Is it possible to receive some additional information from the board you´re using since this issue is not present on the EVK?
Additionally, it will be helpful if you add some information about the SD card used.

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

0 Kudos